Comment 15 for bug 1876157

Revision history for this message
Bernd Edlinger (bernd-edlinger) wrote :

Hi,

I am also affected by this problem. It is an overflow check
using undefined behavior in an overflow check in test.c
that looks like "if (pe + SPINSZ > pe && pe != 0)"
but with >4G memory pe + SIINSZ wraps around.

I think the most simple fix would be the following:

2020-12-15 Bernd Edlinger <email address hidden>

 * Makefile: Use -fwrapv-pointer for test.c.

diff -u memtest86+-5.01.orig/Makefile memtest86+-5.01/Makefile
--- memtest86+-5.01.orig/Makefile 2020-12-15 06:50:42.000000000 +0100
+++ memtest86+-5.01/Makefile 2020-12-15 06:54:08.941390803 +0100
@@ -58,7 +58,8 @@
  $(CC) -c $(CFLAGS) -fno-strict-aliasing reloc.c

 test.o: test.c
- $(CC) -c -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin -ffreestanding test.c
+ $(CC) -c -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin \
+ -ffreestanding -fwrapv-pointer test.c

 random.o: random.c
  $(CC) -c -Wall -march=i486 -m32 -O3 -fomit-frame-pointer -fno-builtin -ffreestanding random.c