[PATCH] Re: Libnet 1.1.2 Released
Frédéric Raynal <[email protected]> Sun, 28 Mar 2004 09:10:40 +0200
| Newsgroups | gmane.comp.security.libnet |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Mar 27, 2004 at 02:28:17PM +0100, Alberto Ornaghi wrote:
> Mike Schiffman wrote:
> >1.1.2 is official (http://www.packetfactory.net/libnet/):
> >
> > Fixed the ICMP error message builders (there was a pblock assembly bug
> > that would prevent you from building more than one ICMP {unreach, time
> > exceed, redirect} in succession; the order of operations has changed
> > slightly for building these packets, see the documenation and
> >sample code
>
> I've looked at the sample code and the new method to construct an icmp
> redirect packet, but if I execute the sample program, I get:
>
> ./icmp_redirect -s 1.1.1.1 -d 2.2.2.2 -g 3.3.3.3
> libnet 1.1 packet shaping: ICMP redirect[link]
> Can't build ICMP header: libnet_pblock_append(): memcpy would overflow
> buffer
>
> any ideas ?
Yep. Someone (I wont tell who he is, but that guy who applied the
patch I sent will recognize himself ... and pay me one more beer) made
a typo in libnet_build_icmpv4_redirect().
Note that I'll pay back a beer to that guy too because I used a
confusing variable name in a macro.
Anyway, here is the patch.
Fred Raynal
icmp_redir.patch
(text/plain, 1.3 KB)
--- libnet/src/libnet_build_icmp.c 2004-03-25 19:50:48.000000000 +0100
+++ libnet-fr/src/libnet_build_icmp.c 2004-03-28 09:00:17.000000000 +0200
@@ -40,10 +40,10 @@
#endif
/* some common cruft for completing ICMP error packets */
-#define LIBNET_BUILD_ICMP_ERR_FINISH(type) \
+#define LIBNET_BUILD_ICMP_ERR_FINISH(len) \
do \
{ \
- n = libnet_pblock_append(l, p, (u_int8_t *)&icmp_hdr, type); \
+ n = libnet_pblock_append(l, p, (u_int8_t *)&icmp_hdr, len); \
if (n == -1) \
{ \
goto bad; \
@@ -425,7 +425,7 @@
icmp_hdr.icmp_sum = (sum ? htons(sum) : 0); /* checksum */
icmp_hdr.hun.gateway = gateway;
- LIBNET_BUILD_ICMP_ERR_FINISH(LIBNET_PBLOCK_ICMPV4_REDIRECT_H);
+ LIBNET_BUILD_ICMP_ERR_FINISH(LIBNET_ICMPV4_REDIRECT_H);
return (ptag ? ptag : libnet_pblock_update(l, p, h,
LIBNET_PBLOCK_ICMPV4_REDIRECT_H));