diff options
authorH. Peter Anvin <hpa@zytor.com>2009-06-09 07:29:13 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-06-09 07:29:13 -0700
commit1feb9b05ea0b9690a5e5af8b5919d63d6979a2eb (patch)
parent6e969f3b4359125780868d9747bc59bbeee86a9e (diff)
pxelinux: cleaner test for OACK trailing null bytes
Instead of looking for a string of null bytes at the end of the OACK string, simply abort parsing if we run into a null byte where an option is expected; either we are seeing junk at the end of the packet, or we are hopelessly confused about how to make sense of the rest of the packet -- in either case, ignoring is the "liberal" option. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 files changed, 9 insertions, 9 deletions
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index de1b10c3..cbfae52f 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -1105,16 +1105,16 @@ searchdir:
; SI -> first byte of options; [E]CX -> byte count
jcxz .done_pkt ; No options acked
- ; Some TFTP servers have junk NUL bytes at the end of the packet.
- ; If all that is left is NUL, then consider the packet processed.
- mov di,si
- push cx
- xor ax,ax
- repz scasb
- pop cx
- jz .done_pkt
+ ; If we find an option which starts with a NUL byte,
+ ; (a null option), we're either seeing garbage that some
+ ; TFTP servers add to the end of the packet, or we have
+ ; no clue how to parse the rest of the packet (what is
+ ; an option name and what is a value?) In either case,
+ ; discard the rest.
+ cmp byte [si],0
+ je .done_pkt
mov di,si
mov bx,si
.opt_name_loop: lodsb