Blob Blame History Raw
From 50bcb7aa73d899dda1a994d3ed8e4cab83c6678a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 17 May 2016 15:34:42 +0100
Subject: [PATCH] utils: boot-analysis: Make insmod message handling a bit more
 robust.

(cherry picked from commit 613fe4c089d132d63edddf1ccb53c082c20aded3)
---
 utils/boot-analysis/boot-analysis-timeline.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/utils/boot-analysis/boot-analysis-timeline.c b/utils/boot-analysis/boot-analysis-timeline.c
index a4b71a1..8198c56 100644
--- a/utils/boot-analysis/boot-analysis-timeline.c
+++ b/utils/boot-analysis/boot-analysis-timeline.c
@@ -48,13 +48,20 @@ static void construct_initcall_timeline (void);
 static char *
 translate_supermin_insmod_message (const char *message)
 {
+  const char *p, *q;
   char *ret;
 
   assert (STRPREFIX (message, "supermin: internal "));
+  p = message       + strlen ("supermin: internal ");
 
-  ret = strdup (message + strlen ("supermin: internal "));
+  /* Strip off the .ko and anything that follows. */
+  q = strstr (p, ".ko");
+  if (q == NULL)
+    error (EXIT_FAILURE, 0, "cannot find '.ko' suffix in '%s'", message);
+
+  ret = strndup (p, q-p);
   if (ret == NULL)
-    error (EXIT_FAILURE, errno, "strdup");
+    error (EXIT_FAILURE, errno, "strndup");
   return ret;
 }
 
-- 
1.8.3.1