Skip to contentSkip to conversation

puzzles: Fix stringop-overflow warning

PATCH New Khem Raj 1 participant 2 messages Feb 27, 2021

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 puzzles: Fix stringop-overflow warning

gcc11 is pedantic about it and finds a case where this maybe used uninitialized

---
 ...01-map-Fix-stringop-overflow-warning.patch | 42 +++++++++++++++++++
 meta/recipes-sato/puzzles/puzzles_git.bb      |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-sato/puzzles/files/0001-map-Fix-stringop-overflow-warning.patch
meta/recipes-sato/puzzles/files/0001-map-Fix-stringop-overflow-warning.patch new file +42 -0
new file mode 100644
index 0000000000..a02d8732ab
@@ -0,0 +1,42 @@
+From 3d78d4cffcdc1242892b6c21c26d1c96938c48d1 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sat, 27 Feb 2021 10:02:43 -0800
+Subject: [PATCH] map: Fix stringop-overflow warning
+
+Fixes
+
+../git/map.c: In function 'new_game_desc':
+../git/map.c:1663:23: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
+ 1663 |         ret[retlen++] = ',';
+      |         ~~~~~~~~~~~~~~^~~~~
+../git/./map.c: In function 'new_game_desc':
+../git/./map.c:1663:23: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
+ 1663 |         ret[retlen++] = ',';
+      |         ~~~~~~~~~~~~~~^~~~~
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ map.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/map.c b/map.c
+index 412305c..fa0c493 100644
+--- a/map.c
++++ b/map.c
+@@ -1659,8 +1659,10 @@ static char *new_game_desc(const game_params *params, random_state *rs,
+ 	    }
+ 	}
+ 
+-	ret[retlen++] = 'a'-1 + run;
+-	ret[retlen++] = ',';
++	if(ret != NULL) {
++		ret[retlen++] = 'a'-1 + run;
++		ret[retlen++] = ',';
++	}
+ 
+ 	run = 0;
+ 	for (i = 0; i < n; i++) {
+-- 
+2.30.1
+
meta/recipes-sato/puzzles/puzzles_git.bb +1 -0
index 5b65cf8655..ecc2b9844d 100644
@@ -15,6 +15,7 @@ SRC_URI = "git://git.tartarus.org/simon/puzzles.git \
            file://0001-pattern.c-Change-string-lenght-parameter-to-be-size_.patch \
            file://fix-ki-uninitialized.patch \
            file://0001-malloc-Check-for-excessive-values-to-malloc.patch \
+           file://0001-map-Fix-stringop-overflow-warning.patch \
            "
 
 UPSTREAM_CHECK_COMMITS = "1"
Signature · 1 line
2.30.1
author
#1 lore raw

PATCH 2/2 igt-gpu-tools: Fix warnings with gcc 11

---
 ...t_edid-Allocate-raw-8-bytes-for-VSDB.patch | 42 +++++++++++++++++++
 .../igt-gpu-tools/igt-gpu-tools_git.bb        |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-graphics/igt-gpu-tools/igt-gpu-tools/0001-lib-igt_edid-Allocate-raw-8-bytes-for-VSDB.patch
meta/recipes-graphics/igt-gpu-tools/igt-gpu-tools/0001-lib-igt_edid-Allocate-raw-8-bytes-for-VSDB.patch new file +42 -0
new file mode 100644
index 0000000000..38bd4550a3
@@ -0,0 +1,42 @@
+From 606349860d27492c328752dca5a3784c0e9a6d24 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sat, 27 Feb 2021 11:05:45 -0800
+Subject: [PATCH i-g-t] lib/igt_edid: Allocate raw 8-bytes for VSDB
+
+hdmi_vsdb is an element of cea_vsdb which makes the size of cea_vsdb to
+be 8 ( 3bytes ieee_oui ) + ( 5bytes hdmi_vsdb struct), its true that we
+only use 7 bytes technically we can only allocate 7byte array but since
+we are writing to elements of hdmi_vsdb struct which is sitting at offet
+4-8 in cea_vsdb, compiler thinks we have an element which is out of
+array bounds since out allocated size is 7bytes
+
+This errors out
+../git/lib/igt_edid.c:365:13: error: array subscript 'struct hdmi_vsdb[0]' is partly outside array bounds of 'char[7]' [-Werror=array-bounds]
+  365 |         hdmi->src_phy_addr[0] = 0x10;
+      |             ^~
+
+allocating one extra byte matches with size of cea_vsdb and compiler is
+happy
+
+Upstream-Status: Submitted [https://lists.freedesktop.org/archives/igt-dev/2021-February/029446.html]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ lib/igt_edid.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/igt_edid.c b/lib/igt_edid.c
+index 1c85486d..ce09cc47 100644
+--- a/lib/igt_edid.c
++++ b/lib/igt_edid.c
+@@ -351,7 +351,7 @@ void cea_sad_init_pcm(struct cea_sad *sad, int channels,
+ const struct cea_vsdb *cea_vsdb_get_hdmi_default(size_t *size)
+ {
+ 	/* We'll generate a VSDB with 2 extension fields. */
+-	static char raw[CEA_VSDB_HDMI_MIN_SIZE + 2] = {0};
++	static char raw[CEA_VSDB_HDMI_MIN_SIZE + 3] = {0};
+ 	struct cea_vsdb *vsdb;
+ 	struct hdmi_vsdb *hdmi;
+ 
+-- 
+2.30.1
+
meta/recipes-graphics/igt-gpu-tools/igt-gpu-tools_git.bb +1 -0
index f25cbc0603..098594cf2c 100644
@@ -11,6 +11,7 @@ SRCREV = "d16ad07e7f2a028e14d61f570931c87fa5ce404c"
 PV = "1.25+git${SRCPV}"
 
 SRC_URI = "git://gitlab.freedesktop.org/drm/igt-gpu-tools.git;protocol=https \
+           file://0001-lib-igt_edid-Allocate-raw-8-bytes-for-VSDB.patch \
            file://reproducibility.patch"
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.30.1