From owner-svn-src-all@freebsd.org Sun Aug 11 15:36:19 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8EDCEBBC52; Sun, 11 Aug 2019 15:36:19 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46633l22XQz4440; Sun, 11 Aug 2019 15:36:19 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0EB5D185A4; Sun, 11 Aug 2019 15:36:19 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7BFaIk4079557; Sun, 11 Aug 2019 15:36:18 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7BFaItn079556; Sun, 11 Aug 2019 15:36:18 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201908111536.x7BFaItn079556@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 11 Aug 2019 15:36:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350859 - head/sbin/ping6 X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/sbin/ping6 X-SVN-Commit-Revision: 350859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Aug 2019 15:36:19 -0000 Author: asomers Date: Sun Aug 11 15:36:18 2019 New Revision: 350859 URL: https://svnweb.freebsd.org/changeset/base/350859 Log: ping6: Remove unnecessary level of indirection from dnsdecode() parameter The `sp' pointer doesn't need to be modified in the caller of dnsdecode(). This fixes -Wcast-qual error (`must have all intermediate pointers const qualified to be safe') when compiled with WARNS=6. Submitted by: Ján Sučan MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21215 Modified: head/sbin/ping6/ping6.c Modified: head/sbin/ping6/ping6.c ============================================================================== --- head/sbin/ping6/ping6.c Sun Aug 11 15:27:34 2019 (r350858) +++ head/sbin/ping6/ping6.c Sun Aug 11 15:36:18 2019 (r350859) @@ -279,7 +279,7 @@ static void pr_suptypes(struct icmp6_nodeinfo *, size static void pr_nodeaddr(struct icmp6_nodeinfo *, int); static int myechoreply(const struct icmp6_hdr *); static int mynireply(const struct icmp6_nodeinfo *); -static char *dnsdecode(const u_char **, const u_char *, const u_char *, +static char *dnsdecode(const u_char *, const u_char *, const u_char *, char *, size_t); static void pr_pack(u_char *, int, struct msghdr *); static void pr_exthdrs(struct msghdr *); @@ -1431,7 +1431,7 @@ mynireply(const struct icmp6_nodeinfo *nip) } static char * -dnsdecode(const u_char **sp, const u_char *ep, const u_char *base, char *buf, +dnsdecode(const u_char *sp, const u_char *ep, const u_char *base, char *buf, size_t bufsiz) /*base for compressed name*/ { @@ -1441,14 +1441,14 @@ dnsdecode(const u_char **sp, const u_char *ep, const u const u_char *comp; int l; - cp = *sp; + cp = sp; *buf = '\0'; if (cp >= ep) return NULL; while (cp < ep) { i = *cp; - if (i == 0 || cp != *sp) { + if (i == 0 || cp != sp) { if (strlcat((char *)buf, ".", bufsiz) >= bufsiz) return NULL; /*result overrun*/ } @@ -1462,7 +1462,7 @@ dnsdecode(const u_char **sp, const u_char *ep, const u return NULL; comp = base + (i & 0x3f); - if (dnsdecode(&comp, cp, base, cresult, + if (dnsdecode(comp, cp, base, cresult, sizeof(cresult)) == NULL) return NULL; if (strlcat(buf, cresult, bufsiz) >= bufsiz) @@ -1486,7 +1486,7 @@ dnsdecode(const u_char **sp, const u_char *ep, const u if (i != 0) return NULL; /*not terminated*/ cp++; - *sp = cp; + sp = cp; return buf; } @@ -1679,7 +1679,7 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr) } else { i = 0; while (cp < end) { - if (dnsdecode((const u_char **)&cp, end, + if (dnsdecode((const u_char *)cp, end, (const u_char *)(ni + 1), dnsname, sizeof(dnsname)) == NULL) { printf("???"); @@ -2461,7 +2461,7 @@ pr_icmph(struct icmp6_hdr *icp, u_char *end) } printf(", subject=%s", niqcode[ni->ni_code]); cp = (const u_char *)(ni + 1); - if (dnsdecode(&cp, end, NULL, dnsname, + if (dnsdecode(cp, end, NULL, dnsname, sizeof(dnsname)) != NULL) printf("(%s)", dnsname); else