From: Prarit Bhargava <prarit@redhat.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: ben@decadent.org.uk, linuxppc-dev@lists.ozlabs.org,
stable@vger.kernel.org
Subject: Re: [PATCH] [PATCH] powerpc/vio: use strcpy in modalias_show
Date: Thu, 17 Oct 2013 08:29:00 -0400 [thread overview]
Message-ID: <525FD80C.4070001@redhat.com> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B7393@saturn3.aculab.com>
On 10/17/2013 08:22 AM, David Laight wrote:
>> Commit e82b89a6f19bae73fb064d1b3dd91fcefbb478f4 used strcat instead of
>> strcpy which can result in an overflow of newlines on the buffer.
> ...
>> --- a/arch/powerpc/kernel/vio.c
>> +++ b/arch/powerpc/kernel/vio.c
>> @@ -1531,12 +1531,12 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute
>> *attr,
>>
>> dn = dev->of_node;
>> if (!dn) {
>> - strcat(buf, "\n");
>> + strcpy(buf, "\n");
>> return strlen(buf);
>> }
>> cp = of_get_property(dn, "compatible", NULL);
>> if (!cp) {
>> - strcat(buf, "\n");
>> + strcpy(buf, "\n");
>> return strlen(buf);
>> }
>
> Why not just:
> buf[0] = '\n';
> buf[1] = 0;
> return 1;
>
> The assignment to buf[1] might not even be needed.
Sure, I guess that'd work too. But it really seems like 1/2 a dozen of one and
six of the other. I'll defer to the preference of the maintainers to see what
they want.
P.
>
> David
>
>
>
prev parent reply other threads:[~2013-10-17 12:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 12:00 [PATCH] [PATCH] powerpc/vio: use strcpy in modalias_show Prarit Bhargava
2013-10-17 12:22 ` David Laight
2013-10-17 12:29 ` Prarit Bhargava [this message]
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=525FD80C.4070001@redhat.com \
--to=prarit@redhat.com \
--cc=David.Laight@ACULAB.COM \
--cc=ben@decadent.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.