]> git.puffer.fish Git - matthieu/frr.git/commitdiff
nhrpd: fixes for clang scan-build issues
authorJorge Boncompte <jbonor@gmail.com>
Fri, 11 Aug 2017 10:19:23 +0000 (12:19 +0200)
committerJorge Boncompte <jbonor@gmail.com>
Fri, 11 Aug 2017 10:19:23 +0000 (12:19 +0200)
Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
nhrpd/vici.c

index a6d835562f4be8e64b54402ffe9b39582ace7d91..fd01a4534e674d0acbb38a009613c5e439d7eb2d 100644 (file)
@@ -27,13 +27,13 @@ struct blob {
 
 static int blob_equal(const struct blob *b, const char *str)
 {
-       if (b->len != (int) strlen(str)) return 0;
+       if (!b || b->len != (int) strlen(str)) return 0;
        return memcmp(b->ptr, str, b->len) == 0;
 }
 
 static int blob2buf(const struct blob *b, char *buf, size_t n)
 {
-       if (b->len >= (int) n) return 0;
+       if (!b || b->len >= (int) n) return 0;
        memcpy(buf, b->ptr, b->len);
        buf[b->len] = 0;
        return 1;
@@ -82,8 +82,8 @@ static void vici_parse_message(
        struct vici_message_ctx *ctx)
 {
        uint8_t *type;
-       struct blob key;
-       struct blob val;
+       struct blob key = { 0 };
+       struct blob val = { 0 };
 
        while ((type = zbuf_may_pull(msg, uint8_t)) != NULL) {
                switch (*type) {
@@ -178,6 +178,9 @@ static void parse_sa_message(
                }
                break;
        default:
+               if (!key)
+                       break;
+
                switch (key->ptr[0]) {
                case 'l':
                        if (blob_equal(key, "local-host") && ctx->nsections == 1) {