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 <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
6f96915a14
commit
43c2b9cfe8
1 changed files with 1 additions and 1 deletions
|
@ -394,7 +394,7 @@ int dns_copy_qname(uint8_t *buf, uint16_t *len, uint16_t size,
|
|||
/* validate that the label (i.e. size + elements),
|
||||
* fits the current msg buffer
|
||||
*/
|
||||
if (DNS_LABEL_LEN_SIZE + lb_size > size - *len) {
|
||||
if (DNS_LABEL_LEN_SIZE + lb_size > MIN(size - *len, msg_size - pos)) {
|
||||
rc = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue