Skip to content

Commit

Permalink
makefsdata: fix buffer corruption with very long paths
Browse files Browse the repository at this point in the history
See bug #64941
  • Loading branch information
goldsimon committed Nov 29, 2023
1 parent ee15236 commit b413b04
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/apps/http/makefsdata/makefsdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,10 @@ static int is_ssi_file(const char *filename)
/* build up the relative path to this file */
size_t sublen = strlen(curSubdir);
size_t freelen = sizeof(curSubdir) - sublen - 1;
if (sublen + strlen(filename) + 1 >= sizeof(curSubdir)) {
/* prevent buffer overflow */
return 0;
}
strncat(curSubdir, "/", freelen);
strncat(curSubdir, filename, freelen - 1);
curSubdir[sizeof(curSubdir) - 1] = 0;
Expand Down

0 comments on commit b413b04

Please sign in to comment.