Skip to content

Commit 4b66e8c

Browse files
committed
asc2log: shrink string buffer for header analysis
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
1 parent e6e3253 commit 4b66e8c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

asc2log.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ static int get_date(struct timeval *tv, char *date)
843843

844844
int main(int argc, char **argv)
845845
{
846-
char buf[BUFLEN], tmp1[BUFLEN], tmp2[BUFLEN];
846+
char buf[BUFLEN], tmp1[10], tmp2[10];
847847

848848
FILE *infile = stdin;
849849
FILE *outfile = stdout;
@@ -897,7 +897,7 @@ int main(int argc, char **argv)
897897

898898
/* check for base and timestamp entries in the header */
899899
if ((!base) &&
900-
(sscanf(buf, "base %s timestamps %s", tmp1, tmp2) == 2)) {
900+
(sscanf(buf, "base %9s timestamps %9s", tmp1, tmp2) == 2)) {
901901
base = tmp1[0];
902902
timestamps = tmp2[0];
903903
if (verbose)
@@ -931,7 +931,7 @@ int main(int argc, char **argv)
931931
}
932932

933933
/* check for decimal places length in valid CAN frames */
934-
if (sscanf(buf, "%llu.%s %s ", &sec, tmp2,
934+
if (sscanf(buf, "%llu.%9s %9s ", &sec, tmp2,
935935
tmp1) != 3)
936936
continue; /* dplace remains zero until first found CAN frame */
937937

@@ -952,7 +952,7 @@ int main(int argc, char **argv)
952952
*/
953953

954954
/* check classic CAN format or the CANFD/CANXL tag which can take different types */
955-
if (sscanf(buf, "%llu.%llu %s ", &sec, &usec, tmp1) == 3){
955+
if (sscanf(buf, "%llu.%llu %9s ", &sec, &usec, tmp1) == 3) {
956956
if (!strncmp(tmp1, "CANXL", 5))
957957
eval_canxl(buf, &date_tv, timestamps, dplace, outfile);
958958
else if (!strncmp(tmp1, "CANFD", 5))

0 commit comments

Comments
 (0)