:: commit bfe3544c13bce7061cf103abbe1963012a5bcf48

Mintsuki <mintsuki@protonmail.com> — 2026-04-04 13:14

parents: 40fb2269b7

lib/misc: Use overflow-checked multiply in ALIGN_UP macro

diff --git a/common/lib/misc.h b/common/lib/misc.h
index 1e8286c5..e733105b 100644
--- a/common/lib/misc.h
+++ b/common/lib/misc.h
@@ -100,7 +100,7 @@ uint64_t strtoui(const char *s, const char **end, int base);
 #define ALIGN_UP(x, a, onerror) ({ \
     __auto_type ALIGN_UP_value = (x); \
     __auto_type ALIGN_UP_align = (a); \
-    ALIGN_UP_value = DIV_ROUNDUP(ALIGN_UP_value, ALIGN_UP_align, onerror) * ALIGN_UP_align; \
+    ALIGN_UP_value = CHECKED_MUL(DIV_ROUNDUP(ALIGN_UP_value, ALIGN_UP_align, onerror), ALIGN_UP_align, onerror); \
     ALIGN_UP_value; \
 })
 
tab: 248 wrap: offon