From 0118a30eba01aef1ad0bbab03c383b382acad183 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Wed, 10 Jun 2020 05:08:41 +0000 Subject: [PATCH] Clamp clipboard data to MAX_INPUTLINE. Fixes heap overflow with console input https://gitlab.com/xonotic/darkplaces/-/merge_requests/84 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12662 d7cf8633-e32d-0410-b094-e92efae38249 --- sys_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys_sdl.c b/sys_sdl.c index 81984861..e3b2956e 100644 --- a/sys_sdl.c +++ b/sys_sdl.c @@ -173,7 +173,7 @@ char *Sys_GetClipboardData (void) cliptext = SDL_GetClipboardText(); if (cliptext != NULL) { size_t allocsize; - allocsize = strlen(cliptext) + 1; + allocsize = min(MAX_INPUTLINE, strlen(cliptext) + 1); data = (char *)Z_Malloc (allocsize); strlcpy (data, cliptext, allocsize); SDL_free(cliptext); -- 2.39.2