From 13c74706ef872aa9ed5f17572b6466ce5af26b95 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 13 Sep 2017 12:51:23 +1000 Subject: deps: upgrade to c-ares v1.13.0 PR-URL: https://github.com/nodejs/node/pull/15378 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- deps/cares/src/ares_getnameinfo.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'deps/cares/src/ares_getnameinfo.c') diff --git a/deps/cares/src/ares_getnameinfo.c b/deps/cares/src/ares_getnameinfo.c index 45161124ca..c77b1f8153 100644 --- a/deps/cares/src/ares_getnameinfo.c +++ b/deps/cares/src/ares_getnameinfo.c @@ -356,12 +356,9 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags, #ifdef HAVE_IF_INDEXTONAME int is_ll, is_mcll; #endif - static const char fmt_u[] = "%u"; - static const char fmt_lu[] = "%lu"; char tmpbuf[IF_NAMESIZE + 2]; size_t bufl; - const char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))? - fmt_lu:fmt_u; + int is_scope_long = sizeof(addr6->sin6_scope_id) > sizeof(unsigned int); tmpbuf[0] = '%'; @@ -371,15 +368,38 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags, if ((flags & ARES_NI_NUMERICSCOPE) || (!is_ll && !is_mcll)) { - sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id); + if (is_scope_long) + { + sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); + } + else + { + sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); + } } else { if (if_indextoname(addr6->sin6_scope_id, &tmpbuf[1]) == NULL) - sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id); + { + if (is_scope_long) + { + sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); + } + else + { + sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); + } + } } #else - sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id); + if (is_scope_long) + { + sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); + } + else + { + sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); + } (void) flags; #endif tmpbuf[IF_NAMESIZE + 1] = '\0'; -- cgit v1.2.3