Fix mandatory parsing and ech printing

This commit is contained in:
Willem Toorop 2021-05-25 15:56:19 +02:00
parent 71904eb0d4
commit 956d7d4e44
2 changed files with 6 additions and 6 deletions

View File

@ -1168,8 +1168,8 @@ sldns_str2wire_svcbparam_mandatory(const char* val, uint8_t* rd, size_t* rd_len)
return -1;
}
}
// @TODO check if we have space to write in rd_len; look for the best spot
if (sizeof(uint16_t) * (count + 2) > *rd_len)
return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
sldns_write_uint16(rd, SVCB_KEY_MANDATORY);
sldns_write_uint16(rd + 2, sizeof(uint16_t) * count);
@ -1179,12 +1179,12 @@ sldns_str2wire_svcbparam_mandatory(const char* val, uint8_t* rd, size_t* rd_len)
if (!(next_key = strchr(val, ','))) {
sldns_write_uint16(rd + *rd_len,
sldns_str2wire_svcparam_key_lookup(val, val_len));
*rd_len += LDNS_IP6ADDRLEN;
*rd_len += 2;
break;
} else {
sldns_write_uint16(rd + *rd_len,
sldns_str2wire_svcparam_key_lookup(val, next_key - val));
*rd_len += LDNS_IP6ADDRLEN;
*rd_len += 2;
}
val_len -= next_key - val + 1;

View File

@ -1091,14 +1091,14 @@ static int sldns_wire2str_svcparam_ech2str(char** s,
size_t* slen, uint16_t data_len, uint8_t* data)
{
int size;
int w;
int w = 0;
assert(data_len > 0); /* Guaranteed by rdata_svcparam_to_string */
w += sldns_str_print(s, slen, "=\"");
/* b64_ntop_calculate size includes null at the end */
size = sldns_b64_ntop_calculate_size(data_len);
size = sldns_b64_ntop_calculate_size(data_len) - 1;
// @TODO store return value?
sldns_b64_ntop(data, data_len, *s, *slen);