summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/include/2common.h4
-rw-r--r--tests/vb2_common_tests.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h
index 181cf4c1..695f50d1 100644
--- a/firmware/2lib/include/2common.h
+++ b/firmware/2lib/include/2common.h
@@ -298,7 +298,7 @@ static inline uint8_t *vb2_packed_key_data_mutable(
static inline const uint8_t *vb2_packed_key_data(
const struct vb2_packed_key *key)
{
- return (const uint8_t *)key + key->key_offset;
+ return (const uint8_t *)((uintptr_t)key + key->key_offset);
}
/**
@@ -331,7 +331,7 @@ static inline uint8_t *vb2_signature_data_mutable(
static inline const uint8_t *vb2_signature_data(
const struct vb2_signature *sig)
{
- return (const uint8_t *)sig + sig->sig_offset;
+ return (const uint8_t *)((uintptr_t)sig + sig->sig_offset);
}
/**
diff --git a/tests/vb2_common_tests.c b/tests/vb2_common_tests.c
index 11d183cf..d76c4023 100644
--- a/tests/vb2_common_tests.c
+++ b/tests/vb2_common_tests.c
@@ -276,9 +276,11 @@ static void test_helper_functions(void)
{
struct vb2_packed_key k = {.key_offset = sizeof(k),
.key_size = 128};
+ const void *lower_base;
TEST_SUCC(vb2_verify_packed_key_inside(&k, sizeof(k)+128, &k),
"vb2_packed_key_inside() ok 1");
- TEST_SUCC(vb2_verify_packed_key_inside(&k - 1,
+ lower_base = (const void *)((uintptr_t)&k - sizeof(k));
+ TEST_SUCC(vb2_verify_packed_key_inside(lower_base,
2*sizeof(k)+128, &k),
"vb2_packed_key_inside() ok 2");
TEST_EQ(vb2_verify_packed_key_inside(&k, 128, &k),
@@ -297,9 +299,11 @@ static void test_helper_functions(void)
{
struct vb2_signature s = {.sig_offset = sizeof(s),
.sig_size = 128};
+ const void *lower_base;
TEST_SUCC(vb2_verify_signature_inside(&s, sizeof(s)+128, &s),
"vb2_verify_signature_inside() ok 1");
- TEST_SUCC(vb2_verify_signature_inside(&s - 1,
+ lower_base = (const void *)((uintptr_t)&s - sizeof(s));
+ TEST_SUCC(vb2_verify_signature_inside(lower_base,
2*sizeof(s)+128, &s),
"vb2_verify_signature_inside() ok 2");
TEST_EQ(vb2_verify_signature_inside(&s, 128, &s),