canonicalize-lgpl was already immune; glibc has the same bug:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=10635
* lib/canonicalize.c (canonicalize_filename_mode): Protect errno
over calls to free.
Signed-off-by: Eric Blake <ebb9@byu.net>
2009-09-17 Eric Blake <ebb9@byu.net>
+ canonicalize: don't lose errno
+ * lib/canonicalize.c (canonicalize_filename_mode): Protect errno
+ over calls to free.
+
canonicalize: simplify errno handling
* lib/canonicalize.c (__set_errno): Delete macro, and use direct
assignment.
char const *rname_limit;
size_t extra_len = 0;
Hash_table *ht = NULL;
+ int saved_errno;
if (name == NULL)
{
if (lstat (rname, &st) != 0)
{
+ saved_errno = errno;
if (can_mode == CAN_EXISTING)
goto error;
if (can_mode == CAN_ALL_BUT_LAST && *end)
{
if (can_mode == CAN_MISSING)
continue;
- errno = ELOOP;
+ saved_errno = ELOOP;
goto error;
}
{
if (can_mode == CAN_MISSING && errno != ENOMEM)
continue;
+ saved_errno = errno;
goto error;
}
{
if (!S_ISDIR (st.st_mode) && *end && (can_mode != CAN_MISSING))
{
- errno = ENOTDIR;
+ saved_errno = ENOTDIR;
goto error;
}
}
free (rname);
if (ht)
hash_free (ht);
+ errno = saved_errno;
return NULL;
}