mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-25 15:37:32 +00:00
usrsock:fix stack-buffer-overflow issue when running basic_send test case
The following error was reported when runing usrsocktest with KASAN check enabled.
==1348590==ERROR: AddressSanitizer: stack-buffer-overflow on address 0xf20ec610 at pc 0x56ac61ba bp 0xf20ec278 sp 0xf20ec268
rootcause:
hdrbuf's size is not large enough to store the data in usrsock's request.
solution:
double herbuf's size to make sure the space, used to store usrsock's request, is enough.
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
This commit is contained in:
parent
2717ba4f88
commit
ffab06c6c5
1 changed files with 3 additions and 2 deletions
|
|
@ -1579,7 +1579,7 @@ static int handle_usrsock_request(int fd, FAR struct daemon_priv_s *priv)
|
|||
},
|
||||
};
|
||||
|
||||
uint8_t hdrbuf[16];
|
||||
uint8_t hdrbuf[32];
|
||||
FAR struct usrsock_request_common_s *common_hdr = (FAR void *)hdrbuf;
|
||||
ssize_t rlen;
|
||||
|
||||
|
|
@ -1601,7 +1601,8 @@ static int handle_usrsock_request(int fd, FAR struct daemon_priv_s *priv)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
assert(handlers[common_hdr->reqid].hdrlen < sizeof(hdrbuf));
|
||||
assert(handlers[common_hdr->reqid].hdrlen <
|
||||
(sizeof(hdrbuf) - sizeof(*common_hdr)));
|
||||
|
||||
rlen = read_req(fd, common_hdr, hdrbuf,
|
||||
handlers[common_hdr->reqid].hdrlen);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue