Skip to content
Snippets Groups Projects
Commit 678f42d2 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Fixes in zoneparser - txt adding was rewriting other records. Fixed checking...

Fixes in zoneparser - txt adding was rewriting other records. Fixed checking of return value from base32 functions.
parent 9c684ee2
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,6 @@
#include <netdb.h>
#include <assert.h>
#include "common/base32.h"
#include "common/base32hex.h"
#include "zcompile/zcompile.h"
#include "zcompile/parser-util.h"
......@@ -808,7 +807,7 @@ uint16_t * zparser_conv_b32(const char *b32)
if (strcmp(b32, "-") == 0) {
return alloc_rdata_init("", 1);
}
if ((base32hex_decode(b32, strlen(b32), (char *)buffer + 1, &i)) == 0) {
if (!(base32hex_decode(b32, strlen(b32), (char *)buffer + 1, &i))) {
zc_error_prev_line("invalid base32 data\n");
} else {
buffer[0] = i; /* store length byte */
......@@ -1343,6 +1342,8 @@ void zadd_rdata_wireformat(uint16_t *data)
*/
void zadd_rdata_txt_wireformat(uint16_t *data, int first)
{
debug_zp("Adding text!\n");
// hex_print(data + 1, data[0]);
knot_rdata_item_t *rd;
/* First STR in str_seq, allocate 65K in first unused rdata
......@@ -1355,9 +1356,14 @@ void zadd_rdata_txt_wireformat(uint16_t *data, int first)
// return;
// }
/*!< \todo Disabled until multiple TXT's are supported. */
// parser->rdata_count++;
rd->raw_data = alloc_rdata(65535 * sizeof(uint8_t));
if (rd->raw_data == NULL) {
parser->error_occurred = 1;
}
parser->rdata_count++;
rd->raw_data[0] = 0;
} else {
assert(0);
rd = &parser->temporary_items[parser->rdata_count-1];
}
......@@ -1369,6 +1375,8 @@ void zadd_rdata_txt_wireformat(uint16_t *data, int first)
memcpy((uint8_t *)rd->raw_data + 2 + rd->raw_data[0],
data + 1, data[0]);
rd->raw_data[0] += data[0];
debug_zp("Item after add\n");
// hex_print(rd->raw_data + 1, rd->raw_data[0]);
}
void zadd_rdata_domain(knot_dname_t *dname)
......@@ -1892,9 +1900,6 @@ int zone_read(const char *name, const char *zonefile, const char *outfile,
debug_zp("zone parsed\n");
find_rrsets_orphans(parser->current_zone->contents,
parser->rrsig_orphans);
if (!(parser->current_zone &&
knot_node_rrset(parser->current_zone->contents->apex,
KNOT_RRTYPE_SOA))) {
......
......@@ -82,12 +82,16 @@ int main(int argc, char **argv)
int error = zone_read(origin, zonefile, outfile, semantic_checks);
if (error) {
fprintf(stderr, "Finished with error: %s.\n",
error_to_str(knot_zcompile_error_msgs, error));
if (error < 0) {
fprintf(stderr, "Finished with error: %s.\n",
error_to_str(knot_zcompile_error_msgs, error));
} else {
fprintf(stderr, "Finished with %u errors.\n");
}
} else {
printf("Compilation successful.\n");
}
//log_close();
return error ? 1 : 0;
return error;
}
......@@ -475,7 +475,7 @@ str_seq: STR
| str_seq sp STR
{
// zadd_rdata_txt_wireformat(zparser_conv_text($3.str, $3.len), 0);
zc_warning("multiple TXT entries are currently not supported!");
// zc_warning("multiple TXT entries are currently not supported!");
free($3.str);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment