summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2020-02-16 23:30:38 +0100
committerMichael Brown2020-02-16 23:30:38 +0100
commit446e8f14e8a22731b52bad45d94b09f6f1672bd9 (patch)
tree4fe7e95f78e3b742f66b81096aa0e71d7710f465
parent[slam] Allow for the possibility of IPv6 multicast addresses (diff)
downloadipxe-446e8f14e8a22731b52bad45d94b09f6f1672bd9.tar.gz
ipxe-446e8f14e8a22731b52bad45d94b09f6f1672bd9.tar.xz
ipxe-446e8f14e8a22731b52bad45d94b09f6f1672bd9.zip
[settings] Eliminate variable-length stack allocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/core/settings.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/settings.c b/src/core/settings.c
index 3e5d416e..430cdc84 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -370,12 +370,14 @@ const char * settings_name ( struct settings *settings ) {
static struct settings *
parse_settings_name ( const char *name, get_child_settings_t get_child ) {
struct settings *settings = &settings_root;
- char name_copy[ strlen ( name ) + 1 ];
+ char *name_copy;
char *subname;
char *remainder;
/* Create modifiable copy of name */
- memcpy ( name_copy, name, sizeof ( name_copy ) );
+ name_copy = strdup ( name );
+ if ( ! name_copy )
+ return NULL;
remainder = name_copy;
/* Parse each name component in turn */
@@ -389,6 +391,9 @@ parse_settings_name ( const char *name, get_child_settings_t get_child ) {
break;
}
+ /* Free modifiable copy of name */
+ free ( name_copy );
+
return settings;
}