Thread (7 messages) 7 messages, 2 authors, 2019-08-19
STALE2478d
Revisions (2)
  1. v0 current
  2. v1 [diff vs current]

[PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow

From: Daniel Wagner <hidden>
Date: 2019-08-16 06:42:23
Subsystem: the rest · Maintainer: Linus Torvalds

Increase the size of the char buffer. gcc 9.1.1 reports:

src/pmqtest/pmqtest.c: In function ‘main’:
src/pmqtest/pmqtest.c:46:21: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 8 [-Wformat-overflow=]
   46 | #define SYNCMQ_NAME "/syncmsg%d"
      |                     ^~~~~~~~~~~~

src/pmqtest/pmqtest.c:445:3: note: ‘sprintf’ output between 10 and 19 bytes into a destination of size 16
  445 |   sprintf(mqname, SYNCMQ_NAME, i);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Daniel Wagner <redacted>
---
 src/pmqtest/pmqtest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
index a04fc49872bf..20164c8d547f 100644
--- a/src/pmqtest/pmqtest.c
+++ b/src/pmqtest/pmqtest.c
@@ -440,7 +440,7 @@ int main(int argc, char *argv[])
 		goto nomem;
 
 	for (i = 0; i < num_threads; i++) {
-		char mqname[16];
+		char mqname[32];
 
 		sprintf(mqname, SYNCMQ_NAME, i);
 		receiver[i].syncmq = mq_open(mqname, oflag, 0777, &mqstat);
@@ -567,7 +567,7 @@ int main(int argc, char *argv[])
 	}
 	nanosleep(&maindelay, NULL);
 	for (i = 0; i < num_threads; i++) {
-		char mqname[16];
+		char mqname[32];
 
 		mq_close(receiver[i].syncmq);
 		sprintf(mqname, SYNCMQ_NAME, i);
-- 
2.21.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help