From 06e6af37659b9522aad8dd829d29fee951fa6452 Mon Sep 17 00:00:00 2001 From: halderen Date: Tue, 20 Feb 2018 12:02:21 +0100 Subject: [PATCH] Some segv problems related to missing files Problems for not always picking up changes. --- httpd.c | 9 +++++++-- libtool | 4 ++-- rpc.c | 9 +-------- zoneinput.c | 4 ++++ zoneoutput.c | 3 +++ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/httpd.c b/httpd.c index e01cdc0..4bc16eb 100644 --- a/httpd.c +++ b/httpd.c @@ -62,8 +62,11 @@ deletedelegation(names_view_type view, struct rpc *rpc) /* delete everything below delegation point, inclusive */ names_iterator iter; dictionary* record; + dictionary r; for (iter = names_viewiterate(view, "allbelow", rpc->delegation_point); names_iterate(&iter, &record); names_advance(&iter, NULL)) { - names_recorddelall(*record, NULL); + r = *record; + names_own(view, &r); + names_recorddelall(r, NULL); } /* in case of error rpc->status = RPC_ERR; */ return 0; @@ -101,7 +104,6 @@ insertrecords(names_view_type view, struct rpc *rpc) free((void*)recorddata); free((void*)recordinfo); } - names_viewcommit(view); rpc->status = RPC_OK; return 0; @@ -114,14 +116,17 @@ dispatch(struct httpd* httpd, struct rpc *rpc) { names_view_type view; view = getzone(rpc->zone)->inputview; + names_viewreset(view); switch (rpc->opc) { case RPC_CHANGE_DELEGATION: deletedelegation(view, rpc); insertrecords(view, rpc); + names_viewcommit(view); break; case RPC_CHANGE_NAME: deleterecordsets(view, rpc); insertrecords(view, rpc); + names_viewcommit(view); break; default: rpc->status = RPC_ERR; diff --git a/libtool b/libtool index 87f3ddc..7613c55 100755 --- a/libtool +++ b/libtool @@ -1,6 +1,6 @@ #! /bin/sh # Generated automatically by config.status (volans) 0.2-dev -# Libtool was configured on host fire: +# Libtool was configured on host nagini: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. @@ -285,7 +285,7 @@ hardcode_into_libs=yes sys_lib_search_path_spec="/usr/lib64/gcc/x86_64-slackware-linux/7.3.0 /usr/lib64 /lib64 /usr/x86_64-slackware-linux/lib /lib /usr/lib " # Detected run-time system search path for libraries. -sys_lib_dlsearch_path_spec="/lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64 /usr/x86_64-slackware-linux/lib64 /usr/lib64/seamonkey " +sys_lib_dlsearch_path_spec="/lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64 /usr/x86_64-slackware-linux/lib64 /usr/local/lib /usr/lib64/seamonkey " # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path="" diff --git a/rpc.c b/rpc.c index 2474032..6154049 100644 --- a/rpc.c +++ b/rpc.c @@ -59,8 +59,6 @@ struct rpc * rpc_decode_json(const char *url, const char *buf, size_t buflen) { - /*printf("incoming data: \"%s\"\n", buf);//not null terminated!*/ - json_error_t error; json_t *root = json_loadb(buf, buflen, 0, &error); if (!root) { @@ -80,11 +78,6 @@ rpc_decode_json(const char *url, const char *buf, size_t buflen) return NULL; } json_t *obj_correlation = json_object_get(root, "transaction"); - if (!obj_correlation || !json_is_string(obj_correlation)) { - printf("correlation not found.\n"); - json_decref(root); - return NULL; - } json_t *obj_entities = json_object_get(root, "entities"); if (!obj_entities || !json_is_array(obj_entities)) { @@ -192,7 +185,7 @@ rpc_decode_json(const char *url, const char *buf, size_t buflen) rpc->zone = strdup(zone); rpc->version = strdup(version); rpc->detail_version = strdup(json_string_value(obj_version)); - rpc->correlation = strdup(json_string_value(obj_correlation)); + rpc->correlation = (obj_correlation ? strdup(json_string_value(obj_correlation)) : NULL); rpc->delegation_point = strdup(delegation_point); rpc->rr_count = rr_count; rpc->rr = rr; diff --git a/zoneinput.c b/zoneinput.c index 26e6750..7f39fee 100644 --- a/zoneinput.c +++ b/zoneinput.c @@ -126,6 +126,10 @@ readzone(names_view_type view, enum operation_enum operation, const char* filena ldns_rr* rr; fp = fopen(filename,"r"); + if(!fp) { + fprintf(stderr,"unable to open file \"%s\"\n",filename); + return -1; + } origin = NULL; prevowner = NULL; diff --git a/zoneoutput.c b/zoneoutput.c index 8b423b6..42a8fc4 100644 --- a/zoneoutput.c +++ b/zoneoutput.c @@ -33,6 +33,9 @@ writezone(names_view_type view, const char* filename, const char* apex, int* def origin = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, apex); fp = fopen(filename,"w"); + if(!fp) { + fprintf(stderr,"unable to open file \"%s\"\n",filename); + } s = ldns_rdf2str(origin); fprintf(fp, "$ORIGIN %s\n", s);