]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
left in the debug code - something is not quite right
authorMiek Gieben <miekg@NLnetLabs.nl>
Wed, 6 Apr 2005 10:04:18 +0000 (10:04 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Wed, 6 Apr 2005 10:04:18 +0000 (10:04 +0000)
but, I'm off to lunch

ldns/parse.h
parse.c
rr.c
run-test18.c

index d6f7b0d6e07b9429e0e888985195501b6ddb3609..adea50b060591fe195c7441beb2ed0489f78f642 100644 (file)
@@ -57,7 +57,8 @@ ldns_bget_keyword_data(ldns_buffer *b, const char *keyword, const char *k_del, c
 
 /*
  * Remove \DDD constructs from the input. See RFC 1035, section 5.1.
+ * dest is alloced in this function!
  */
-size_t zoctet(char *text);
+size_t ldns_unquote(char *text, char **dest);
 
 #endif /*  _PARSE_H_ */
diff --git a/parse.c b/parse.c
index 21d3d9e434ec37362519c3f8603ee4c1c35d4d5b..d9e355104368d195ab95f8cdab90566d2fe7cc76 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -246,20 +246,20 @@ tokenread:
        }
 }
 
-/* should text be writeable? Or should we return a new
- * string??
- */
 size_t
-zoctet(char *text)
+ldns_unquote(char *text, char **dest)
 {
         /*
          * s follows the string, p lags behind and rebuilds 
-        * the new string
+        * the new string.
+        * Assumes: the new string will be <= old string
          */
-        char *s;
+       char *s;
         char *p;
 
-        for (s = p = text; *s; ++s, ++p) {
+       *dest = strdup(text);
+
+        for (s = p = *dest; *s; ++s, ++p) {
                 assert(p <= s);
                 if (s[0] != '\\') {
                         /* Ordinary character.  */
@@ -273,8 +273,8 @@ zoctet(char *text)
                                 s += 3;
                                 *p = val;
                         } else {
-                                printf("text escape \\DDD overflow");
-                               /* kuch, another printf... */
+                                printf("text escape \\DDD overflow\n");
+                               /* TODO, another printf... */
                                 *p = *++s;
                         }
                 } else if (s[1] != '\0') {
@@ -286,6 +286,6 @@ zoctet(char *text)
                         --p;
                 }
         }
-        *p = '\0';
-        return p - text;
+        *p  = '\0';
+        return (size_t)((p - *dest));
 }
diff --git a/rr.c b/rr.c
index aab63ae241eff20205b5788bf083f6be9536d61a..6b17b8e1d66f1cbe93126ed26a150f2caada3d54 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -98,6 +98,7 @@ ldns_rr_new_frm_str(const char *str)
        ldns_rr_type rr_type;
        ldns_buffer *rr_buf;
        ldns_buffer *rd_buf;
+       char  *unquoted;
        char  *owner; 
        char  *ttl; 
        char  *clas;
@@ -106,11 +107,15 @@ ldns_rr_new_frm_str(const char *str)
        char  *rd;
        
        ldns_rdf *r;
+       size_t  unquoted_len;
        uint16_t r_cnt;
        uint16_t r_min;
        uint16_t r_max;
 
        new = ldns_rr_new();
+       unquoted_len = ldns_unquote((char *)str, &unquoted);
+       printf("unq: [%s]\n", unquoted);
+       printf("unq: [%d] %d\n", strlen(unquoted), unquoted_len);
 
        owner = XMALLOC(char, MAX_DOMAINLEN + 1);
        ttl = XMALLOC(char, 21);
@@ -122,7 +127,7 @@ ldns_rr_new_frm_str(const char *str)
        rd = XMALLOC(char, MAX_RDFLEN);
        r_cnt = 0;
 
-       ldns_buffer_new_frm_data(rr_buf, str, strlen(str));
+       ldns_buffer_new_frm_data(rr_buf, unquoted, unquoted_len);
        
        /* split the rr in its parts -1 signal trouble */
        if (ldns_bget_token(rr_buf, owner, "\t ", MAX_DOMAINLEN) == -1) {
index 7d659646b6b3460225d0dd7864ea630b03d09f70..8abfdb5f000be4aee948a299de98103be87785c6 100644 (file)
@@ -40,6 +40,14 @@ main()
        rr = ldns_rr_new_frm_str("a.miek.nl. 1800    IN     MX     10    www.atoom.net");
        ldns_rr_print(stdout, rr);
        printf("\n");
+
+       rr = ldns_rr_new_frm_str("a.miek.nl. 1800    IN     MX     10    w\065.atoom.net");
+       ldns_rr_print(stdout, rr);
+       printf("\n");
+
+       rr = ldns_rr_new_frm_str("a.miek.nl. 1800    IN     MX     10    w\65.atoom.net");
+       ldns_rr_print(stdout, rr);
+       printf("\n");
        
        /* miss formed */
        rr = ldns_rr_new_frm_str("a.miek.nl. 1800 IN MX 10");