* [PATCH] [PATCH] powerpc/vio: use strcpy in modalias_show
@ 2013-10-17 12:00 Prarit Bhargava
2013-10-17 12:22 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Prarit Bhargava @ 2013-10-17 12:00 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Prarit Bhargava, ben, stable
Commit e82b89a6f19bae73fb064d1b3dd91fcefbb478f4 used strcat instead of
strcpy which can result in an overflow of newlines on the buffer.
Signed-off-by: Prarit Bhargava
Cc: benh@kernel.crashing.org
Cc: ben@decadent.org.uk
Cc: stable@vger.kernel.org
---
arch/powerpc/kernel/vio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index d38cc08..cb92d82 100644
--- 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);
}
--
1.7.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] [PATCH] powerpc/vio: use strcpy in modalias_show
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
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2013-10-17 12:22 UTC (permalink / raw)
To: Prarit Bhargava, linuxppc-dev; +Cc: ben, stable
> 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,
>=20
> dn =3D dev->of_node;
> if (!dn) {
> - strcat(buf, "\n");
> + strcpy(buf, "\n");
> return strlen(buf);
> }
> cp =3D of_get_property(dn, "compatible", NULL);
> if (!cp) {
> - strcat(buf, "\n");
> + strcpy(buf, "\n");
> return strlen(buf);
> }
Why not just:
buf[0] =3D '\n';
buf[1] =3D 0;
return 1;
The assignment to buf[1] might not even be needed.
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [PATCH] powerpc/vio: use strcpy in modalias_show
2013-10-17 12:22 ` David Laight
@ 2013-10-17 12:29 ` Prarit Bhargava
0 siblings, 0 replies; 3+ messages in thread
From: Prarit Bhargava @ 2013-10-17 12:29 UTC (permalink / raw)
To: David Laight; +Cc: ben, linuxppc-dev, stable
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
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-17 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).