mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 15:39:59 -04:00
lib/isc/pkc11.c: Fix possible NULL pointer dereference in push_attribute()
(cherry picked from commit e8948fd9b4)
This commit is contained in:
parent
ac1127b2ad
commit
4acf396f83
1 changed files with 5 additions and 1 deletions
|
|
@ -802,13 +802,17 @@ 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));
|
||||
if (obj->repr == NULL) {
|
||||
obj->repr = old;
|
||||
return (NULL);
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue