Avoid truncating filenames with snprintf().
This commit is contained in:
parent
2ca2fb4fa3
commit
ad903dff1e
@ -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