From f26874c523e56c59fd23f002e0d7cae9c4ab840c Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 26 Jun 2014 20:31:35 +0200 Subject: [PATCH] shlwapi: Avoid buffer overflow in PathCombineA. --- dlls/shlwapi/path.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index 01e3ae77f15..5c7a88a86d8 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -155,20 +155,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; }