diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2016-11-22 11:00:42 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2016-11-24 11:42:25 +1100 |
commit | 5bf4ee3677385d655ad06878b9a504f606baa73e (patch) | |
tree | da5a76edc3b329c53e0f24a45377a702b6f8ed25 /discover/platform-powerpc.c | |
parent | 3daa33e027e327e75835ed5570bab150cb5e7a10 (diff) | |
download | petitboot-5bf4ee3677385d655ad06878b9a504f606baa73e.zip petitboot-5bf4ee3677385d655ad06878b9a504f606baa73e.tar.gz |
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 <sam@mendozajonas.com>
Diffstat (limited to 'discover/platform-powerpc.c')
-rw-r--r-- | discover/platform-powerpc.c | 9 |
1 files changed, 5 insertions, 4 deletions
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 */ |