summaryrefslogtreecommitdiffstats
path: root/libc/inet/if_index.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-05 23:37:40 +0200
committerAustin Foxley <austinf@cetoncorp.com>2009-09-18 11:37:16 -0700
commit7bd16c28e51c92f58f9415ea05dda039df706d5a (patch)
treec0e916ebf2cbc343bd26fa4925141b004e7b0d64 /libc/inet/if_index.c
parent276d3e4e98371c6988f39b3167fe651d6ff3068c (diff)
downloaduClibc-alpine-7bd16c28e51c92f58f9415ea05dda039df706d5a.tar.bz2
uClibc-alpine-7bd16c28e51c92f58f9415ea05dda039df706d5a.tar.xz
do not save/restore errno around free() calls
In any non-buggy program free() does not fail. And when it fails in a buggy program, the failure is usually fatal (heap corruption and segfault). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'libc/inet/if_index.c')
-rw-r--r--libc/inet/if_index.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/libc/inet/if_index.c b/libc/inet/if_index.c
index 968cd37c1..1c59ee20e 100644
--- a/libc/inet/if_index.c
+++ b/libc/inet/if_index.c
@@ -38,14 +38,6 @@
#include "netlinkaccess.h"
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* libc_hidden_proto(ioctl) */
-/* libc_hidden_proto(close) */
-#if __ASSUME_NETLINK_SUPPORT
-/* Experimentally off - libc_hidden_proto(strndup) */
-#endif
-
extern int __opensock(void) attribute_hidden;
/* libc_hidden_proto(if_nametoindex) */
@@ -65,14 +57,15 @@ if_nametoindex(const char* ifname)
strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
if (ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
{
- int saved_errno = errno;
+ // close never fails here, fd is just a unconnected socket
+ //int saved_errno = errno;
#ifdef __UCLIBC_HAS_THREADS_NATIVE__
close_not_cancel_no_status(fd);
#else
close(fd);
#endif
- if (saved_errno == EINVAL)
- __set_errno(ENOSYS);
+ //if (saved_errno == EINVAL)
+ // __set_errno(ENOSYS);
return 0;
}