]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
hinfo treatment.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 13 Aug 2007 11:53:24 +0000 (11:53 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 13 Aug 2007 11:53:24 +0000 (11:53 +0000)
git-svn-id: file:///svn/unbound/trunk@510 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
validator/val_sigcrypt.c

index ca477f7d6283c4323d3df3e6494b7c2a1c57e3ae..b4448653daf931f4950e44b1f5f3eb99bb487898 100644 (file)
@@ -2,6 +2,7 @@
        - fixup makefile, if lexer is missing give nice error and do not
          mess up the dependencies.
        - canonical compare routine updated.
+       - canonical hinfo compare.
 
 10 August 2007: Wouter
        - malloc and free overrides that track total allocation and frees.
index 01d6bf914a1915388e935f9a2aa3aa621c7edff4..9de8ed358a5e2a0adb28a76146472229cca4c3dd 100644 (file)
@@ -446,6 +446,55 @@ struct canon_rr {
        size_t rr_idx;
 };
 
+/**
+ * Compare HINFO rrsets. For them, the string length bytes are not lowercased,
+ * but the string contents are lowercased.
+ *
+ * This routine works for any 'all STR' RR type. It works similar to the
+ * compare_byfield routine, but stripped down, and modified to lowercase
+ * STR fields.
+ *
+ * @param d: rrset data
+ * @param i: first RR to compare
+ * @param j: first RR to compare
+ * @return comparison code.
+ */
+static int
+canonical_compare_hinfo(struct packed_rrset_data* d, size_t i, size_t j)
+{
+       uint8_t* di = d->rr_data[i]+2; /* ptr to current rdata byte */
+       uint8_t* dj = d->rr_data[j]+2;
+       size_t ilen = d->rr_len[i]-2; /* length left in rdata */
+       size_t jlen = d->rr_len[j]-2;
+       size_t strlen_i = 0;
+       size_t strlen_j = 0;
+       while(ilen > 0 && jlen > 0) {
+               /* compare this pair of bytes */
+               if( ((strlen_i)?(uint8_t)tolower((int)*di++):*di++)
+                != ((strlen_j)?(uint8_t)tolower((int)*dj++):*dj++)
+                ) {
+                 if(((strlen_i)?(uint8_t)tolower((int)*di++):*di++)
+                 < ((strlen_j)?(uint8_t)tolower((int)*dj++):*dj++))
+                       return -1;
+                   return 1;
+               }
+               ilen --;
+               jlen --;
+               /* read length byte of the string in rdata if strlen=0 */
+               if(strlen_i == 0) {
+                       strlen_i = (size_t)di[-1];
+               } else  strlen_i--;
+               if(strlen_j == 0) {
+                       strlen_j = (size_t)dj[-1];
+               } else  strlen_j--;
+       }
+       if(ilen == 0 && jlen == 0)
+               return 0;
+       if(ilen == 0)
+               return -1;
+       return 1;
+}
+
 /**
  * Compare two RR for canonical order, in a field-style sweep.
  * @param d: rrset data
@@ -650,6 +699,7 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j)
                /* This RR type is special, as the contents of text fields
                 * is lowercased. */
                case LDNS_RR_TYPE_HINFO:
+                       return canonical_compare_hinfo(d, i, j);
 
        default:
                /* For unknown RR types, or types not listed above,