From nobody Fri Feb 25 15:31:08 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 001DE19CC53E; Fri, 25 Feb 2022 15:31:08 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K4tz03wtqz4WSS; Fri, 25 Feb 2022 15:31:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645803068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CHcseEIyxzkcKXrJoKlEElRQ5UPvWjC/KEkAxUP2OlU=; b=OwDoDb2HlwByH/AEk27Gewhod/6VPvHssScN9YlJxQQX/emWpE1IFpLu2G5TpsAe1Ll5XF Mj2PUJ2kd1PeWNyU5oVNQMF7kU7R3KTaufFqpryPw8/m8HlIiPxTlNpqxtJwdxjEOPT1Yi dpIrJsm8F+f2mL5Iq9ysuD/jKDiq1atu2Nn7Ix9ccAMUdYjaNqKafA/BbuGdHsT50wSv8x UbuD+ZzAG1ZsY4Ok/q9+8uEX9kqr9gXHB0y7kepf9obouAgRwdnFzBhMkTJ+c/0SeUk/Vf 6pewcurmIHbo9jZadsCSfbS0ZvzNjoUkRGcuGaL5zBZR0EldDa1DqXnV36I7sA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29CCC2213C; Fri, 25 Feb 2022 15:31:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21PFV8FJ076273; Fri, 25 Feb 2022 15:31:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21PFV8br076272; Fri, 25 Feb 2022 15:31:08 GMT (envelope-from git) Date: Fri, 25 Feb 2022 15:31:08 GMT Message-Id: <202202251531.21PFV8br076272@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: d0f4e583bff6 - main - efivar: handle error when reading --fromfile List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d0f4e583bff67e2bdd816549c460da6daa3f67b1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645803068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CHcseEIyxzkcKXrJoKlEElRQ5UPvWjC/KEkAxUP2OlU=; b=BLtOH9SVQ+GDXn82T2CLWsazkoLAD1A3jnB8ari+p2cYQFnXj2U+leew1Mk8yBxCf7o6+h +FuH5RJZP/gokTZBuwZRLNmeWjsFKKCD/udUsCnGbvm6/tND6QNqv83yygjwCUY3XntF/L LCTW9Aea08qtzr6XT2LOOlHu1rXM88NQiYzB7sCBxBYoo+20iGhgUpHjGONdWw0kXYIXH0 VyoAl7zELYaB2M6Sjn9s28THALxPb/Ul6ChPeNaFpr2yUis+92Y9syVvja8WILxo2wZkYv 1BnD3HsRgdMGVInXHek5p9fAb4sVkoX11v+cslriRfe6RRXan0OeFjS0vdXdLw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645803068; a=rsa-sha256; cv=none; b=p5y1EjwqNdDBklfu54W4Dg1hSnAtXXh9GsZP9bf75y8fbHvB2GnBcAc9PBc58TPkqDTxJd HkUwf4vFY3ez21D+tXquTDln7T+RQnUD4Qjy15mezVIRZrXVIfDJoHeVySg6Si+hR5kCdN yKFP9U+zOl5IUZxpGEfLUAdItuAjuHrAu9hrO1WTL0VnuOJyOs0cQAeM36ovd70TuEviPk F3SwqHyN1K3Kbdaxs2HGEe5Jd8Gl2MESl885OxqUwo+C1SzBJLevrfEj8nR/RK4UMLxIeZ 2Z/e7RRPX2k9NMrslk3bt7hsdVFFCUSs0d4qYbtoqE6xl9opXZg/HOHWeR+hEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=d0f4e583bff67e2bdd816549c460da6daa3f67b1 commit d0f4e583bff67e2bdd816549c460da6daa3f67b1 Author: Eric van Gyzen AuthorDate: 2022-02-23 18:15:34 +0000 Commit: Eric van Gyzen CommitDate: 2022-02-25 15:30:29 +0000 efivar: handle error when reading --fromfile The result of read() was stored in an unsigned variable, so the test for a negative value would never work. While I'm here, print a better error message for an empty file, omitting the misleading errno message. Reported by: Coverity MFC after: 1 week Sponsored by: Dell EMC Isilon --- usr.sbin/efivar/efivar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/efivar/efivar.c b/usr.sbin/efivar/efivar.c index eb9a6e0257c8..5bdf0c11a488 100644 --- a/usr.sbin/efivar/efivar.c +++ b/usr.sbin/efivar/efivar.c @@ -239,8 +239,10 @@ print_var(efi_guid_t *guid, char *name) if (data == NULL) rep_err(1, "malloc"); datalen = read(fd, data, 64 * 1024); - if (datalen <= 0) + if ((ssize_t)datalen < 0) rep_err(1, "read"); + if (datalen == 0) + rep_errx(1, "empty file"); close(fd); } else { rv = efi_get_variable(*guid, name, &data, &datalen, &att);