]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
text-progress-bar: Initial os-string to "" when can't be read
authorRay Strode <rstrode@redhat.com>
Wed, 13 Jun 2012 10:56:56 +0000 (06:56 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 13 Jun 2012 10:58:40 +0000 (06:58 -0400)
get_os_string either returns a string describing the distribution,
or NULL on error.

This NULL later causes problems since we run strlen on it.

This commit makes get_os_string return "" instead of NULL for error
cases.

Spotted by Andreas Henriksson.

src/libply-splash-core/ply-text-progress-bar.c

index faf84a4d7b9070fadc1247fca0f45933e050f5aa..7c9d688c30e0effac1c5784d791f2594894ca56b 100644 (file)
@@ -102,13 +102,15 @@ get_os_string (void)
   char *buf, *pos, *pos2;
   struct stat sbuf;
 
+  buf = NULL;
+
   fd = open (RELEASE_FILE, O_RDONLY);
   if (fd == -1)
-    return;
+    goto out;
 
   if (fstat (fd, &sbuf) == -1) {
     close (fd);
-    return;
+    goto out;
   }
 
   buf = calloc (sbuf.st_size + 1, sizeof(char));
@@ -158,6 +160,9 @@ get_os_string (void)
 
 out:
   free (buf);
+
+  if (os_string == NULL)
+    os_string = strdup ("");
 }
 
 void