When logging is enabled, an empty line input (press Enter only)
will cause SIGSEGV. This patch fixes the problem by checking
the command length first.
Type: fix
Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Change-Id: Ib4cbd1c7bfd6a694e289d28958875c7d2356a93e
format_timeval, 0 /* current bat-time */ ,
0 /* current bat-format */ ,
cli_file_index, cf->current_command);
- if (cf->current_command[vec_len (cf->current_command) - 1] != '\n')
+ if ((vec_len (cf->current_command) > 0) &&
+ (cf->current_command[vec_len (cf->current_command) - 1] != '\n'))
lv = format (lv, "\n");
int rv __attribute__ ((unused)) = write (um->log_fd, lv, vec_len (lv));
}