]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
warnings: ensure printf will not overflow
authorSami Kerola <kerolasa@iki.fi>
Thu, 29 Sep 2016 18:26:45 +0000 (19:26 +0100)
committerSami Kerola <kerolasa@iki.fi>
Thu, 29 Sep 2016 18:28:20 +0000 (19:28 +0100)
Overflow in here should be only a theoretical possibility, but making even
such impossible cannot be a bad thing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
dns.c

diff --git a/dns.c b/dns.c
index 92e9fb7c30b373ccfe2801d32142a63f9fc47293..6a325abb76cbf92da0d44bde5990d60a2094fd9a 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -285,7 +285,7 @@ extern char *dns_lookup2(struct mtr_ctl *ctl, ip_t * ip)
 
      //printf ("lookup: %s\n", strlongip (ctl, ip));
 
-     sprintf (buf, "%s\n", strlongip (ctl, ip));
+     snprintf (buf, sizeof(buf), "%s\n", strlongip (ctl, ip));
      rv = write  (todns[1], buf, strlen (buf));
      if (rv < 0)
        error (0, errno, "couldn't write to resolver process");