Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit e487d0b

Browse files
committed
Fix recvfrom() to avoid unnecessary copy
recvfrom() copied data by the buffer size, but it should copy only the amount actually received.
1 parent aa68538 commit e487d0b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/net/net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ DEFINE_SYSCALL(recvfrom, int, socket, gaddr_t, buf_ptr, int, length, int, flags,
339339
int ret = syswrap(recvfrom(socket, buf, length, flags, sock_ptr, socklen_ptr));
340340
if (ret < 0)
341341
return ret;
342-
if (copy_to_user(buf_ptr, buf, length))
342+
if (copy_to_user(buf_ptr, buf, ret))
343343
return -LINUX_EFAULT;
344344
if (addr_ptr != 0) {
345345
char addr[sock_ptr->sa_len];

0 commit comments

Comments
 (0)