Blame SOURCES/e2fsprogs-1.45.6-libss-handle-memory-allcation-failure-in-ss_help.patch

e427d2
From 22c751c1ab47277e90f63ac774288f67d2e42c51 Mon Sep 17 00:00:00 2001
e427d2
From: Lukas Czerner <lczerner@redhat.com>
e427d2
Date: Fri, 6 Aug 2021 11:58:18 +0200
e427d2
Subject: [PATCH 42/46] libss: handle memory allcation failure in ss_help()
e427d2
Content-Type: text/plain
e427d2
e427d2
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
e427d2
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e427d2
---
e427d2
 lib/ss/help.c | 7 ++++++-
e427d2
 1 file changed, 6 insertions(+), 1 deletion(-)
e427d2
e427d2
diff --git a/lib/ss/help.c b/lib/ss/help.c
e427d2
index 96eb1092..a22b4017 100644
e427d2
--- a/lib/ss/help.c
e427d2
+++ b/lib/ss/help.c
e427d2
@@ -96,7 +96,12 @@ void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr)
e427d2
     }
e427d2
     if (fd < 0) {
e427d2
 #define MSG "No info found for "
e427d2
-        char *buf = malloc(strlen (MSG) + strlen (argv[1]) + 1);
e427d2
+	char *buf = malloc(strlen (MSG) + strlen (argv[1]) + 1);
e427d2
+	if (!buf) {
e427d2
+		ss_perror(sci_idx, 0,
e427d2
+			  "couldn't allocate memory to print error message");
e427d2
+		return;
e427d2
+	}
e427d2
 	strcpy(buf, MSG);
e427d2
 	strcat(buf, argv[1]);
e427d2
 	ss_perror(sci_idx, 0, buf);
e427d2
-- 
e427d2
2.35.1
e427d2