Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/gen Be more careful about preserving errno. Might c...



details:   https://anonhg.NetBSD.org/src/rev/8aee188a5e89
branches:  trunk
changeset: 348017:8aee188a5e89
user:      dholland <dholland%NetBSD.org@localhost>
date:      Fri Sep 30 06:22:21 2016 +0000

description:
Be more careful about preserving errno. Might conceivably be related
to PR 51432.

diffstat:

 lib/libc/gen/sysctlgetmibinfo.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 7bc31aa01d40 -r 8aee188a5e89 lib/libc/gen/sysctlgetmibinfo.c
--- a/lib/libc/gen/sysctlgetmibinfo.c   Fri Sep 30 06:16:47 2016 +0000
+++ b/lib/libc/gen/sysctlgetmibinfo.c   Fri Sep 30 06:22:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctlgetmibinfo.c,v 1.12 2016/09/30 06:16:47 dholland Exp $ */
+/*     $NetBSD: sysctlgetmibinfo.c,v 1.13 2016/09/30 06:22:21 dholland Exp $ */
 
 /*-
  * Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.12 2016/09/30 06:16:47 dholland Exp $");
+__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.13 2016/09/30 06:22:21 dholland Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -277,6 +277,7 @@
        struct sysctlnode qnode;
        uint32_t rc;
        size_t sz;
+       int serrno;
 
        if (pnode == NULL)
                pnode = &sysctl_mibroot;
@@ -303,7 +304,9 @@
        rc = sysctl(name, namelen + 1, pnode->sysctl_child, &sz,
                    &qnode, sizeof(qnode));
        if (sz == 0) {
+               serrno = errno;
                free(pnode->sysctl_child);
+               errno = serrno;
                pnode->sysctl_child = NULL;
                return (rc);
        }
@@ -324,7 +327,9 @@
                rc = sysctl(name, namelen + 1, pnode->sysctl_child, &sz,
                            &qnode, sizeof(qnode));
                if (rc) {
+                       serrno = errno;
                        free(pnode->sysctl_child);
+                       errno = serrno;
                        pnode->sysctl_child = NULL;
                        return (rc);
                }



Home | Main Index | Thread Index | Old Index