Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate length of configuration names from add*Conf HPM commands #3324

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading