Merge pull request #814 from zhaozihanzzh/dev-ldpreload

Fix cplen calculation error in ff_hook_getsockname
This commit is contained in:
johnjiang 2024-04-19 15:00:10 +08:00 committed by GitHub
commit a4a53bacfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -419,7 +419,7 @@ ff_hook_getsockname(int fd, struct sockaddr *name,
SYSCALL(FF_SO_GETSOCKNAME, args);
if (ret == 0) {
socklen_t cplen = *namelen ? *sh_namelen > *namelen
socklen_t cplen = *sh_namelen > *namelen ? *namelen
: *sh_namelen;
rte_memcpy(name, sh_name, cplen);
*namelen = *sh_namelen;
@ -475,7 +475,7 @@ ff_hook_getpeername(int fd, struct sockaddr *name,
SYSCALL(FF_SO_GETPEERNAME, args);
if (ret == 0) {
socklen_t cplen = *namelen ? *sh_namelen > *namelen
socklen_t cplen = *sh_namelen > *namelen ? *namelen
: *sh_namelen;
rte_memcpy(name, sh_name, cplen);
*namelen = *sh_namelen;
@ -794,7 +794,7 @@ ff_hook_recvfrom(int fd, void *buf, size_t len, int flags,
if (ret >= 0) {
rte_memcpy(buf, sh_buf, ret);
if (from) {
socklen_t cplen = *fromlen ? *sh_fromlen > *fromlen
socklen_t cplen = *sh_fromlen > *fromlen ? *fromlen
: *sh_fromlen;
rte_memcpy(from, sh_from, cplen);
*fromlen = *sh_fromlen;