From f4ec38eedf40f54e0fb13af2bb495687634287e4 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 27 Jun 2014 18:08:00 +0000 Subject: [PATCH] [shlwapi] fix buffer overflow svn path=/trunk/; revision=63649 --- reactos/dll/win32/shlwapi/path.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/shlwapi/path.c b/reactos/dll/win32/shlwapi/path.c index c0589ac9780..40a2a853d95 100644 --- a/reactos/dll/win32/shlwapi/path.c +++ b/reactos/dll/win32/shlwapi/path.c @@ -137,20 +137,21 @@ LPSTR WINAPI PathCombineA(LPSTR lpszDest, LPCSTR lpszDir, LPCSTR lpszFile) if (!lpszDest) return NULL; if (!lpszDir && !lpszFile) - { - lpszDest[0] = 0; - return NULL; - } + goto fail; if (lpszDir) - MultiByteToWideChar(CP_ACP,0,lpszDir,-1,szDir,MAX_PATH); + if (!MultiByteToWideChar(CP_ACP,0,lpszDir,-1,szDir,MAX_PATH)) + goto fail; + if (lpszFile) - MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH); + if (!MultiByteToWideChar(CP_ACP,0,lpszFile,-1,szFile,MAX_PATH)) + goto fail; if (PathCombineW(szDest, lpszDir ? szDir : NULL, lpszFile ? szFile : NULL)) if (WideCharToMultiByte(CP_ACP,0,szDest,-1,lpszDest,MAX_PATH,0,0)) return lpszDest; +fail: lpszDest[0] = 0; return NULL; }