From owner-svn-src-head@freebsd.org Thu Oct 1 19:56:39 2020 Return-Path: Delivered-To: svn-src-head@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 5F5CE4326C2; Thu, 1 Oct 2020 19:56:39 +0000 (UTC) (envelope-from kevans@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4C2P5g1srSz4ctQ; Thu, 1 Oct 2020 19:56:39 +0000 (UTC) (envelope-from kevans@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 23A59165BA; Thu, 1 Oct 2020 19:56:39 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 091JudjA056307; Thu, 1 Oct 2020 19:56:39 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 091Jud8f056306; Thu, 1 Oct 2020 19:56:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202010011956.091Jud8f056306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 1 Oct 2020 19:56:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366342 - head/lib/libc/gen X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/lib/libc/gen X-SVN-Commit-Revision: 366342 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 19:56:39 -0000 Author: kevans Date: Thu Oct 1 19:56:38 2020 New Revision: 366342 URL: https://svnweb.freebsd.org/changeset/base/366342 Log: auxv: partially revert r366207, cast buflen to unsigned int as needed The warning generated pre-r366207 is actually a sign comparison warning: error: comparison of integers of different signs: 'unsigned long' and 'int' if (strlcpy(buf, execpath, buflen) >= buflen) Revert parts that affected other lines and just cast this to unsigned int. The buflen < 0 -> EINVAL has been kept despite no longer serving any purposes w.r.t. sign-extension because I do believe it's the right thing to do: "The provided buffer was not the right size for the requested item." The original warning is confirmed to still be gone with an: env WARNS=6 make WITHOUT_TESTS=yes. Reviewed by: asomers, kib X-MFC-With: r366207 Differential Revision: https://reviews.freebsd.org/D26631 Modified: head/lib/libc/gen/auxv.c Modified: head/lib/libc/gen/auxv.c ============================================================================== --- head/lib/libc/gen/auxv.c Thu Oct 1 19:55:52 2020 (r366341) +++ head/lib/libc/gen/auxv.c Thu Oct 1 19:56:38 2020 (r366342) @@ -67,8 +67,7 @@ __init_elf_aux_vector(void) } static pthread_once_t aux_once = PTHREAD_ONCE_INIT; -static int pagesize, osreldate, ncpus, bsdflags; -static size_t canary_len, pagesizes_len; +static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags; static int hwcap_present, hwcap2_present; static char *canary, *pagesizes, *execpath; static void *ps_strings, *timekeep; @@ -246,7 +245,6 @@ int _elf_aux_info(int aux, void *buf, int buflen) { int res; - size_t buflen_; __init_elf_aux_vector(); if (__elf_aux_vector == NULL) @@ -255,12 +253,11 @@ _elf_aux_info(int aux, void *buf, int buflen) if (buflen < 0) return (EINVAL); - buflen_ = (size_t)buflen; switch (aux) { case AT_CANARY: - if (canary != NULL && canary_len >= buflen_) { - memcpy(buf, canary, buflen_); + if (canary != NULL && canary_len >= buflen) { + memcpy(buf, canary, buflen); memset(canary, 0, canary_len); canary = NULL; res = 0; @@ -273,35 +270,36 @@ _elf_aux_info(int aux, void *buf, int buflen) else if (buf == NULL) res = EINVAL; else { - if (strlcpy(buf, execpath, buflen_) >= buflen_) + if (strlcpy(buf, execpath, buflen) >= + (unsigned int)buflen) res = EINVAL; else res = 0; } break; case AT_HWCAP: - if (hwcap_present && buflen_ == sizeof(u_long)) { + if (hwcap_present && buflen == sizeof(u_long)) { *(u_long *)buf = hwcap; res = 0; } else res = ENOENT; break; case AT_HWCAP2: - if (hwcap2_present && buflen_ == sizeof(u_long)) { + if (hwcap2_present && buflen == sizeof(u_long)) { *(u_long *)buf = hwcap2; res = 0; } else res = ENOENT; break; case AT_PAGESIZES: - if (pagesizes != NULL && pagesizes_len >= buflen_) { - memcpy(buf, pagesizes, buflen_); + if (pagesizes != NULL && pagesizes_len >= buflen) { + memcpy(buf, pagesizes, buflen); res = 0; } else res = ENOENT; break; case AT_PAGESZ: - if (buflen_ == sizeof(int)) { + if (buflen == sizeof(int)) { if (pagesize != 0) { *(int *)buf = pagesize; res = 0; @@ -311,7 +309,7 @@ _elf_aux_info(int aux, void *buf, int buflen) res = EINVAL; break; case AT_OSRELDATE: - if (buflen_ == sizeof(int)) { + if (buflen == sizeof(int)) { if (osreldate != 0) { *(int *)buf = osreldate; res = 0; @@ -321,7 +319,7 @@ _elf_aux_info(int aux, void *buf, int buflen) res = EINVAL; break; case AT_NCPUS: - if (buflen_ == sizeof(int)) { + if (buflen == sizeof(int)) { if (ncpus != 0) { *(int *)buf = ncpus; res = 0; @@ -331,7 +329,7 @@ _elf_aux_info(int aux, void *buf, int buflen) res = EINVAL; break; case AT_TIMEKEEP: - if (buflen_ == sizeof(void *)) { + if (buflen == sizeof(void *)) { if (timekeep != NULL) { *(void **)buf = timekeep; res = 0; @@ -341,14 +339,14 @@ _elf_aux_info(int aux, void *buf, int buflen) res = EINVAL; break; case AT_BSDFLAGS: - if (buflen_ == sizeof(int)) { + if (buflen == sizeof(int)) { *(int *)buf = bsdflags; res = 0; } else res = EINVAL; break; case AT_PS_STRINGS: - if (buflen_ == sizeof(void *)) { + if (buflen == sizeof(void *)) { if (ps_strings != NULL) { *(void **)buf = ps_strings; res = 0;