Browse Source

[settings] Eliminate variable-length stack allocation

Signed-off-by: Michael Brown <mcb30@ipxe.org>
master
Michael Brown 4 years ago
parent
commit
446e8f14e8
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      src/core/settings.c

+ 7
- 2
src/core/settings.c View File

370
 static struct settings *
370
 static struct settings *
371
 parse_settings_name ( const char *name, get_child_settings_t get_child ) {
371
 parse_settings_name ( const char *name, get_child_settings_t get_child ) {
372
 	struct settings *settings = &settings_root;
372
 	struct settings *settings = &settings_root;
373
-	char name_copy[ strlen ( name ) + 1 ];
373
+	char *name_copy;
374
 	char *subname;
374
 	char *subname;
375
 	char *remainder;
375
 	char *remainder;
376
 
376
 
377
 	/* Create modifiable copy of name */
377
 	/* Create modifiable copy of name */
378
-	memcpy ( name_copy, name, sizeof ( name_copy ) );
378
+	name_copy = strdup ( name );
379
+	if ( ! name_copy )
380
+		return NULL;
379
 	remainder = name_copy;
381
 	remainder = name_copy;
380
 
382
 
381
 	/* Parse each name component in turn */
383
 	/* Parse each name component in turn */
389
 			break;
391
 			break;
390
 	}
392
 	}
391
 
393
 
394
+	/* Free modifiable copy of name */
395
+	free ( name_copy );
396
+
392
 	return settings;
397
 	return settings;
393
 }
398
 }
394
 
399
 

Loading…
Cancel
Save