From: Al Dunsmuir <al.dunsmuir@sympatico•ca>
To: Paul Clarke <pc@us•ibm.com>, Breno Leitao <leitao@debian•org>,
Segher Boessenkool <segher@kernel•crashing.org>
Cc: linuxppc-dev@lists•ozlabs.org,
Anshuman Khandual <khandual@linux•vnet.ibm.com>
Subject: Re: [PATCH] selftests/powerpc: Fix strncpy usage
Date: Fri, 22 Jun 2018 17:01:45 -0400 [thread overview]
Message-ID: <56894976.20180622170145@sympatico.ca> (raw)
In-Reply-To: <12953a47-a6a7-5f70-a46c-c95f8c424d11@us.ibm.com>
On Friday, June 22, 2018, 11:15:29 AM, Paul Clarke wrote:
> On 06/22/2018 09:43 AM, Breno Leitao wrote:
>> If you don't mind, I would solve this problem slightly different, as it seems
>> to be more readable.
>>
>> - strncpy(prog, argv[0], strlen(argv[0]));
>> + if (strlen(argv[0]) >= LEN_MAX){
>> + fprintf(stderr, "Very big executable name: %s\n", argv[0]);
> "Very big" is an observation. "Too big" indicates a problem
> better. Or, more explicitly "Executable name is too long".
Or even better, display the limit that is being exceeded, in case that
value changes over time. Something like.
- strncpy(prog, argv[0], strlen(argv[0]));
+ if (strlen(argv[0]) >= LEN_MAX){
+ fprintf(stderr, "Executable name exceeds limit (%d): %s\n",
+ LEN_MAX,
+ argv[0]);
next prev parent reply other threads:[~2018-06-22 21:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 22:51 [PATCH] selftests/powerpc: Fix strncpy usage Breno Leitao
2018-06-21 23:18 ` Segher Boessenkool
2018-06-22 14:43 ` Breno Leitao
2018-06-22 14:51 ` Christophe LEROY
2018-06-23 1:00 ` Segher Boessenkool
2018-06-22 15:15 ` Paul Clarke
2018-06-22 21:01 ` Al Dunsmuir [this message]
2018-06-23 1:10 ` Segher Boessenkool
2018-06-25 21:21 ` Breno Leitao
2018-06-25 21:30 ` [PATCH v2] " Breno Leitao
2018-06-26 5:24 ` Michael Ellerman
2018-06-26 13:13 ` Breno Leitao
2018-06-26 13:20 ` [PATCH v3 1/2] " Breno Leitao
2018-06-26 13:20 ` [PATCH v3 2/2] selftests/powerpc: Fix typos Breno Leitao
2018-07-11 13:24 ` [v3,1/2] selftests/powerpc: Fix strncpy usage Michael Ellerman
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=56894976.20180622170145@sympatico.ca \
--to=al.dunsmuir@sympatico$(echo .)ca \
--cc=khandual@linux$(echo .)vnet.ibm.com \
--cc=leitao@debian$(echo .)org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=pc@us$(echo .)ibm.com \
--cc=segher@kernel$(echo .)crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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