From 508c4d93548ceb75dfdada53372e968b8dee0be9 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 16 Feb 2001 19:52:50 +0000 Subject: [PATCH] Assert on output buffer overflow. --- dlls/ntdll/debugtools.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c index 9cc73b7c7bb..1e5ae584b67 100644 --- a/dlls/ntdll/debugtools.c +++ b/dlls/ntdll/debugtools.c @@ -2,6 +2,7 @@ * Debugging functions */ +#include #include #include #include @@ -198,9 +199,17 @@ const char *wine_dbgstr_guid( const GUID *id ) int wine_dbg_vprintf( const char *format, va_list args ) { struct debug_info *info = get_info(); + char *p; - int ret = vsprintf( info->out_pos, format, args ); - char *p = strrchr( info->out_pos, '\n' ); + int ret = vsnprintf( info->out_pos, sizeof(info->output) - (info->out_pos - info->output), + format, args ); + + /* make sure we didn't exceed the buffer length + * the two asserts are due to glibc changes in vsnprintfs return value */ + assert( ret != -1 ); + assert( ret < sizeof(info->output) - (info->out_pos - info->output) ); + + p = strrchr( info->out_pos, '\n' ); if (!p) info->out_pos += ret; else {