lib: make sprint_canframe the buffer size aware snprintf_canframe

Make sure the library functions to convert CAN frames into ASCII
represenation do not exceed the given buffer size. This also applies
to the long CAN frame output library function.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
Oliver Hartkopp
2024-03-12 19:11:58 +01:00
parent 8e131401c1
commit 27030b3e54
8 changed files with 94 additions and 28 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ void prframe(FILE *file, struct timeval *tv, int dev, struct canfd_frame *cf, ch
else
fprintf(file, "canX ");
sprint_canframe(abuf, (cu_t *)cf, 0);
snprintf_canframe(abuf, sizeof(abuf), (cu_t *)cf, 0);
fprintf(file, "%s%s", abuf, extra_info);
}