diff mbox series

[BlueZ,v1] rctest: replace sprintf() with snprintf() in recv_mode()

Message ID 20240628131531.551699-1-r.smirnov@omp.ru
State New
Headers show
Series [BlueZ,v1] rctest: replace sprintf() with snprintf() in recv_mode() | expand

Commit Message

Roman Smirnov June 28, 2024, 1:15 p.m. UTC
Use snprintf() instead of sprintf() to avoid buffer overflow.

Found with the SVACE static analysis tool.
---
 tools/rctest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/rctest.c b/tools/rctest.c
index ff91eb2f1..e39d313eb 100644
--- a/tools/rctest.c
+++ b/tools/rctest.c
@@ -500,7 +500,7 @@  static void recv_mode(int sk)
 					timestamp = 0;
 					memset(ts, 0, sizeof(ts));
 				} else {
-					sprintf(ts, "[%lld.%lld] ",
+					snprintf(ts, sizeof(ts), "[%lld.%lld] ",
 							(long long)tv.tv_sec,
 							(long long)tv.tv_usec);
 				}