From 70c9889d16082194b6931c88cf151b20db8fc37f Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Mon, 31 Aug 2015 18:53:18 +0200 Subject: [PATCH] Info_RemoveKey: use memmove instead of strcpy for overlapping memory areas. Submitted by: Ozkan Sezer --- src/shared/shared.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/shared/shared.c b/src/shared/shared.c index 717cb51..caafe7a 100644 --- a/src/shared/shared.c +++ b/src/shared/shared.c @@ -322,8 +322,8 @@ anglemod(float a) int i; vec3_t corners[2]; -/* - * This is the slow, general version +/* + * This is the slow, general version */ int BoxOnPlaneSide2(vec3_t emins, vec3_t emaxs, struct cplane_s *p) @@ -441,7 +441,7 @@ BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct cplane_s *p) p->normal[2] * emaxs[2]; break; default: - dist1 = dist2 = 0; + dist1 = dist2 = 0; break; } @@ -760,7 +760,7 @@ COM_DefaultExtension(char *path, const char *extension) qboolean bigendien; -/* can't just use function pointers, or dll linkage can +/* can't just use function pointers, or dll linkage can mess up when qcommon is included in multiple places */ short (*_BigShort)(short l); short (*_LittleShort)(short l); @@ -772,37 +772,37 @@ float (*_LittleFloat)(float l); short BigShort(short l) { - return _BigShort(l); + return _BigShort(l); } short LittleShort(short l) -{return - _LittleShort(l); +{return + _LittleShort(l); } int BigLong(int l) { - return _BigLong(l); + return _BigLong(l); } int LittleLong(int l) { - return _LittleLong(l); + return _LittleLong(l); } float BigFloat(float l) { - return _BigFloat(l); + return _BigFloat(l); } float LittleFloat(float l) { - return _LittleFloat(l); + return _LittleFloat(l); } short @@ -893,7 +893,7 @@ Swap_Init(void) } /* - * does a varargs printf into a temp buffer, so I don't + * does a varargs printf into a temp buffer, so I don't * need to have varargs versions of all text functions. */ char * @@ -1113,7 +1113,7 @@ char * Info_ValueForKey(char *s, char *key) { char pkey[512]; - static char value[2][512]; /* use two buffers so compares + static char value[2][512]; /* use two buffers so compares work without stomping on each other */ static int valueindex; char *o; @@ -1223,7 +1223,7 @@ Info_RemoveKey(char *s, char *key) if (!strcmp(key, pkey)) { - strcpy(start, s); /* remove this part */ + memmove(start, s, strlen(s) + 1); /* remove this part */ return; }