Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/inet PR/48585: Set errno when returning NULL for AF...



details:   https://anonhg.NetBSD.org/src/rev/f0a8592d827d
branches:  trunk
changeset: 830239:f0a8592d827d
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Mar 02 06:31:53 2018 +0000

description:
PR/48585: Set errno when returning NULL for AF_INET

In inet_ntop4(), errno wasn't set before returning NULL.
Seems like an oversight in the existing fix for PR/48585.
Noticed by code inspection.

diffstat:

 lib/libc/inet/inet_ntop.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 228387b33feb -r f0a8592d827d lib/libc/inet/inet_ntop.c
--- a/lib/libc/inet/inet_ntop.c Fri Mar 02 06:04:16 2018 +0000
+++ b/lib/libc/inet/inet_ntop.c Fri Mar 02 06:31:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet_ntop.c,v 1.11 2014/02/10 16:30:54 christos Exp $  */
+/*     $NetBSD: inet_ntop.c,v 1.12 2018/03/02 06:31:53 lukem Exp $     */
 
 /*
  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -22,7 +22,7 @@
 #if 0
 static const char rcsid[] = "Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka Exp";
 #else
-__RCSID("$NetBSD: inet_ntop.c,v 1.11 2014/02/10 16:30:54 christos Exp $");
+__RCSID("$NetBSD: inet_ntop.c,v 1.12 2018/03/02 06:31:53 lukem Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -106,8 +106,10 @@
 
        l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
            src[0], src[1], src[2], src[3]);
-       if (l <= 0 || (socklen_t) l >= size)
+       if (l <= 0 || (socklen_t) l >= size) {
+               errno = ENOSPC;
                return NULL;
+       }
        strlcpy(dst, tmp, size);
        return dst;
 }



Home | Main Index | Thread Index | Old Index