From 5bf4ee3677385d655ad06878b9a504f606baa73e Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Tue, 22 Nov 2016 11:00:42 +1100 Subject: discover/platform-powerpc: Reject bootdevs with empty UUIDs If a "uuid:" label is set in the petitboot,bootdevs parameter without a matching UUID, the UUID is unintentionally accepted and set to NULL. This can cause a segfault in nc-config when device UUIDs are compared against the autoboot option. Instead treat options like this as malformed. Signed-off-by: Samuel Mendoza-Jonas --- discover/platform-powerpc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'discover/platform-powerpc.c') diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 247b4e6..e5c83a0 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -410,11 +410,9 @@ static int read_bootdev(void *ctx, char **pos, struct autoboot_option *opt) if (!strncmp(*pos, "uuid:", strlen("uuid:"))) { prefix = strlen("uuid:"); opt->boot_type = BOOT_DEVICE_UUID; - rc = 0; } else if (!strncmp(*pos, "mac:", strlen("mac:"))) { prefix = strlen("mac:"); opt->boot_type = BOOT_DEVICE_UUID; - rc = 0; } else { type = find_device_type(*pos); if (type != DEVICE_TYPE_UNKNOWN) { @@ -428,9 +426,12 @@ static int read_bootdev(void *ctx, char **pos, struct autoboot_option *opt) if (delim) len = (int)(delim - *pos) - prefix; else - len = strlen(*pos); + len = strlen(*pos) - prefix; - opt->uuid = talloc_strndup(ctx, *pos + prefix, len); + if (len) { + opt->uuid = talloc_strndup(ctx, *pos + prefix, len); + rc = 0; + } } /* Always advance pointer to next option or end */ -- cgit v1.1