aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/efivar/efiutil.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-10-26 23:44:39 +0000
committerWarner Losh <imp@FreeBSD.org>2018-10-26 23:44:39 +0000
commit92f9212ba6ab4a7fc1265883eb3292d42e6dde9b (patch)
treea10a527b198e2f03475183e741fcd5596a96aed8 /usr.sbin/efivar/efiutil.c
parentdf65fbc5699cb0bbec72e72335895721a61f959f (diff)
downloadsrc-92f9212ba6ab4a7fc1265883eb3292d42e6dde9b.tar.gz
src-92f9212ba6ab4a7fc1265883eb3292d42e6dde9b.zip
Fix pointer arithmetic botch.
Pointer subtraction to find size only works with char pointers. Noticed by: jhb@ Sponsored by: Netflix, Inc
Notes
Notes: svn path=/head/; revision=339801
Diffstat (limited to 'usr.sbin/efivar/efiutil.c')
-rw-r--r--usr.sbin/efivar/efiutil.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/efivar/efiutil.c b/usr.sbin/efivar/efiutil.c
index a7dfc2474b04..0ccf2950df2a 100644
--- a/usr.sbin/efivar/efiutil.c
+++ b/usr.sbin/efivar/efiutil.c
@@ -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, int Aflag, int bflag, int u
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);
}