netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] arpd: drop unnecessary explicit null termination
@ 2016-01-03 16:09 Andreas Henriksson
  2016-01-03 17:04 ` Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Henriksson @ 2016-01-03 16:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Andreas Henriksson

This is a followup to a previous commit 61170fd88d264c
"get rid of unnecessary fgets() buffer size limitation".

If fgets guarantees buffer will be null terminated in the
given size, then we can also drop the explicit termination.

While at it, also add an unrelated FIXME comment about
potential unlikely long comment handling bug spotted in
nearby code.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
 misc/arpd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/misc/arpd.c b/misc/arpd.c
index 6bb9bd1..3be700d 100644
--- a/misc/arpd.c
+++ b/misc/arpd.c
@@ -702,12 +702,16 @@ int main(int argc, char **argv)
 			goto do_abort;
 		}
 
-		buf[sizeof(buf)-1] = 0;
 		while (fgets(buf, sizeof(buf), fp)) {
 			__u8 b1[6];
 			char ipbuf[128];
 			char macbuf[128];
 
+			/* FIXME: this does not properly handle the case where
+			 * the comment line is longer than sizeof(buf).
+			 * Should check if buf contains '\n' or skip upcoming
+			 * bufs until '\n' is found.
+			 */
 			if (buf[0] == '#')
 				continue;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-03 23:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-03 16:09 [PATCH iproute2] arpd: drop unnecessary explicit null termination Andreas Henriksson
2016-01-03 17:04 ` Stephen Hemminger
2016-01-03 18:39   ` [PATCH iproute2 v2 1/2] " Andreas Henriksson
2016-01-03 18:39     ` [PATCH iproute2 v2 2/2] arpd: fix parsing of unlikely long comments Andreas Henriksson
2016-01-03 18:44       ` Andreas Henriksson
2016-01-03 23:04         ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).