1 /* 2 * testcode/unitdname.c - unit test for dname routines. 3 * 4 * Copyright (c) 2007, NLnet Labs. All rights reserved. 5 * 6 * This software is open source. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 19 * Neither the name of the NLNET LABS nor the names of its contributors may 20 * be used to endorse or promote products derived from this software without 21 * specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 */ 36 /** 37 * \file 38 * Calls dname unit tests. Exits with code 1 on a failure. 39 */ 40 41 #include "config.h" 42 #include <ctype.h> 43 #include "util/log.h" 44 #include "testcode/unitmain.h" 45 #include "util/data/dname.h" 46 #include "sldns/sbuffer.h" 47 #include "sldns/str2wire.h" 48 49 /** put dname into buffer */ 50 static sldns_buffer* 51 dname_to_buf(sldns_buffer* b, const char* str) 52 { 53 int e; 54 size_t len = sldns_buffer_capacity(b); 55 sldns_buffer_clear(b); 56 e = sldns_str2wire_dname_buf(str, sldns_buffer_begin(b), &len); 57 if(e != 0) 58 fatal_exit("%s ldns: %s", __func__, 59 sldns_get_errorstr_parse(e)); 60 sldns_buffer_set_position(b, len); 61 sldns_buffer_flip(b); 62 return b; 63 } 64 65 /** test query_dname_len function */ 66 static void 67 dname_test_qdl(sldns_buffer* buff) 68 { 69 unit_show_func("util/data/dname.c", "query_dname_len"); 70 unit_assert( query_dname_len(buff) == 0); 71 unit_assert( query_dname_len(dname_to_buf(buff, ".")) == 1 ); 72 unit_assert( query_dname_len(dname_to_buf(buff, "bla.foo.")) == 9 ); 73 unit_assert( query_dname_len(dname_to_buf(buff, "x.y.z.example.com." 74 )) == 19 ); 75 } 76 77 /** test query_dname_tolower */ 78 static void 79 dname_test_qdtl(sldns_buffer* buff) 80 { 81 unit_show_func("util/data/dname.c", "query_dname_tolower"); 82 sldns_buffer_write_at(buff, 0, "\012abCDeaBCde\003cOm\000", 16); 83 query_dname_tolower(sldns_buffer_begin(buff)); 84 unit_assert( memcmp(sldns_buffer_begin(buff), 85 "\012abcdeabcde\003com\000", 16) == 0); 86 87 sldns_buffer_write_at(buff, 0, "\001+\012abC{e-ZYXe\003NET\000", 18); 88 query_dname_tolower(sldns_buffer_begin(buff)); 89 unit_assert( memcmp(sldns_buffer_begin(buff), 90 "\001+\012abc{e-zyxe\003net\000", 18) == 0); 91 92 sldns_buffer_write_at(buff, 0, "\000", 1); 93 query_dname_tolower(sldns_buffer_begin(buff)); 94 unit_assert( memcmp(sldns_buffer_begin(buff), "\000", 1) == 0); 95 96 sldns_buffer_write_at(buff, 0, "\002NL\000", 4); 97 query_dname_tolower(sldns_buffer_begin(buff)); 98 unit_assert( memcmp(sldns_buffer_begin(buff), "\002nl\000", 4) == 0); 99 } 100 101 /** test query_dname_compare */ 102 static void 103 dname_test_query_dname_compare(void) 104 { 105 unit_show_func("util/data/dname.c", "query_dname_compare"); 106 unit_assert(query_dname_compare((uint8_t*)"", (uint8_t*)"") == 0); 107 unit_assert(query_dname_compare((uint8_t*)"\001a", 108 (uint8_t*)"\001a") == 0); 109 unit_assert(query_dname_compare((uint8_t*)"\003abc\001a", 110 (uint8_t*)"\003abc\001a") == 0); 111 unit_assert(query_dname_compare((uint8_t*)"\003aBc\001a", 112 (uint8_t*)"\003AbC\001A") == 0); 113 unit_assert(query_dname_compare((uint8_t*)"\003abc", 114 (uint8_t*)"\003abc\001a") == -1); 115 unit_assert(query_dname_compare((uint8_t*)"\003abc\001a", 116 (uint8_t*)"\003abc") == +1); 117 unit_assert(query_dname_compare((uint8_t*)"\003abc\001a", 118 (uint8_t*)"") == +1); 119 unit_assert(query_dname_compare((uint8_t*)"", 120 (uint8_t*)"\003abc\001a") == -1); 121 unit_assert(query_dname_compare((uint8_t*)"\003abc\001a", 122 (uint8_t*)"\003xxx\001a") == -1); 123 unit_assert(query_dname_compare((uint8_t*)"\003axx\001a", 124 (uint8_t*)"\003abc\001a") == 1); 125 unit_assert(query_dname_compare((uint8_t*)"\003abc\001a", 126 (uint8_t*)"\003abc\001Z") == -1); 127 unit_assert(query_dname_compare((uint8_t*)"\003abc\001Z", 128 (uint8_t*)"\003abc\001a") == 1); 129 } 130 131 /** test dname_count_labels */ 132 static void 133 dname_test_count_labels(void) 134 { 135 unit_show_func("util/data/dname.c", "dname_count_labels"); 136 unit_assert(dname_count_labels((uint8_t*)"") == 1); 137 unit_assert(dname_count_labels((uint8_t*)"\003com") == 2); 138 unit_assert(dname_count_labels((uint8_t*)"\003org") == 2); 139 unit_assert(dname_count_labels((uint8_t*)"\007example\003com") == 3); 140 unit_assert(dname_count_labels((uint8_t*)"\003bla\007example\003com") 141 == 4); 142 } 143 144 /** test dname_count_size_labels */ 145 static void 146 dname_test_count_size_labels(void) 147 { 148 size_t sz = 0; 149 unit_show_func("util/data/dname.c", "dname_count_size_labels"); 150 unit_assert(dname_count_size_labels((uint8_t*)"", &sz) == 1); 151 unit_assert(sz == 1); 152 unit_assert(dname_count_size_labels((uint8_t*)"\003com", &sz) == 2); 153 unit_assert(sz == 5); 154 unit_assert(dname_count_size_labels((uint8_t*)"\003org", &sz) == 2); 155 unit_assert(sz == 5); 156 unit_assert(dname_count_size_labels((uint8_t*)"\007example\003com", 157 &sz) == 3); 158 unit_assert(sz == 13); 159 unit_assert(dname_count_size_labels((uint8_t*)"\003bla\007example" 160 "\003com", &sz) == 4); 161 unit_assert(sz == 17); 162 } 163 164 165 /** test pkt_dname_len */ 166 static void 167 dname_test_pkt_dname_len(sldns_buffer* buff) 168 { 169 unit_show_func("util/data/dname.c", "pkt_dname_len"); 170 sldns_buffer_clear(buff); 171 sldns_buffer_write(buff, "\000", 1); 172 sldns_buffer_flip(buff); 173 unit_assert( pkt_dname_len(buff) == 1 ); 174 unit_assert( sldns_buffer_position(buff) == 1); 175 176 sldns_buffer_clear(buff); 177 sldns_buffer_write(buff, "\003org\000", 5); 178 sldns_buffer_flip(buff); 179 unit_assert( pkt_dname_len(buff) == 5 ); 180 unit_assert( sldns_buffer_position(buff) == 5); 181 182 sldns_buffer_clear(buff); 183 sldns_buffer_write(buff, "\002os\007example\003org\000", 16); 184 sldns_buffer_flip(buff); 185 unit_assert( pkt_dname_len(buff) == 16 ); 186 unit_assert( sldns_buffer_position(buff) == 16); 187 188 /* invalid compression pointer: to self */ 189 sldns_buffer_clear(buff); 190 sldns_buffer_write(buff, "\300\000os\007example\003org\000", 17); 191 sldns_buffer_flip(buff); 192 unit_assert( pkt_dname_len(buff) == 0 ); 193 194 /* valid compression pointer */ 195 sldns_buffer_clear(buff); 196 sldns_buffer_write(buff, "\003com\000\040\300\000", 8); 197 sldns_buffer_flip(buff); 198 sldns_buffer_set_position(buff, 6); 199 unit_assert( pkt_dname_len(buff) == 5 ); 200 unit_assert( sldns_buffer_position(buff) == 8); 201 202 /* unknown label type */ 203 sldns_buffer_clear(buff); 204 sldns_buffer_write(buff, "\002os\107example\003org\000", 16); 205 sldns_buffer_flip(buff); 206 unit_assert( pkt_dname_len(buff) == 0 ); 207 208 /* label too long */ 209 sldns_buffer_clear(buff); 210 sldns_buffer_write(buff, "\002os\047example\003org\000", 16); 211 sldns_buffer_flip(buff); 212 unit_assert( pkt_dname_len(buff) == 0 ); 213 214 /* label exceeds packet */ 215 sldns_buffer_clear(buff); 216 sldns_buffer_write(buff, "\002os\007example\007org\004", 16); 217 sldns_buffer_flip(buff); 218 unit_assert( pkt_dname_len(buff) == 0 ); 219 220 /* name very long */ 221 sldns_buffer_clear(buff); 222 sldns_buffer_write(buff, 223 "\020a1cdef5555544444" 224 "\020a2cdef5555544444" 225 "\020a3cdef5555544444" 226 "\020a4cdef5555544444" 227 "\020a5cdef5555544444" 228 "\020a6cdef5555544444" 229 "\020a7cdef5555544444" 230 "\020a8cdef5555544444" 231 "\020a9cdef5555544444" 232 "\020aAcdef5555544444" 233 "\020aBcdef5555544444" 234 "\020aCcdef5555544444" 235 "\020aDcdef5555544444" 236 "\020aEcdef5555544444" /* 238 up to here */ 237 "\007aabbccd" /* 246 up to here */ 238 "\007example\000" /* 255 to here */ 239 , 255); 240 sldns_buffer_flip(buff); 241 unit_assert( pkt_dname_len(buff) == 255 ); 242 unit_assert( sldns_buffer_position(buff) == 255); 243 244 /* name too long */ 245 sldns_buffer_clear(buff); 246 sldns_buffer_write(buff, 247 "\020a1cdef5555544444" 248 "\020a2cdef5555544444" 249 "\020a3cdef5555544444" 250 "\020a4cdef5555544444" 251 "\020a5cdef5555544444" 252 "\020a6cdef5555544444" 253 "\020a7cdef5555544444" 254 "\020a8cdef5555544444" 255 "\020a9cdef5555544444" 256 "\020aAcdef5555544444" 257 "\020aBcdef5555544444" 258 "\020aCcdef5555544444" 259 "\020aXcdef5555544444" 260 "\020aXcdef5555544444" 261 "\020aXcdef5555544444" 262 "\020aDcdef5555544444" 263 "\020aEcdef5555544444" /* 238 up to here */ 264 "\007aabbccd" /* 246 up to here */ 265 "\007example\000" /* 255 to here */ 266 , 255); 267 sldns_buffer_flip(buff); 268 unit_assert( pkt_dname_len(buff) == 0 ); 269 } 270 271 /** test dname_lab_cmp */ 272 static void 273 dname_test_dname_lab_cmp(void) 274 { 275 int ml = 0; /* number of labels that matched exactly */ 276 unit_show_func("util/data/dname.c", "dname_lab_cmp"); 277 278 /* test for equality succeeds */ 279 unit_assert(dname_lab_cmp((uint8_t*)"", 1, (uint8_t*)"", 1, &ml) == 0); 280 unit_assert(ml == 1); 281 unit_assert(dname_lab_cmp( 282 (uint8_t*)"\003net", 2, 283 (uint8_t*)"\003net", 2, 284 &ml) == 0); 285 unit_assert(ml == 2); 286 unit_assert(dname_lab_cmp( 287 (uint8_t*)"\007example\003net", 3, 288 (uint8_t*)"\007example\003net", 3, 289 &ml) == 0); 290 unit_assert(ml == 3); 291 unit_assert(dname_lab_cmp( 292 (uint8_t*)"\004test\007example\003net", 4, 293 (uint8_t*)"\004test\007example\003net", 4, 294 &ml) == 0); 295 unit_assert(ml == 4); 296 297 /* root is smaller than anything else */ 298 unit_assert(dname_lab_cmp( 299 (uint8_t*)"", 1, 300 (uint8_t*)"\003net", 2, 301 &ml) == -1); 302 unit_assert(ml == 1); 303 unit_assert(dname_lab_cmp( 304 (uint8_t*)"\003net", 2, 305 (uint8_t*)"", 1, 306 &ml) == 1); 307 unit_assert(ml == 1); 308 unit_assert(dname_lab_cmp( 309 (uint8_t*)"", 1, 310 (uint8_t*)"\007example\003net", 3, 311 &ml) == -1); 312 unit_assert(ml == 1); 313 unit_assert(dname_lab_cmp( 314 (uint8_t*)"\007example\003net", 3, 315 (uint8_t*)"", 1, 316 &ml) == 1); 317 unit_assert(ml == 1); 318 319 /* label length makes a difference */ 320 unit_assert(dname_lab_cmp( 321 (uint8_t*)"\004neta", 2, 322 (uint8_t*)"\003net", 2, 323 &ml) != 0); 324 unit_assert(ml == 1); 325 unit_assert(dname_lab_cmp( 326 (uint8_t*)"\002ne", 2, 327 (uint8_t*)"\004neta", 2, 328 &ml) != 0); 329 unit_assert(ml == 1); 330 331 /* contents follow the zone apex */ 332 unit_assert(dname_lab_cmp( 333 (uint8_t*)"\003bla\007example\003net", 4, 334 (uint8_t*)"\007example\003net", 3, 335 &ml) == 1); 336 unit_assert(ml == 3); 337 unit_assert(dname_lab_cmp( 338 (uint8_t*)"\007example\003net", 3, 339 (uint8_t*)"\003bla\007example\003net", 4, 340 &ml) == -1); 341 unit_assert(ml == 3); 342 343 /* label content makes a difference */ 344 unit_assert(dname_lab_cmp( 345 (uint8_t*)"\003aag\007example\003net", 4, 346 (uint8_t*)"\003bla\007example\003net", 4, 347 &ml) == -1); 348 unit_assert(ml == 3); 349 unit_assert(dname_lab_cmp( 350 (uint8_t*)"\003aag\007example\003net", 4, 351 (uint8_t*)"\003bla\007example\003net", 4, 352 &ml) == -1); 353 unit_assert(ml == 3); 354 unit_assert(dname_lab_cmp( 355 (uint8_t*)"\003bla\003aag\007example\003net", 5, 356 (uint8_t*)"\003aag\003bla\007example\003net", 5, 357 &ml) == -1); 358 unit_assert(ml == 3); 359 unit_assert(dname_lab_cmp( 360 (uint8_t*)"\02sn\003opt\003aag\007example\003net", 6, 361 (uint8_t*)"\02sn\003opt\003bla\007example\003net", 6, 362 &ml) == -1); 363 unit_assert(ml == 3); 364 365 /* but lowercase/uppercase does not make a difference. */ 366 unit_assert(dname_lab_cmp( 367 (uint8_t*)"\003bLa\007examPLe\003net", 4, 368 (uint8_t*)"\003bla\007eXAmple\003nET", 4, 369 &ml) == 0); 370 unit_assert(ml == 4); 371 } 372 373 /** test dname_subdomain_c */ 374 static void 375 dname_test_subdomain(void) 376 { 377 unit_show_func("util/data/dname.c", "dname_subdomain"); 378 unit_assert(dname_subdomain_c( 379 (uint8_t*)"", 380 (uint8_t*)"")); 381 unit_assert(dname_subdomain_c( 382 (uint8_t*)"\003com", 383 (uint8_t*)"")); 384 unit_assert(!dname_subdomain_c( 385 (uint8_t*)"", 386 (uint8_t*)"\003com")); 387 unit_assert(dname_subdomain_c( 388 (uint8_t*)"\007example\003com", 389 (uint8_t*)"\003com")); 390 unit_assert(!dname_subdomain_c( 391 (uint8_t*)"\003com", 392 (uint8_t*)"\007example\003com")); 393 unit_assert(dname_subdomain_c( 394 (uint8_t*)"\007example\003com", 395 (uint8_t*)"")); 396 unit_assert(!dname_subdomain_c( 397 (uint8_t*)"\003net", 398 (uint8_t*)"\003com")); 399 unit_assert(!dname_subdomain_c( 400 (uint8_t*)"\003net", 401 (uint8_t*)"\003org")); 402 unit_assert(!dname_subdomain_c( 403 (uint8_t*)"\007example\003net", 404 (uint8_t*)"\003org")); 405 unit_assert(!dname_subdomain_c( 406 (uint8_t*)"\003net", 407 (uint8_t*)"\007example\003org")); 408 } 409 410 /** test dname_strict_subdomain */ 411 static void 412 dname_test_strict_subdomain(void) 413 { 414 unit_show_func("util/data/dname.c", "dname_strict_subdomain"); 415 unit_assert(!dname_strict_subdomain( 416 (uint8_t*)"", 1, 417 (uint8_t*)"", 1)); 418 unit_assert(dname_strict_subdomain( 419 (uint8_t*)"\003com", 2, 420 (uint8_t*)"", 1)); 421 unit_assert(!dname_strict_subdomain( 422 (uint8_t*)"", 1, 423 (uint8_t*)"\003com", 2)); 424 unit_assert(dname_strict_subdomain( 425 (uint8_t*)"\007example\003com", 3, 426 (uint8_t*)"\003com", 2)); 427 unit_assert(!dname_strict_subdomain( 428 (uint8_t*)"\003com", 2, 429 (uint8_t*)"\007example\003com", 3)); 430 unit_assert(dname_strict_subdomain( 431 (uint8_t*)"\007example\003com", 3, 432 (uint8_t*)"", 1)); 433 unit_assert(!dname_strict_subdomain( 434 (uint8_t*)"\003net", 2, 435 (uint8_t*)"\003com", 2)); 436 unit_assert(!dname_strict_subdomain( 437 (uint8_t*)"\003net", 2, 438 (uint8_t*)"\003org", 2)); 439 unit_assert(!dname_strict_subdomain( 440 (uint8_t*)"\007example\003net", 3, 441 (uint8_t*)"\003org", 2)); 442 unit_assert(!dname_strict_subdomain( 443 (uint8_t*)"\003net", 2, 444 (uint8_t*)"\007example\003org", 3)); 445 } 446 447 /** test dname_is_root */ 448 static void 449 dname_test_isroot(void) 450 { 451 unit_show_func("util/data/dname.c", "dname_isroot"); 452 unit_assert(dname_is_root((uint8_t*)"\000")); 453 unit_assert(!dname_is_root((uint8_t*)"\001a\000")); 454 unit_assert(!dname_is_root((uint8_t*)"\005abvcd\003com\000")); 455 /* malformed dname in this test, but should work */ 456 unit_assert(!dname_is_root((uint8_t*)"\077a\000")); 457 unit_assert(dname_is_root((uint8_t*)"\000")); 458 } 459 460 /** test dname_remove_label */ 461 static void 462 dname_test_removelabel(void) 463 { 464 uint8_t* orig = (uint8_t*)"\007example\003com\000"; 465 uint8_t* n = orig; 466 size_t l = 13; 467 unit_show_func("util/data/dname.c", "dname_remove_label"); 468 dname_remove_label(&n, &l); 469 unit_assert( n == orig+8 ); 470 unit_assert( l == 5 ); 471 dname_remove_label(&n, &l); 472 unit_assert( n == orig+12 ); 473 unit_assert( l == 1 ); 474 dname_remove_label(&n, &l); 475 unit_assert( n == orig+12 ); 476 unit_assert( l == 1 ); 477 } 478 479 /** test dname_signame_label_count */ 480 static void 481 dname_test_sigcount(void) 482 { 483 unit_show_func("util/data/dname.c", "dname_signame_label_count"); 484 unit_assert(dname_signame_label_count((uint8_t*)"\000") == 0); 485 unit_assert(dname_signame_label_count((uint8_t*)"\001*\000") == 0); 486 unit_assert(dname_signame_label_count((uint8_t*)"\003xom\000") == 1); 487 unit_assert(dname_signame_label_count( 488 (uint8_t*)"\001*\003xom\000") == 1); 489 unit_assert(dname_signame_label_count( 490 (uint8_t*)"\007example\003xom\000") == 2); 491 unit_assert(dname_signame_label_count( 492 (uint8_t*)"\001*\007example\003xom\000") == 2); 493 unit_assert(dname_signame_label_count( 494 (uint8_t*)"\003www\007example\003xom\000") == 3); 495 unit_assert(dname_signame_label_count( 496 (uint8_t*)"\001*\003www\007example\003xom\000") == 3); 497 } 498 499 /** test dname_is_wild routine */ 500 static void 501 dname_test_iswild(void) 502 { 503 unit_show_func("util/data/dname.c", "dname_iswild"); 504 unit_assert( !dname_is_wild((uint8_t*)"\000") ); 505 unit_assert( dname_is_wild((uint8_t*)"\001*\000") ); 506 unit_assert( !dname_is_wild((uint8_t*)"\003net\000") ); 507 unit_assert( dname_is_wild((uint8_t*)"\001*\003net\000") ); 508 } 509 510 /** test dname_canonical_compare */ 511 static void 512 dname_test_canoncmp(void) 513 { 514 unit_show_func("util/data/dname.c", "dname_canonical_compare"); 515 /* equality */ 516 unit_assert( dname_canonical_compare( 517 (uint8_t*)"\000", 518 (uint8_t*)"\000" 519 ) == 0); 520 unit_assert( dname_canonical_compare( 521 (uint8_t*)"\003net\000", 522 (uint8_t*)"\003net\000" 523 ) == 0); 524 unit_assert( dname_canonical_compare( 525 (uint8_t*)"\007example\003net\000", 526 (uint8_t*)"\007example\003net\000" 527 ) == 0); 528 unit_assert( dname_canonical_compare( 529 (uint8_t*)"\004test\007example\003net\000", 530 (uint8_t*)"\004test\007example\003net\000" 531 ) == 0); 532 533 /* subdomains */ 534 unit_assert( dname_canonical_compare( 535 (uint8_t*)"\003com", 536 (uint8_t*)"\000" 537 ) == 1); 538 unit_assert( dname_canonical_compare( 539 (uint8_t*)"\000", 540 (uint8_t*)"\003com" 541 ) == -1); 542 unit_assert( dname_canonical_compare( 543 (uint8_t*)"\007example\003com", 544 (uint8_t*)"\003com" 545 ) == 1); 546 unit_assert( dname_canonical_compare( 547 (uint8_t*)"\003com", 548 (uint8_t*)"\007example\003com" 549 ) == -1); 550 unit_assert( dname_canonical_compare( 551 (uint8_t*)"\007example\003com", 552 (uint8_t*)"\000" 553 ) == 1); 554 unit_assert( dname_canonical_compare( 555 (uint8_t*)"\000", 556 (uint8_t*)"\007example\003com" 557 ) == -1); 558 559 /* compare rightmost label */ 560 unit_assert( dname_canonical_compare( 561 (uint8_t*)"\003com", 562 (uint8_t*)"\003net" 563 ) == -1); 564 unit_assert( dname_canonical_compare( 565 (uint8_t*)"\003net", 566 (uint8_t*)"\003com" 567 ) == 1); 568 unit_assert( dname_canonical_compare( 569 (uint8_t*)"\003net", 570 (uint8_t*)"\003org" 571 ) == -1); 572 unit_assert( dname_canonical_compare( 573 (uint8_t*)"\007example\003net", 574 (uint8_t*)"\003org" 575 ) == -1); 576 unit_assert( dname_canonical_compare( 577 (uint8_t*)"\003org", 578 (uint8_t*)"\007example\003net" 579 ) == 1); 580 581 /* label length makes a difference; but only if rest is equal */ 582 unit_assert( dname_canonical_compare( 583 (uint8_t*)"\004neta", 584 (uint8_t*)"\003net" 585 ) == 1); 586 unit_assert( dname_canonical_compare( 587 (uint8_t*)"\002ne", 588 (uint8_t*)"\004neta" 589 ) == -1); 590 591 /* label content */ 592 unit_assert( dname_canonical_compare( 593 (uint8_t*)"\003aag\007example\003net", 594 (uint8_t*)"\003bla\007example\003net" 595 ) == -1); 596 unit_assert( dname_canonical_compare( 597 (uint8_t*)"\003bla\007example\003net", 598 (uint8_t*)"\003aag\007example\003net" 599 ) == 1); 600 unit_assert( dname_canonical_compare( 601 (uint8_t*)"\003bla\003aag\007example\003net", 602 (uint8_t*)"\003aag\003bla\007example\003net" 603 ) == -1); 604 unit_assert( dname_canonical_compare( 605 (uint8_t*)"\02sn\003opt\003aag\007example\003net", 606 (uint8_t*)"\02sn\003opt\003bla\007example\003net" 607 ) == -1); 608 609 /* lowercase during compare */ 610 unit_assert( dname_canonical_compare( 611 (uint8_t*)"\003bLa\007examPLe\003net", 612 (uint8_t*)"\003bla\007eXAmple\003nET" 613 ) == 0); 614 615 /* example from 4034 */ 616 /* example a.example yljkjljk.a.example Z.a.example zABC.a.EXAMPLE 617 z.example \001.z.example *.z.example \200.z.example */ 618 unit_assert( dname_canonical_compare( 619 (uint8_t*)"", 620 (uint8_t*)"\007example" 621 ) == -1); 622 unit_assert( dname_canonical_compare( 623 (uint8_t*)"\007example", 624 (uint8_t*)"\001a\007example" 625 ) == -1); 626 unit_assert( dname_canonical_compare( 627 (uint8_t*)"\001a\007example", 628 (uint8_t*)"\010yljkjljk\001a\007example" 629 ) == -1); 630 unit_assert( dname_canonical_compare( 631 (uint8_t*)"\010yljkjljk\001a\007example", 632 (uint8_t*)"\001Z\001a\007example" 633 ) == -1); 634 unit_assert( dname_canonical_compare( 635 (uint8_t*)"\001Z\001a\007example", 636 (uint8_t*)"\004zABC\001a\007EXAMPLE" 637 ) == -1); 638 unit_assert( dname_canonical_compare( 639 (uint8_t*)"\004zABC\001a\007EXAMPLE", 640 (uint8_t*)"\001z\007example" 641 ) == -1); 642 unit_assert( dname_canonical_compare( 643 (uint8_t*)"\001z\007example", 644 (uint8_t*)"\001\001\001z\007example" 645 ) == -1); 646 unit_assert( dname_canonical_compare( 647 (uint8_t*)"\001\001\001z\007example", 648 (uint8_t*)"\001*\001z\007example" 649 ) == -1); 650 unit_assert( dname_canonical_compare( 651 (uint8_t*)"\001*\001z\007example", 652 (uint8_t*)"\001\200\001z\007example" 653 ) == -1); 654 /* same example in reverse */ 655 unit_assert( dname_canonical_compare( 656 (uint8_t*)"\007example", 657 (uint8_t*)"" 658 ) == 1); 659 unit_assert( dname_canonical_compare( 660 (uint8_t*)"\001a\007example", 661 (uint8_t*)"\007example" 662 ) == 1); 663 unit_assert( dname_canonical_compare( 664 (uint8_t*)"\010yljkjljk\001a\007example", 665 (uint8_t*)"\001a\007example" 666 ) == 1); 667 unit_assert( dname_canonical_compare( 668 (uint8_t*)"\001Z\001a\007example", 669 (uint8_t*)"\010yljkjljk\001a\007example" 670 ) == 1); 671 unit_assert( dname_canonical_compare( 672 (uint8_t*)"\004zABC\001a\007EXAMPLE", 673 (uint8_t*)"\001Z\001a\007example" 674 ) == 1); 675 unit_assert( dname_canonical_compare( 676 (uint8_t*)"\001z\007example", 677 (uint8_t*)"\004zABC\001a\007EXAMPLE" 678 ) == 1); 679 unit_assert( dname_canonical_compare( 680 (uint8_t*)"\001\001\001z\007example", 681 (uint8_t*)"\001z\007example" 682 ) == 1); 683 unit_assert( dname_canonical_compare( 684 (uint8_t*)"\001*\001z\007example", 685 (uint8_t*)"\001\001\001z\007example" 686 ) == 1); 687 unit_assert( dname_canonical_compare( 688 (uint8_t*)"\001\200\001z\007example", 689 (uint8_t*)"\001*\001z\007example" 690 ) == 1); 691 /* same example for equality */ 692 unit_assert( dname_canonical_compare( 693 (uint8_t*)"\007example", 694 (uint8_t*)"\007example" 695 ) == 0); 696 unit_assert( dname_canonical_compare( 697 (uint8_t*)"\001a\007example", 698 (uint8_t*)"\001a\007example" 699 ) == 0); 700 unit_assert( dname_canonical_compare( 701 (uint8_t*)"\010yljkjljk\001a\007example", 702 (uint8_t*)"\010yljkjljk\001a\007example" 703 ) == 0); 704 unit_assert( dname_canonical_compare( 705 (uint8_t*)"\001Z\001a\007example", 706 (uint8_t*)"\001Z\001a\007example" 707 ) == 0); 708 unit_assert( dname_canonical_compare( 709 (uint8_t*)"\004zABC\001a\007EXAMPLE", 710 (uint8_t*)"\004zABC\001a\007EXAMPLE" 711 ) == 0); 712 unit_assert( dname_canonical_compare( 713 (uint8_t*)"\001z\007example", 714 (uint8_t*)"\001z\007example" 715 ) == 0); 716 unit_assert( dname_canonical_compare( 717 (uint8_t*)"\001\001\001z\007example", 718 (uint8_t*)"\001\001\001z\007example" 719 ) == 0); 720 unit_assert( dname_canonical_compare( 721 (uint8_t*)"\001*\001z\007example", 722 (uint8_t*)"\001*\001z\007example" 723 ) == 0); 724 unit_assert( dname_canonical_compare( 725 (uint8_t*)"\001\200\001z\007example", 726 (uint8_t*)"\001\200\001z\007example" 727 ) == 0); 728 } 729 730 /** Test dname_get_shared_topdomain */ 731 static void 732 dname_test_topdomain(void) 733 { 734 unit_show_func("util/data/dname.c", "dname_get_shared_topdomain"); 735 unit_assert( query_dname_compare( 736 dname_get_shared_topdomain( 737 (uint8_t*)"", 738 (uint8_t*)""), 739 (uint8_t*)"") == 0); 740 unit_assert( query_dname_compare( 741 dname_get_shared_topdomain( 742 (uint8_t*)"\003www\007example\003com", 743 (uint8_t*)"\003www\007example\003com"), 744 (uint8_t*)"\003www\007example\003com") == 0); 745 unit_assert( query_dname_compare( 746 dname_get_shared_topdomain( 747 (uint8_t*)"\003www\007example\003com", 748 (uint8_t*)"\003bla\007example\003com"), 749 (uint8_t*)"\007example\003com") == 0); 750 } 751 752 /** Test dname_valid */ 753 static void 754 dname_test_valid(void) 755 { 756 unit_show_func("util/data/dname.c", "dname_valid"); 757 unit_assert( dname_valid( 758 (uint8_t*)"\003www\007example\003com", 255) == 17); 759 unit_assert( dname_valid((uint8_t*)"", 255) == 1); 760 unit_assert( dname_valid( (uint8_t*) 761 "\020a1cdef5555544444" 762 "\020a2cdef5555544444" 763 "\020a3cdef5555544444" 764 "\020a4cdef5555544444" 765 "\020a5cdef5555544444" 766 "\020a6cdef5555544444" 767 "\020a7cdef5555544444" 768 "\020a8cdef5555544444" 769 "\020a9cdef5555544444" 770 "\020aAcdef5555544444" 771 "\020aBcdef5555544444" 772 "\020aCcdef5555544444" 773 "\020aDcdef5555544444" 774 "\020aEcdef5555544444" /* 238 up to here */ 775 "\007aabbccd" /* 246 up to here */ 776 "\007example\000" /* 255 to here */ 777 , 255) == 255); 778 unit_assert( dname_valid( (uint8_t*) 779 "\020a1cdef5555544444" 780 "\020a2cdef5555544444" 781 "\020a3cdef5555544444" 782 "\020a4cdef5555544444" 783 "\020a5cdef5555544444" 784 "\020a6cdef5555544444" 785 "\020a7cdef5555544444" 786 "\020a8cdef5555544444" 787 "\020a9cdef5555544444" 788 "\020aAcdef5555544444" 789 "\020aBcdef5555544444" 790 "\020aCcdef5555544444" 791 "\020aDcdef5555544444" 792 "\020aEcdef5555544444" /* 238 up to here */ 793 "\007aabbccd" /* 246 up to here */ 794 "\010exampleX\000" /* 256 to here */ 795 , 4096) == 0); 796 } 797 798 /** Test dname_has_label */ 799 static void 800 dname_test_has_label(void) 801 { 802 unit_show_func("util/data/dname.c", "dname_has_label"); 803 /* label past root label */ 804 unit_assert(dname_has_label((uint8_t*)"\01a\0\01c", 5, (uint8_t*)"\01c") == 0); 805 /* label not found */ 806 unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 6, (uint8_t*)"\01e") == 0); 807 /* buffer too short */ 808 unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 5, (uint8_t*)"\0") == 0); 809 unit_assert(dname_has_label((uint8_t*)"\1a\0", 2, (uint8_t*)"\0") == 0); 810 unit_assert(dname_has_label((uint8_t*)"\0", 0, (uint8_t*)"\0") == 0); 811 unit_assert(dname_has_label((uint8_t*)"\02ab\01c", 4, (uint8_t*)"\01c") == 0); 812 unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 19, (uint8_t*)"\01c") == 0); 813 814 /* positive cases */ 815 unit_assert(dname_has_label((uint8_t*)"\0", 1, (uint8_t*)"\0") == 1); 816 unit_assert(dname_has_label((uint8_t*)"\1a\0", 3, (uint8_t*)"\0") == 1); 817 unit_assert(dname_has_label((uint8_t*)"\01a\0\01c", 5, (uint8_t*)"\0") == 1); 818 unit_assert(dname_has_label((uint8_t*)"\02ab\01c", 5, (uint8_t*)"\01c") == 1); 819 unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 10, (uint8_t*)"\0") == 1); 820 unit_assert(dname_has_label((uint8_t*)"\02ab\01c\0", 7, (uint8_t*)"\0") == 1); 821 unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 22, (uint8_t*)"\03def") == 1); 822 unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 22, (uint8_t*)"\02ab") == 1); 823 unit_assert(dname_has_label((uint8_t*)"\02ab\03qwe\06oqieur\03def\01c\0", 22, (uint8_t*)"\01c") == 1); 824 } 825 826 /** test pkt_dname_tolower */ 827 static void 828 dname_test_pdtl(sldns_buffer* loopbuf, sldns_buffer* boundbuf) 829 { 830 unit_show_func("util/data/dname.c", "pkt_dname_tolower"); 831 pkt_dname_tolower(loopbuf, sldns_buffer_at(loopbuf, 12)); 832 pkt_dname_tolower(boundbuf, sldns_buffer_at(boundbuf, 12)); 833 } 834 835 /** setup looped dname and out-of-bounds dname ptr */ 836 static void 837 dname_setup_bufs(sldns_buffer* loopbuf, sldns_buffer* boundbuf) 838 { 839 sldns_buffer_write_u16(loopbuf, 0xd54d); /* id */ 840 sldns_buffer_write_u16(loopbuf, 0x12); /* flags */ 841 sldns_buffer_write_u16(loopbuf, 1); /* qdcount */ 842 sldns_buffer_write_u16(loopbuf, 0); /* ancount */ 843 sldns_buffer_write_u16(loopbuf, 0); /* nscount */ 844 sldns_buffer_write_u16(loopbuf, 0); /* arcount */ 845 sldns_buffer_write_u8(loopbuf, 0xc0); /* PTR back at itself */ 846 sldns_buffer_write_u8(loopbuf, 0x0c); 847 sldns_buffer_flip(loopbuf); 848 849 sldns_buffer_write_u16(boundbuf, 0xd54d); /* id */ 850 sldns_buffer_write_u16(boundbuf, 0x12); /* flags */ 851 sldns_buffer_write_u16(boundbuf, 1); /* qdcount */ 852 sldns_buffer_write_u16(boundbuf, 0); /* ancount */ 853 sldns_buffer_write_u16(boundbuf, 0); /* nscount */ 854 sldns_buffer_write_u16(boundbuf, 0); /* arcount */ 855 sldns_buffer_write_u8(boundbuf, 0x01); /* len=1 */ 856 sldns_buffer_write_u8(boundbuf, (uint8_t)'A'); /* A. label */ 857 sldns_buffer_write_u8(boundbuf, 0xc0); /* PTR out of bounds */ 858 sldns_buffer_write_u8(boundbuf, 0xcc); 859 sldns_buffer_flip(boundbuf); 860 } 861 862 static void 863 dname_test_str(sldns_buffer* buff) 864 { 865 char result[LDNS_MAX_DOMAINLEN], expect[LDNS_MAX_DOMAINLEN], *e; 866 size_t i; 867 unit_show_func("util/data/dname.c", "dname_str"); 868 869 /* root ; expected OK */ 870 sldns_buffer_clear(buff); 871 sldns_buffer_write(buff, "\000", 1); 872 sldns_buffer_flip(buff); 873 unit_assert( sldns_buffer_limit(buff) == 1 ); 874 unit_assert( pkt_dname_len(buff) == 1 ); 875 dname_str(sldns_buffer_begin(buff), result); 876 unit_assert( strcmp( ".", result) == 0 ); 877 878 /* LDNS_MAX_DOMAINLEN - 1 ; expected OK */ 879 sldns_buffer_clear(buff); 880 sldns_buffer_write(buff, 881 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 64 up to here */ 882 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 128 up to here */ 883 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 192 up to here */ 884 "\074abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567" /* 253 up to here */ 885 "\000" /* 254 up to here */ 886 , 254); 887 sldns_buffer_flip(buff); 888 unit_assert( sldns_buffer_limit(buff) == 254 ); 889 unit_assert( pkt_dname_len(buff) == 254 ); 890 dname_str(sldns_buffer_begin(buff), result); 891 unit_assert( strcmp( 892 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 893 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 894 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 895 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567" 896 ".", result) == 0 ); 897 898 /* LDNS_MAX_DOMAINLEN ; expected OK */ 899 sldns_buffer_clear(buff); 900 sldns_buffer_write(buff, 901 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 64 up to here */ 902 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 128 up to here */ 903 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 192 up to here */ 904 "\075abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678" /* 254 up to here */ 905 "\000" /* 255 up to here */ 906 , 255); 907 sldns_buffer_flip(buff); 908 unit_assert( sldns_buffer_limit(buff) == 255 ); 909 unit_assert( pkt_dname_len(buff) == 255 ); 910 dname_str(sldns_buffer_begin(buff), result); 911 unit_assert( strcmp( 912 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 913 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 914 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 915 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678" 916 ".", result) == 0 ); 917 918 /* LDNS_MAX_DOMAINLEN + 1 ; expected to fail, output uses '&' on the latest label */ 919 sldns_buffer_clear(buff); 920 sldns_buffer_write(buff, 921 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 64 up to here */ 922 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 128 up to here */ 923 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 192 up to here */ 924 "\076abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" /* 255 up to here */ 925 "\000" /* 256 up to here */ 926 , 256); 927 sldns_buffer_flip(buff); 928 unit_assert( sldns_buffer_limit(buff) == 256 ); 929 unit_assert( pkt_dname_len(buff) == 0 ); 930 dname_str(sldns_buffer_begin(buff), result); 931 unit_assert( strcmp( 932 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 933 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 934 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 935 "&", result) == 0 ); 936 937 /* LDNS_MAX_LABELLEN + 1 ; expected to fail, output uses '#' on the offending label */ 938 sldns_buffer_clear(buff); 939 sldns_buffer_write(buff, 940 "\077abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" /* 64 up to here */ 941 "\100abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890a" /* 129 up to here */ 942 "\000" /* 130 up to here */ 943 , 130); 944 sldns_buffer_flip(buff); 945 unit_assert( sldns_buffer_limit(buff) == 130 ); 946 unit_assert( pkt_dname_len(buff) == 0 ); 947 dname_str(sldns_buffer_begin(buff), result); 948 unit_assert( strcmp( 949 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890." 950 "#", result) == 0 ); 951 952 /* LDNS_MAX_DOMAINLEN with single labels; expected OK */ 953 sldns_buffer_clear(buff); 954 for(i=0; i<=252; i+=2) 955 sldns_buffer_write(buff, "\001a", 2); 956 sldns_buffer_write_u8(buff, 0); 957 sldns_buffer_flip(buff); 958 unit_assert( sldns_buffer_limit(buff) == 255 ); 959 unit_assert( pkt_dname_len(buff) == 255 ); 960 dname_str(sldns_buffer_begin(buff), result); 961 e = expect; 962 for(i=0; i<=252; i+=2) { 963 *e++ = 'a'; 964 *e++ = '.'; 965 } 966 *e = '\0'; 967 unit_assert( strcmp(expect, result) == 0 ); 968 969 /* LDNS_MAX_DOMAINLEN + 1 with single labels; expected to fail, output uses '&' on the latest label */ 970 sldns_buffer_clear(buff); 971 for(i=0; i<=250; i+=2) 972 sldns_buffer_write(buff, "\001a", 2); 973 sldns_buffer_write(buff, "\002ab", 3); 974 sldns_buffer_write_u8(buff, 0); 975 sldns_buffer_flip(buff); 976 unit_assert( sldns_buffer_limit(buff) == 256 ); 977 unit_assert( pkt_dname_len(buff) == 0 ); 978 dname_str(sldns_buffer_begin(buff), result); 979 e = expect; 980 for(i=0; i<=250; i+=2) { 981 *e++ = 'a'; 982 *e++ = '.'; 983 } 984 *e++ = '&'; 985 *e = '\0'; 986 unit_assert( strcmp(expect, result) == 0 ); 987 988 /* Only alphas, numericals and '-', '_' and '*' are allowed in the output */ 989 for(i=1; i<=255; i++) { 990 if(isalnum(i) || i == '-' || i == '_' || i == '*') 991 continue; 992 sldns_buffer_clear(buff); 993 sldns_buffer_write_u8(buff, 1); 994 sldns_buffer_write_u8(buff, (uint8_t)i); 995 sldns_buffer_write_u8(buff, 0); 996 sldns_buffer_flip(buff); 997 unit_assert( sldns_buffer_limit(buff) == 3 ); 998 unit_assert( pkt_dname_len(buff) == 3); 999 dname_str(sldns_buffer_begin(buff), result); 1000 if(strcmp( "?.", result) != 0 ) { 1001 log_err("ASCII value '0x%lX' allowed in string output", (unsigned long)i); 1002 unit_assert(0); 1003 } 1004 } 1005 } 1006 1007 void dname_test(void) 1008 { 1009 sldns_buffer* loopbuf = sldns_buffer_new(14); 1010 sldns_buffer* boundbuf = sldns_buffer_new(16); 1011 sldns_buffer* buff = sldns_buffer_new(65800); 1012 unit_assert(loopbuf && boundbuf && buff); 1013 sldns_buffer_flip(buff); 1014 dname_setup_bufs(loopbuf, boundbuf); 1015 dname_test_qdl(buff); 1016 dname_test_qdtl(buff); 1017 dname_test_pdtl(loopbuf, boundbuf); 1018 dname_test_query_dname_compare(); 1019 dname_test_count_labels(); 1020 dname_test_count_size_labels(); 1021 dname_test_dname_lab_cmp(); 1022 dname_test_pkt_dname_len(buff); 1023 dname_test_strict_subdomain(); 1024 dname_test_subdomain(); 1025 dname_test_isroot(); 1026 dname_test_removelabel(); 1027 dname_test_sigcount(); 1028 dname_test_iswild(); 1029 dname_test_canoncmp(); 1030 dname_test_topdomain(); 1031 dname_test_valid(); 1032 dname_test_has_label(); 1033 dname_test_str(buff); 1034 sldns_buffer_free(buff); 1035 sldns_buffer_free(loopbuf); 1036 sldns_buffer_free(boundbuf); 1037 } 1038