From: John Hughes Date: Fri, 24 May 2002 10:19:44 +0000 (+0000) Subject: fix unsigned arithmetic bug in previous change X-Git-Tag: v4.5.18~976 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c4e3a8061130493bd196564f096b677c5528fc1;p=strace fix unsigned arithmetic bug in previous change --- diff --git a/ChangeLog b/ChangeLog index 55ec542e..cd0c9e25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-05-24 John Hughes + + * stream.h, net.h: Avoid possible infinite loop caused by + unsigned arithmetic in preceeding change. + 2002-05-23 John Hughes * acconfig.h: Add HAVE_OPTHDR and HAVE_T_OPTHDR defines. diff --git a/net.c b/net.c index 34659803..5ab0d675 100644 --- a/net.c +++ b/net.c @@ -1436,7 +1436,7 @@ int len; int c = 0; struct opthdr hdr; - while (len >= sizeof hdr) { + while (len >= (int) sizeof hdr) { if (umove(tcp, addr, &hdr) < 0) break; if (c++) { tprintf (", "); @@ -1448,8 +1448,10 @@ int len; addr += sizeof hdr; len -= sizeof hdr; printsockopt (tcp, hdr.level, hdr.name, addr, hdr.len); - addr += hdr.len; - len -= hdr.len; + if (hdr.len > 0) { + addr += hdr.len; + len -= hdr.len; + } tprintf ("}"); } if (len > 0) { diff --git a/stream.c b/stream.c index a8ea11ef..42bfcc8f 100644 --- a/stream.c +++ b/stream.c @@ -505,7 +505,7 @@ int len; int c = 0; struct t_opthdr hdr; - while (len >= sizeof hdr) { + while (len >= (int) sizeof hdr) { if (umove(tcp, addr, &hdr) < 0) break; if (c++) { tprintf (", ");