From 68ddb1366215b6476fc205b4da0ed66e68998fd2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 28 Jan 2015 14:40:10 +0100 Subject: [PATCH] fdisk: check return and robust label usage [coverity scan] Signed-off-by: Karel Zak --- disk-utils/fdisk-menu.c | 3 ++- disk-utils/fdisk.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index 64e7ba1446..a77a13f80d 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -257,7 +257,8 @@ static const struct menu_entry *next_menu_entry( assert(cxt); - type = fdisk_label_get_type(lb); + if (lb) + type = fdisk_label_get_type(lb); if (parent) pr_type = fdisk_label_get_type(fdisk_get_label(parent, NULL)); diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 8807940eca..8a0bfd575d 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -107,7 +107,7 @@ static int ask_menu(struct fdisk_context *cxt, struct fdisk_ask *ask, do { char prompt[128]; - int key, c; + int key, c, rc; const char *name, *desc; size_t i = 0; @@ -117,7 +117,9 @@ static int ask_menu(struct fdisk_context *cxt, struct fdisk_ask *ask, /* ask for key */ snprintf(prompt, sizeof(prompt), _("Select (default %c): "), dft); - get_user_reply(cxt, prompt, buf, bufsz); + rc = get_user_reply(cxt, prompt, buf, bufsz); + if (rc) + return rc; if (!*buf) { fdisk_info(cxt, _("Using default response %c."), dft); c = dft; -- 2.39.5