Do variable length arrays the C99 way

Variable length arrays are supported by C99, but having it denoted as "1" confused the compiler and is not defined.

Note that because we don't get the inferred NULL terminator, we have to increase the malloc size by one.
This commit is contained in:
Rose
2023-05-18 14:49:45 -04:00
parent 64b666471a
commit 7fd680c983
6 changed files with 10 additions and 10 deletions

View File

@@ -452,7 +452,7 @@ sudo_ldap_parse_keyword(const char *keyword, const char *value,
if (len > 0) {
head = (struct ldap_config_str_list *)cur->valp;
if ((str = malloc(sizeof(*str) + len)) == NULL) {
if ((str = malloc(sizeof(*str) + len + 1)) == NULL) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}