Blame SOURCES/0024-Always-error-check-getLineByType.patch

903092
From 9549dc0d747d8987dd11643340adfa7b6f799460 Mon Sep 17 00:00:00 2001
903092
From: Peter Jones <pjones@redhat.com>
903092
Date: Thu, 25 Sep 2014 13:24:15 -0400
903092
Subject: [PATCH 24/41] Always error check getLineByType()
903092
903092
Signed-off-by: Peter Jones <pjones@redhat.com>
903092
---
903092
 grubby.c | 20 +++++++++++++++-----
903092
 1 file changed, 15 insertions(+), 5 deletions(-)
903092
903092
diff --git a/grubby.c b/grubby.c
903092
index f8e9c25..febc1ad 100644
903092
--- a/grubby.c
903092
+++ b/grubby.c
903092
@@ -2363,9 +2363,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) {
903092
     } else {
903092
 	char * title;
903092
 	line = getLineByType(LT_MENUENTRY, entry->lines);
903092
-	title = grub2ExtractTitle(line);
903092
-	if (title)
903092
-	    printf("title=%s\n", title);
903092
+	if (!line) {
903092
+	    title = grub2ExtractTitle(line);
903092
+	    if (title)
903092
+		printf("title=%s\n", title);
903092
+	}
903092
     }
903092
 }
903092
 
903092
@@ -3302,9 +3304,13 @@ int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
903092
 
903092
 	/* if title is supplied, the entry's title must match it. */
903092
 	if (title) {
903092
+	    char *linetitle;
903092
+
903092
 	    line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
903092
-	    char *linetitle = extractTitle(line);
903092
+	    if (!line)
903092
+		continue;
903092
 
903092
+	    linetitle = extractTitle(line);
903092
 	    if (!linetitle)
903092
 		continue;
903092
 	    if (strcmp(title, linetitle)) {
903092
@@ -3352,9 +3358,13 @@ int updateInitrd(struct grubConfig * cfg, const char * image,
903092
 
903092
 	/* if title is supplied, the entry's title must match it. */
903092
 	if (title) {
903092
+	    char *linetitle;
903092
+
903092
 	    line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
903092
-	    char *linetitle = extractTitle(line);
903092
+	    if (!line)
903092
+		continue;
903092
 
903092
+	    linetitle = extractTitle(line);
903092
 	    if (!linetitle)
903092
 		continue;
903092
 	    if (strcmp(title, linetitle)) {
903092
-- 
903092
2.4.3
903092