sanity check the strings to snprintf in open_file as we seem to somehow be

getting a stack overflow in there.
This commit is contained in:
Bill Currie 2002-08-27 17:53:24 +00:00
parent bb1adf63a9
commit 68f607de3c

View file

@ -525,6 +525,13 @@ open_file (searchpath_t *search, const char *filename, QFile **gzfile,
return com_filesize;
}
} else {
// sanity check the strings
if (strnlen (search->filename, sizeof (netpath))
+ strnlen (filename, sizeof (netpath)) + 2 > sizeof (netpath))
Sys_Error ("open_file: search->filename and/or filename "
"bogus: `%.*s' `%.*s'",
(int) sizeof (netpath), search->filename,
(int) sizeof (netpath), filename);
// check a file in the directory tree
snprintf (netpath, sizeof (netpath), "%s%s%s", search->filename,
search->filename[0] ? "/" : "", filename);