]> Zhao Yanbai Git Server - minix.git/commitdiff
Fix out of array bounds errors with -O3 14/1014/1
authorLionel Sambuc <lionel@minix3.org>
Tue, 8 Oct 2013 09:43:31 +0000 (11:43 +0200)
committerLionel Sambuc <lionel@minix3.org>
Tue, 8 Oct 2013 09:43:31 +0000 (11:43 +0200)
When compiling with -O3 gcc seems to be a lot stricter on its checks for
index out of bounds error.

Change-Id: I5a63e1db6aa2375223ff13c6352643a9804fa93d

lib/libcurses/copywin.c
usr.sbin/mtree/spec.c

index 0bec7224fcd3f98dabd2be8163ba546004c3466b..6db2b3bb8df8480368c0d3540aa29530cf17713a 100644 (file)
@@ -118,7 +118,8 @@ int copywin(const WINDOW *srcwin, WINDOW *dstwin,
                                cc.elements = 1;
                                np = sp->nsp;
                                if (np) {
-                                       while (np && cc.elements <=
+                                       /* MINIX: off-by one error, has to be strictly less than. */
+                                       while (np && cc.elements <
                                            CURSES_CCHAR_MAX) {
                                                cc.vals[cc.elements++] = np->ch;
                                                np = np->next;
index 1dcedb434dd987fedb98ffbba7e8a856ef32b012..62eaa0d572f32363a26befd2e2d7ec6b34f6a97e 100644 (file)
@@ -454,7 +454,8 @@ parsedev(char *arg)
                        if (*ep != '\0')
                                mtree_err("invalid number `%s'",
                                    p);
-                       if (argc > MAX_PACK_ARGS)
+                       /* MINIX: 03 warns for above array bounds*/
+                       if (argc >= MAX_PACK_ARGS)
                                mtree_err("too many arguments");
                }
                if (argc < 2)