powerpc/vio: use strcpy in modalias_show
PATCH 1/1 powerpc/vio: use strcpy in modalias_show
Commit e82b89a6f19bae73fb064d1b3dd91fcefbb478f4 used strcat instead of strcpy which can result in an overflow of newlines on the buffer.
--- arch/powerpc/kernel/vio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/vio.c +2 -2
@@ -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); }
Signature · 1 line
1.7.9.3
Quoted 2 lines
Commit
e82b89a6f19bae73fb064d1b3dd91fcefbb478f4used strcat instead of strcpy which can result in an overflow of newlines on the buffer.
...
arch/powerpc/kernel/vio.c static ssize_t modalias_show(struct device =
Quoted 3 lines
arch/powerpc/kernel/vio.c +0
-0@@ -1531,12 +1531,12 @@ static ssize_t modalias_show(struct device =
*dev, struct device_attribute
Quoted 4 lines
arch/powerpc/kernel/vio.c +0
-0*attr,=20
arch/powerpc/kernel/vio.c +0
-0dn =3D dev->of_node;if (!dn) {
arch/powerpc/kernel/vio.c static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, · line 1541
Quoted 10 lines
arch/powerpc/kernel/vio.c +2
-2-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
Quoted 22 lines · David Laight
Quoted 2 lines
Commit
e82b89a6f19bae73fb064d1b3dd91fcefbb478f4used strcat instead of strcpy which can result in an overflow of newlines on the buffer....
Quoted 7 lines
arch/powerpc/kernel/vio.c +0
-0@@ -1531,12 +1531,12 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, dn = dev->of_node;if (!dn) {arch/powerpc/kernel/vio.c static ssize_t modalias_show(struct device *dev, struct device_attribute · line 1542
Quoted 10 lines
arch/powerpc/kernel/vio.c +2
-2-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:
Quoted 5 lines
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.
Quoted 5 lines
David