From 182c4f32e65373ccefc3d170db30b89981a606c5 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 7 Nov 2018 03:55:00 +0000 Subject: [PATCH] user_get_property() changed to include a 'maxlen' argument so that every buffer passed to it doesn't have to be INI_MAX_VALUE_LEN in size. --- src/sbbs3/userdat.c | 7 +++++-- src/sbbs3/userdat.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sbbs3/userdat.c b/src/sbbs3/userdat.c index 531c6172c3..2fa4f44e87 100644 --- a/src/sbbs3/userdat.c +++ b/src/sbbs3/userdat.c @@ -3277,14 +3277,17 @@ static FILE* user_ini_open(scfg_t* scfg, unsigned user_number, BOOL create) return iniOpenFile(path, create); } -BOOL DLLCALL user_get_property(scfg_t* scfg, unsigned user_number, const char* section, const char* key, char* value) +BOOL DLLCALL user_get_property(scfg_t* scfg, unsigned user_number, const char* section, const char* key, char* value, size_t maxlen) { FILE* fp; + char buf[INI_MAX_VALUE_LEN]; fp = user_ini_open(scfg, user_number, /* create: */FALSE); if(fp == NULL) return FALSE; - char* result = iniReadValue(fp, section, key, NULL, value); + char* result = iniReadValue(fp, section, key, NULL, buf); + if(result != NULL) + safe_snprintf(value, maxlen, "%s", result); iniCloseFile(fp); return result != NULL; } diff --git a/src/sbbs3/userdat.h b/src/sbbs3/userdat.h index 4b7d1e9321..9bd104afd9 100644 --- a/src/sbbs3/userdat.h +++ b/src/sbbs3/userdat.h @@ -127,7 +127,7 @@ DLLEXPORT BOOL DLLCALL filter_ip(scfg_t*, const char* prot, const char* reason, ,const char* ip_addr, const char* username, const char* fname); /* user .ini file access */ -DLLEXPORT BOOL DLLCALL user_get_property(scfg_t*, unsigned user_number, const char* section, const char* key, char* value); +DLLEXPORT BOOL DLLCALL user_get_property(scfg_t*, unsigned user_number, const char* section, const char* key, char* value, size_t maxlen); DLLEXPORT BOOL DLLCALL user_set_property(scfg_t*, unsigned user_number, const char* section, const char* key, const char* value); DLLEXPORT BOOL DLLCALL user_set_time_property(scfg_t*, unsigned user_number, const char* section, const char* key, time_t); -- GitLab