Skip to content

Commit c77a0e1

Browse files
net: dns: dns_sd: fix incorrect use of buffer size
The functions that add DNS records (PTR, SRV, TXT, AAAA, A) all use a buf_size argument which represents the size of the whole buffer, not the remaining size. The higher function that calls these did not provide the correct argument: it passed the remaining size in the buffer. Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
1 parent 3638fc5 commit c77a0e1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

subsys/net/lib/dns/dns_sd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ int dns_sd_handle_ptr_query(struct net_if *iface, const struct dns_sd_rec *inst,
885885
}
886886

887887
/* first add the answer record */
888-
r = add_ptr_record(inst, DNS_SD_PTR_TTL, buf, offset, buf_size - offset, &service_offset,
888+
r = add_ptr_record(inst, DNS_SD_PTR_TTL, buf, offset, buf_size, &service_offset,
889889
&instance_offset, &domain_offset);
890890
if (r < 0) {
891891
return r; /* LCOV_EXCL_LINE */
@@ -895,7 +895,7 @@ int dns_sd_handle_ptr_query(struct net_if *iface, const struct dns_sd_rec *inst,
895895
offset += r;
896896

897897
/* then add the additional records */
898-
r = add_txt_record(inst, DNS_SD_TXT_TTL, instance_offset, buf, offset, buf_size - offset);
898+
r = add_txt_record(inst, DNS_SD_TXT_TTL, instance_offset, buf, offset, buf_size);
899899
if (r < 0) {
900900
return r; /* LCOV_EXCL_LINE */
901901
}
@@ -904,7 +904,7 @@ int dns_sd_handle_ptr_query(struct net_if *iface, const struct dns_sd_rec *inst,
904904
offset += r;
905905

906906
r = add_srv_record(inst, DNS_SD_SRV_TTL, instance_offset, domain_offset, buf, offset,
907-
buf_size - offset, &host_offset);
907+
buf_size, &host_offset);
908908
if (r < 0) {
909909
return r; /* LCOV_EXCL_LINE */
910910
}
@@ -914,7 +914,7 @@ int dns_sd_handle_ptr_query(struct net_if *iface, const struct dns_sd_rec *inst,
914914

915915
if (addr6 != NULL && !net_ipv6_is_addr_unspecified(addr6)) {
916916
r = add_aaaa_record(inst, DNS_SD_AAAA_TTL, host_offset, addr6->s6_addr, buf, offset,
917-
buf_size - offset); /* LCOV_EXCL_LINE */
917+
buf_size); /* LCOV_EXCL_LINE */
918918
if (r < 0) {
919919
return r; /* LCOV_EXCL_LINE */
920920
}
@@ -926,7 +926,7 @@ int dns_sd_handle_ptr_query(struct net_if *iface, const struct dns_sd_rec *inst,
926926
if (addr4 != NULL && !net_ipv4_is_addr_unspecified(addr4)) {
927927
tmp = net_htonl(*(addr4->s4_addr32));
928928
r = add_a_record(inst, DNS_SD_A_TTL, host_offset, tmp, buf, offset,
929-
buf_size - offset);
929+
buf_size);
930930
if (r < 0) {
931931
return r; /* LCOV_EXCL_LINE */
932932
}

0 commit comments

Comments
 (0)