]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #2482 from pacovn/clang_scan_bgpd_bgp_rpki_deref
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 18 Jun 2018 20:09:56 +0000 (16:09 -0400)
committerGitHub <noreply@github.com>
Mon, 18 Jun 2018 20:09:56 +0000 (16:09 -0400)
bgpd: null check (Clang scan-build)

27 files changed:
alpine/APKBUILD.in
babeld/babel_interface.c
babeld/message.c
babeld/neighbour.c
babeld/util.c
bgpd/bgp_mpath.c
bgpd/bgp_updgrp.c
bgpd/rfapi/bgp_rfapi_cfg.c
bgpd/rfapi/rfapi.c
eigrpd/eigrp_network.c
eigrpd/eigrp_snmp.c
isisd/isis_circuit.c
ldpd/packet.c
lib/csv.c
lib/ptm_lib.c
lib/sigevent.c
nhrpd/resolver.c
ospfd/ospf_dump.c
ospfd/ospf_interface.c
ospfd/ospf_snmp.c
pimd/mtracebis.c
pimd/pim_oil.c
tests/lib/test_checksum.c
tests/lib/test_graph.c
tests/lib/test_timer_performance.c
vtysh/vtysh.c
vtysh/vtysh_main.c

index c3e7e939e4d29b67c9f85afcc36a7f1a20784ce4..42896c21a55795b4db21791d301676aa55a70d35 100644 (file)
@@ -20,6 +20,7 @@ makedepends="ncurses-dev net-snmp-dev gawk texinfo perl
     patch pax-utils pcre perl pkgconf python2 python2-dev readline
     readline-dev sqlite-libs squashfs-tools sudo tar texinfo xorriso xz-libs
     py-sphinx"
+checkdepends="pytest py-setuptools"
 install="$pkgname.pre-install $pkgname.pre-deinstall $pkgname.post-deinstall"
 subpackages="$pkgname-dev $pkgname-doc $pkgname-dbg"
 source="$pkgname-$pkgver.tar.gz docker-start daemons daemons.conf"
