Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ldconfig: don't crash on empty path in config file
  • Loading branch information
Andreas Schwab authored and Ulrich Drepper committed May 3, 2011
1 parent 1bfbe0d commit 00ee369
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions 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-28 Maciej Babinski <mbabinski@google.com>

[BZ #12714]
Expand Down
15 changes: 9 additions & 6 deletions elf/ldconfig.c
Expand Up @@ -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)
Expand Down

0 comments on commit 00ee369

Please sign in to comment.