From e5404d4bf621c1e8bbdfd47381ce3f609d10b20a Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 29 Apr 2016 17:55:43 +0200 Subject: [PATCH] mscoree: Avoid buffer overflow when mono print handler returns huge string at once. Signed-off-by: Sebastian Lackner Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- dlls/mscoree/metahost.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c index 252740d29b3..30b9739e70b 100644 --- a/dlls/mscoree/metahost.c +++ b/dlls/mscoree/metahost.c @@ -272,7 +272,13 @@ static void CDECL mono_shutdown_callback_fn(MonoProfiler *prof) static void CDECL mono_print_handler_fn(const char *string, INT is_stdout) { - wine_dbg_printf("%s", string); + const char *p; + for (; *string; string = p) + { + if ((p = strstr(string, "\n"))) p++; + else p = string + strlen(string); + wine_dbg_printf("%.*s", (int)(p - string), string); + } } static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result)