Skip to content

Commit 43c2b9c

Browse files
jukkarkartben
authored andcommitted
net: dns: Validate source buffer length properly
Make sure that when copying the qname, the source buffer is large enough for the data. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 6f96915 commit 43c2b9c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/net/lib/dns/dns_pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int dns_copy_qname(uint8_t *buf, uint16_t *len, uint16_t size,
394394
/* validate that the label (i.e. size + elements),
395395
* fits the current msg buffer
396396
*/
397-
if (DNS_LABEL_LEN_SIZE + lb_size > size - *len) {
397+
if (DNS_LABEL_LEN_SIZE + lb_size > MIN(size - *len, msg_size - pos)) {
398398
rc = -ENOMEM;
399399
break;
400400
}

0 commit comments

Comments
 (0)