Skip to content

Commit f516c57

Browse files
Merge pull request #3324 from guilherme-gm/config-len-validation
Validate length of configuration names from add*Conf HPM commands
2 parents aec44c1 + f5e11d4 commit f516c57

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/common/HPM.c

+5
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,11 @@ static bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, c
451451
return false;
452452
}
453453

454+
if (strnlen(name, HPM_ADDCONF_LENGTH) >= HPM_ADDCONF_LENGTH) {
455+
ShowError("HPM->addConf:%s: config '%s' name/path is too long. Maximum is %d characters (see #define HPM_ADDCONF_LENGTH). Skipping it.\n", HPM->pid2name(pluginID), name, HPM_ADDCONF_LENGTH - 1);
456+
return false;
457+
}
458+
454459
ARR_FIND(0, VECTOR_LENGTH(HPM->config_listeners[type]), i, strcmpi(name, VECTOR_INDEX(HPM->config_listeners[type], i).key) == 0);
455460
if (i != VECTOR_LENGTH(HPM->config_listeners[type])) {
456461
ShowError("HPM->addConf:%s: duplicate '%s', already in use by '%s'!",

src/common/HPMi.h

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct map_session_data;
3535
struct hplugin_data_store;
3636

3737
#define HPM_VERSION "1.2"
38+
39+
// Maximum length of the configuration path for configs added with add*Conf
3840
#define HPM_ADDCONF_LENGTH 40
3941

4042
struct hplugin_info {

0 commit comments

Comments
 (0)