aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-03-03 20:18:10 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-03-03 20:18:10 -0800
commit03abbde81db7484ccdb4e1808881e1df20df2fb0 (patch)
tree6d9722ba6c8373122bb86c7562ac8cd5c6ed1598
parent763bb1f82a4519bdf240fd5d43f7e776c0d5206f (diff)
downloadsyslinux-elf-03abbde81db7484ccdb4e1808881e1df20df2fb0.tar.gz
syslinux-elf-03abbde81db7484ccdb4e1808881e1df20df2fb0.tar.xz
syslinux-elf-03abbde81db7484ccdb4e1808881e1df20df2fb0.zip
Prevent inclusion of system include files when inappropriate
Use "-nostdinc -iwithprefix include" to prevent the inclusion of system header files, but still permitting *compiler* header files.
-rw-r--r--com32/lib/MCONFIG3
-rw-r--r--com32/libutil/Makefile8
-rw-r--r--com32/libutil/sha256crypt.c5
-rw-r--r--com32/libutil/sha512crypt.c5
-rw-r--r--com32/menu/Makefile7
-rw-r--r--com32/menu/menumain.c2
-rw-r--r--com32/modules/Makefile5
-rw-r--r--com32/samples/Makefile5
-rw-r--r--dos/Makefile3
9 files changed, 30 insertions, 13 deletions
diff --git a/com32/lib/MCONFIG b/com32/lib/MCONFIG
index 781292ba..7f88055a 100644
--- a/com32/lib/MCONFIG
+++ b/com32/lib/MCONFIG
@@ -28,7 +28,8 @@ LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \
# fallback anyway, just use that on old machines...
# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED
-REQFLAGS = $(GCCOPT) -g -mregparm=3 -DREGPARM=3 -D__COM32__ -I. -I./sys -I../include
+REQFLAGS = $(GCCOPT) -g -mregparm=3 -DREGPARM=3 -D__COM32__ \
+ -nostdinc -iwithprefix include -I. -I./sys -I../include
OPTFLAGS = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \
-falign-labels=0 -ffast-math -fomit-frame-pointer
WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index 426c3335..d9f2a6c8 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -42,7 +42,11 @@ AR = ar
NASM = nasm
NASMOPT = -O9999
RANLIB = ranlib
-CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -D__COM32__ -W -Wall -march=i386 -Os -fomit-frame-pointer -I./include -I../include
+CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I./include -I../include \
+ -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
SFLAGS = $(M32) -D__COM32__ -march=i386
LDFLAGS = -T ../lib/com32.ld
LNXCFLAGS = -I./include -W -Wall -O -g -D_GNU_SOURCE
@@ -112,3 +116,5 @@ spotless: clean
install: all
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
install -m 644 libutil_com.a libutil_lnx.a $(INSTALLROOT)$(COM32DIR)
+
+-include .*.d
diff --git a/com32/libutil/sha256crypt.c b/com32/libutil/sha256crypt.c
index 7dbd8faf..27f912e7 100644
--- a/com32/libutil/sha256crypt.c
+++ b/com32/libutil/sha256crypt.c
@@ -10,11 +10,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/param.h>
+#include <minmax.h>
#include <sys/types.h>
#include "xcrypt.h"
+#define MIN(x,y) min(x,y)
+#define MAX(x,y) max(x,y)
+
/* Structure to save state of computation between the single steps. */
struct sha256_ctx
{
diff --git a/com32/libutil/sha512crypt.c b/com32/libutil/sha512crypt.c
index 9ff587b8..9553ec1e 100644
--- a/com32/libutil/sha512crypt.c
+++ b/com32/libutil/sha512crypt.c
@@ -10,11 +10,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/param.h>
+#include <minmax.h>
#include <sys/types.h>
#include "xcrypt.h"
+#define MIN(x,y) min(x,y)
+#define MAX(x,y) max(x,y)
+
/* Structure to save state of computation between the single steps. */
struct sha512_ctx
{
diff --git a/com32/menu/Makefile b/com32/menu/Makefile
index b898ce08..4e0abc55 100644
--- a/com32/menu/Makefile
+++ b/com32/menu/Makefile
@@ -16,7 +16,7 @@
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
+gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
then echo $(1); else echo $(2); fi; rm -f $$tmpf)
M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-fno-stack-protector,)
@@ -28,8 +28,9 @@ NASM = nasm
NASMOPT = -O9999
RANLIB = ranlib
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -I../libutil/include -I../include \
- -D__COM32__ \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I../libutil/include -I../include \
-Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
LNXCFLAGS = -W -Wall -O -g -I../libutil/include -D_GNU_SOURCE
LNXSFLAGS = -g
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index ac1f9439..f79d00e4 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -803,7 +803,7 @@ run_menu(void)
to_clear = 0;
}
- this_timeout = min(min(key_timeout, timeout_left), CLK_TCK);
+ this_timeout = min(min(key_timeout, timeout_left), (clock_t)CLK_TCK);
key = mygetkey(this_timeout);
if ( key != KEY_NONE ) {
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 88c8593e..4849d1cd 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -28,8 +28,9 @@ NASM = nasm
NASMOPT = -O9999
RANLIB = ranlib
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -I../libutil/include -I../include \
- -D__COM32__ \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I../libutil/include -I../include \
-Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
LNXCFLAGS = -W -Wall -O -g -I../libutil/include
LNXSFLAGS = -g
diff --git a/com32/samples/Makefile b/com32/samples/Makefile
index f17911d7..177f351e 100644
--- a/com32/samples/Makefile
+++ b/com32/samples/Makefile
@@ -28,8 +28,9 @@ NASM = nasm
NASMOPT = -O9999
RANLIB = ranlib
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
- -fomit-frame-pointer -I../libutil/include -I../include \
- -D__COM32__ \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I../libutil/include -I../include \
-Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
LNXCFLAGS = -W -Wall -O -g -I../libutil/include
LNXSFLAGS = -g
diff --git a/dos/Makefile b/dos/Makefile
index 1bfc5135..ad202ee8 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -11,7 +11,8 @@ CC = gcc
LD = ld -m elf_i386
OBJCOPY = objcopy
OPTFLAGS = -g -Os -march=i386 -falign-functions=0 -falign-jumps=0 -falign-loops=0 -fomit-frame-pointer
-INCLUDES = -include code16.h -I. -I.. -I../libfat -I ../libinstaller
+INCLUDES = -include code16.h -nostdinc -iwithprefix include \
+ -I. -I.. -I../libfat -I ../libinstaller
CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -msoft-float $(OPTFLAGS) $(INCLUDES)
LDFLAGS = -T com16.ld
AR = ar