From owner-svn-src-projects@freebsd.org Wed Jun 13 23:56:23 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 711D5100351F for ; Wed, 13 Jun 2018 23:56:23 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1E7B6836C9; Wed, 13 Jun 2018 23:56:23 +0000 (UTC) (envelope-from rmacklem@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 F321220803; Wed, 13 Jun 2018 23:56:22 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DNuMS3058403; Wed, 13 Jun 2018 23:56:22 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DNuM6J058402; Wed, 13 Jun 2018 23:56:22 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201806132356.w5DNuM6J058402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 13 Jun 2018 23:56:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r335096 - projects/pnfs-planb-server/usr.bin/pnfsdsfile X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/pnfs-planb-server/usr.bin/pnfsdsfile X-SVN-Commit-Revision: 335096 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 23:56:23 -0000 Author: rmacklem Date: Wed Jun 13 23:56:22 2018 New Revision: 335096 URL: https://svnweb.freebsd.org/changeset/base/335096 Log: Fix a few things in preparation for a merge to head. Get rid of SPDX-License-Identifier for now. Use a second ssize_t variable to avoid a "signed vs unsigned" warning for powerpc. Copy ai_addr to a struct sockaddr_in instead of casting the pointer, since mips warns that the alignment requirements are different. Modified: projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c Modified: projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c ============================================================================== --- projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c Wed Jun 13 23:48:49 2018 (r335095) +++ projects/pnfs-planb-server/usr.bin/pnfsdsfile/pnfsdsfile.c Wed Jun 13 23:56:22 2018 (r335096) @@ -1,6 +1,4 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * * Copyright (c) 2017 Rick Macklem * * Redistribution and use in source and binary forms, with or without @@ -67,13 +65,13 @@ int main(int argc, char *argv[]) { struct addrinfo *res, *ad, *newres; - struct sockaddr_in *sin, *adsin; - struct sockaddr_in6 *sin6, *adsin6; + struct sockaddr_in *sin, adsin; + struct sockaddr_in6 *sin6, adsin6; char hostn[2 * NI_MAXHOST + 2], *cp; struct pnfsdsfile dsfile[NFSDEV_MAXMIRRORS]; int ch, dosetxattr, i, mirrorcnt, quiet, zerods, zerofh; in_port_t tport; - ssize_t xattrsize; + ssize_t xattrsize, xattrsize2; zerods = 0; zerofh = 0; @@ -81,6 +79,7 @@ main(int argc, char *argv[]) dosetxattr = 0; res = NULL; newres = NULL; + cp = NULL; while ((ch = getopt_long(argc, argv, "c:qr:s:z", longopts, NULL)) != -1) { switch (ch) { @@ -145,7 +144,8 @@ main(int argc, char *argv[]) xattrsize = extattr_get_file(*argv, EXTATTR_NAMESPACE_SYSTEM, "pnfsd.dsfile", dsfile, sizeof(dsfile)); mirrorcnt = xattrsize / sizeof(struct pnfsdsfile); - if (mirrorcnt < 1 || xattrsize != mirrorcnt * sizeof(struct pnfsdsfile)) + xattrsize2 = mirrorcnt * sizeof(struct pnfsdsfile); + if (mirrorcnt < 1 || xattrsize != xattrsize2) err(1, "Can't get extattr pnfsd.dsfile for %s", *argv); if (quiet == 0) @@ -166,16 +166,22 @@ main(int argc, char *argv[]) sin6 = &dsfile[i].dsf_sin6; ad = res; while (ad != NULL) { - adsin = (struct sockaddr_in *)ad->ai_addr; - adsin6 = (struct sockaddr_in6 *)ad->ai_addr; - if (adsin->sin_family == sin->sin_family) { - if (sin->sin_family == AF_INET && - sin->sin_addr.s_addr == - adsin->sin_addr.s_addr) + if (ad->ai_addr->sa_family == AF_INET && + sin->sin_family == AF_INET && + ad->ai_addrlen >= sizeof(adsin)) { + memcpy(&adsin, ad->ai_addr, + sizeof(adsin)); + if (sin->sin_addr.s_addr == + adsin.sin_addr.s_addr) break; - else if (sin->sin_family == AF_INET6 && - IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, - &adsin6->sin6_addr)) + } + if (ad->ai_addr->sa_family == AF_INET6 && + sin6->sin6_family == AF_INET6 && + ad->ai_addrlen >= sizeof(adsin6)) { + memcpy(&adsin6, ad->ai_addr, + sizeof(adsin6)); + if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, + &adsin6.sin6_addr)) break; } ad = ad->ai_next; @@ -198,16 +204,22 @@ main(int argc, char *argv[]) sin6 = &dsfile[i].dsf_sin6; ad = res; while (ad != NULL) { - adsin = (struct sockaddr_in *)ad->ai_addr; - adsin6 = (struct sockaddr_in6 *)ad->ai_addr; - if (adsin->sin_family == sin->sin_family) { - if (sin->sin_family == AF_INET && - sin->sin_addr.s_addr == - adsin->sin_addr.s_addr) + if (ad->ai_addr->sa_family == AF_INET && + sin->sin_family == AF_INET && + ad->ai_addrlen >= sizeof(adsin)) { + memcpy(&adsin, ad->ai_addr, + sizeof(adsin)); + if (sin->sin_addr.s_addr == + adsin.sin_addr.s_addr) break; - else if (sin->sin_family == AF_INET6 && - IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, - &adsin6->sin6_addr)) + } + if (ad->ai_addr->sa_family == AF_INET6 && + sin6->sin6_family == AF_INET6 && + ad->ai_addrlen >= sizeof(adsin6)) { + memcpy(&adsin6, ad->ai_addr, + sizeof(adsin6)); + if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, + &adsin6.sin6_addr)) break; } ad = ad->ai_next; @@ -234,16 +246,22 @@ main(int argc, char *argv[]) sin6 = &dsfile[i].dsf_sin6; ad = res; while (ad != NULL) { - adsin = (struct sockaddr_in *)ad->ai_addr; - adsin6 = (struct sockaddr_in6 *)ad->ai_addr; - if (adsin->sin_family == sin->sin_family) { - if (sin->sin_family == AF_INET && - sin->sin_addr.s_addr == - adsin->sin_addr.s_addr) + if (ad->ai_addr->sa_family == AF_INET && + sin->sin_family == AF_INET && + ad->ai_addrlen >= sizeof(adsin)) { + memcpy(&adsin, ad->ai_addr, + sizeof(adsin)); + if (sin->sin_addr.s_addr == + adsin.sin_addr.s_addr) break; - else if (sin->sin_family == AF_INET6 && - IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, - &adsin6->sin6_addr)) + } + if (ad->ai_addr->sa_family == AF_INET6 && + sin6->sin6_family == AF_INET6 && + ad->ai_addrlen >= sizeof(adsin6)) { + memcpy(&adsin6, ad->ai_addr, + sizeof(adsin6)); + if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, + &adsin6.sin6_addr)) break; } ad = ad->ai_next;