git.samba.org
/
socket_wrapper.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
12c6934
)
swrap: Don't pass NULL pointers to memcpy()
author
Joseph Sutton
<josephsutton@catalyst.net.nz>
Thu, 29 Jul 2021 23:12:12 +0000
(11:12 +1200)
committer
Andreas Schneider
<asn@samba.org>
Mon, 4 Apr 2022 13:20:10 +0000
(15:20 +0200)
Doing so is undefined behaviour.
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/socket_wrapper.c
patch
|
blob
|
history
diff --git
a/src/socket_wrapper.c
b/src/socket_wrapper.c
index 44cfad8c6cfd4790ba82a3a76cc91799a28c7466..8141b8b186f0b9282de2c4070805890f969e1bb6 100644
(file)
--- a/
src/socket_wrapper.c
+++ b/
src/socket_wrapper.c
@@
-6285,9
+6285,11
@@
static void swrap_sendmsg_after(int fd,
for (i = 0; i < (size_t)msg->msg_iovlen; i++) {
size_t this_time = MIN(remain, (size_t)msg->msg_iov[i].iov_len);
- memcpy(buf + ofs,
- msg->msg_iov[i].iov_base,
- this_time);
+ if (this_time > 0) {
+ memcpy(buf + ofs,
+ msg->msg_iov[i].iov_base,
+ this_time);
+ }
ofs += this_time;
remain -= this_time;
}