mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Clean up and refactor dns_adb_getcookie()
The dns_adb_getcookie() doesn't use the 'adb' parameter, remove it. Refactor the dns_adb_getcookie() function to just return the size of the cookie when the caller passes 'NULL' as the 'cookie' argument.
This commit is contained in:
@@ -3465,21 +3465,26 @@ dns_adb_setcookie(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
|
||||
}
|
||||
|
||||
size_t
|
||||
dns_adb_getcookie(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
|
||||
unsigned char *cookie, size_t len) {
|
||||
REQUIRE(DNS_ADB_VALID(adb));
|
||||
dns_adb_getcookie(dns_adbaddrinfo_t *addr, unsigned char *cookie, size_t len) {
|
||||
REQUIRE(DNS_ADBADDRINFO_VALID(addr));
|
||||
|
||||
dns_adbentry_t *entry = addr->entry;
|
||||
|
||||
LOCK(&entry->lock);
|
||||
if (cookie != NULL && entry->cookie != NULL && len >= entry->cookielen)
|
||||
{
|
||||
memmove(cookie, entry->cookie, entry->cookielen);
|
||||
len = entry->cookielen;
|
||||
} else {
|
||||
if (entry->cookie == NULL) {
|
||||
len = 0;
|
||||
goto unlock;
|
||||
}
|
||||
if (cookie != NULL) {
|
||||
if (len < entry->cookielen) {
|
||||
len = 0;
|
||||
goto unlock;
|
||||
}
|
||||
memmove(cookie, entry->cookie, entry->cookielen);
|
||||
}
|
||||
len = entry->cookielen;
|
||||
|
||||
unlock:
|
||||
UNLOCK(&entry->lock);
|
||||
|
||||
return (len);
|
||||
|
Reference in New Issue
Block a user