2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

If a group plugin has optional arguments, NULL terminate the vector.

Otherwise, the plugin cannot determine the end of arguments.
The behavior now matches the plugin documentation.
This commit is contained in:
Todd C. Miller
2019-11-19 10:30:22 -07:00
parent 368e12b0f9
commit a3266edc27

View File

@@ -133,14 +133,19 @@ group_plugin_load(char *plugin_info)
}
}
if (ac != 0) {
argv = reallocarray(NULL, ac, sizeof(char *));
argv = reallocarray(NULL, ac + 1, sizeof(char *));
if (argv == NULL) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudo_warnx(U_("%s: %s"), __func__,
U_("unable to allocate memory"));
goto done;
}
ac = 0;
for ((cp = strtok_r(args, " \t", &last)); cp != NULL; (cp = strtok_r(NULL, " \t", &last)))
cp = strtok_r(args, " \t", &last);
while (cp != NULL) {
argv[ac++] = cp;
cp = strtok_r(NULL, " \t", &last);
}
argv[ac] = NULL;
}
}