mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-03 09:00:21 +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