Re: [PATCH] [PATCH] powerpc/vio: use strcpy in modalias_show

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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
> 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]