summaryrefslogtreecommitdiff
path: root/src/boot/efi/util.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-03-08 14:16:40 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-03-12 13:32:45 +0100
commit7a2cb0228c2f1b7d95f6be7a751d1074d03e9cb5 (patch)
tree93581f83d1e44975dafe1bc465ced907b10260a6 /src/boot/efi/util.h
parentff19ad888d2a7a9f390e492841763d5b8d1061c4 (diff)
downloadsystemd-7a2cb0228c2f1b7d95f6be7a751d1074d03e9cb5.tar.gz
boot: avoid 32-bit calculation for a 64-bit lvalue
Coverity CID#1399116: > Potentially overflowing expression > gpt_header_buffer.gpt_header.SizeOfPartitionEntry * gpt_header_buffer.gpt_header.NumberOfPartitionEntries > with type unsigned int (32 bits, unsigned) is evaluated using 32-bit > arithmetic, and then used in a context that expects an expression of type > UINTN (64 bits, unsigned). Let's import the ALIGN_TO macro to sd-boot and use it to avoid the issue.
Diffstat (limited to 'src/boot/efi/util.h')
-rw-r--r--src/boot/efi/util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h
index 8c5e35ad25..cef127f400 100644
--- a/src/boot/efi/util.h
+++ b/src/boot/efi/util.h
@@ -7,6 +7,10 @@
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
#define OFFSETOF(x,y) __builtin_offsetof(x,y)
+static inline UINTN ALIGN_TO(UINTN l, UINTN ali) {
+ return ((l + ali - 1) & ~(ali - 1));
+}
+
static inline const CHAR16 *yes_no(BOOLEAN b) {
return b ? L"yes" : L"no";
}