]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
lib/isc/pkc11.c: Fix possible NULL pointer dereference in push_attribute()
authorOndřej Surý <ondrej@sury.org>
Fri, 27 Sep 2019 10:01:30 +0000 (12:01 +0200)
committerOndřej Surý <ondrej@sury.org>
Thu, 3 Oct 2019 07:04:27 +0000 (09:04 +0200)
lib/isc/pk11.c

index 6dfd51ffa238db6a5b867d96783c7b1a3ec5ef53..1e7c503d8fe080595e0ccf9df06961f81ea0c8ef 100644 (file)
@@ -800,9 +800,13 @@ push_attribute(pk11_object_t *obj, isc_mem_t *mctx, size_t len) {
        CK_ATTRIBUTE *attr;
        CK_BYTE cnt = obj->attrcnt;
 
+       REQUIRE(old != NULL || cnt == 0);
+
        obj->repr = isc_mem_get(mctx, (cnt + 1) * sizeof(*attr));
        memset(obj->repr, 0, (cnt + 1) * sizeof(*attr));
-       memmove(obj->repr, old, cnt * sizeof(*attr));
+       if (old != NULL) {
+               memmove(obj->repr, old, cnt * sizeof(*attr));
+       }
        attr = obj->repr + cnt;
        attr->ulValueLen = (CK_ULONG) len;
        attr->pValue = isc_mem_get(mctx, len);