Skip to content

Commit

Permalink
Bugfix Info_ValueForKey: Fix wrong comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed May 6, 2018
1 parent f324df8 commit 2fa7655
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rehlds/common/port.h
Expand Up @@ -105,7 +105,7 @@
extern char g_szEXEName[ 4096 ];

#define _snprintf snprintf

#if defined(OSX)
#define SO_ARCH_SUFFIX ".dylib"
#else
Expand Down
6 changes: 3 additions & 3 deletions rehlds/engine/info.cpp
Expand Up @@ -73,6 +73,7 @@ const char* EXT_FUNC Info_ValueForKey(const char *s, const char *lookup)
static char valueBuf[INFO_MAX_BUFFER_VALUES][MAX_KV_LEN];
static int valueIndex;

size_t lookupLen = Q_strlen(lookup);
while (*s == '\\')
{
// skip starting slash
Expand All @@ -87,7 +88,6 @@ const char* EXT_FUNC Info_ValueForKey(const char *s, const char *lookup)
s++;
}

size_t keyLen = s - key;
const char* value = ++s; // skip separating slash

// skip value
Expand All @@ -96,7 +96,7 @@ const char* EXT_FUNC Info_ValueForKey(const char *s, const char *lookup)

size_t valueLen = Q_min(s - value, MAX_KV_LEN - 1);

if (!Q_strncmp(key, lookup, keyLen))
if (!Q_strncmp(key, lookup, lookupLen))
{
char* dest = valueBuf[valueIndex];
Q_memcpy(dest, value, valueLen);
Expand Down Expand Up @@ -865,7 +865,7 @@ qboolean Info_IsValid(const char *s)
// key should end with a '\', not a NULL
if (*s == '\0')
return FALSE;

// quotes are deprecated
if (*s == '"')
return FALSE;
Expand Down

0 comments on commit 2fa7655

Please sign in to comment.