Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ping deduct phdrlen after computing max size.



details:   https://anonhg.NetBSD.org/src/rev/cb46e4533893
branches:  trunk
changeset: 783575:cb46e4533893
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 30 03:19:24 2012 +0000

description:
deduct phdrlen after computing max size.

diffstat:

 sbin/ping/ping.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 334e5da86b8f -r cb46e4533893 sbin/ping/ping.c
--- a/sbin/ping/ping.c  Sun Dec 30 02:41:11 2012 +0000
+++ b/sbin/ping/ping.c  Sun Dec 30 03:19:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ping.c,v 1.104 2012/12/30 02:41:11 christos Exp $      */
+/*     $NetBSD: ping.c,v 1.105 2012/12/30 03:19:24 christos Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -58,7 +58,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.104 2012/12/30 02:41:11 christos Exp $");
+__RCSID("$NetBSD: ping.c,v 1.105 2012/12/30 03:19:24 christos Exp $");
 #endif
 
 #include <stdio.h>
@@ -468,8 +468,8 @@
        } else
                phdrlen = 0;
 
+       packlen = datalen + 60 + 76;    /* MAXIP + MAXICMP */
        datalen -= phdrlen;
-       packlen = datalen + 60 + 76;    /* MAXIP + MAXICMP */
        if ((packet = malloc(packlen)) == NULL)
                err(1, "Out of memory");
 
@@ -637,7 +637,7 @@
 #endif /*IPSEC*/
 
        (void)printf("PING %s (%s): %d data bytes\n", hostname,
-                    inet_ntoa(whereto.sin_addr), datalen);
+                    inet_ntoa(whereto.sin_addr), datalen + phdrlen);
 
        /* When pinging the broadcast address, you can get a lot
         * of answers.  Doing something so evil is useful if you



Home | Main Index | Thread Index | Old Index