]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
when a zone starts with @ we don't have a previous dname nor an origin
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 13 Dec 2005 10:33:48 +0000 (10:33 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 13 Dec 2005 10:33:48 +0000 (10:33 +0000)
handle this case.
Not that named-xfer does not write out zone like that, only the zone
generated at SIDN looks like that

examples/ldns-splitzone.c
examples/ldns-threshold-update.c
rdata.c
zone.c

index 106118916762e5d026dcfe39a53bfaeb8bee495b..ae40aec5cc54774c43c8f4f56f5a50b9d307441e 100644 (file)
@@ -27,7 +27,8 @@ usage(FILE *f, char *progname)
                fprintf(f, "Usage: %s [OPTIONS] <zonefile>\n", progname);
                fprintf(f, "\tSplit a zone file up.\n");
                fprintf(f, "\nOPTIONS:\n");
-               fprintf(f, "-n = NUMBER\tSplit after this many names\n");
+               fprintf(f, "-n NUMBER\tSplit after this many names\n");
+               fprintf(f, "-o ORIGIN\tUse this as initial origin. For zones starting with @\n");
 }
 
 int
@@ -45,6 +46,7 @@ main(int argc, char **argv)
        int splitting;
        size_t file_counter;
        char filename[255];
+       ldns_rdf *origin = NULL;
 
        progname = strdup(argv[0]);
        split = 0;
@@ -52,7 +54,7 @@ main(int argc, char **argv)
        file_counter = 1;
        lastname = NULL;
 
-       while ((c = getopt(argc, argv, "n:")) != -1) {
+       while ((c = getopt(argc, argv, "n:o:")) != -1) {
                switch(c) {
                        case 'n':
                                split = (size_t)atoi(optarg);
@@ -61,6 +63,13 @@ main(int argc, char **argv)
                                        exit(EXIT_FAILURE);
                                }
                                break;
+                       case 'o':
+                               origin = ldns_dname_new_frm_str(strdup(optarg));
+                               if (!origin) {
+                                       printf("cannot convert to dname\n");
+                                       exit(EXIT_FAILURE);
+                               }
+                               break;
                        default:
                                printf("Unrecognized option\n");
                                usage(stdout, progname);
@@ -84,7 +93,12 @@ main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
        /* suck in the entire zone ... */
-       z = ldns_zone_new_frm_fp_l(fp, NULL, 0, LDNS_RR_CLASS_IN, &line_nr);
+       if (!origin) {
+               printf("Warning no origin is given I'm using . now\n");
+               origin = ldns_dname_new_frm_str(".");
+       }
+       
+       z = ldns_zone_new_frm_fp_l(fp, origin, 0, LDNS_RR_CLASS_IN, &line_nr);
        fclose(fp);
 
        if (!z) {
index d09c4019ba96f0854c0d3676f0a617ca9a464394..d2223533d9fa321fd5c33c051f919d8961a69af2 100644 (file)
@@ -54,7 +54,7 @@ main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
 
-       k = ldns_rr_new_frm_fp(kf, NULL, NULL);
+       k = ldns_rr_new_frm_fp(kf, NULL, NULL, NULL);
        if (!k) {
                exit(EXIT_FAILURE);
        }
diff --git a/rdata.c b/rdata.c
index 41c7283dd8615c61557ddc67af49be708b768de2..c28fcf349a461c7f17d2323b087137a18910cf98 100644 (file)
--- a/rdata.c
+++ b/rdata.c
@@ -187,6 +187,7 @@ ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data)
 ldns_rdf *
 ldns_rdf_clone(const ldns_rdf *r)
 {
+       assert(r != NULL);
        return (ldns_rdf_new_frm_data(
                                ldns_rdf_get_type(r),
                                ldns_rdf_size(r), 
diff --git a/zone.c b/zone.c
index 387b04915dbbff08e25971264e9c16c570167a9c..8fefe9f6eea908a379b91ebce5126bc0324890fa 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -158,11 +158,11 @@ ldns_zone_new_frm_fp_l(FILE *fp, ldns_rdf *origin, uint16_t ttl, ldns_rr_class c
 {
        ldns_zone *newzone;
        ldns_rr *rr;
-       ldns_rdf *my_origin = NULL;
        uint16_t my_ttl = ttl;
        ldns_rr_class my_class = c;
        ldns_rr *last_rr = NULL;
-       ldns_rdf *my_prev = NULL;
+       ldns_rdf *my_origin = NULL;
+       ldns_rdf *my_prev;
        uint8_t i;
 
        newzone = ldns_zone_new();
@@ -176,6 +176,8 @@ ldns_zone_new_frm_fp_l(FILE *fp, ldns_rdf *origin, uint16_t ttl, ldns_rr_class c
 
        if (origin) {
                my_origin = ldns_rdf_clone(origin);
+               /* also set the prev */
+               my_prev   = ldns_rdf_clone(origin);
        }
        
        i = 0;