[PATCH] cmd: avoid potential buffer overflow (Coverity)
Marcus Meissner
marcus at jet.franken.de
Sat Jun 18 02:50:59 CDT 2016
713256 Out-of-bounds access
We do not have MAX_PATH characters left in "q", at least a \n is already
in the buffer, if not more. Calculate remaining size.
Signed-off-by: Marcus Meissner <marcus at jet.franken.de>
---
programs/cmd/wcmdmain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 435c7d5..0b2e819 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -375,7 +375,7 @@ static void WCMD_show_prompt (void) {
*q++ = '(';
break;
case 'D':
- GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, q, MAX_PATH);
+ GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, q, MAX_PATH - (q - out_string));
while (*q) q++;
break;
case 'E':
--
2.8.4
More information about the wine-patches
mailing list