public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [B.A.T.M.A.N.] [PATCH 5/6] batctl: Initialize complete ping packet before write
Date: Sat, 24 May 2014 14:16:43 +0200	[thread overview]
Message-ID: <1400933804-9661-5-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1400933804-9661-1-git-send-email-sven@narfation.org>

The data structure for ping packets is not completely initialized by the
userspace because the kernel sets the originator address of the packet. This
is not only a bad practice but also irritate tools like valgrind.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 ping.c       | 1 +
 traceroute.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/ping.c b/ping.c
index 6642188..bdca222 100644
--- a/ping.c
+++ b/ping.c
@@ -176,6 +176,7 @@ int ping(char *mesh_iface, int argc, char **argv)
 
 	packet_len = sizeof(struct batadv_icmp_packet);
 
+	memset(&icmp_packet_out, 0, sizeof(icmp_packet_out));
 	memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN);
 	icmp_packet_out.packet_type = BATADV_ICMP;
 	icmp_packet_out.version = BATADV_COMPAT_VERSION;
diff --git a/traceroute.c b/traceroute.c
index 22b90f2..4ebfec2 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -133,6 +133,7 @@ int traceroute(char *mesh_iface, int argc, char **argv)
 		goto out;
 	}
 
+	memset(&icmp_packet_out, 0, sizeof(icmp_packet_out));
 	memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN);
 	icmp_packet_out.version = BATADV_COMPAT_VERSION;
 	icmp_packet_out.packet_type = BATADV_ICMP;
-- 
2.0.0.rc2


  parent reply	other threads:[~2014-05-24 12:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-24 12:16 [B.A.T.M.A.N.] [PATCH 1/6] batctl: Don't try to close negative file descriptors Sven Eckelmann
2014-05-24 12:16 ` [B.A.T.M.A.N.] [PATCH 2/6] batctl: Force null termination of string after strncpy Sven Eckelmann
2014-06-10 14:41   ` Marek Lindner
2014-05-24 12:16 ` [B.A.T.M.A.N.] [PATCH 3/6] batctl: Use strncpy instead of strcpy for string copy Sven Eckelmann
2014-06-10 14:49   ` Marek Lindner
2014-05-24 12:16 ` [B.A.T.M.A.N.] [PATCH 4/6] batctl: Return success only with valid line_ptr in read_file Sven Eckelmann
2014-06-10 14:53   ` Marek Lindner
2014-05-24 12:16 ` Sven Eckelmann [this message]
2014-06-10 14:58   ` [B.A.T.M.A.N.] [PATCH 5/6] batctl: Initialize complete ping packet before write Marek Lindner
2014-05-24 12:16 ` [B.A.T.M.A.N.] [PATCH 6/6] batctl: Don't provide uninitialized parameter to read_file Sven Eckelmann
2014-06-10 14:59   ` Marek Lindner
2014-06-10 14:31 ` [B.A.T.M.A.N.] [PATCH 1/6] batctl: Don't try to close negative file descriptors Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400933804-9661-5-git-send-email-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox