aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-07-26 13:24:24 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-07-26 13:24:24 +0800
commit8092b5ba226dfd890e687041cc0f3f368bc5ee22 (patch)
treea9aed29d42aad45a7681fa3ab412b1282c54c230
parentf8656a106215d6bb464edbf978a518b6f1dad39b (diff)
downloadpxelinux-8092b5ba226dfd890e687041cc0f3f368bc5ee22.tar.gz
pxelinux-8092b5ba226dfd890e687041cc0f3f368bc5ee22.tar.xz
pxelinux-8092b5ba226dfd890e687041cc0f3f368bc5ee22.zip
Core:PXELINUX: ip_ok converted
-rw-r--r--core/extern.inc2
-rw-r--r--core/pxe.c31
-rw-r--r--core/pxelinux.asm27
3 files changed, 34 insertions, 26 deletions
diff --git a/core/extern.inc b/core/extern.inc
index 9cb03f18..2aa25e23 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -16,7 +16,7 @@
extern parse_dotquad, is_url, lchexbytes, uchexbytes, is_pxe, is_pxenv
extern memory_scan_for_pxe_struct, memory_scan_for_pxenv_struct
extern gendotquad, pxe_load_config, try_load, allocate_socket
- extern free_socket
+ extern free_socket, ip_ok
; debug.c
extern debug, print_reg
diff --git a/core/pxe.c b/core/pxe.c
index 2b484925..206105f6 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -504,7 +504,36 @@ void allocate_socket(com32sys_t *regs)
*/
void free_socket(com32sys_t *regs)
{
- memset(regs->esi.w[0], 0, sizeof(struct open_file_t));
+ /* tftp_pktbuf is not cleared */
+ memset(regs->esi.w[0], 0, sizeof(struct open_file_t) - 2);
regs->esi.w[0] = 0;
regs->eflags.l |= EFLAGS_ZF;
}
+
+
+/************
+;
+; 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.
+;
+*************/
+void ip_ok(com32sys_t *regs)
+{
+ int ip = regs->eax.l;
+
+ if (ip == -1) /* Refuse the all-one address */
+ goto bad;
+ if ((ip & 0xff) == 0) /* Refuse network zero */
+ goto bad;
+ if ((ip & 0xff) == 0xff) /* Refuse loopback */
+ goto bad;
+ if ((ip & 0xf0) == 0xe0) /* Refuse class D */
+ goto bad;
+ regs->eflags.l &= ~EFLAGS_ZF;
+ return;
+
+ bad:
+ regs->eflags.l |= EFLAGS_ZF;
+}
+
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 809d3f87..9b18702e 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -1853,27 +1853,6 @@ get_packet_msg db 'Getting cached packet', 0
section .text16
;
-; 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"
@@ -1898,13 +1877,13 @@ ip_ok:
parse_dhcp:
mov byte [OverLoad],0 ; Assume no overload
mov eax, [trackbuf+bootp.yip]
- call ip_ok
+ pm_call ip_ok
jz .noyip
mov [MyIP], eax
.noyip:
mov eax, [trackbuf+bootp.sip]
and eax, eax
- call ip_ok
+ pm_call ip_ok
jz .nosip
mov [ServerIP], eax
.nosip:
@@ -2060,7 +2039,7 @@ dopt_%2:
mov eax,[si]
cmp dword [ServerIP],0
jne .skip ; Already have a next server IP
- call ip_ok
+ pm_call ip_ok
jz .skip
mov [ServerIP],eax
.skip: ret