logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: 9dc52fbf3393cbfb66f27d051cf26fed3a235afe
parent 8f1c4ae1520fd65bc4259c542dfd7a4ef422cf8e
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 16 Jun 2019 23:38:47 -0700

nsd: Fix a few portability issues

Diffstat:

Apkg/nsd/patch/0003-Avoid-pointer-arithmetic-on-void.patch179+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkg/nsd/patch/0004-Avoid-unnecessary-VLA.patch34++++++++++++++++++++++++++++++++++
Mpkg/nsd/ver2+-
3 files changed, 214 insertions(+), 1 deletion(-)

diff --git a/pkg/nsd/patch/0003-Avoid-pointer-arithmetic-on-void.patch b/pkg/nsd/patch/0003-Avoid-pointer-arithmetic-on-void.patch @@ -0,0 +1,179 @@ +From 832067946e71d1d09e47beb328c70f56c097adeb Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 16 Jun 2019 23:17:47 -0700 +Subject: [PATCH] Avoid pointer arithmetic on `void *` + +The pointer operand to the binary `+` operator must be to a complete +object type. +--- + dbaccess.c | 8 ++++---- + difffile.c | 4 ++-- + region-allocator.c | 4 ++-- + udb.c | 12 ++++++------ + udb.h | 4 ++-- + xfrd.c | 2 +- + 6 files changed, 17 insertions(+), 17 deletions(-) + +diff --git a/dbaccess.c b/dbaccess.c +index da0762e9..87f75f9c 100644 +--- a/dbaccess.c ++++ b/dbaccess.c +@@ -210,19 +210,19 @@ static void read_zone_recurse(udb_base* udb, namedb_type* db, + /* pre-order process of node->elem, for radix tree this is + * also in-order processing (identical to order tree_next()) */ + read_node_elem(udb, db, dname_region, zone, (struct domain_d*) +- (udb->base + node->elem.data)); ++ ((char*)udb->base + node->elem.data)); + } + if(node->lookup.data) { + uint16_t i; + struct udb_radarray_d* a = (struct udb_radarray_d*) +- (udb->base + node->lookup.data); ++ ((char*)udb->base + node->lookup.data); + /* we do not care for what the exact radix key is, we want + * to add all of them and the read routine does not need + * the radix-key, it has it stored */ + for(i=0; i<a->len; i++) { + if(a->array[i].node.data) { + read_zone_recurse(udb, db, dname_region, zone, +- (struct udb_radnode_d*)(udb->base + ++ (struct udb_radnode_d*)((char*)udb->base + + a->array[i].node.data)); + } + } +@@ -240,7 +240,7 @@ read_zone_data(udb_base* udb, namedb_type* db, region_type* dname_region, + if(RADTREE(&dtree)->root.data) + read_zone_recurse(udb, db, dname_region, zone, + (struct udb_radnode_d*) +- (udb->base + RADTREE(&dtree)->root.data)); ++ ((char*)udb->base + RADTREE(&dtree)->root.data)); + udb_ptr_unlink(&dtree, udb); + } + +diff --git a/difffile.c b/difffile.c +index b3aee0b4..82056ada 100644 +--- a/difffile.c ++++ b/difffile.c +@@ -1631,7 +1631,7 @@ void* task_new_stat_info(udb_base* udb, udb_ptr* last, struct nsdst* stat, + p = TASKLIST(&e)->zname; + memcpy(p, stat, sizeof(*stat)); + udb_ptr_unlink(&e, udb); +- return p + sizeof(*stat); ++ return (char*)p + sizeof(*stat); + } + #endif /* BIND8_STATS */ + +@@ -1653,7 +1653,7 @@ task_new_add_zone(udb_base* udb, udb_ptr* last, const char* zone, + TASKLIST(&e)->yesno = zonestatid; + p = TASKLIST(&e)->zname; + memcpy(p, zone, zlen+1); +- memmove(p+zlen+1, pattern, plen+1); ++ memmove((char*)p+zlen+1, pattern, plen+1); + udb_ptr_unlink(&e, udb); + } + +diff --git a/region-allocator.c b/region-allocator.c +index 638c861b..f53841ad 100644 +--- a/region-allocator.c ++++ b/region-allocator.c +@@ -272,7 +272,7 @@ region_alloc(region_type *region, size_t size) + region->total_allocated += size; + ++region->large_objects; + +- return result + sizeof(struct large_elem); ++ return (char *)result + sizeof(struct large_elem); + } + + if (region->recycle_bin && region->recycle_bin[aligned_size]) { +@@ -469,7 +469,7 @@ region_recycle(region_type *region, void *block, size_t size) + region->total_allocated -= size; + --region->large_objects; + +- l = (struct large_elem*)(block-sizeof(struct large_elem)); ++ l = (struct large_elem*)((char*)block-sizeof(struct large_elem)); + if(l->prev) + l->prev->next = l->next; + else region->large_list = l->next; +diff --git a/udb.c b/udb.c +index 1b41ab91..b02a482b 100644 +--- a/udb.c ++++ b/udb.c +@@ -192,13 +192,13 @@ udb_base_create_fd(const char* fname, int fd, udb_walk_relptr_func walkfunc, + } + + /* init completion */ +- udb->glob_data = (udb_glob_d*)(udb->base+sizeof(uint64_t)); ++ udb->glob_data = (udb_glob_d*)((char*)udb->base+sizeof(uint64_t)); + r = 0; + /* cannot be dirty because that is goto fail above */ + if(udb->glob_data->dirty_alloc != udb_dirty_clean) + r = 1; + udb->alloc = udb_alloc_create(udb, (udb_alloc_d*)( +- (void*)udb->glob_data+sizeof(*udb->glob_data))); ++ (char*)udb->glob_data+sizeof(*udb->glob_data))); + if(!udb->alloc) { + log_msg(LOG_ERR, "out of memory"); + udb_base_free(udb); +@@ -555,10 +555,10 @@ udb_base_remap(udb_base* udb, udb_alloc* alloc, uint64_t nsize) + /* fix up realpointers in udb and alloc */ + /* but mremap may have been nice and not move the base */ + udb->base = nb; +- udb->glob_data = (udb_glob_d*)(nb+sizeof(uint64_t)); ++ udb->glob_data = (udb_glob_d*)((char*)nb+sizeof(uint64_t)); + /* use passed alloc pointer because the udb->alloc may not + * be initialized yet */ +- alloc->disk = (udb_alloc_d*)((void*)udb->glob_data ++ alloc->disk = (udb_alloc_d*)((char*)udb->glob_data + +sizeof(*udb->glob_data)); + } + udb->base_size = nsize; +@@ -798,7 +798,7 @@ regen_ptrlist(void* base, udb_base* udb, udb_alloc* alloc, + if(exp == UDB_EXP_XL) { + assert(at != rb_old); /* should have been freed */ + regen_its_ptrs(base, udb, atp, +- ((void*)atp)+sizeof(udb_xl_chunk_d), ++ ((char*)atp)+sizeof(udb_xl_chunk_d), + sz-sizeof(udb_xl_chunk_d) - sizeof(uint64_t)*2, + rb_old, rb_new); + at += sz; +@@ -807,7 +807,7 @@ regen_ptrlist(void* base, udb_base* udb, udb_alloc* alloc, + } else { /* data chunk */ + assert(at != rb_old); /* should have been freed */ + regen_its_ptrs(base, udb, atp, +- ((void*)atp)+sizeof(udb_chunk_d), ++ ((char*)atp)+sizeof(udb_chunk_d), + sz-sizeof(udb_chunk_d)-1, rb_old, rb_new); + at += sz; + } +diff --git a/udb.h b/udb.h +index 8d7ee137..3ee98648 100644 +--- a/udb.h ++++ b/udb.h +@@ -52,9 +52,9 @@ typedef struct udb_alloc udb_alloc; + typedef uint64_t udb_void; + + /** convert relptr to usable pointer */ +-#define UDB_REL(base, relptr) ((base) + (relptr)) ++#define UDB_REL(base, relptr) ((void*)((char*)(base) + (relptr))) + /** from system pointer to relative pointer */ +-#define UDB_SYSTOREL(base, ptr) ((udb_void)((void*)(ptr) - (base))) ++#define UDB_SYSTOREL(base, ptr) ((udb_void)((char*)(ptr) - (char*)(base))) + + /** MAX 2**x exponent of alloced chunks, for 1Mbytes. The smallest + * chunk is 16bytes (8preamble+8data), so 0-3 is unused. */ +diff --git a/xfrd.c b/xfrd.c +index c2eeff8a..2d261089 100644 +--- a/xfrd.c ++++ b/xfrd.c +@@ -2455,7 +2455,7 @@ static void + xfrd_process_stat_info_task(xfrd_state_type* xfrd, struct task_list_d* task) + { + size_t i; +- stc_type* p = (void*)task->zname + sizeof(struct nsdst); ++ stc_type* p = (void*)((char*)task->zname + sizeof(struct nsdst)); + stats_add(&xfrd->nsd->st, (struct nsdst*)task->zname); + for(i=0; i<xfrd->nsd->child_count; i++) { + xfrd->nsd->children[i].query_count += *p++; +-- +2.20.1 + diff --git a/pkg/nsd/patch/0004-Avoid-unnecessary-VLA.patch b/pkg/nsd/patch/0004-Avoid-unnecessary-VLA.patch @@ -0,0 +1,34 @@ +From badd4b57dee6c34643a2b79b682956c56c33bc36 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 16 Jun 2019 23:37:11 -0700 +Subject: [PATCH] Avoid unnecessary VLA + +--- + xfrd-tcp.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/xfrd-tcp.c b/xfrd-tcp.c +index 3c176a38..a4d795c7 100644 +--- a/xfrd-tcp.c ++++ b/xfrd-tcp.c +@@ -214,12 +214,12 @@ pipeline_find(struct xfrd_tcp_set* set, xfrd_zone_type* zone) + struct xfrd_tcp_pipeline* r; + /* smaller buf than a full pipeline with 64kb ID array, only need + * the front part with the key info, this front part contains the +- * members that the compare function uses. */ +- const size_t keysize = sizeof(struct xfrd_tcp_pipeline) - +- ID_PIPE_NUM*(sizeof(struct xfrd_zone*) + sizeof(uint16_t)); +- /* void* type for alignment of the struct, ++ * members that the compare function uses. ++ * ++ * void* type for alignment of the struct, + * divide the keysize by ptr-size and then add one to round up */ +- void* buf[ (keysize / sizeof(void*)) + 1 ]; ++ void* buf[ ((sizeof(struct xfrd_tcp_pipeline) - ++ ID_PIPE_NUM*(sizeof(struct xfrd_zone*) + sizeof(uint16_t))) / sizeof(void*)) + 1 ]; + struct xfrd_tcp_pipeline* key = (struct xfrd_tcp_pipeline*)buf; + key->node.key = key; + key->ip_len = xfrd_acl_sockaddr_to(zone->master, &key->ip); +-- +2.20.1 + diff --git a/pkg/nsd/ver b/pkg/nsd/ver @@ -1 +1 @@ -4.2.0 r0 +4.2.0 r1