app: aboot: Check to avoid overflow, while roundoff operation.

This change return UNIT_MAX in ROUND_TO_PAGE operation, if overflow
occurs.

Change-Id: I93843959c6e5e131737a0c7db8d56c81d30da285
diff --git a/include/stdlib.h b/include/stdlib.h
index 22dcf4c..4a90831 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -49,6 +49,9 @@
 #define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
 #define ROUNDDOWN(a, b) ((a) & ~((b)-1))
 
+/* Macro returns UINT_MAX in case of overflow */
+#define ROUND_TO_PAGE(x,y) (ROUNDUP((x),(y)+1) < (x))?UINT_MAX:ROUNDUP((x),(y)+1)
+
 /* allocate a buffer on the stack aligned and padded to the cpu's cache line size */
 #define STACKBUF_DMA_ALIGN(var, size) \
 	uint8_t __##var[(size) + CACHE_LINE] __attribute__((aligned(CACHE_LINE))); uint8_t *var = (uint8_t *)(ROUNDUP((addr_t)__##var, CACHE_LINE))