net: socket: mgmt: Check buf size in recvfrom()
Return EMSGSIZE if trying to copy too much data into user supplied buffer. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
2f79f5e992
commit
0a16d5c7c3
|
@ -209,8 +209,12 @@ again:
|
|||
|
||||
if (info) {
|
||||
ret = info_len + sizeof(hdr);
|
||||
ret = MIN(max_len, ret);
|
||||
memcpy(©_to[sizeof(hdr)], info, ret);
|
||||
if (ret > max_len) {
|
||||
errno = EMSGSIZE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(©_to[sizeof(hdr)], info, info_len);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue