mirror of https://github.com/getdnsapi/getdns.git
Sync tools shared with unbound
This commit is contained in:
parent
fe30672afa
commit
f3a38e9a40
|
@ -123,7 +123,7 @@ gldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *l
|
||||||
if (line_nr) {
|
if (line_nr) {
|
||||||
*line_nr = *line_nr + 1;
|
*line_nr = *line_nr + 1;
|
||||||
}
|
}
|
||||||
if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
|
if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) {
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,8 @@ gldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *l
|
||||||
if (c != '\0' && c != '\n') {
|
if (c != '\0' && c != '\n') {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
|
/* is there space for the character and the zero after it */
|
||||||
|
if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) {
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -329,8 +330,8 @@ gldns_bget_token_par(gldns_buffer *b, char *token, const char *delim,
|
||||||
/* in parentheses */
|
/* in parentheses */
|
||||||
/* do not write ' ' if we want to skip spaces */
|
/* do not write ' ' if we want to skip spaces */
|
||||||
if(!(skipw && (strchr(skipw, c)||strchr(skipw, ' ')))) {
|
if(!(skipw && (strchr(skipw, c)||strchr(skipw, ' ')))) {
|
||||||
/* check for space for the space character */
|
/* check for space for the space character and a zero delimiter after that. */
|
||||||
if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
|
if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) {
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -357,7 +358,7 @@ gldns_bget_token_par(gldns_buffer *b, char *token, const char *delim,
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
|
if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) {
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ static int gldns_str2wire_dname_buf_rel(const char* str, uint8_t* buf,
|
||||||
for (s = str; *s; s++, q++) {
|
for (s = str; *s; s++, q++) {
|
||||||
if (q >= buf + *olen)
|
if (q >= buf + *olen)
|
||||||
return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf);
|
return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf);
|
||||||
if (q > buf + GLDNS_MAX_DOMAINLEN)
|
if (q >= buf + GLDNS_MAX_DOMAINLEN)
|
||||||
return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf);
|
return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf);
|
||||||
switch (*s) {
|
switch (*s) {
|
||||||
case '.':
|
case '.':
|
||||||
|
@ -118,7 +118,7 @@ static int gldns_str2wire_dname_buf_rel(const char* str, uint8_t* buf,
|
||||||
if(rel) *rel = 1;
|
if(rel) *rel = 1;
|
||||||
if (q >= buf + *olen)
|
if (q >= buf + *olen)
|
||||||
return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf);
|
return RET_ERR(GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf);
|
||||||
if (q > buf + GLDNS_MAX_DOMAINLEN) {
|
if (q >= buf + GLDNS_MAX_DOMAINLEN) {
|
||||||
return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf);
|
return RET_ERR(GLDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf);
|
||||||
}
|
}
|
||||||
if (label_len > GLDNS_MAX_LABELLEN) {
|
if (label_len > GLDNS_MAX_LABELLEN) {
|
||||||
|
|
|
@ -821,9 +821,12 @@ int gldns_wire2str_dname_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
|
||||||
if(!pkt || target >= pktlen)
|
if(!pkt || target >= pktlen)
|
||||||
return w + gldns_str_print(s, slen,
|
return w + gldns_str_print(s, slen,
|
||||||
"ErrorComprPtrOutOfBounds");
|
"ErrorComprPtrOutOfBounds");
|
||||||
if(counter++ > maxcompr)
|
if(counter++ > maxcompr) {
|
||||||
|
if(comprloop && *comprloop < 10)
|
||||||
|
(*comprloop)++;
|
||||||
return w + gldns_str_print(s, slen,
|
return w + gldns_str_print(s, slen,
|
||||||
"ErrorComprPtrLooped");
|
"ErrorComprPtrLooped");
|
||||||
|
}
|
||||||
in_buf = 0;
|
in_buf = 0;
|
||||||
pos = pkt+target;
|
pos = pkt+target;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -327,8 +327,10 @@ setup_dsa_sig(unsigned char** sig, unsigned int* len)
|
||||||
#ifdef HAVE_DSA_SIG_SET0
|
#ifdef HAVE_DSA_SIG_SET0
|
||||||
if(!DSA_SIG_set0(dsasig, R, S)) return 0;
|
if(!DSA_SIG_set0(dsasig, R, S)) return 0;
|
||||||
#else
|
#else
|
||||||
|
# ifndef S_SPLINT_S
|
||||||
dsasig->r = R;
|
dsasig->r = R;
|
||||||
dsasig->s = S;
|
dsasig->s = S;
|
||||||
|
# endif /* S_SPLINT_S */
|
||||||
#endif
|
#endif
|
||||||
*sig = NULL;
|
*sig = NULL;
|
||||||
newlen = i2d_DSA_SIG(dsasig, sig);
|
newlen = i2d_DSA_SIG(dsasig, sig);
|
||||||
|
@ -1508,13 +1510,21 @@ dnskey_algo_id_is_supported(int id)
|
||||||
{
|
{
|
||||||
/* uses libnettle */
|
/* uses libnettle */
|
||||||
switch(id) {
|
switch(id) {
|
||||||
#if defined(USE_DSA) && defined(USE_SHA1)
|
|
||||||
case LDNS_DSA:
|
case LDNS_DSA:
|
||||||
case LDNS_DSA_NSEC3:
|
case LDNS_DSA_NSEC3:
|
||||||
|
#if defined(USE_DSA) && defined(USE_SHA1)
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
if(fake_dsa || fake_sha1) return 1;
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SHA1
|
|
||||||
case LDNS_RSASHA1:
|
case LDNS_RSASHA1:
|
||||||
case LDNS_RSASHA1_NSEC3:
|
case LDNS_RSASHA1_NSEC3:
|
||||||
|
#ifdef USE_SHA1
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
if(fake_sha1) return 1;
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SHA2
|
#ifdef USE_SHA2
|
||||||
case LDNS_RSASHA256:
|
case LDNS_RSASHA256:
|
||||||
|
@ -1741,6 +1751,7 @@ _verify_nettle_ecdsa(sldns_buffer* buf, unsigned int digest_size, unsigned char*
|
||||||
res &= nettle_ecdsa_verify (&pubkey, SHA256_DIGEST_SIZE, digest, &signature);
|
res &= nettle_ecdsa_verify (&pubkey, SHA256_DIGEST_SIZE, digest, &signature);
|
||||||
mpz_clear(x);
|
mpz_clear(x);
|
||||||
mpz_clear(y);
|
mpz_clear(y);
|
||||||
|
nettle_ecc_point_clear(&pubkey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHA384_DIGEST_SIZE:
|
case SHA384_DIGEST_SIZE:
|
||||||
|
@ -1827,6 +1838,15 @@ verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock,
|
||||||
return sec_status_bogus;
|
return sec_status_bogus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_DSA
|
||||||
|
if((algo == LDNS_DSA || algo == LDNS_DSA_NSEC3) &&(fake_dsa||fake_sha1))
|
||||||
|
return sec_status_secure;
|
||||||
|
#endif
|
||||||
|
#ifndef USE_SHA1
|
||||||
|
if(fake_sha1 && (algo == LDNS_DSA || algo == LDNS_DSA_NSEC3 || algo == LDNS_RSASHA1 || algo == LDNS_RSASHA1_NSEC3))
|
||||||
|
return sec_status_secure;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(algo) {
|
switch(algo) {
|
||||||
#if defined(USE_DSA) && defined(USE_SHA1)
|
#if defined(USE_DSA) && defined(USE_SHA1)
|
||||||
case LDNS_DSA:
|
case LDNS_DSA:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
REPO=http://unbound.net/svn/trunk
|
REPO=https://raw.githubusercontent.com/NLnetLabs/unbound/master
|
||||||
|
|
||||||
wget -O rbtree.c ${REPO}/util/rbtree.c
|
wget -O rbtree.c ${REPO}/util/rbtree.c
|
||||||
wget -O orig-headers/rbtree.h ${REPO}/util/rbtree.h
|
wget -O orig-headers/rbtree.h ${REPO}/util/rbtree.h
|
||||||
wget -O val_secalgo.c ${REPO}/validator/val_secalgo.c
|
wget -O ../tls/val_secalgo.c ${REPO}/validator/val_secalgo.c
|
||||||
wget -O orig-headers/val_secalgo.h ${REPO}/validator/val_secalgo.h
|
wget -O orig-headers/val_secalgo.h ${REPO}/validator/val_secalgo.h
|
||||||
wget -O lruhash.c ${REPO}/util/storage/lruhash.c
|
wget -O lruhash.c ${REPO}/util/storage/lruhash.c
|
||||||
wget -O orig-headers/lruhash.h ${REPO}/util/storage/lruhash.h
|
wget -O orig-headers/lruhash.h ${REPO}/util/storage/lruhash.h
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
/*
|
/*
|
||||||
|
May 2019(Wouter) patch to enable the valgrind clean implementation all the
|
||||||
|
time. This enables better security audit and checks, which is better
|
||||||
|
than the speedup. Git issue #30. Renamed the define ARRAY_CLEAN_ACCESS.
|
||||||
February 2013(Wouter) patch defines for BSD endianness, from Brad Smith.
|
February 2013(Wouter) patch defines for BSD endianness, from Brad Smith.
|
||||||
January 2012(Wouter) added randomised initial value, fallout from 28c3.
|
January 2012(Wouter) added randomised initial value, fallout from 28c3.
|
||||||
March 2007(Wouter) adapted from lookup3.c original, add config.h include.
|
March 2007(Wouter) adapted from lookup3.c original, add config.h include.
|
||||||
|
@ -44,21 +47,14 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
/*#define SELF_TEST 1*/
|
/*#define SELF_TEST 1*/
|
||||||
|
#define ARRAY_CLEAN_ACCESS 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "util/storage/lookup3.h"
|
#include "util/storage/lookup3.h"
|
||||||
#include <stdio.h> /* defines printf for tests */
|
#include <stdio.h> /* defines printf for tests */
|
||||||
#include <time.h> /* defines time_t for timings in the test */
|
#include <time.h> /* defines time_t for timings in the test */
|
||||||
|
/*#include <stdint.h> defines uint32_t etc (from config.h) */
|
||||||
#if defined(HAVE_TARGET_ENDIANNESS)
|
#include <sys/param.h> /* attempt to define endianness */
|
||||||
# if defined(TARGET_IS_BIG_ENDIAN)
|
|
||||||
# define HASH_LITTLE_ENDIAN 0
|
|
||||||
# define HASH_BIG_ENDIAN 1
|
|
||||||
# else
|
|
||||||
# define HASH_LITTLE_ENDIAN 1
|
|
||||||
# define HASH_BIG_ENDIAN 0
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
# include <sys/types.h> /* attempt to define endianness (solaris) */
|
# include <sys/types.h> /* attempt to define endianness (solaris) */
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,6 +69,15 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||||
#include <sys/endian.h> /* attempt to define endianness */
|
#include <sys/endian.h> /* attempt to define endianness */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* random initial value */
|
||||||
|
static uint32_t raninit = (uint32_t)0xdeadbeef;
|
||||||
|
|
||||||
|
void
|
||||||
|
hash_set_raninit(uint32_t v)
|
||||||
|
{
|
||||||
|
raninit = v;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* My best guess at if you are big-endian or little-endian. This may
|
* My best guess at if you are big-endian or little-endian. This may
|
||||||
* need adjustment.
|
* need adjustment.
|
||||||
|
@ -102,16 +107,6 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||||
# define HASH_LITTLE_ENDIAN 0
|
# define HASH_LITTLE_ENDIAN 0
|
||||||
# define HASH_BIG_ENDIAN 0
|
# define HASH_BIG_ENDIAN 0
|
||||||
#endif
|
#endif
|
||||||
#endif /* defined(TARGET_IS_BIG_ENDIAN) */
|
|
||||||
|
|
||||||
/* random initial value */
|
|
||||||
static uint32_t raninit = (uint32_t)0xdeadbeef;
|
|
||||||
|
|
||||||
void
|
|
||||||
hash_set_raninit(uint32_t v)
|
|
||||||
{
|
|
||||||
raninit = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define hashsize(n) ((uint32_t)1<<(n))
|
#define hashsize(n) ((uint32_t)1<<(n))
|
||||||
#define hashmask(n) (hashsize(n)-1)
|
#define hashmask(n) (hashsize(n)-1)
|
||||||
|
@ -345,7 +340,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
|
||||||
u.ptr = key;
|
u.ptr = key;
|
||||||
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
|
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
|
||||||
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
|
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
|
||||||
#ifdef VALGRIND
|
#ifdef ARRAY_CLEAN_ACCESS
|
||||||
const uint8_t *k8;
|
const uint8_t *k8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -370,7 +365,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
|
||||||
* still catch it and complain. The masking trick does make the hash
|
* still catch it and complain. The masking trick does make the hash
|
||||||
* noticeably faster for short strings (like English words).
|
* noticeably faster for short strings (like English words).
|
||||||
*/
|
*/
|
||||||
#ifndef VALGRIND
|
#ifndef ARRAY_CLEAN_ACCESS
|
||||||
|
|
||||||
switch(length)
|
switch(length)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue