chanduusc / libdnet

Automatically exported from code.google.com/p/libdnet
Other
0 stars 0 forks source link

dnet ip fragment offset check #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. dnet ip off 8192 
Usage: dnet ip [tos|id|off|ttl|proto|src|dst <value>] ... 

What is the expected output? What do you see instead?

The fragment offset should be limited to 0xfff8 but the actual limit is
0x1fff because a shift is missing.  Fragments for big IP packets cannot
be created.

What version of the product are you using? On what operating system?

libdnet-1.12 OpenBSD 4.9-beta

Please provide any additional information below.

Just add the correct shift in the check code.
Then this will work: dnet ip off 65528

--- test/dnet/aton.c.orig       Mon Oct 14 17:42:10 2002
+++ test/dnet/aton.c    Thu Jan 20 03:26:57 2011
@@ -86,7 +86,7 @@ off_aton(char *string, uint16_t *off)
        } else {
                i = strtol(string, &p, 10);
                if (*string == '\0' || (*p != '\0' && *p != '+') ||
-                   i > IP_OFFMASK)
+                   i > (IP_OFFMASK << 3))
                        return (-1);
                *off = htons(((*p == '+') ? IP_MF : 0) | (i >> 3));
        }

Original issue reported on code.google.com by alexande...@gmx.net on 20 Jan 2011 at 2:40

Attachments: