]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #2563 from pacovn/Coverity_1465494_String_not_null_terminated_2
authorQuentin Young <qlyoung@users.noreply.github.com>
Wed, 27 Jun 2018 19:15:22 +0000 (15:15 -0400)
committerGitHub <noreply@github.com>
Wed, 27 Jun 2018 19:15:22 +0000 (15:15 -0400)
lib zebra: str-z check (2) (Coverity 1465494)

lib/clippy.c
lib/command_match.c
lib/linklist.h
ospf6d/ospf6_abr.c
ospfd/ospf_apiserver.c

index bcec6c2ccab3113a76183729b2047e642445686e..44dcc02eb8645b765a5ee04ccd5a363b8aa45bd7 100644 (file)
 #define pychar wchar_t
 static wchar_t *wconv(const char *s)
 {
-       size_t outlen = mbstowcs(NULL, s, 0);
+       size_t outlen = s ? mbstowcs(NULL, s, 0) : 0;
        wchar_t *out = malloc((outlen + 1) * sizeof(wchar_t));
-       mbstowcs(out, s, outlen + 1);
+
+       if (outlen > 0)
+               mbstowcs(out, s, outlen);
        out[outlen] = 0;
        return out;
 }
index 4893ead0421a830631cbfcc1089fc1ae7913906c..c165305d78315a7c9e4f440f574e825af7a0ad1d 100644 (file)
@@ -608,12 +608,14 @@ static struct cmd_token *disambiguate_tokens(struct cmd_token *first,
 static struct list *disambiguate(struct list *first, struct list *second,
                                 vector vline, unsigned int n)
 {
+       assert(first != NULL);
+       assert(second != NULL);
        // doesn't make sense for these to be inequal length
-       assert(first && second);
        assert(first->count == second->count);
        assert(first->count == vector_active(vline) - n + 1);
 
-       struct listnode *fnode = listhead(first), *snode = listhead(second);
+       struct listnode *fnode = listhead_unchecked(first),
+                       *snode = listhead_unchecked(second);
        struct cmd_token *ftok = listgetdata(fnode), *stok = listgetdata(snode),
                         *best = NULL;
 
index ea5a3531ab10caddbb8a8d62a3665cd259c87468..1e2631ea46157157d05f406adb052cbcb9524637 100644 (file)
@@ -54,6 +54,7 @@ struct list {
 #define listnextnode(X) ((X) ? ((X)->next) : NULL)
 #define listnextnode_unchecked(X) ((X)->next)
 #define listhead(X) ((X) ? ((X)->head) : NULL)
+#define listhead_unchecked(X) ((X)->head)
 #define listtail(X) ((X) ? ((X)->tail) : NULL)
 #define listcount(X) ((X)->count)
 #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
index b3aa3b21d2b5221e1d3eb76cf9395cd6764b1a23..5398ea5054186f7a0ed8ac8173b402062e3fc8f7 100644 (file)
@@ -641,6 +641,11 @@ void ospf6_abr_originate_summary(struct ospf6_route *route)
 
        if (route->type == OSPF6_DEST_TYPE_NETWORK) {
                oa = ospf6_area_lookup(route->path.area_id, ospf6);
+               if (!oa) {
+                       zlog_err("OSPFv6 area lookup failed");
+                       return;
+               }
+
                range = ospf6_route_lookup_bestmatch(&route->prefix,
                                                     oa->range_table);
                if (range) {
index 92e2a3dcb908062ee871abf3eff55f11dbbce35b..8f8900e147fee286bc442f9d970055d35674655a 100644 (file)
@@ -1753,6 +1753,7 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
                        dump_lsa_key(lsa));
                lsa->data->ls_age =
                        htons(OSPF_LSA_MAXAGE); /* Flush it anyway. */
+               goto out;
        }
 
        if (IS_LSA_MAXAGE(lsa)) {