From 6b07f6e1e8bcb2aa7424784a86328d0658513aea Mon Sep 17 00:00:00 2001 From: Jorge Boncompte Date: Fri, 11 Aug 2017 12:19:23 +0200 Subject: [PATCH] nhrpd: fixes for clang scan-build issues Signed-off-by: Jorge Boncompte --- nhrpd/vici.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nhrpd/vici.c b/nhrpd/vici.c index a6d835562f..fd01a4534e 100644 --- a/nhrpd/vici.c +++ b/nhrpd/vici.c @@ -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) { -- 2.39.5