From 621399c49bf9132292d31063d5889fca98d7ff92 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 3 Oct 2021 03:42:30 +0300 Subject: [PATCH] engine: add safe ParseFile to client MobilityAPI --- engine/client/cl_mobile.c | 3 ++- engine/mobility_int.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/client/cl_mobile.c b/engine/client/cl_mobile.c index 54d0d0e4..52d6df2b 100644 --- a/engine/client/cl_mobile.c +++ b/engine/client/cl_mobile.c @@ -108,7 +108,8 @@ static mobile_engfuncs_t gpMobileEngfuncs = pfnDrawScaledCharacter, Sys_Warn, pfnGetNativeObject, - ID_SetCustomClientID + ID_SetCustomClientID, + _COM_ParseFileSafe }; qboolean Mobile_Init( void ) diff --git a/engine/mobility_int.h b/engine/mobility_int.h index d8b6120a..c6471dff 100644 --- a/engine/mobility_int.h +++ b/engine/mobility_int.h @@ -36,6 +36,10 @@ extern "C" { #define TOUCH_FL_STROKE (1U << 8) #define TOUCH_FL_PRECISION (1U << 9) +// flags for COM_ParseFileSafe +#define PFILE_IGNOREBRACKET (1<<0) +#define PFILE_HANDLECOLON (1<<1) + typedef struct mobile_engfuncs_s { // indicates version of API. Should be equal to MOBILITY_API_VERSION @@ -77,6 +81,9 @@ typedef struct mobile_engfuncs_s void *(*pfnGetNativeObject)( const char *obj ); void (*pfnSetCustomClientID)( const char *id ); + + // COM_ParseFile but with buffer size limit, len reports written size or -1 on overflow + char* (*pfnParseFile)( char *data, char *buf, const int size, unsigned int flags, int *len ); // To be continued... } mobile_engfuncs_t;