"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "util.c" between
nsd-4.3.6.tar.gz and nsd-4.3.7.tar.gz

About: NSD is an authoritative only, high performance, simple name server daemon.

util.c  (nsd-4.3.6):util.c  (nsd-4.3.7)
skipping to change at line 39 skipping to change at line 39
#ifdef HAVE_SYS_RANDOM_H #ifdef HAVE_SYS_RANDOM_H
#include <sys/random.h> #include <sys/random.h>
#endif #endif
#include "util.h" #include "util.h"
#include "region-allocator.h" #include "region-allocator.h"
#include "dname.h" #include "dname.h"
#include "namedb.h" #include "namedb.h"
#include "rdata.h" #include "rdata.h"
#include "zonec.h" #include "zonec.h"
#include "nsd.h"
#ifdef USE_MMAP_ALLOC #ifdef USE_MMAP_ALLOC
#include <sys/mman.h> #include <sys/mman.h>
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON #define MAP_ANONYMOUS MAP_ANON
#elif defined(MAP_ANONYMOUS) && !defined(MAP_ANON) #elif defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
#define MAP_ANON MAP_ANONYMOUS #define MAP_ANON MAP_ANONYMOUS
#endif #endif
skipping to change at line 1234 skipping to change at line 1235
#else #else
/* FreeBSD */ /* FreeBSD */
int set_cpu_affinity(cpuset_t *set) int set_cpu_affinity(cpuset_t *set)
{ {
assert(set != NULL); assert(set != NULL);
return cpuset_setaffinity( return cpuset_setaffinity(
CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(*set), set); CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(*set), set);
} }
#endif #endif
#endif /* HAVE_CPUSET_T */ #endif /* HAVE_CPUSET_T */
void add_cookie_secret(struct nsd* nsd, uint8_t* secret)
{
/* New cookie secret becomes the staging secret (position 1)
* unless there is no active cookie yet, then it becomes the active
* secret. If the NSD_COOKIE_HISTORY_SIZE > 2 then all staging cookies
* are moved one position down.
*/
if(nsd->cookie_count == 0) {
memcpy( nsd->cookie_secrets->cookie_secret
, secret, NSD_COOKIE_SECRET_SIZE);
nsd->cookie_count = 1;
explicit_bzero(secret, NSD_COOKIE_SECRET_SIZE);
return;
}
#if NSD_COOKIE_HISTORY_SIZE > 2
memmove( &nsd->cookie_secrets[2], &nsd->cookie_secrets[1]
, sizeof(struct cookie_secret) * (NSD_COOKIE_HISTORY_SIZE - 2));
#endif
memcpy( nsd->cookie_secrets[1].cookie_secret
, secret, NSD_COOKIE_SECRET_SIZE);
nsd->cookie_count = nsd->cookie_count < NSD_COOKIE_HISTORY_SIZE
? nsd->cookie_count + 1 : NSD_COOKIE_HISTORY_SIZE;
explicit_bzero(secret, NSD_COOKIE_SECRET_SIZE);
}
void activate_cookie_secret(struct nsd* nsd)
{
uint8_t active_secret[NSD_COOKIE_SECRET_SIZE];
/* The staging secret becomes the active secret.
* The active secret becomes a staging secret.
* If the NSD_COOKIE_HISTORY_SIZE > 2 then all staging secrets are moved
* one position up and the previously active secret becomes the last
* staging secret.
*/
if(nsd->cookie_count < 2)
return;
memcpy( active_secret, nsd->cookie_secrets[0].cookie_secret
, NSD_COOKIE_SECRET_SIZE);
memmove( &nsd->cookie_secrets[0], &nsd->cookie_secrets[1]
, sizeof(struct cookie_secret) * (NSD_COOKIE_HISTORY_SIZE - 1));
memcpy( nsd->cookie_secrets[nsd->cookie_count - 1].cookie_secret
, active_secret, NSD_COOKIE_SECRET_SIZE);
explicit_bzero(active_secret, NSD_COOKIE_SECRET_SIZE);
}
void drop_cookie_secret(struct nsd* nsd)
{
/* Drops a staging cookie secret. If there are more than one, it will
* drop the last staging secret. */
if(nsd->cookie_count < 2)
return;
explicit_bzero( nsd->cookie_secrets[nsd->cookie_count - 1].cookie_secret
, NSD_COOKIE_SECRET_SIZE);
nsd->cookie_count -= 1;
}
 End of changes. 2 change blocks. 
0 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)