From owner-svn-src-head@freebsd.org Fri Oct 26 23:44:40 2018 Return-Path: Delivered-To: svn-src-head@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 9DB2010CCC46; Fri, 26 Oct 2018 23:44:40 +0000 (UTC) (envelope-from imp@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 4F5686FFC7; Fri, 26 Oct 2018 23:44:40 +0000 (UTC) (envelope-from imp@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 26F0D27DAA; Fri, 26 Oct 2018 23:44:40 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9QNiecb075518; Fri, 26 Oct 2018 23:44:40 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9QNieZN075517; Fri, 26 Oct 2018 23:44:40 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201810262344.w9QNieZN075517@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 26 Oct 2018 23:44:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339801 - head/usr.sbin/efivar X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/usr.sbin/efivar X-SVN-Commit-Revision: 339801 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.29 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: Fri, 26 Oct 2018 23:44:40 -0000 Author: imp Date: Fri Oct 26 23:44:39 2018 New Revision: 339801 URL: https://svnweb.freebsd.org/changeset/base/339801 Log: Fix pointer arithmetic botch. Pointer subtraction to find size only works with char pointers. Noticed by: jhb@ Sponsored by: Netflix, Inc Modified: head/usr.sbin/efivar/efiutil.c Modified: head/usr.sbin/efivar/efiutil.c ============================================================================== --- head/usr.sbin/efivar/efiutil.c Fri Oct 26 23:08:22 2018 (r339800) +++ head/usr.sbin/efivar/efiutil.c Fri Oct 26 23:44:39 2018 (r339801) @@ -116,6 +116,8 @@ bindump(uint8_t *data, size_t datalen) #define LOAD_OPTION_ACTIVE 1 +#define SIZE(dp, edp) (size_t)((intptr_t)(void *)edp - (intptr_t)(void *)dp) + void efi_print_load_option(uint8_t *data, size_t datalen, int Aflag, int bflag, int uflag) { @@ -159,9 +161,8 @@ efi_print_load_option(uint8_t *data, size_t datalen, i ucs2_to_utf8(descr, &str); printf("%s", str); free(str); - while (dp < edp && (size_t)(edp - dp) > sizeof(efidp_header)) { - efidp_format_device_path(buf, sizeof(buf), dp, - (intptr_t)(void *)edp - (intptr_t)(void *)dp); + while (dp < edp && SIZE(dp, edp) > sizeof(efidp_header)) { + efidp_format_device_path(buf, sizeof(buf), dp, SIZE(dp, edp)); dp = (efidp)((char *)dp + efidp_size(dp)); printf(" %s\n", buf); }