From 68f607de3c0fff536e737667a083497cefed4722 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 27 Aug 2002 17:53:24 +0000 Subject: [PATCH] sanity check the strings to snprintf in open_file as we seem to somehow be getting a stack overflow in there. --- libs/util/quakefs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 52b9fcefa..953718af9 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -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);