diff options
Diffstat (limited to 'meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch')
-rw-r--r-- | meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch b/meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch index 66af6afa2f..b572b55d1c 100644 --- a/meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch +++ b/meta/recipes-sato/puzzles/files/0001-malloc-Check-for-excessive-values-to-malloc.patch @@ -1,49 +1,45 @@ -From 1c01a5bc9ac7f8aaa484b1a8e0e74aa5f8899d0e Mon Sep 17 00:00:00 2001 -From: Khem Raj <raj.khem@gmail.com> -Date: Sun, 8 Nov 2020 11:17:59 -0800 -Subject: [PATCH] malloc: Check for excessive values to malloc - -with whole program optimizers like lto smalloc() -is inlined the excessive constant argument is propagated to -malloc() and ultimately triggers the warning. - -malloc.c:15:9: error: argument 1 range [18446744065119617024, 18446744073709551580] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=] - -therefore add a check before excessive constant argument before calling -malloc - -Note that this will not happen with normal compile since they happen to -be in different translation units and compiler can not semantically -analyze as much - -Upstream-Status: Pending - -Signed-off-by: Khem Raj <raj.khem@gmail.com> ---- - malloc.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/malloc.c b/malloc.c -index a7fa7c5..520377c 100644 ---- a/malloc.c -+++ b/malloc.c -@@ -2,6 +2,7 @@ - * malloc.c: safe wrappers around malloc, realloc, free, strdup - */ +tree234: Avoid excessive values to malloc + +with whole program optimizers like lto, smalloc() is inlined the excessive +constant argument is propagated to malloc() and ultimately triggers the warning. + +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c: In function 'disptree': +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:46:17: error: argument 1 value '18446744073709551612' exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=] +| 46 | #define smalloc malloc +| | ^ +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:1631:17: note: in expansion of macro 'smalloc' +| 1631 | leveldata = smalloc(ht * (width+2)); +| | ^~~~~~~ +| In file included from tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:29: +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/recipe-sysroot/usr/include/stdlib.h:539:14: note: in a call to allocation function 'malloc' declared here +| 539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__ +| | ^~~~~~ +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:46:17: error: argument 1 value '18446744073709551600' exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=] +| 46 | #define smalloc malloc +| | ^ +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:1632:18: note: in expansion of macro 'smalloc' +| 1632 | ctx.levels = smalloc(ht * sizeof(char *)); +| | ^~~~~~~ +| In file included from tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/git/tree234.c:29: +| tmp/work/core2-64-poky-linux/puzzles/2_0.0+gitAUTOINC+640f9235c7-r0/recipe-sysroot/usr/include/stdlib.h:539:14: note: in a call to allocation function 'malloc' declared here +| 539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__ +| | ^~~~~~ +| cc1: some warnings being treated as errors + +Upstream-Status: Submitted [email discussion with upstream] + +Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> + +Index: git/tree234.c +=================================================================== +--- git.orig/tree234.c ++++ git/tree234.c +@@ -1621,7 +1621,7 @@ void disptree(tree234 *t) { + dispctx ctx; + char *leveldata; + int width = count234(t); +- int ht = height234(t) * 3 - 2; ++ unsigned int ht = height234(t) * 3 - 2; + int i; -+#include <stdint.h> - #include <stdlib.h> - #include <string.h> - #include "puzzles.h" -@@ -12,6 +13,8 @@ - */ - void *smalloc(size_t size) { - void *p; -+ if (size > PTRDIFF_MAX) -+ fatal("exceeds maximum object size"); - p = malloc(size); - if (!p) - fatal("out of memory"); --- -2.29.2 - + if (!t->root) { |