From a568c712c1f1ed754aa0f5fd3935011aac1c80cc Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 26 Jan 2015 23:35:55 +0000 Subject: [PATCH] tab completion: lower size of filelist_item_t name buffer from MAX_OSPATH to 32 to avoid filling up the zone memory (this limits the length of maps / games you can tab-complete). Prior to r1153 it was 32 for maps and MAX_OSPATH for mods. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1158 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/console.c | 12 +++++------- Quake/host_cmd.c | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Quake/console.c b/Quake/console.c index 577a7177..cdd4edc2 100644 --- a/Quake/console.c +++ b/Quake/console.c @@ -720,8 +720,6 @@ tablist is a doubly-linked loop, alphabetized by name // aka Linux Bash shell. -- S.A. static char bash_partial[80]; static qboolean bash_singlematch; -static qboolean map_singlematch; -static qboolean mod_singlematch; void AddToTabList (const char *name, const char *type) { @@ -786,7 +784,7 @@ void AddToTabList (const char *name, const char *type) // This is redefined from host_cmd.c typedef struct filelist_item_s { - char name[MAX_OSPATH]; + char name[32]; struct filelist_item_s *next; } filelist_item_t; @@ -816,12 +814,12 @@ FindCompletion -- stevenaaus */ const char *FindCompletion (const char *partial, filelist_item_t *filelist, int *nummatches_out) { - static char matched[MAX_OSPATH]; + static char matched[32]; char *i_matched, *i_name; filelist_item_t *file; int init, match, plen; - memset(matched, 0, MAX_OSPATH); + memset(matched, 0, sizeof(matched)); plen = strlen(partial); match = 0; @@ -832,8 +830,8 @@ const char *FindCompletion (const char *partial, filelist_item_t *filelist, int if (init == 0) { init = 1; - strncpy (matched, file->name, MAX_OSPATH-1); - matched[MAX_OSPATH-1] = '\0'; + strncpy (matched, file->name, sizeof(matched)-1); + matched[sizeof(matched)-1] = '\0'; } else { // find max common diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index c84d695d..1c573e99 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -59,7 +59,7 @@ void Host_Quit_f (void) // to simplify completion code typedef struct filelist_item_s { - char name[MAX_OSPATH]; + char name[32]; struct filelist_item_s *next; } filelist_item_t;