diff options
author | Toomas Soome <tsoome@me.com> | 2022-11-29 13:52:50 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2022-12-05 21:26:59 +0200 |
commit | eaf9751f5dce3a91368ffd99bccc978d5812e4fb (patch) | |
tree | 880a6b44faee8c17a066104a66fdfdca5ae73ad1 | |
parent | 0b49aa923f72d28badbed5f4d3ed43a816f07a39 (diff) | |
download | illumos-gate-eaf9751f5dce3a91368ffd99bccc978d5812e4fb.tar.gz |
9293 bootadm: empty line between boot entries in menu.lst cause bootadm list-menu to segfault
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@mnx.io>
-rw-r--r-- | usr/src/cmd/boot/bootadm/bootadm_loader.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/usr/src/cmd/boot/bootadm/bootadm_loader.c b/usr/src/cmd/boot/bootadm/bootadm_loader.c index e2d99b24b0..2d15fdbc42 100644 --- a/usr/src/cmd/boot/bootadm/bootadm_loader.c +++ b/usr/src/cmd/boot/bootadm/bootadm_loader.c @@ -325,29 +325,34 @@ menu_read(struct menu_lst *menu, char *menu_path) ret = BAM_ERROR; goto done; } + if (buf[0] == '\n') /* Skip empty lines */ + continue; + key = strtok(buf, " \n"); - if (strcmp(key, "title") != 0) { + if (key == NULL || strcmp(key, "title") != 0) { ret = BAM_ERROR; goto done; } value = strtok(NULL, " \n"); - if ((title = strdup(value)) == NULL) { + if (value == NULL || (title = strdup(value)) == NULL) { ret = BAM_ERROR; goto done; } - if (fgets(buf, PATH_MAX, fp) == NULL) { - ret = BAM_ERROR; - goto done; - } + do { + if (fgets(buf, PATH_MAX, fp) == NULL) { + ret = BAM_ERROR; + goto done; + } + } while (buf[0] == '\n'); /* Skip empty lines */ key = strtok(buf, " \n"); - if ((type = strdup(key)) == NULL) { + if (key == NULL || (type = strdup(key)) == NULL) { ret = BAM_ERROR; goto done; } value = strtok(NULL, " \n"); - if ((bootfs = strdup(value)) == NULL) { + if (value == NULL || (bootfs = strdup(value)) == NULL) { ret = BAM_ERROR; goto done; } |