]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
ldconfig: don't crash on empty path in config file
authorAndreas Schwab <schwab@redhat.com>
Tue, 3 May 2011 17:44:25 +0000 (13:44 -0400)
committerPetr Baudis <pasky@ucw.cz>
Thu, 26 May 2011 22:49:23 +0000 (00:49 +0200)
(cherry picked from commit 00ee369c1cbdcc4ca4a009e9223799951c6c8f04)

ChangeLog
elf/ldconfig.c

index 853f82d6e66fb8023191be7958ab8dfc99510001..e3875af7f414e96bfec78abf28f82d2aa86cd63b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-03  Andreas Schwab  <schwab@redhat.com>
+
+       * elf/ldconfig.c (add_dir): Don't crash on empty path.
+
 2011-04-30  Bruno Haible  <bruno@clisp.org>
 
        [BZ #12717]
index 6ba8e071eaf104cec9aec1e5fd8794b1d38b9104..c11b1f539ce4f530123f028d4fa8774217f201f9 100644 (file)
@@ -384,14 +384,17 @@ add_dir (const char *line)
     }
 
   /* Canonify path: for now only remove leading and trailing
-     whitespace and the trailing slashes slashes.  */
-  i = strlen (entry->path) - 1;
+     whitespace and the trailing slashes.  */
+  i = strlen (entry->path);
 
-  while (isspace (entry->path[i]) && i > 0)
-    entry->path[i--] = '\0';
+  while (i > 0 && isspace (entry->path[i - 1]))
+    entry->path[--i] = '\0';
 
-  while (entry->path[i] == '/' && i > 0)
-    entry->path[i--] = '\0';
+  while (i > 0 && entry->path[i - 1] == '/')
+    entry->path[--i] = '\0';
+
+  if (i == 0)
+    return;
 
   char *path = entry->path;
   if (opt_chroot)