From 378c4f30f36408296343dcc8e30e500eeb5c3dca Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 1 Oct 2021 20:38:52 +0300 Subject: [PATCH] public: ParseFile drops const qualifier, return -1 length on overflow As we usually put allocated data to ParseFile, we don't need const qualifier --- public/crtlib.c | 5 ++++- public/crtlib.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/crtlib.c b/public/crtlib.c index 8e087bac..e9321f9a 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -995,7 +995,7 @@ COM_ParseFile text parser ============== */ -const char *_COM_ParseFileSafe( const char *data, char *token, const int size, unsigned int flags, int *plen ) +char *_COM_ParseFileSafe( char *data, char *token, const int size, unsigned int flags, int *plen ) { int c, len = 0; qboolean overflow = false; @@ -1054,6 +1054,7 @@ skipwhite: token[len] = (byte)*data; len++; } + else overflow = true; data++; continue; @@ -1071,6 +1072,7 @@ skipwhite: token[len] = c; len++; } + else overflow = true; } } @@ -1102,6 +1104,7 @@ skipwhite: token[len] = c; len++; } + else overflow = true; data++; c = ((byte)*data); diff --git a/public/crtlib.h b/public/crtlib.h index ad1d7cc0..2e676f53 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -95,7 +95,7 @@ char COM_Hex2Char( uint8_t hex ); void COM_Hex2String( uint8_t hex, char *str ); #define COM_CheckString( string ) ( ( !string || !*string ) ? 0 : 1 ) #define COM_CheckStringEmpty( string ) ( ( !*string ) ? 0 : 1 ) -const char *_COM_ParseFileSafe( const char *data, char *token, const int size, unsigned int flags, int *len ); +char *_COM_ParseFileSafe( char *data, char *token, const int size, unsigned int flags, int *len ); #define COM_ParseFile( data, token, size ) _COM_ParseFileSafe( data, token, size, 0, NULL ) #define COM_ParseFileLegacy( data, token ) COM_ParseFileSafe( data, token, INT_MAX ) int matchpattern( const char *in, const char *pattern, qboolean caseinsensitive );