summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-11-22 11:00:42 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-11-24 11:42:25 +1100
commit5bf4ee3677385d655ad06878b9a504f606baa73e (patch)
treeda5a76edc3b329c53e0f24a45377a702b6f8ed25
parent3daa33e027e327e75835ed5570bab150cb5e7a10 (diff)
downloadpetitboot-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>
-rw-r--r--discover/platform-powerpc.c9
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 */
OpenPOWER on IntegriCloud