linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Clark Williams <williams@redhat.com>,
	John Kacur <jkacur@redhat.com>,
	linux-rt-users@vger.kernel.org
Subject: Re: [PATCH rt-tests v0 1/4] pmqtest: Increase buffer to avoid overflow
Date: Mon, 19 Aug 2019 08:34:50 +0200	[thread overview]
Message-ID: <ebd1627d-bbc5-d6dc-48b6-159b265bd2dd@monom.org> (raw)
In-Reply-To: <20190816154132.xk5u7di6d5jdzw5v@linutronix.de>

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.

  reply	other threads:[~2019-08-19  6:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebd1627d-bbc5-d6dc-48b6-159b265bd2dd@monom.org \
    --to=wagi@monom.org \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).