@@ -45,13 +46,19 @@ build() {
                --enable-multipath=64 \
                --enable-vty-group=frrvty \
                --enable-user=$_user \
-               --enable-group=$_user || return 1
-       make || return 1
+               --enable-group=$_user
+       make
+}
+
+check() {
+       cd "$builddir"
+
+       make -j 1 check
 }
 
 package() {
        cd "$builddir"
-       make DESTDIR="$pkgdir" install || return 1
+       make DESTDIR="$pkgdir" install
 
        install -Dm755 "$srcdir"/docker-start "$pkgdir"$_sbindir
        install -Dm644 "$srcdir"/daemons "$pkgdir"$_sysconfdir
index d4958ddf249e35c15d56c7f108510c127492d5a8..453fd8e04e62732c59a085e81717c8d283e75121 100644 (file)
@@ -1001,7 +1001,7 @@ show_babel_routes_sub(struct babel_route *route, struct vty *vty,
                 break;
             if(k > 0)
                 channels[j++] = ',';
-            snprintf(channels + j, 100 - j, "%d", route->channels[k]);
+            snprintf(channels + j, 100 - j, "%u", route->channels[k]);
             j = strlen(channels);
         }
         snprintf(channels + j, 100 - j, ")");
index 1ff4867908cf19a134f291564d9fc112c3b3633e..95b4e87cc7e64b487a00aca8c5a3f96a754ade99 100644 (file)
@@ -662,7 +662,7 @@ static int
 check_bucket(struct interface *ifp)
 {
     babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
-    if(babel_ifp->bucket <= 0) {
+    if(babel_ifp->bucket == 0) {
         int seconds = babel_now.tv_sec - babel_ifp->bucket_time;
         if(seconds > 0) {
             babel_ifp->bucket = MIN(BUCKET_TOKENS_MAX,
index 48a32c4a9c39c658d86ee6564958475685ed20cf..3db121fd263ea9114cb84ffcdef7fe3b602790f5 100644 (file)
@@ -120,7 +120,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
     int rc = 0;
 
     if(hello < 0) {
-        if(neigh->hello_interval <= 0)
+        if(neigh->hello_interval == 0)
             return rc;
         missed_hellos =
             ((int)timeval_minus_msec(&babel_now, &neigh->hello_time) -
index 7dff11d124bddce3b20226eab3a6b4ecb4d94604..4a3ecace0ccad0748ac8dca4463b93fa273586fc 100644 (file)
@@ -303,7 +303,7 @@ format_thousands(unsigned int value)
     static char buf[4][15];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], 15, "%d.%.3d", value / 1000, value % 1000);
+    snprintf(buf[i], 15, "%u.%.3u", value / 1000, value % 1000);
     return buf[i];
 }
 
index 915387ca2defc86c42030743f8686fcb9c847fd7..333d09806e29af2c56a8a0f128d4d016ed3357af 100644 (file)
@@ -471,7 +471,7 @@ void bgp_info_mpath_update(struct bgp_node *rn, struct bgp_info *new_best,
                zlog_debug(
                        "%s: starting mpath update, newbest %s num candidates %d old-mpath-count %d",
                        pfx_buf, new_best ? new_best->peer->host : "NONE",
-                       listcount(mp_list), old_mpath_count);
+                       mp_list ? listcount(mp_list) : 0, old_mpath_count);
 
        /*
         * We perform an ordered walk through both lists in parallel.
index d2e89a67852f07c91bf41b20ae63ed29de25ec3b..c607c4577d34dbb8cf7de6cbe3e046e48b8c4604 100644 (file)
@@ -812,7 +812,7 @@ static void update_subgroup_delete(struct update_subgroup *subgrp)
                THREAD_TIMER_OFF(subgrp->t_coalesce);
        sync_delete(subgrp);
 
-       if (BGP_DEBUG(update_groups, UPDATE_GROUPS))
+       if (BGP_DEBUG(update_groups, UPDATE_GROUPS) && subgrp->update_group)
                zlog_debug("delete subgroup u%" PRIu64 ":s%" PRIu64,
                           subgrp->update_group->id, subgrp->id);
 
index 2f93328887efcf874b19fa67571c3e7d9ec62acc..72255e54fbd35b77830b866e9d5bf1e0d0070fd6 100644 (file)
@@ -662,7 +662,8 @@ static int rfapi_str2route_type(const char *l3str, const char *pstr, afi_t *afi,
                        vnc_import_bgp_exterior_redist_enable((bgp), (afi));   \
                        break;                                                 \
                default:                                                       \
-                       vnc_redistribute_set((bgp), (afi), (type));            \
+                       if ((type) < ZEBRA_ROUTE_MAX)                          \
+                               vnc_redistribute_set((bgp), (afi), (type));    \
                        break;                                                 \
                }                                                              \
        } while (0)
@@ -677,7 +678,8 @@ static int rfapi_str2route_type(const char *l3str, const char *pstr, afi_t *afi,
                        vnc_import_bgp_exterior_redist_disable((bgp), (afi));  \
                        break;                                                 \
                default:                                                       \
-                       vnc_redistribute_unset((bgp), (afi), (type));          \
+                       if ((type) < ZEBRA_ROUTE_MAX)                          \
+                               vnc_redistribute_unset((bgp), (afi), (type));  \
                        break;                                                 \
                }                                                              \
        } while (0)
index 8d782864c8c5c3958bf17f4611803f7f35cc0620..177244d2778bb882b6bd84f1592c2484795fb724 100644 (file)
@@ -3368,13 +3368,7 @@ DEFUN (debug_rfapi_query_vn_un_l2o,
 {
        struct rfapi_ip_addr vn;
        struct rfapi_ip_addr un;
-       struct rfapi_ip_addr target;
-       rfapi_handle handle;
        int rc;
-       struct rfapi_next_hop_entry *pNextHopEntry;
-       struct rfapi_l2address_option l2o_buf;
-       struct bgp_tea_options hopt;
-       uint8_t valbuf[14];
 
        /*
         * Get VN addr
@@ -3389,69 +3383,8 @@ DEFUN (debug_rfapi_query_vn_un_l2o,
        if ((rc = rfapiCliGetRfapiIpAddr(vty, argv[6]->arg, &un)))
                return rc;
 
-
-#if 0 /* there is no IP target arg here ?????? */
-  /*
-   * Get target addr
-   */
-  if ((rc = rfapiCliGetRfapiIpAddr (vty, argv[2], &target)))
-    return rc;
-#else
        vty_out(vty, "%% This command is broken.\n");
        return CMD_WARNING_CONFIG_FAILED;
-#endif
-
-       if (rfapi_find_handle_vty(vty, &vn, &un, &handle)) {
-               vty_out(vty, "can't locate handle matching vn=%s, un=%s\n",
-                       argv[4]->arg, argv[6]->arg);
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       /*
-        * Set up L2 parameters
-        */
-       memset(&l2o_buf, 0, sizeof(l2o_buf));
-       if (rfapiStr2EthAddr(argv[10]->arg, &l2o_buf.macaddr)) {
-               vty_out(vty, "Bad mac address \"%s\"\n", argv[10]->arg);
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       l2o_buf.logical_net_id = strtoul(argv[8]->arg, NULL, 10);
-
-       /* construct option chain */
-
-       memset(valbuf, 0, sizeof(valbuf));
-       memcpy(valbuf, &l2o_buf.macaddr.octet, ETH_ALEN);
-       valbuf[11] = (l2o_buf.logical_net_id >> 16) & 0xff;
-       valbuf[12] = (l2o_buf.logical_net_id >> 8) & 0xff;
-       valbuf[13] = l2o_buf.logical_net_id & 0xff;
-
-       memset(&hopt, 0, sizeof(hopt));
-       hopt.options_count = 1;
-       hopt.options_length = sizeof(valbuf); /* is this right? */
-       hopt.type = RFAPI_VN_OPTION_TYPE_L2ADDR;
-       hopt.length = sizeof(valbuf);
-       hopt.value = valbuf;
-
-
-       /*
-        * options parameter not used? Set to NULL for now
-        */
-       rc = rfapi_query(handle, &target, &l2o_buf, &pNextHopEntry);
-
-       if (rc) {
-               vty_out(vty, "rfapi_query failed with rc=%d (%s)\n", rc,
-                       strerror(rc));
-       } else {
-               /*
-                * print nexthop list
-                */
-               /* TBD enhance to print L2 information */
-               test_nexthops_callback(/*&target, */ pNextHopEntry,
-                                      vty); /* frees nh list! */
-       }
-
-       return CMD_SUCCESS;
 }
 
 
index 2578fecb35ccad6f07beaec573c42f760001706d..629beddec39a305c0a4a7ad659c7215fa9a978fd 100644 (file)
@@ -55,7 +55,10 @@ static void eigrp_network_run_interface(struct eigrp *, struct prefix *,
 int eigrp_sock_init(void)
 {
        int eigrp_sock;
-       int ret, hincl = 1;
+       int ret;
+#ifdef IP_HDRINCL
+       int hincl = 1;
+#endif
 
        if (eigrpd_privs.change(ZPRIVS_RAISE))
                zlog_err("eigrp_sock_init: could not raise privs, %s",
index 7dd95b7bc6c860177b8d3dc0209fca72be2efa9e..21c92386aeb42fd767e52bbbcb5f18a960456cb0 100644 (file)
@@ -514,7 +514,6 @@ eigrp_snmp_nbr_lookup_next(struct in_addr *nbr_addr, unsigned int *ifindex,
        struct listnode *node, *nnode, *node2, *nnode2;
        struct eigrp_interface *ei;
        struct eigrp_neighbor *nbr;
-       struct route_node *rn;
        struct eigrp_neighbor *min = NULL;
        struct eigrp *eigrp;
 
@@ -573,7 +572,7 @@ static struct eigrp_neighbor *eigrpNbrLookup(struct variable *v, oid *name,
                first = 0;
                len = *length - v->namelen;
 
-               if (len <= 0)
+               if (len == 0)
                        first = 1;
 
                if (len > IN_ADDR_SIZE)
@@ -918,8 +917,6 @@ static uint8_t *eigrpTopologyEntry(struct variable *v, oid *name,
                                   WriteMethod **write_method)
 {
        struct eigrp *eigrp;
-       struct eigrp_interface *ei;
-       struct listnode *node, *nnode;
 
        eigrp = eigrp_lookup();
 
@@ -1067,7 +1064,6 @@ static uint8_t *eigrpPeerEntry(struct variable *v, oid *name, size_t *length,
 {
        struct eigrp *eigrp;
        struct eigrp_interface *ei;
-       struct listnode *node, *nnode;
        struct eigrp_neighbor *nbr;
        struct in_addr nbr_addr;
        unsigned int ifindex;
@@ -1199,11 +1195,9 @@ static uint8_t *eigrpInterfaceEntry(struct variable *v, oid *name,
                                    WriteMethod **write_method)
 {
        struct eigrp *eigrp;
-       struct eigrp_interface *ei;
        struct listnode *node, *nnode;
        struct keychain *keychain;
        struct list *keylist;
-       int counter;
 
        eigrp = eigrp_lookup();
 
index 6f4d72cb1fe067ce84bc0fa323bd1c9f56948fb7..f8df33d3ee99df7f2afa07d7f21cd7380cc8021c 100644 (file)
@@ -357,14 +357,14 @@ void isis_circuit_del_addr(struct isis_circuit *circuit,
                        for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node,
                                                  ip6)) {
                                prefix2str((struct prefix *)ip6, (char *)buf,
-                                          BUFSIZ);
+                                          sizeof(buf));
                                zlog_warn("  %s", buf);
                        }
                        zlog_warn(" -----");
                        for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node,
                                                  ip6)) {
                                prefix2str((struct prefix *)ip6, (char *)buf,
-                                          BUFSIZ);
+                                          sizeof(buf));
                                zlog_warn("  %s", buf);
                        }
                        zlog_warn("End of addresses");
index 4a4b258b91b1c416399838d9c6bcf7732c1cb683..b0f9c5eb14f8abadd7dcbf8129f6647610ff061d 100644 (file)
@@ -144,7 +144,7 @@ disc_recv_packet(struct thread *thread)
 
        /* reschedule read */
        *threadp = NULL;
-       thread_add_read(master, disc_recv_packet, threadp, fd, &*threadp);
+       thread_add_read(master, disc_recv_packet, threadp, fd, threadp);
 
        /* setup buffer */
        memset(&m, 0, sizeof(m));
index e6a5eae2e2bba4306026e6de5c9f33643cb57943..ce84783aa6f7570da98027cabbc489a8cf1cd4b6 100644 (file)
--- a/lib/csv.c
+++ b/lib/csv.c
@@ -663,8 +663,8 @@ int main()
 
        log_verbose("Mem: %d\n", get_memory_usage(getpid()));
        csv_init(&csv, buf, 256);
-       sprintf(hdr1, "%4u", 0);
-       sprintf(hdr2, "%4u", 1);
+       sprintf(hdr1, "%4d", 0);
+       sprintf(hdr2, "%4d", 1);
        log_verbose("(%zu/%zu/%d/%d)\n", strlen(hdr1), strlen(hdr2), atoi(hdr1),
                    atoi(hdr2));
        rec = csv_encode(&csv, 2, hdr1, hdr2);
@@ -676,8 +676,8 @@ int main()
        }
        csv_encode(&csv, 2, "pdfadfadfadsadsaddfdfdsfdsd", "35444554545454545");
        log_verbose("%s\n", buf);
-       sprintf(hdr1, "%4u", csv.csv_len);
-       sprintf(hdr2, "%4u", 1);
+       sprintf(hdr1, "%4d", csv.csv_len);
+       sprintf(hdr2, "%4d", 1);
        log_verbose("(%zu/%zu/%d/%d)\n", strlen(hdr1), strlen(hdr2), atoi(hdr1),
                    atoi(hdr2));
        rec = csv_encode_record(&csv, rec, 2, hdr1, hdr2);
index fea5a8cc4015ba6ac858dc1f8a91891b67bcd5e4..69fd61e2a06998ea914551f4b02b3aeb71e43c24 100644 (file)
@@ -60,10 +60,10 @@ static csv_record_t *_ptm_lib_encode_header(csv_t *csv, csv_record_t *rec,
        char client_buf[32];
        csv_record_t *rec1;
 
-       sprintf(msglen_buf, "%4u", msglen);
-       sprintf(vers_buf, "%4u", version);
-       sprintf(type_buf, "%4u", type);
-       sprintf(cmdid_buf, "%4u", cmd_id);
+       sprintf(msglen_buf, "%4d", msglen);
+       sprintf(vers_buf, "%4d", version);
+       sprintf(type_buf, "%4d", type);
+       sprintf(cmdid_buf, "%4d", cmd_id);
        snprintf(client_buf, 17, "%16.16s", client_name);
        if (rec) {
                rec1 = csv_encode_record(csv, rec, 5, msglen_buf, vers_buf,
index d299760fabe0ffafffb8e801d11d5b78975c8683..59eaa8037075a754073cd40433c26fa3e9830fc6 100644 (file)
@@ -119,8 +119,6 @@ int quagga_sigevent_process(void)
 int quagga_signal_timer(struct thread *t)
 {
        struct quagga_sigevent_master_t *sigm;
-       struct quagga_signal_t *sig;
-       int i;
 
        sigm = THREAD_ARG(t);
        sigm->t = NULL;
index 6349224adcb241448ed38f5e427c7e94921e6242..415e7523de047b67ddf3c65d94f9a6e5f3512b26 100644 (file)
@@ -164,7 +164,7 @@ static void ares_address_cb(void *arg, int status, int timeouts,
                return;
        }
 
-       for (i = 0; he->h_addr_list[i] != NULL && i < ZEBRA_NUM_OF(addr); i++) {
+       for (i = 0; i < ZEBRA_NUM_OF(addr) && he->h_addr_list[i] != NULL; i++) {
                memset(&addr[i], 0, sizeof(addr[i]));
                addr[i].sa.sa_family = he->h_addrtype;
                switch (he->h_addrtype) {
index 08bedadf41bba43493c81947bb95890fc4f5e12a..d8742943c0043022494ac545da87104a1926715b 100644 (file)
@@ -146,8 +146,6 @@ void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size)
        else
                state = ISM_DROther;
 
-       memset(buf, 0, size);
-
        snprintf(buf, size, "%s/%s",
                 lookup_msg(ospf_nsm_state_msg, nbr->state, NULL),
                 lookup_msg(ospf_ism_state_msg, state, NULL));
@@ -201,17 +199,17 @@ const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size)
        }
 
        if (w > 99)
-               snprintf(buf, size, "%ldw%1ldd", w, d);
+               snprintf(buf, size, "%luw%1lud", w, d);
        else if (w)
-               snprintf(buf, size, "%ldw%1ldd%02ldh", w, d, h);
+               snprintf(buf, size, "%luw%1lud%02luh", w, d, h);
        else if (d)
-               snprintf(buf, size, "%1ldd%02ldh%02ldm", d, h, m);
+               snprintf(buf, size, "%1lud%02luh%02lum", d, h, m);
        else if (h)
-               snprintf(buf, size, "%ldh%02ldm%02lds", h, m, (long)t->tv_sec);
+               snprintf(buf, size, "%luh%02lum%02lds", h, m, (long)t->tv_sec);
        else if (m)
-               snprintf(buf, size, "%ldm%02lds", m, (long)t->tv_sec);
+               snprintf(buf, size, "%lum%02lds", m, (long)t->tv_sec);
        else if (ms)
-               snprintf(buf, size, "%ld.%03lds", (long)t->tv_sec, ms);
+               snprintf(buf, size, "%ld.%03lus", (long)t->tv_sec, ms);
        else
                snprintf(buf, size, "%ld usecs", (long)t->tv_usec);
 
@@ -254,8 +252,6 @@ static void ospf_packet_hello_dump(struct stream *s, uint16_t length)
 
 static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size)
 {
-       memset(buf, 0, size);
-
        snprintf(buf, size, "%s|%s|%s", (flags & OSPF_DD_FLAG_I) ? "I" : "-",
                 (flags & OSPF_DD_FLAG_M) ? "M" : "-",
                 (flags & OSPF_DD_FLAG_MS) ? "MS" : "-");
@@ -265,8 +261,6 @@ static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size)
 
 static char *ospf_router_lsa_flags_dump(uint8_t flags, char *buf, size_t size)
 {
-       memset(buf, 0, size);
-
        snprintf(buf, size, "%s|%s|%s",
                 (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-",
                 (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-",
@@ -1689,7 +1683,7 @@ static int config_write_debug(struct vty *vty)
                return CMD_SUCCESS;
 
        if (ospf->instance)
-               sprintf(str, " %d", ospf->instance);
+               sprintf(str, " %u", ospf->instance);
 
        /* debug ospf ism (status|events|timers). */
        if (IS_CONF_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM)
index ea31d8c2ca2bbb8f50d6801d0a8750489a9b6c1b..23353b3c309f089a3e124ac5ff2ab2fb90bf364d 100644 (file)
@@ -857,7 +857,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
                        "ospf_vl_new(): creating pseudo zebra interface vrf id %u",
                        ospf->vrf_id);
 
-       snprintf(ifname, sizeof(ifname), "VLINK%d", vlink_count);
+       snprintf(ifname, sizeof(ifname), "VLINK%u", vlink_count);
        vi = if_create(ifname, ospf->vrf_id);
        /*
         * if_create sets ZEBRA_INTERFACE_LINKDETECTION
index 6825be83ac89b007078e9ee369690c771f2d34ec..c90db031dcf2f2137687d2cf81da53bc8e122980 100644 (file)
@@ -1626,7 +1626,7 @@ static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
                len = *length - v->namelen;
                if (len >= IN_ADDR_SIZE)
                        len = IN_ADDR_SIZE;
-               if (len <= 0)
+               if (len == 0)
                        ifaddr_next = 1;
 
                oid2in_addr(name + v->namelen, len, ifaddr);
@@ -1990,7 +1990,7 @@ ospfVirtIfLookup(struct variable *v, oid *name, size_t *length,
                first = 0;
 
                len = *length - v->namelen;
-               if (len <= 0)
+               if (len == 0)
                        first = 1;
                if (len > IN_ADDR_SIZE)
                        len = IN_ADDR_SIZE;
@@ -2176,7 +2176,7 @@ static struct ospf_neighbor *ospfNbrLookup(struct variable *v, oid *name,
                first = 0;
                len = *length - v->namelen;
 
-               if (len <= 0)
+               if (len == 0)
                        first = 1;
 
                if (len > IN_ADDR_SIZE)
index a073fa70beeead052838a736e6b6a79c5809dd66..731fdb1beb5c5e71f9d382820e30439549a41c0d 100644 (file)
@@ -296,6 +296,10 @@ static int recv_response(int fd, int *hops, struct igmp_mtrace *mtracer)
 
        mtrace_len = ntohs(ip->ip_len) - ip->ip_hl * 4;
 
+       if ((char *)mtrace + mtrace_len
+           > (char *)mtrace_buf + IP_AND_MTRACE_BUF_LEN)
+               return -1;
+
        if (mtrace_len < (int)MTRACE_HDR_SIZE)
                return -1;
 
index fd3c04e8ca3d6043bde503d3b92076be26ebbfb5..d49484f869f91fdb8c325e9017d431a9a0ea32e4 100644 (file)
@@ -40,7 +40,6 @@ char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)
        struct prefix_sg sg;
        int i;
 
-       memset(buf, 0, size);
        sg.src = c_oil->oil.mfcc_origin;
        sg.grp = c_oil->oil.mfcc_mcastgrp;
        sprintf(buf, "%s IIF: %d, OIFS: ", pim_str_sg_dump(&sg),
index 3972f76763e3bbc4c21722763e0f94ec4df1484c..13d35b0e995862f9bc453cd7c01c9db7c8ab3817 100644 (file)
@@ -506,7 +506,7 @@ int main(int argc, char **argv)
                        printf("verify: lib failed\n");
 
                if (ospfd != lib) {
-                       printf("Mismatch in values at size %u\n"
+                       printf("Mismatch in values at size %d\n"
                               "ospfd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
                               "isisd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
                               "lib: 0x%04x\n",
index f21f8b793c731012385ea8620dd537ea30acd169..2801c48bc53bacb7d38f48e33712763dc2bc37aa 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, char **argv)
 
        /* create vertices */
        for (unsigned int i = 0; i < NUMNODES; i++) {
-               snprintf(names[i], sizeof(names[i]), "%d", i);
+               snprintf(names[i], sizeof(names[i]), "%u", i);
                gn[i] = graph_new_node(g, names[i], NULL);
        }
 
index f9a244e2595f942ca808a1eec12cc303f5d61db9..d5f4badc85b5cdeff32971f96695e6e3a3733e10 100644 (file)
@@ -92,9 +92,9 @@ int main(int argc, char **argv)
        t_remove = 1000 * (tv_stop.tv_sec - tv_lap.tv_sec);
        t_remove += (tv_stop.tv_usec - tv_lap.tv_usec) / 1000;
 
-       printf("Scheduling %d random timers took %ld.%03ld seconds.\n",
+       printf("Scheduling %d random timers took %lu.%03lu seconds.\n",
               SCHEDULE_TIMERS, t_schedule / 1000, t_schedule % 1000);
-       printf("Removing %d random timers took %ld.%03ld seconds.\n",
+       printf("Removing %d random timers took %lu.%03lu seconds.\n",
               REMOVE_TIMERS, t_remove / 1000, t_remove % 1000);
        fflush(stdout);
 
index c6e060500b83a4e4b72da761ae4999e2bfad557e..859d126e7656d82275ca51759a5f14b3d30671c0 100644 (file)
@@ -2623,8 +2623,12 @@ int vtysh_write_config_integrated(void)
        char line[] = "do write terminal\n";
        FILE *fp;
        int fd;
+#ifdef FRR_USER
        struct passwd *pwentry;
+#endif
+#ifdef FRR_GROUP
        struct group *grentry;
+#endif
        uid_t uid = -1;
        gid_t gid = -1;
        struct stat st;
index ad7d072d3daa7430983aac4de233a9a0dd82bd6a..7d882620e8d62a336ebaea5847b6a444c2fda91b 100644 (file)
@@ -471,7 +471,8 @@ int main(int argc, char **argv, char **env)
        }
 
        if (dryrun && cmd && cmd->line) {
-               vtysh_execute("enable");
+               if (!user_mode)
+                       vtysh_execute("enable");
                while (cmd) {
                        struct cmd_rec *cr;
                        char *cmdnow = cmd->line, *next;
@@ -527,6 +528,14 @@ int main(int argc, char **argv, char **env)
        suid_off();
 
        if (writeconfig) {
+               if (user_mode) {
+                       fprintf(stderr,
+                               "writeconfig cannot be used when running as an unprivileged user.\n");
+                       if (no_error)
+                               exit(0);
+                       else
+                               exit(1);
+               }
                vtysh_execute("enable");
                return vtysh_write_config_integrated();
        }
@@ -573,7 +582,8 @@ int main(int argc, char **argv, char **env)
        /* If eval mode. */
        if (cmd && cmd->line) {
                /* Enter into enable node. */
-               vtysh_execute("enable");
+               if (!user_mode)
+                       vtysh_execute("enable");
 
                while (cmd != NULL) {
                        int ret;
@@ -663,7 +673,8 @@ int main(int argc, char **argv, char **env)
        vty_hello(vty);
 
        /* Enter into enable node. */
-       vtysh_execute("enable");
+       if (!user_mode)
+               vtysh_execute("enable");
 
        /* Preparation for longjmp() in sigtstp(). */
        sigsetjmp(jmpbuf, 1);