]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
bugfix #1568: Possible NULL pointer dereference found
authorWillem Toorop <willem@nlnetlabs.nl>
Mon, 16 Oct 2017 08:38:52 +0000 (10:38 +0200)
committerWillem Toorop <willem@nlnetlabs.nl>
Mon, 16 Oct 2017 08:38:52 +0000 (10:38 +0200)
Thanks Bill Parker

Changelog
keys.c

index da0e9b829e301852e5da8de2c36030e58646fc72..a86c7673a013892deda19af6ff2105121e278692 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,5 @@
 1.7.1  ????-??-??
-       * bugfix #1566: Possible NULL Pointer Dereference
+       * bugfix #1566, #1568: Possible NULL Pointer Dereference
          Thanks Bill Parker
        * bugfix #1260: Anticipate strchr returning NULL on unfound char
          Thanks Stephan Zeisberg
diff --git a/keys.c b/keys.c
index 4eed0f4f8065d2b211ea0110f1069247009dae85..ca2883fc17fe29325029acaf6566c1226c8a60d1 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -1047,24 +1047,18 @@ ldns_key_new_frm_fp_hmac_l( FILE *f
                          , size_t *hmac_size
                          )
 {
-       size_t i, bufsz;
+       size_t bufsz;
        char d[LDNS_MAX_LINELEN];
        unsigned char *buf = NULL;
 
-       if (ldns_fget_keyword_data_l(f, "Key", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
-               goto error;
-       }
-       bufsz = ldns_b64_ntop_calculate_size(strlen(d));
-       buf = LDNS_XMALLOC(unsigned char, bufsz);
-       i = (size_t) ldns_b64_pton((const char*)d, buf, bufsz);
-
-       *hmac_size = i;
+       *hmac_size = ldns_fget_keyword_data_l(f, "Key", ": ", d, "\n",
+                                             LDNS_MAX_LINELEN, line_nr) == -1
+                  ? 0
+                  : (buf = LDNS_XMALLOC( unsigned char, (bufsz =
+                           ldns_b64_ntop_calculate_size(strlen(d))))) == NULL
+                  ? 0
+                  : (size_t) ldns_b64_pton((const char*)d, buf, bufsz);
        return buf;
-
-       error:
-       LDNS_FREE(buf);
-       *hmac_size = 0;
-       return NULL;
 }
 #endif /* HAVE_SSL */