mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 04:43:32 +00:00
Avoid truncating filenames with snprintf().
This commit is contained in:
parent
88485b4a2f
commit
e12c2e18a5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99024
@ -227,8 +227,11 @@ newfile(void)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
snprintf(currfile, sizeof(currfile), "%s%0*ld", prefix, (int)sufflen,
|
||||
nfiles);
|
||||
if (snprintf(currfile, sizeof(currfile), "%s%0*ld", prefix,
|
||||
(int)sufflen, nfiles) >= sizeof(currfile)) {
|
||||
errno = ENAMETOOLONG;
|
||||
err(1, NULL);
|
||||
}
|
||||
if ((fp = fopen(currfile, "w+")) == NULL)
|
||||
err(1, "%s", currfile);
|
||||
nfiles++;
|
||||
|
Loading…
Reference in New Issue
Block a user