Tighten boundary check in split(1) to prevent a potential buffer overflow.
(cherry picked from commit 95032b58a1)
This commit is contained in:
parent
0d47501246
commit
45764d1d48
1 changed files with 4 additions and 0 deletions
|
|
@ -401,6 +401,10 @@ newfile(void)
|
|||
*/
|
||||
if (!dflag && autosfx && (fpnt[0] == 'y') &&
|
||||
strspn(fpnt+1, "z") == strlen(fpnt+1)) {
|
||||
/* Ensure the generated filenames will fit into the buffer. */
|
||||
if (strlen(fname) + 2 >= sizeof(fname))
|
||||
errx(EX_USAGE, "combined filenames would be too long");
|
||||
|
||||
fpnt = fname + strlen(fname) - sufflen;
|
||||
fpnt[sufflen + 2] = '\0';
|
||||
fpnt[0] = end;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue