summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--com32/include/dmi/dmi_bios.h14
-rw-r--r--com32/include/sys/pci.h6
-rw-r--r--com32/lib/pci/scan.c42
-rw-r--r--com32/libutil/Makefile2
-rw-r--r--com32/modules/Makefile2
-rw-r--r--com32/modules/dmi_utils.c6
-rw-r--r--com32/samples/Makefile2
-rw-r--r--dos/Makefile2
-rw-r--r--extlinux/Makefile2
-rw-r--r--mbr/Makefile2
-rw-r--r--memdisk/Makefile2
-rw-r--r--memdump/Makefile2
-rw-r--r--menu/Makefile2
-rw-r--r--mtools/Makefile2
-rw-r--r--pxelinux.asm32
-rw-r--r--sample/Makefile2
-rw-r--r--unix/Makefile2
-rw-r--r--win32/Makefile2
19 files changed, 75 insertions, 59 deletions
diff --git a/Makefile b/Makefile
index 9fddb8a9..cde7db04 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ MAKEFLAGS = -r
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) dummy.c -o $$tmpf 2>/dev/null; \
+gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) dummy.c -o $$tmpf 2>/dev/null; \
then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
comma := ,
@@ -232,9 +232,9 @@ clean: local-tidy local-clean
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
dist: tidy
- for dir in . sample memdisk ; do \
- ( cd $$dir && rm -f *~ \#* core ) ; \
- done
+ find . \( -name '*~' -o -name '#*' -o -name core \
+ -o -name '.*.d' -o -name .depend \) -type f -print0 \
+ | xargs -0rt rm -f
local-spotless:
rm -f $(BTARGET) .depend *.so.*
diff --git a/com32/include/dmi/dmi_bios.h b/com32/include/dmi/dmi_bios.h
index d9be233b..0241f0b2 100644
--- a/com32/include/dmi/dmi_bios.h
+++ b/com32/include/dmi/dmi_bios.h
@@ -22,7 +22,7 @@
#define BIOS_BIOS_REVISION_SIZE 16
#define BIOS_FIRMWARE_REVISION_SIZE 16
-#define BIOS_CHAR_NB_ELEMENTS 27
+#define BIOS_CHAR_NB_ELEMENTS 28
#define BIOS_CHAR_X1_NB_ELEMENTS 8
#define BIOS_CHAR_X2_NB_ELEMENTS 3
@@ -58,8 +58,8 @@ static const char *bios_charac_strings[]={
"NEC PC-98" /* 31 */
};
-/* this struct have BIOS_CHAR_NB_ELEMENTS */
-/* each bool is associated to the relevant message above */
+/* this struct has BIOS_CHAR_NB_ELEMENTS */
+/* each bool is associated with the relevant message above */
typedef struct {
bool bios_characteristics_not_supported;
bool isa;
@@ -102,8 +102,8 @@ static const char *bios_charac_x1_strings[]={
"Smart battery is supported" /* 7 */
};
-/* this struct have BIOS_CHAR_X1_NB_ELEMENTS */
-/* each bool is associated to the relevant message above */
+/* this struct has BIOS_CHAR_X1_NB_ELEMENTS */
+/* each bool is associated with the relevant message above */
typedef struct {
bool acpi;
bool usb_legacy;
@@ -121,8 +121,8 @@ static const char *bios_charac_x2_strings[]={
"Targeted content distribution is supported" /* 2 */
};
-/* this struct have BIOS_CHAR_X2_NB_ELEMENTS */
-/* each bool is associated to the relevant message above */
+/* this struct has BIOS_CHAR_X2_NB_ELEMENTS */
+/* each bool is associated with the relevant message above */
typedef struct {
bool bios_boot_specification;
bool bios_network_boot_by_keypress;
diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h
index 3f9b0d97..a49475b6 100644
--- a/com32/include/sys/pci.h
+++ b/com32/include/sys/pci.h
@@ -11,9 +11,9 @@ typedef uint32_t pciaddr_t;
/* a structure for extended pci information */
struct pci_dev_info {
- char *vendor_name;
- char *product_name;
- char *linux_kernel_module;
+ char vendor_name[255];
+ char product_name[255];
+ char linux_kernel_module[64];
};
/* a struct to represent a pci device */
diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c
index 11869930..94c83bbe 100644
--- a/com32/lib/pci/scan.c
+++ b/com32/lib/pci/scan.c
@@ -92,13 +92,14 @@ void get_module_name_from_pci_ids(struct pci_device_list *pci_device_list)
/* initialize the pci_dev_info structure if it doesn't exist yet. */
if (! pci_device->pci_dev_info) {
- pci_device->pci_dev_info = calloc(1,sizeof (struct pci_device));
+ pci_device->pci_dev_info = calloc(1,sizeof *pci_device->pci_dev_info);
+
if (!pci_device->pci_dev_info) {
printf("Can't allocate memory\n");
return;
}
}
- pci_device->pci_dev_info->linux_kernel_module=strdup("unknown");
+ strlcpy(pci_device->pci_dev_info->linux_kernel_module,"unknown",7);
}
/* Opening the modules.pcimap (ofa linux kernel) from the boot device*/
@@ -162,9 +163,9 @@ void get_module_name_from_pci_ids(struct pci_device_list *pci_device_list)
void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
{
char line[MAX_LINE];
- char *vendor=NULL;
+ char vendor[255];
char vendor_id[5];
- char *product=NULL;
+ char product[255];
char product_id[5];
char sub_product_id[5];
char sub_vendor_id[5];
@@ -178,7 +179,7 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
/* initialize the pci_dev_info structure if it doesn't exist yet. */
if (! pci_device->pci_dev_info) {
- pci_device->pci_dev_info = calloc(1,sizeof (struct pci_device));
+ pci_device->pci_dev_info = calloc(1,sizeof *pci_device->pci_dev_info);
if (!pci_device->pci_dev_info) {
printf("Can't allocate memory\n");
@@ -186,15 +187,14 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
}
}
- pci_device->pci_dev_info->vendor_name=strdup("unknown");
- pci_device->pci_dev_info->product_name=strdup("unknown");
+ strlcpy(pci_device->pci_dev_info->vendor_name,"unknown",7);
+ strlcpy(pci_device->pci_dev_info->product_name,"unknown",7);
}
/* Opening the pci.ids from the boot device*/
f=fopen("pci.ids","r");
if (!f)
return;
-
strcpy(vendor_id,"0000");
strcpy(product_id,"0000");
strcpy(sub_product_id,"0000");
@@ -203,7 +203,6 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
/* for each line we found in the pci.ids*/
while ( fgets(line, sizeof line, f) ) {
-
/* Skipping uncessary lines */
if ((line[0] == '#') || (line[0] == ' ') || (line[0] == 'C') ||
(line[0] == 10))
@@ -212,13 +211,13 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
if (line[0] != '\t') {
/* the 4th first chars are the vendor_id */
- strncpy(vendor_id,line,4);
+ strlcpy(vendor_id,line,4);
/* the vendor name is the next field*/
vendor_id[4]=0;
- vendor=strdup(skipspace(strstr(line," ")));
- remove_eol(vendor);
+ strlcpy(vendor,skipspace(strstr(line," ")),255);
+ remove_eol(vendor);
/* init product_id, sub_product and sub_vendor */
strcpy(product_id,"0000");
strcpy(sub_product_id,"0000");
@@ -226,24 +225,23 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
/* ffff is an invalid vendor id */
if (strstr(vendor_id,"ffff")) break;
-
/* assign the vendor_name to any matching pci device*/
for (pci_dev=0; pci_dev < pci_device_list->count; pci_dev++) {
struct pci_device *pci_device =
&pci_device_list->pci_device[pci_dev];
if (hex_to_int(vendor_id) == pci_device->vendor)
- pci_device->pci_dev_info->vendor_name=strdup(vendor);
+ strlcpy(pci_device->pci_dev_info->vendor_name,vendor,255);
}
/* if we have a tab + a char, it means this is a product id */
} else if ((line[0] == '\t') && (line[1] != '\t')) {
/* the product name the second field */
- product=strdup(skipspace(strstr(line," ")));
+ strlcpy(product,skipspace(strstr(line," ")),255);
remove_eol(product);
/* the product id is first field */
- strncpy(product_id,&line[1],4);
+ strlcpy(product_id,&line[1],4);
product_id[4]=0;
/* init sub_product and sub_vendor */
@@ -256,23 +254,23 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
&pci_device_list->pci_device[pci_dev];
if (hex_to_int(vendor_id) == pci_device->vendor &&
hex_to_int(product_id) == pci_device->product)
- pci_device->pci_dev_info->product_name=strdup(product);
+ strlcpy(pci_device->pci_dev_info->product_name,product,255);
}
/* if we have two tabs, it means this is a sub product */
} else if ((line[0] == '\t') && (line[1] == '\t')) {
/* the product name is last field */
- product=skipspace(strstr(line," "));
- product=strdup(skipspace(strstr(product," ")));
+ strlcpy(product,skipspace(strstr(line," ")),255);
+ strlcpy(product,skipspace(strstr(product," ")),255);
remove_eol(product);
/* the sub_vendor id is first field */
- strncpy(sub_vendor_id,&line[2],4);
+ strlcpy(sub_vendor_id,&line[2],4);
sub_vendor_id[4]=0;
/* the sub_vendor id is second field */
- strncpy(sub_product_id,&line[7],4);
+ strlcpy(sub_product_id,&line[7],4);
sub_product_id[4]=0;
/* assign the product_name to any matching pci device*/
@@ -284,7 +282,7 @@ void get_name_from_pci_ids(struct pci_device_list *pci_device_list)
hex_to_int(product_id) == pci_device->product &&
hex_to_int(sub_product_id) == pci_device->sub_product &&
hex_to_int(sub_vendor_id) == pci_device->sub_vendor)
- pci_device->pci_dev_info->product_name=strdup(product);
+ strlcpy(pci_device->pci_dev_info->product_name,product,255);
}
}
}
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index 45e21607..5514f8b6 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -31,7 +31,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,)
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 4849d1cd..8a127e62 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/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,)
diff --git a/com32/modules/dmi_utils.c b/com32/modules/dmi_utils.c
index 83b50d82..df03ba7c 100644
--- a/com32/modules/dmi_utils.c
+++ b/com32/modules/dmi_utils.c
@@ -31,18 +31,18 @@
void display_bios_characteristics(s_dmi *dmi) {
int i;
- for (i=0;i<=BIOS_CHAR_NB_ELEMENTS; i++) {
+ for (i=0;i<BIOS_CHAR_NB_ELEMENTS; i++) {
if (((bool *)(& dmi->bios.characteristics))[i] == true) {
moreprintf("\t\t%s\n", bios_charac_strings[i]);
}
}
- for (i=0;i<=BIOS_CHAR_X1_NB_ELEMENTS; i++) {
+ for (i=0;i<BIOS_CHAR_X1_NB_ELEMENTS; i++) {
if (((bool *)(& dmi->bios.characteristics_x1))[i] == true) {
moreprintf("\t\t%s\n", bios_charac_x1_strings[i]);
}
}
- for (i=0;i<=BIOS_CHAR_X2_NB_ELEMENTS; i++) {
+ for (i=0;i<BIOS_CHAR_X2_NB_ELEMENTS; i++) {
if (((bool *)(& dmi->bios.characteristics_x2))[i] == true) {
moreprintf("\t\t%s\n", bios_charac_x2_strings[i]);
}
diff --git a/com32/samples/Makefile b/com32/samples/Makefile
index 177f351e..189dc187 100644
--- a/com32/samples/Makefile
+++ b/com32/samples/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,)
diff --git a/dos/Makefile b/dos/Makefile
index ad202ee8..4f344f49 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -1,6 +1,6 @@
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,-ffreestanding,) \
diff --git a/extlinux/Makefile b/extlinux/Makefile
index 908d1ce5..9dd7ec94 100644
--- a/extlinux/Makefile
+++ b/extlinux/Makefile
@@ -1,6 +1,6 @@
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) ../dummy.c -o $$tmpf 2>/dev/null; \
+gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) ../dummy.c -o $$tmpf 2>/dev/null; \
then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
comma := ,
diff --git a/mbr/Makefile b/mbr/Makefile
index a64869b1..6a1bcb7b 100644
--- a/mbr/Makefile
+++ b/mbr/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,-ffreestanding,) $(call gcc_ok,-fno-stack-protector)
diff --git a/memdisk/Makefile b/memdisk/Makefile
index e90c72cf..d9cc7f9f 100644
--- a/memdisk/Makefile
+++ b/memdisk/Makefile
@@ -14,7 +14,7 @@ VERSION := $(shell cat ../version)
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,)
diff --git a/memdump/Makefile b/memdump/Makefile
index 40497028..585381d6 100644
--- a/memdump/Makefile
+++ b/memdump/Makefile
@@ -1,6 +1,6 @@
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,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
diff --git a/menu/Makefile b/menu/Makefile
index 512f61aa..58c0e2f0 100644
--- a/menu/Makefile
+++ b/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,)
diff --git a/mtools/Makefile b/mtools/Makefile
index 4b52cb67..7175bb3f 100644
--- a/mtools/Makefile
+++ b/mtools/Makefile
@@ -1,6 +1,6 @@
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) ../dummy.c -o $$tmpf 2>/dev/null; \
+gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) ../dummy.c -o $$tmpf 2>/dev/null; \
then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
comma := ,
diff --git a/pxelinux.asm b/pxelinux.asm
index d0f82771..ba9c6e19 100644
--- a/pxelinux.asm
+++ b/pxelinux.asm
@@ -2099,6 +2099,27 @@ pxe_get_cached_info:
jmp kaboom
;
+; ip_ok
+;
+; Tests an IP address in EAX for validity; return with ZF=1 for bad.
+; We used to refuse class E, but class E addresses are likely to become
+; assignable unicast addresses in the near future.
+;
+ip_ok:
+ push ax
+ cmp eax,-1 ; Refuse the all-ones address
+ jz .out
+ and al,al ; Refuse network zero
+ jz .out
+ cmp al,127 ; Refuse loopback
+ jz .out
+ and al,0F0h
+ cmp al,224 ; Refuse class D
+.out:
+ pop ax
+ ret
+
+;
; parse_dhcp
;
; Parse a DHCP packet. This includes dealing with "overloaded"
@@ -2123,17 +2144,14 @@ pxe_get_cached_info:
parse_dhcp:
mov byte [OverLoad],0 ; Assume no overload
mov eax, [trackbuf+bootp.yip]
- and eax, eax
+ call ip_ok
jz .noyip
- cmp al,224 ; Class D or higher -> bad
- jae .noyip
mov [MyIP], eax
.noyip:
mov eax, [trackbuf+bootp.sip]
and eax, eax
+ call ip_ok
jz .nosip
- cmp al,224 ; Class D or higher -> bad
- jae .nosip
mov [ServerIP], eax
.nosip:
sub cx, bootp.options
@@ -2288,8 +2306,8 @@ dopt_%2:
mov eax,[si]
cmp dword [ServerIP],0
jne .skip ; Already have a next server IP
- cmp al,224 ; Class D or higher
- jae .skip
+ call ip_ok
+ jz .skip
mov [ServerIP],eax
.skip: ret
diff --git a/sample/Makefile b/sample/Makefile
index bd64e906..3ed7907e 100644
--- a/sample/Makefile
+++ b/sample/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,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
diff --git a/unix/Makefile b/unix/Makefile
index 75f7cba2..8d92d3a2 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -1,6 +1,6 @@
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
-gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) ../dummy.c -o $$tmpf 2>/dev/null; \
+gcc_ok = $(shell tmpf=$(TMPFILE); if $(CC) $(1) ../dummy.c -o $$tmpf 2>/dev/null; \
then echo '$(1)'; else echo '$(2)'; fi; rm -f $$tmpf)
comma := ,
diff --git a/win32/Makefile b/win32/Makefile
index 037002b0..ed0ad0ab 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -63,7 +63,7 @@ all:
endif
tidy:
- -rm -f *.o *.i *.s *.a .*.d *_bin.c
+ -rm -f *.o *.i *.s *.a .*.d *_bin.c hello.exe
clean: tidy