diff options
Diffstat (limited to 'src/zcompile/zparser.y')
-rw-r--r-- | src/zcompile/zparser.y | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/zcompile/zparser.y b/src/zcompile/zparser.y index 6f081e5..c43b968 100644 --- a/src/zcompile/zparser.y +++ b/src/zcompile/zparser.y @@ -270,7 +270,6 @@ line: NL // printf("Current rrset name: %p (%s)\n", parser->current_rrset->owner->name, // knot_dname_to_str(parser->current_rrset->owner)); -// getchar(); // knot_dname_release(parser->current_rrset->owner); @@ -329,7 +328,7 @@ rr: owner classttl type_and_rdata // printf("new owner assigned: %p\n", $1); parser->current_rrset->type = $3; } - ; + ; owner: dname sp { @@ -341,7 +340,7 @@ owner: dname sp // knot_dname_release(parser->prev_dname); } parser->prev_dname = $1;//knot_dname_deep_copy($1); -// knot_dname_retain(parser->prev_dname); + knot_dname_retain(parser->prev_dname); $$ = $1; } | PREV @@ -394,7 +393,6 @@ dname: abs_dname $$ = knot_dname_cat($1, parser->origin->owner); // printf("leak: %s\n", knot_dname_to_str($$)); -// getchar(); } } ; @@ -1335,6 +1333,7 @@ rdata_rrsig: STR sp STR sp STR sp STR sp STR sp STR $15.len));*/ knot_dname_t *dname = knot_dname_new_from_wire((uint8_t *)$15.str, $15.len, NULL); + knot_dname_retain(dname); if (dname == NULL) { parser->error_occurred = KNOTDZCOMPILE_ENOMEM; } else { @@ -1365,7 +1364,7 @@ rdata_nsec: wire_dname nsec_seq knot_dname_t *dname = knot_dname_new_from_wire((uint8_t *)$1.str, $1.len, NULL); - + knot_dname_retain(dname); free($1.str); knot_dname_cat(dname, parser->root_domain); @@ -1458,8 +1457,8 @@ rdata_ipsec_base: STR sp STR sp STR sp dotted_str if(strlen($7.str) == 0) zc_error_prev_line("IPSECKEY must specify" "gateway name"); - name = knot_dname_new_from_wire((uint8_t*)$7.str + 1, - strlen($7.str + 1), + name = knot_dname_new_from_str($7.str, + strlen($7.str), NULL); if(!name) { zc_error_prev_line("IPSECKEY bad gateway" @@ -1470,21 +1469,15 @@ rdata_ipsec_base: STR sp STR sp STR sp dotted_str 1); YYABORT; } - if($7.str[strlen($7.str)-1] != '.') { - knot_dname_t* tmpd = - knot_dname_new_from_wire(name->name, - name->size, - NULL); - if (tmpd == NULL) { - zc_error_prev_line("Could not create dname!"); - knot_rrset_deep_free(&(parser->current_rrset), - 0, 0, 0); - knot_zone_deep_free(&(parser->current_zone), - 1); + + if(!knot_dname_is_fqdn(name)) { + assert(parser->origin); + name = knot_dname_cat(name, + parser->origin->owner); + if (name == NULL) { + zc_error_prev_line("Cannot concatenete dnames, probably run out of memory!\n"); YYABORT; } - name = knot_dname_cat(tmpd, - knot_node_parent(parser->origin, 0)->owner); } free($1.str); @@ -1492,7 +1485,8 @@ rdata_ipsec_base: STR sp STR sp STR sp dotted_str free($5.str); free($7.str); - uint8_t* dncpy = malloc(sizeof(uint8_t) * name->size); + uint16_t* dncpy = malloc(sizeof(uint8_t) * name->size + 2); + dncpy[0] = name->size; if (dncpy == NULL) { ERR_ALLOC_FAILED; knot_rrset_deep_free(&(parser->current_rrset), @@ -1501,9 +1495,10 @@ rdata_ipsec_base: STR sp STR sp STR sp dotted_str 1); YYABORT; } - memcpy(dncpy, name->name, name->size); - zadd_rdata_wireformat((uint16_t *)dncpy); - //knot_dname_free(&name); + + memcpy((uint8_t *)(dncpy + 1), name->name, name->size); + zadd_rdata_wireformat(dncpy); + knot_dname_free(&name); break; default: zc_error_prev_line("unknown IPSECKEY gateway type"); @@ -1581,6 +1576,7 @@ zparser_type *zparser_create() return NULL; } + knot_dname_retain(result->root_domain); return result; } |