netresolv: Merge patches from 2017 to current HEAD.

Commits merged from the semi-official Git mirror of NetBSD
trunk (https://github.com/IIJ-NetBSD/netbsd-src/).

Commit authors/messages in chronological order follow:
---------------------------------------
From: christos <christos@netbsd.org>
Date: Thu, 28 Sep 2017 23:32:01 +0000
Subject: [PATCH] PR/52578: Benjamin M. Schwartz Set the AD bit when DNSSEC is
 enabled (RFC 6840 Section 5.7).

From: lukem <lukem@netbsd.org>
Date: Fri, 2 Mar 2018 06:31:53 +0000
Subject: [PATCH] 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.
This commit is contained in:
Augustin Cavalier 2018-07-31 20:56:43 -04:00
parent faf38d0fc0
commit 4cc9ce9ddd
2 changed files with 14 additions and 5 deletions

View File

@ -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 */
@ -101,8 +101,10 @@ inet_ntop4(const u_char *src, char *dst, socklen_t size)
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;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_mkquery.c,v 1.15 2015/02/24 17:56:20 christos Exp $ */
/* $NetBSD: res_mkquery.c,v 1.16 2017/09/28 23:32:01 christos Exp $ */
/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
@ -66,12 +66,18 @@
* SOFTWARE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#ifdef notdef
static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
static const char rcsid[] = "Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp";
#else
__RCSID("$NetBSD: res_mkquery.c,v 1.16 2017/09/28 23:32:01 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
@ -126,6 +132,7 @@ res_nmkquery(res_state statp,
hp->id = htons(statp->id);
hp->opcode = op;
hp->rd = (statp->options & RES_RECURSE) != 0U;
hp->ad = (statp->options & RES_USE_DNSSEC) != 0U;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;
ep = buf + buflen;