1
1

* util.c (diff_two_paths): Abort when second symlink can't be resolved

(fixes segfault).
Этот коммит содержится в:
Leonard den Ottolander 2005-09-17 11:40:31 +00:00
родитель 8491ac0c7d
Коммит b2952be541
2 изменённых файлов: 14 добавлений и 12 удалений

Просмотреть файл

@ -1,3 +1,8 @@
2005-09-17 Jindrich Novy <jnovy@redhat.com>
* util.c (diff_two_paths): Abort when second symlink can't be
resolved (fixes segfault).
2005-09-07 Roland Illig <roland.illig@gmx.de>
* setup.c: Renamed options[] to int_options[].
@ -9,7 +14,6 @@
to have more than just four characters. Added generic support
for string options.
2005-09-06 Roland Illig <roland.illig@gmx.de>
* cmd.c: Added single_dirsize_cmd(), which computes the size of

Просмотреть файл

@ -1151,22 +1151,20 @@ static char *resolve_symlinks (const char *path)
* as needed up in first and then goes down using second */
char *diff_two_paths (const char *first, const char *second)
{
char *p, *q, *r, *s, *buf = 0;
char *p, *q, *r, *s, *buf = NULL;
int i, j, prevlen = -1, currlen;
char *my_first = NULL, *my_second = NULL;
my_first = resolve_symlinks (first);
if (my_first == NULL)
return NULL;
my_second = resolve_symlinks (second);
if (my_second == NULL) {
g_free (my_first);
return NULL;
}
for (j = 0; j < 2; j++) {
p = my_first;
if (j) {
my_second = resolve_symlinks (second);
if (my_second == NULL) {
g_free (my_first);
return buf;
}
}
q = my_second;
for (;;) {
r = strchr (p, PATH_SEP);
@ -1190,15 +1188,15 @@ char *diff_two_paths (const char *first, const char *second)
if (currlen < prevlen)
g_free (buf);
else {
g_free (my_first);
g_free (my_second);
g_free (my_first);
g_free (my_second);
return buf;
}
}
p = buf = g_malloc (currlen);
prevlen = currlen;
for (; i >= 0; i--, p += 3)
strcpy (p, "../");
strcpy (p, "../");
strcpy (p, q);
}
g_free (my_first);