Linux-rt-users archive on lore.kernel.org
 help / color / Atom feed
* [PATCH rt-tests v0 0/4] Fix gcc warning
@ 2019-08-16  6:42 Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow Daniel Wagner
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Daniel Wagner @ 2019-08-16  6:42 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

On F29 and F30 gcc is warning about too small buffers. Let's fix this.

Daniel Wagner (4):
  pmqtest: Increase buffer to avoid overflow
  sigwaittest: Increase buffer to avoid overflow
  svsematest: Increase buffer to avoid overflow
  deadline_test: Increase buffer to avoid overflow

 src/pmqtest/pmqtest.c              | 4 ++--
 src/sched_deadline/deadline_test.c | 2 +-
 src/sigwaittest/sigwaittest.c      | 2 +-
 src/svsematest/svsematest.c        | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.21.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow
  2019-08-16  6:42 [PATCH rt-tests v0 0/4] Fix gcc warning Daniel Wagner
@ 2019-08-16  6:42 ` Daniel Wagner
  2019-08-16 15:41   ` Sebastian Andrzej Siewior
  2019-08-16  6:42 ` [PATCH rt-tests v0 2/4] sigwaittest: " Daniel Wagner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Daniel Wagner @ 2019-08-16  6:42 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

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 <wagi@monom.org>
---
 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH rt-tests v0 2/4] sigwaittest: Increase buffer to avoid overflow
  2019-08-16  6:42 [PATCH rt-tests v0 0/4] Fix gcc warning Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow Daniel Wagner
@ 2019-08-16  6:42 ` " Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 3/4] svsematest: " Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 4/4] deadline_test: " Daniel Wagner
  3 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2019-08-16  6:42 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

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

src/sigwaittest/sigwaittest.c:494:5: note: ‘sprintf’ output between 5 and 14 bytes into a destination of size 8
  494 |     sprintf(f_opt, "-fr%d", i);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/sigwaittest/sigwaittest.c:522:24: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 5 [-Wformat-overflow=]
  522 |     sprintf(f_opt, "-fs%d", i);
      |                        ^~

Signed-off-by: Daniel Wagner <wagi@monom.org>
---
 src/sigwaittest/sigwaittest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index 59f28a5babcb..a98332f13e38 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -352,7 +352,7 @@ int main(int argc, char *argv[])
 	struct params *sender = NULL;
 	sigset_t sigset;
 	void *param = NULL;
-	char f_opt[8];
+	char f_opt[32];
 	struct timespec launchdelay, maindelay;
 
 	process_options(argc, argv);
-- 
2.21.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH rt-tests v0 3/4] svsematest: Increase buffer to avoid overflow
  2019-08-16  6:42 [PATCH rt-tests v0 0/4] Fix gcc warning Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 2/4] sigwaittest: " Daniel Wagner
@ 2019-08-16  6:42 ` " Daniel Wagner
  2019-08-16  6:42 ` [PATCH rt-tests v0 4/4] deadline_test: " Daniel Wagner
  3 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2019-08-16  6:42 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

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

rc/svsematest/svsematest.c:578:24: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 5 [-Wformat-overflow=]
  578 |     sprintf(f_opt, "-fr%d", i);
      |                        ^~
src/svsematest/svsematest.c:606:5: note: ‘sprintf’ output between 5 and 14 bytes into a destination of size 8
  606 |     sprintf(f_opt, "-fs%d", i);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Daniel Wagner <wagi@monom.org>
---
 src/svsematest/svsematest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index 8f880786ec0f..ea9da2b8e593 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -401,7 +401,7 @@ int main(int argc, char *argv[])
 	struct params *sender = NULL;
 	sigset_t sigset;
 	void *param = NULL;
-	char f_opt[8];
+	char f_opt[32];
 	struct timespec launchdelay, maindelay;
 
 	myfile = getenv("_");
-- 
2.21.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH rt-tests v0 4/4] deadline_test: Increase buffer to avoid overflow
  2019-08-16  6:42 [PATCH rt-tests v0 0/4] Fix gcc warning Daniel Wagner
                   ` (2 preceding siblings ...)
  2019-08-16  6:42 ` [PATCH rt-tests v0 3/4] svsematest: " Daniel Wagner
@ 2019-08-16  6:42 ` " Daniel Wagner
  3 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2019-08-16  6:42 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

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

src/sched_deadline/deadline_test.c:1803:24: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=]
 1803 |   sprintf(setcpu_buf, "%d", cpu_count - 1);
      |                        ^~
src/sched_deadline/deadline_test.c:1803:23: note: directive argument in the range [-2147483648, 2147483646]
 1803 |   sprintf(setcpu_buf, "%d", cpu_count - 1);
      |                       ^~~~
src/sched_deadline/deadline_test.c:1803:3: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 10
 1803 |   sprintf(setcpu_buf, "%d", cpu_count - 1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Daniel Wagner <wagi@monom.org>
---
 src/sched_deadline/deadline_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
index e2898de328bb..5b5f40dbb74d 100644
--- a/src/sched_deadline/deadline_test.c
+++ b/src/sched_deadline/deadline_test.c
@@ -1795,7 +1795,7 @@ int main (int argc, char **argv)
 
 	/* -b has us bind to the last CPU. */
 	if (!all_cpus && !setcpu) {
-		setcpu_buf = malloc(10);
+		setcpu_buf = malloc(12);
 		if (!setcpu_buf) {
 			perror("malloc");
 			exit(-1);
-- 
2.21.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow
  2019-08-16  6:42 ` [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow Daniel Wagner
@ 2019-08-16 15:41   ` Sebastian Andrzej Siewior
  2019-08-19  6:34     ` Daniel Wagner
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-08-16 15:41 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, John Kacur, linux-rt-users

On 2019-08-16 08:42:01 [+0200], Daniel Wagner wrote:
> 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 <wagi@monom.org>
> ---
>  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];

The compiler says, based on SYNCMQ_NAME's size and maximum possible %d
we will have 19 bytes max. Why do you change it to 32? Why it is not
wrong, one might ask what the extra storage is for.

Sebastian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow
  2019-08-16 15:41   ` Sebastian Andrzej Siewior
@ 2019-08-19  6:34     ` Daniel Wagner
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2019-08-19  6:34 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: Clark Williams, John Kacur, linux-rt-users

On 8/16/19 5:41 PM, Sebastian Andrzej Siewior wrote:
> On 2019-08-16 08:42:01 [+0200], Daniel Wagner wrote:
>> 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 <wagi@monom.org>
>> ---
>>   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];
> 
> The compiler says, based on SYNCMQ_NAME's size and maximum possible %d
> we will have 19 bytes max. Why do you change it to 32? Why it is not
> wrong, one might ask what the extra storage is for.

I was taking the 16 bytes value as reference and doubled it. Indeed, 19 
bytes would be a better choice. Let me refresh the series.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-16  6:42 [PATCH rt-tests v0 0/4] Fix gcc warning Daniel Wagner
2019-08-16  6:42 ` [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow Daniel Wagner
2019-08-16 15:41   ` Sebastian Andrzej Siewior
2019-08-19  6:34     ` Daniel Wagner
2019-08-16  6:42 ` [PATCH rt-tests v0 2/4] sigwaittest: " Daniel Wagner
2019-08-16  6:42 ` [PATCH rt-tests v0 3/4] svsematest: " Daniel Wagner
2019-08-16  6:42 ` [PATCH rt-tests v0 4/4] deadline_test: " Daniel Wagner

Linux-rt-users archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org linux-rt-users@archiver.kernel.org
	public-inbox-index linux-rt-users


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox