[PATCH 2/5] Convert strncpy/strncat to strlcpy/strlcat
Alan Coopersmith
alan.coopersmith at oracle.com
Sat Oct 29 08:30:48 PDT 2011
On 10/29/11 02:21, walter harms wrote:
>> /* We need the full path name to open the file */
>> > - strncpy(path_name, PCI_TXT_IDS_PATH, 256);
>> > - strncat(path_name, "/", 1);
>> > - strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
>> > + strlcpy(path_name, PCI_TXT_IDS_PATH, sizeof(path_name));
>> > + strlcat(path_name, "/", sizeof(path_name));
>> > + strlcat(path_name, direntry->d_name, sizeof(path_name));
> hi Alan,
> to improve readablity (and no clue what path_name actualy is):
> asprintf(&path_name,"%s/%s",PCI_TXT_IDS_PATH,direntry->d_name);
It's already allocated on the stack: char path_name[256]
so snprintf should be good enough, but yes, that's probably clearer to read.
--
-Alan Coopersmith- alan.coopersmith at oracle.com
Oracle Solaris Platform Engineering: X Window System
More information about the xorg-devel
mailing list