]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: use appropriate buffer sizes, specifiers
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 20 Apr 2020 18:28:39 +0000 (14:28 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 20 Apr 2020 23:14:33 +0000 (19:14 -0400)
- Fix 1 byte overflow when showing GR info in bgpd
- Use PATH_MAX for path buffers
- Use unsigned specifiers for uint16_t's in zebra pbr

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_vty.c
lib/csv.c
nhrpd/linux.c
tools/start-stop-daemon.c
zebra/zebra_netns_notify.c
zebra/zebra_pbr.c

index 8e1913a8d07ab6caa48835302a5a9cbde2eb7dbe..b7a7d2c3828eeb4fa47fca7ec03098e55b67a71d 100644 (file)
@@ -9860,7 +9860,8 @@ static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p,
 {
        char buf[SU_ADDRSTRLEN] = {0};
        char dn_flag[2] = {0};
-       char neighborAddr[INET6_ADDRSTRLEN] = {0};
+       /* '*' + v6 address of neighbor */
+       char neighborAddr[INET6_ADDRSTRLEN + 1] = {0};
 
        if (!p->conf_if && peer_dynamic_neighbor(p))
                dn_flag[0] = '*';
index b4d7464bffe2ebda99dde375d645d8ac560fab92..b48b79792e6ed7f728831ee14e6434f9684c3850 100644 (file)
--- a/lib/csv.c
+++ b/lib/csv.c
@@ -637,7 +637,7 @@ void csv_dump(csv_t *csv)
 static int get_memory_usage(pid_t pid)
 {
        int fd, data, stack;
-       char buf[4096], status_child[BUFSIZ];
+       char buf[4096], status_child[PATH_MAX];
        char *vm;
 
        snprintf(status_child, sizeof(status_child), "/proc/%d/status", pid);
index 74aec155fc051f502a8dc59b725a2cba736042c6..59c82b1c554ca8adba51c5c9377c4da4bdaa9a5c 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/ip.h>
 #include <linux/if_arp.h>
 #include <linux/if_tunnel.h>
+#include <linux/limits.h>
 
 #include "nhrp_protocol.h"
 #include "os.h"
@@ -127,7 +128,7 @@ static int linux_configure_arp(const char *iface, int on)
 
 static int linux_icmp_redirect_off(const char *iface)
 {
-       char fname[256];
+       char fname[PATH_MAX];
        int fd, ret = -1;
 
        snprintf(fname, sizeof(fname),
index ba40a02f5045cfe0f60855248b0cd085f6d90f96..7ad2a845002d76aad521ffc413094a4be8e39b1e 100644 (file)
@@ -605,7 +605,7 @@ static void parse_options(int argc, char *const *argv)
 static int pid_is_exec(pid_t pid, const struct stat *esb)
 {
        struct stat sb;
-       char buf[32];
+       char buf[PATH_MAX];
 
        snprintf(buf, sizeof(buf), "/proc/%ld/exe", (long)pid);
        if (stat(buf, &sb) != 0)
@@ -617,7 +617,7 @@ static int pid_is_exec(pid_t pid, const struct stat *esb)
 static int pid_is_user(pid_t pid, uid_t uid)
 {
        struct stat sb;
-       char buf[32];
+       char buf[PATH_MAX];
 
        snprintf(buf, sizeof(buf), "/proc/%ld", (long)pid);
        if (stat(buf, &sb) != 0)
@@ -628,7 +628,7 @@ static int pid_is_user(pid_t pid, uid_t uid)
 
 static int pid_is_cmd(pid_t pid, const char *name)
 {
-       char buf[32];
+       char buf[PATH_MAX];
        FILE *f;
        int c;
 
index 2e0f9cd3f3972e81949491c57a521a79f599f4d3..c5d11f1837406039605ebf27c6cb34f3e4223d7c 100644 (file)
@@ -153,7 +153,7 @@ static int zebra_ns_delete(char *name)
 
 static int zebra_ns_notify_self_identify(struct stat *netst)
 {
-       char net_path[64];
+       char net_path[PATH_MAX];
        int netns;
 
        snprintf(net_path, sizeof(net_path), "/proc/self/ns/net");
index a53363f086434010812ccd42067989b32d8087cd..62cbcbda4b244731e8e04393235970955b90a8e6 100644 (file)
@@ -877,14 +877,14 @@ static void zebra_pbr_display_icmp(struct vty *vty,
 
        /* range icmp type */
        if (zpie->src_port_max || zpie->dst_port_max) {
-               vty_out(vty, ":icmp:[type <%d:%d>;code <%d:%d>",
+               vty_out(vty, ":icmp:[type <%u:%u>;code <%u:%u>",
                        zpie->src_port_min, zpie->src_port_max,
                        zpie->dst_port_min, zpie->dst_port_max);
        } else {
                port = ((zpie->src_port_min << 8) & 0xff00) +
                        (zpie->dst_port_min & 0xff);
                memset(decoded_str, 0, sizeof(decoded_str));
-               snprintf(decoded_str, sizeof(decoded_str), "%d/%d",
+               snprintf(decoded_str, sizeof(decoded_str), "%u/%u",
                         zpie->src_port_min, zpie->dst_port_min);
                vty_out(vty, ":icmp:%s",
                        lookup_msg(icmp_typecode_str,