]> granicus.if.org Git - strace/commitdiff
fix unsigned arithmetic bug in previous change
authorJohn Hughes <john@Calva.COM>
Fri, 24 May 2002 10:19:44 +0000 (10:19 +0000)
committerJohn Hughes <john@Calva.COM>
Fri, 24 May 2002 10:19:44 +0000 (10:19 +0000)
ChangeLog
net.c
stream.c

index 55ec542e19a1b92ae21f18bf23265c5095673ec2..cd0c9e25e68c5a7e32cdffbb1c9c6cc58a5779c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-24  John Hughes <john@calva.com>
+
+       * stream.h, net.h: Avoid possible infinite loop caused by
+       unsigned arithmetic in preceeding change.
+
 2002-05-23  John Hughes <john@calva.com>
 
        * acconfig.h: Add HAVE_OPTHDR and HAVE_T_OPTHDR defines.
diff --git a/net.c b/net.c
index 34659803cf154ecb5455124ed5d58da25f201d8a..5ab0d6755a83a7e1ed545795a7e4bb1942f1b3fe 100644 (file)
--- 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) {
index a8ea11efbb8a77cb339bc080535835d3104ab3c5..42bfcc8fd121a4e2eaeca913c7fea9dba39d6afc 100644 (file)
--- 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 (", ");