Skip to content

Commit

Permalink
Merge pull request #3324 from guilherme-gm/config-len-validation
Browse files Browse the repository at this point in the history
Validate length of configuration names from add*Conf HPM commands
  • Loading branch information
MishimaHaruna authored Sep 29, 2024
2 parents aec44c1 + f5e11d4 commit f516c57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/common/HPM.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ static bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, c
return false;
}

if (strnlen(name, HPM_ADDCONF_LENGTH) >= HPM_ADDCONF_LENGTH) {
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);
return false;
}

ARR_FIND(0, VECTOR_LENGTH(HPM->config_listeners[type]), i, strcmpi(name, VECTOR_INDEX(HPM->config_listeners[type], i).key) == 0);
if (i != VECTOR_LENGTH(HPM->config_listeners[type])) {
ShowError("HPM->addConf:%s: duplicate '%s', already in use by '%s'!",
Expand Down
2 changes: 2 additions & 0 deletions src/common/HPMi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct map_session_data;
struct hplugin_data_store;

#define HPM_VERSION "1.2"

// Maximum length of the configuration path for configs added with add*Conf
#define HPM_ADDCONF_LENGTH 40

struct hplugin_info {
Expand Down

0 comments on commit f516c57

Please sign in to comment.