From: H. Peter Anvin Date: Tue, 9 Jun 2009 14:29:13 +0000 (-0700) Subject: pxelinux: cleaner test for OACK trailing null bytes X-Git-Tag: syslinux-3.82~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1feb9b05ea0b9690a5e5af8b5919d63d6979a2eb;p=platform%2Fupstream%2Fsyslinux.git 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 --- diff --git a/core/pxelinux.asm b/core/pxelinux.asm index de1b10c..cbfae52 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -1105,16 +1105,16 @@ searchdir: ; SI -> first byte of options; [E]CX -> byte count .parse_oack: jcxz .done_pkt ; No options acked -.get_opt_name: - ; 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 +.get_opt_name: mov di,si mov bx,si .opt_name_loop: lodsb