From 5f65095e47a844de67bbd01fe1122a7c116f3ed9 Mon Sep 17 00:00:00 2001 From: Tobias Schramm Date: Tue, 20 Feb 2018 12:17:49 +0100 Subject: [PATCH] autoupdater: Replace malloc by safe_malloc During argument parsing the allocation of the string array for the mirror list had no NULL check leading to a possible null ptr dereference Signed-off-by: Tobias Schramm --- admin/autoupdater/src/autoupdater.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/autoupdater/src/autoupdater.c b/admin/autoupdater/src/autoupdater.c index 0c08f3a..5db868b 100644 --- a/admin/autoupdater/src/autoupdater.c +++ b/admin/autoupdater/src/autoupdater.c @@ -144,7 +144,8 @@ static void parse_args(int argc, char *argv[], struct settings *settings) { if (optind < argc) { settings->n_mirrors = argc - optind; - settings->mirrors = malloc(settings->n_mirrors * sizeof(char *)); + settings->mirrors = safe_malloc(settings->n_mirrors * sizeof(char *), "failed to allocate memory for mirror list"); + for (int i = optind; i < argc; i++) { settings->mirrors[i - optind] = argv[i]; }