From b577595d1289dec5eacb671adbd5592eab39c5eb Mon Sep 17 00:00:00 2001 From: smatz Date: Sun, 1 Nov 2009 17:49:23 +0000 Subject: (svn r17936) -Fix: deadlock when trying to create screenshot with too long name (including path) --- src/screenshot.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 200151b70..1515186e8 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -554,7 +554,11 @@ static char *MakeScreenshotName(const char *ext) snprintf(&_screenshot_name[len], lengthof(_screenshot_name) - len, ".%s", ext); for (serial = 1;; serial++) { - snprintf(filename, lengthof(filename), "%s%s", _personal_dir, _screenshot_name); + if (snprintf(filename, lengthof(filename), "%s%s", _personal_dir, _screenshot_name) >= (int)lengthof(filename)) { + /* We need more characters than MAX_PATH -> end with error */ + filename[0] = '\0'; + break; + } if (!FileExists(filename)) break; /* If file exists try another one with same name, but just with a higher index */ snprintf(&_screenshot_name[len], lengthof(_screenshot_name) - len, "#%d.%s", serial, ext); -- cgit v1.2.3-70-g09d2