From: Breno Leitao <leitao@debian.org>
To: 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: Mon, 25 Jun 2018 18:21:24 -0300 [thread overview]
Message-ID: <ed94efce-10cb-5ea3-7bdf-5e544cd25bf7@debian.org> (raw)
In-Reply-To: <20180623011009.GX16221@gate.crashing.org>
hi Segher,
On 06/22/2018 10:10 PM, Segher Boessenkool wrote:
>> - strncpy(prog, argv[0], strlen(argv[0]));
>> + if (strlen(argv[0]) >= LEN_MAX){
>> + fprintf(stderr, "Very big executable name: %s\n", argv[0]);
>> + return 1;
>> + }
>> +
>> + strncpy(prog, argv[0], sizeof(prog) - 1);
>
> The strlen reads all of argv[0], which can be very big in theory. It won't
> matter in this test file -- program arguments cannot be super long, for one
> thing -- but it's not a good idea in general (that is one of the problems
> of strlcpy, btw).
>
> Best of course is to avoid string length restrictions completely, if you can.
Right, I was thinking about this problem and there is no motivation to have a
statically allocated and limited region.
I will send a v2 where 'prog' and avoid this restriction completely.
Thanks
next prev parent reply other threads:[~2018-06-25 21:21 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
2018-06-23 1:10 ` Segher Boessenkool
2018-06-25 21:21 ` Breno Leitao [this message]
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=ed94efce-10cb-5ea3-7bdf-5e544cd25bf7@debian.org \
--to=leitao@debian.org \
--cc=khandual@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=segher@kernel.crashing.org \
/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).