diff options
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/bsd/ptsname.c | 11 | ||||
-rw-r--r-- | sysdeps/unix/getlogin.c | 9 | ||||
-rw-r--r-- | sysdeps/unix/readdir_r.c | 14 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/getsysstats.c | 14 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/fallocate.c | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/fallocate64.c | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/readdir64_r.c | 3 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ifaddrs.c | 55 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c | 2 |
10 files changed, 89 insertions, 37 deletions
diff --git a/sysdeps/unix/bsd/ptsname.c b/sysdeps/unix/bsd/ptsname.c index fd446a4b66..6063201b0f 100644 --- a/sysdeps/unix/bsd/ptsname.c +++ b/sysdeps/unix/bsd/ptsname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998,2002 Free Software Foundation, Inc. +/* Copyright (C) 1998,2002,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -44,6 +44,7 @@ int __ptsname_r (int fd, char *buf, size_t buflen) { int save_errno = errno; + int err; struct stat st; if (buf == NULL) @@ -62,8 +63,12 @@ __ptsname_r (int fd, char *buf, size_t buflen) return ERANGE; } - if (__ttyname_r (fd, buf, buflen) != 0) - return errno; + err = __ttyname_r (fd, buf, buflen); + if (err != 0) + { + __set_errno (err); + return errno; + } buf[sizeof (_PATH_DEV) - 1] = 't'; diff --git a/sysdeps/unix/getlogin.c b/sysdeps/unix/getlogin.c index 4752685f86..7345af0886 100644 --- a/sysdeps/unix/getlogin.c +++ b/sysdeps/unix/getlogin.c @@ -33,6 +33,7 @@ getlogin (void) { char tty_pathname[2 + 2 * NAME_MAX]; char *real_tty_path = tty_pathname; + int err; char *result = NULL; static char name[UT_NAMESIZE + 1]; struct utmp *ut, line, buffer; @@ -46,8 +47,12 @@ getlogin (void) thing to do. Note that ttyname(open("/dev/tty")) on those systems returns /dev/tty, so that is not a possible solution for getlogin(). */ - if (__ttyname_r (0, real_tty_path, sizeof (tty_pathname)) != 0) - return NULL; + err = __ttyname_r (0, real_tty_path, sizeof (tty_pathname)); + if (err != 0) + { + __set_errno (err); + return NULL; + } real_tty_path += 5; /* Remove "/dev/". */ diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c index f84709e737..93727912c1 100644 --- a/sysdeps/unix/readdir_r.c +++ b/sysdeps/unix/readdir_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02 +/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02,10 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -113,7 +113,17 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result) while (dp->d_ino == 0); if (dp != NULL) - *result = memcpy (entry, dp, reclen); + { +#ifdef GETDENTS_64BIT_ALIGNED + /* The d_reclen value might include padding which is not part of + the DIRENT_TYPE data structure. */ + reclen = MIN (reclen, sizeof (DIRENT_TYPE)); +#endif + *result = memcpy (entry, dp, reclen); +#ifdef GETDENTS_64BIT_ALIGNED + entry->d_reclen = reclen; +#endif + } else *result = NULL; diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index 97e20d249b..af454b650d 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -1,5 +1,5 @@ /* Determine various system internal values, Linux version. - Copyright (C) 1996-2003, 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1996-2003,2006,2007,2009,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -117,18 +117,6 @@ next_line (int fd, char *const buffer, char **cp, char **re, if (nl == NULL) nl = *re - 1; } - else if (nl + 5 >= *re) - { - memmove (buffer, nl, *re - nl); - *re = buffer + (*re - nl); - nl = *cp = buffer; - - ssize_t n = read_not_cancel (fd, *re, buffer_end - *re); - if (n < 0) - return NULL; - - *re += n; - } *cp = nl + 1; assert (*cp <= *re); diff --git a/sysdeps/unix/sysv/linux/i386/fallocate.c b/sysdeps/unix/sysv/linux/i386/fallocate.c index 14e788386c..1434a833f9 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate.c @@ -30,7 +30,13 @@ int fallocate (int fd, int mode, __off_t offset, __off_t len) { #ifdef __NR_fallocate - return __call_fallocate (fd, mode, offset, len); + int err = __call_fallocate (fd, mode, offset, len); + if (__builtin_expect (err, 0)) + { + __set_errno (err); + err = -1; + } + return err; #else __set_errno (ENOSYS); return -1; diff --git a/sysdeps/unix/sysv/linux/i386/fallocate64.c b/sysdeps/unix/sysv/linux/i386/fallocate64.c index 85f315c9b6..063bab06e9 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate64.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate64.c @@ -30,7 +30,13 @@ int fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) { #ifdef __NR_fallocate - return __call_fallocate (fd, mode, offset, len); + int err = __call_fallocate (fd, mode, offset, len); + if (__builtin_expect (err, 0)) + { + __set_errno (err); + err = -1; + } + return err; #else __set_errno (ENOSYS); return -1; diff --git a/sysdeps/unix/sysv/linux/i386/readdir64_r.c b/sysdeps/unix/sysv/linux/i386/readdir64_r.c index c6da57b75e..f96f16a6f2 100644 --- a/sysdeps/unix/sysv/linux/i386/readdir64_r.c +++ b/sysdeps/unix/sysv/linux/i386/readdir64_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2004, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,6 +19,7 @@ #define __READDIR_R __readdir64_r #define __GETDENTS __getdents64 #define DIRENT_TYPE struct dirent64 +#define GETDENTS_64BIT_ALIGNED 1 #include <sysdeps/unix/readdir_r.c> diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index 149bd1c3ba..84f223ddbd 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -1,5 +1,5 @@ /* getifaddrs -- get names and addresses of all network interfaces - Copyright (C) 2003-2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2003-2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -315,17 +315,19 @@ map_newlink (int index, struct ifaddrs_storage *ifas, int *map, int max) else if (map[i] == index) return i; } - /* This should never be reached. If this will be reached, we have - a very big problem. */ - abort (); + + /* This means interfaces changed inbetween the reading of the + RTM_GETLINK and RTM_GETADDR information. We have to repeat + everything. */ + return -1; } /* Create a linked list of `struct ifaddrs' structures, one for each network interface on the host machine. If successful, store the list in *IFAP and return 0. On errors, return -1 and set `errno'. */ -int -getifaddrs (struct ifaddrs **ifap) +static int +getifaddrs_internal (struct ifaddrs **ifap) { struct netlink_handle nh = { 0, 0, 0, NULL, NULL }; struct netlink_res *nlp; @@ -481,6 +483,13 @@ getifaddrs (struct ifaddrs **ifap) kernel. */ ifa_index = map_newlink (ifim->ifi_index - 1, ifas, map_newlink_data, newlink); + if (__builtin_expect (ifa_index == -1, 0)) + { + try_again: + result = -EAGAIN; + free (ifas); + goto exit_free; + } ifas[ifa_index].ifa.ifa_flags = ifim->ifi_flags; while (RTA_OK (rta, rtasize)) @@ -565,9 +574,11 @@ getifaddrs (struct ifaddrs **ifap) that we have holes in the interface part of the list, but we always have already the interface for this address. */ ifa_index = newlink + newaddr_idx; - ifas[ifa_index].ifa.ifa_flags - = ifas[map_newlink (ifam->ifa_index - 1, ifas, - map_newlink_data, newlink)].ifa.ifa_flags; + int idx = map_newlink (ifam->ifa_index - 1, ifas, + map_newlink_data, newlink); + if (__builtin_expect (idx == -1, 0)) + goto try_again; + ifas[ifa_index].ifa.ifa_flags = ifas[idx].ifa.ifa_flags; if (ifa_index > 0) ifas[ifa_index - 1].ifa.ifa_next = &ifas[ifa_index].ifa; ++newaddr_idx; @@ -747,9 +758,13 @@ getifaddrs (struct ifaddrs **ifap) /* If we didn't get the interface name with the address, use the name from the interface entry. */ if (ifas[ifa_index].ifa.ifa_name == NULL) - ifas[ifa_index].ifa.ifa_name - = ifas[map_newlink (ifam->ifa_index - 1, ifas, - map_newlink_data, newlink)].ifa.ifa_name; + { + int idx = map_newlink (ifam->ifa_index - 1, ifas, + map_newlink_data, newlink); + if (__builtin_expect (idx == -1, 0)) + goto try_again; + ifas[ifa_index].ifa.ifa_name = ifas[idx].ifa.ifa_name; + } /* Calculate the netmask. */ if (ifas[ifa_index].ifa.ifa_addr @@ -826,6 +841,22 @@ getifaddrs (struct ifaddrs **ifap) return result; } + + +/* Create a linked list of `struct ifaddrs' structures, one for each + network interface on the host machine. If successful, store the + list in *IFAP and return 0. On errors, return -1 and set `errno'. */ +int +getifaddrs (struct ifaddrs **ifap) +{ + int res; + + do + res = getifaddrs_internal (ifap); + while (res == -EAGAIN); + + return res; +} libc_hidden_def (getifaddrs) diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c index b28e587498..f2c1518572 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c @@ -46,7 +46,7 @@ { \ if ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \ - >= oss.ss_size)) \ + < oss.ss_size)) \ __fortify_fail ("longjmp causes uninitialized stack frame");\ } \ } \ diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c index dcf58fb50b..261be250dc 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c @@ -46,7 +46,7 @@ { \ if ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \ - >= oss.ss_size)) \ + < oss.ss_size)) \ __fortify_fail ("longjmp causes uninitialized stack frame");\ } \ } \ |