When a short time format is used with sar's options -s or -e (e.g.,
sar -s 04:00), 5 characters are copied by strncpy in parse_timestamp
to timestamp variable. Unfortunately these 5 characters do not contain
the termination, therefore the following strcat appends after the
next "random" null byte. Therefore writing beyond the end of timestamp.
This patch tries to prevent this by explicitly terminating.
Debian bug #863197.
Reported-by: Robert Luberda
Signed-off-by: Bernhard Ubelacker <bernhardu@mailbox.org>
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
case 5:
strncpy(timestamp, argv[(*opt)++], 5);
+ timestamp[5] = '\0';
strcat(timestamp,":00");
break;