Module Name: src Committed By: riz Date: Sun Nov 8 00:35:45 UTC 2015
Modified Files: src/external/gpl3/binutils/dist/binutils [netbsd-7]: arsup.c src/lib/libc/net [netbsd-7]: getnetnamadr.c Log Message: Pull up following revision(s) (requested by christos in ticket #1012): lib/libc/net/getnetnamadr.c: revision 1.43 lib/libc/net/getnetnamadr.c: revision 1.44 external/gpl3/binutils/dist/binutils/arsup.c: revision 1.2 put the state back after it is used. PR/50367: Stefan Schaeckeler: Apply fix to obey RES_CHECKNAME to getnetbyaddr and getnetbyname. use asprintf(3) To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r1.1.1.2.20.1 \ src/external/gpl3/binutils/dist/binutils/arsup.c cvs rdiff -u -r1.42 -r1.42.10.1 src/lib/libc/net/getnetnamadr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/binutils/dist/binutils/arsup.c diff -u src/external/gpl3/binutils/dist/binutils/arsup.c:1.1.1.2 src/external/gpl3/binutils/dist/binutils/arsup.c:1.1.1.2.20.1 --- src/external/gpl3/binutils/dist/binutils/arsup.c:1.1.1.2 Sat Sep 24 22:39:13 2011 +++ src/external/gpl3/binutils/dist/binutils/arsup.c Sun Nov 8 00:35:45 2015 @@ -149,13 +149,20 @@ maybequit (void) void ar_open (char *name, int t) { - char *tname = (char *) xmalloc (strlen (name) + 10); + char *tname; const char *bname = lbasename (name); real_name = name; /* Prepend tmp- to the beginning, to avoid file-name clashes after truncation on filesystems with limited namespaces (DOS). */ - sprintf (tname, "%.*stmp-%s", (int) (bname - name), name, bname); + if (asprintf (&tname, "%.*stmp-%s", (int) (bname - name), name, bname) == -1) + { + fprintf (stderr, _("%s: Can't allocate memory for temp name (%s)\n"), + program_name, strerror(errno)); + maybequit (); + return; + } + obfd = bfd_openw (tname, NULL); if (!obfd) Index: src/lib/libc/net/getnetnamadr.c diff -u src/lib/libc/net/getnetnamadr.c:1.42 src/lib/libc/net/getnetnamadr.c:1.42.10.1 --- src/lib/libc/net/getnetnamadr.c:1.42 Tue Mar 13 21:13:41 2012 +++ src/lib/libc/net/getnetnamadr.c Sun Nov 8 00:35:45 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: getnetnamadr.c,v 1.42 2012/03/13 21:13:41 christos Exp $ */ +/* $NetBSD: getnetnamadr.c,v 1.42.10.1 2015/11/08 00:35:45 riz Exp $ */ /* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro * Dep. Matematica Universidade de Coimbra, Portugal, Europe @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)getnetbyaddr static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; static char rcsid[] = "Id: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp "; #else -__RCSID("$NetBSD: getnetnamadr.c,v 1.42 2012/03/13 21:13:41 christos Exp $"); +__RCSID("$NetBSD: getnetnamadr.c,v 1.42.10.1 2015/11/08 00:35:45 riz Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -77,6 +77,12 @@ __weak_alias(getnetbyaddr,_getnetbyaddr) __weak_alias(getnetbyname,_getnetbyname) #endif +#define maybe_ok(res, nm, ok) (((res)->options & RES_NOCHECKNAME) != 0U || \ + (ok)(nm) != 0) +#define maybe_hnok(res, hn) maybe_ok((res), (hn), res_hnok) +#define maybe_dnok(res, dn) maybe_ok((res), (dn), res_dnok) + + extern int _net_stayopen; #define BYADDR 0 @@ -105,7 +111,7 @@ static struct netent net_entry; static char *net_aliases[MAXALIASES]; static int parse_reversed_addr(const char *, in_addr_t *); -static struct netent *getnetanswer(querybuf *, int, int); +static struct netent *getnetanswer(res_state, querybuf *, int, int); static int _files_getnetbyaddr(void *, void *, va_list); static int _files_getnetbyname(void *, void *, va_list); static int _dns_getnetbyaddr(void *, void *, va_list); @@ -159,7 +165,7 @@ parse_reversed_addr(const char *str, in_ } static struct netent * -getnetanswer(querybuf *answer, int anslen, int net_i) +getnetanswer(res_state res, querybuf *answer, int anslen, int net_i) { static char n_name[MAXDNAME]; static char netbuf[PACKETSZ]; @@ -172,6 +178,7 @@ getnetanswer(querybuf *answer, int ansle char *in, *bp, **ap, *ep; _DIAGASSERT(answer != NULL); + _DIAGASSERT(res != NULL); /* * find first satisfactory answer @@ -216,7 +223,7 @@ getnetanswer(querybuf *answer, int ansle n_name[0] = '\0'; while (--ancount >= 0 && cp < eom) { n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !res_dnok(bp)) + if ((n < 0) || !maybe_dnok(res, bp)) break; cp += n; (void)strlcpy(n_name, bp, sizeof(n_name)); @@ -226,7 +233,7 @@ getnetanswer(querybuf *answer, int ansle GETSHORT(n, cp); if (class == C_IN && type == T_PTR) { n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !res_hnok(bp)) { + if ((n < 0) || !maybe_hnok(res, bp)) { cp += n; return NULL; } @@ -358,8 +365,8 @@ _dns_getnetbyaddr(void *cbrv, void *cbda __res_put_state(res); return NS_NOTFOUND; } + np = getnetanswer(res, buf, anslen, BYADDR); __res_put_state(res); - np = getnetanswer(buf, anslen, BYADDR); free(buf); if (np) { /* maybe net should be unsigned? */ @@ -470,8 +477,8 @@ _dns_getnetbyname(void *cbrv, void *cbda __res_put_state(res); return NS_NOTFOUND; } + np = getnetanswer(res, buf, anslen, BYNAME); __res_put_state(res); - np = getnetanswer(buf, anslen, BYNAME); free(buf); if (np != NULL) {