mirror of
https://github.com/linux-can/can-utils.git
synced 2026-09-22 16:09:52 +02:00
fix timeval to ASCII unsigned value conversion
As reported by Oleksij Rempel here https://github.com/linux-can/can-utils/issues/233#issuecomment-674818935 the representation of timeval timestamps are signed values which leads to negative values on 32 bit machines addressing the year 2038 unix sec counter overflow. Fix the issue on 32 bit systems by converting the timeval values to unsigned ASCII value representations. Fixes: https://github.com/linux-can/can-utils/issues/234 Reported-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
+2
-2
@@ -410,7 +410,7 @@ int main(int argc, char **argv)
|
||||
|
||||
idx = idx2dindex(addr.can_ifindex, s[i]);
|
||||
|
||||
sprintf(temp, "(%ld.%06ld) %*s ",
|
||||
sprintf(temp, "(%lu.%06lu) %*s ",
|
||||
tv.tv_sec, tv.tv_usec, max_devname_len, devname[idx]);
|
||||
sprint_canframe(temp+strlen(temp), &frame, 0, maxdlen);
|
||||
strcat(temp, "\n");
|
||||
@@ -422,7 +422,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#if 0
|
||||
/* print CAN frame in log file style to stdout */
|
||||
printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
|
||||
printf("(%lu.%06lu) ", tv.tv_sec, tv.tv_usec);
|
||||
printf("%*s ", max_devname_len, devname[idx]);
|
||||
fprint_canframe(stdout, &frame, "\n", 0, maxdlen);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user