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>
transfer_test.c:66:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
int fd = (int)pvarg;
^
transfer_test.c: In function 'transfer_writer':
transfer_test.c:122:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
int fd = (int)pvarg;
^
transfer_test.c: In function 'transfer_test':
transfer_test.c:169:58: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
ret = pthread_create(&readerid, NULL, transfer_reader, (pthread_addr_t)fdin);
^
transfer_test.c:179:58: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
ret = pthread_create(&writerid, NULL, transfer_writer, (pthread_addr_t)fdout);
^
transfer_test.c:202:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
ret = (int)value;
^
transfer_test.c:216:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
tmp = (int)value;
^
Signed-off-by: nietingting <nietingting@xiaomi.com>
fix usrsock remote_disconnect fail:
nsh> usrsocktest
...
Testing group "remote_disconnect" =>
[TEST ASSERT FAILED!]
In function "receive":
line 497: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "remote_disconnect": [FAILED]
...
Reference:
RECV(2)
NAME
recv, recvfrom, recvmsg - receive a message from a socket
...
RETURN VALUE
...
When a stream socket peer has performed an orderly shutdown,
the return value will be 0 (the traditional "end-of-file" return).
Datagram sockets in various domains (e.g., the UNIX and Internet domains)
permit zero-length datagrams. When such a datagram is received, the return value is 0.
Signed-off-by: chao an <anchao@xiaomi.com>
The test model of usrsock ioctl() has changed after file socket layer implemented from vfs,
usrsock must implement the ioctl() hook to pass this test
Signed-off-by: chao an <anchao@xiaomi.com>
usrsocktest_wake_with_signal.c: In function ‘do_wake_test’:
usrsocktest_wake_with_signal.c:553:16: error: ‘USEC_PER_MSEC’ undeclared (first use in this function)
553 | usleep(100 * USEC_PER_MSEC); /* Let worker thread proceed to blocking
| ^~~~~~~~~~~~~
Signed-off-by: chao an <anchao@xiaomi.com>
DUP(2) Linux Programmer's Manual
NAME
dup, dup2, dup3 - duplicate a file descriptor
...
RETURN VALUE
On success, these system calls return the new file descriptor.
On error, -1 is returned, and errno is set appropriately.
Signed-off-by: chao an <anchao@xiaomi.com>