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
+2 -2
View File
@@ -178,7 +178,7 @@ int parse_canframe(char *cs, cu_t *cu);
* - CAN FD frames do not have a RTR bit
*/
int sprint_canframe(char *buf , cu_t *cu, int sep);
int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep);
/*
* Creates a CAN frame hexadecimal output in compact format.
* The CAN data[] is separated by '.' when sep != 0.
@@ -211,7 +211,7 @@ int sprint_canframe(char *buf , cu_t *cu, int sep);
#define SWAP_DELIMITER '`'
int sprint_long_canframe(char *buf , cu_t *cu, int view);
int snprintf_long_canframe(char *buf, size_t size, cu_t *cu, int view);
/*
* Creates a CAN frame hexadecimal output in user readable format.
*