Commit 590d4349 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Fix nullptr dereference

Summary: Fix nullptr dereference

Reviewed By: kevin-vigor

Differential Revision: D25687105

fbshipit-source-id: 59b0f3e4adc810f6e1a89447667cd167c52f7fb5
parent 69bbfc4b
......@@ -479,23 +479,27 @@ ssize_t AsyncUDPSocket::writeChain(
[CMSG_SPACE(sizeof(uint16_t)) + /*gro*/
CMSG_SPACE(sizeof(uint64_t)) /*txtime*/
] = {};
struct cmsghdr* cm = CMSG_FIRSTHDR(&msg);
msg.msg_control = control;
struct cmsghdr* cm = nullptr;
if (options.gso > 0) {
msg.msg_control = control;
msg.msg_controllen = CMSG_SPACE(sizeof(uint16_t));
cm = CMSG_FIRSTHDR(&msg);
cm->cmsg_level = SOL_UDP;
cm->cmsg_type = UDP_SEGMENT;
cm->cmsg_len = CMSG_LEN(sizeof(uint16_t));
auto gso_len = static_cast<uint16_t>(options.gso);
memcpy(CMSG_DATA(cm), &gso_len, sizeof(gso_len));
cm = CMSG_NXTHDR(&msg, cm);
}
if (options.txTime.count() > 0 && txTime_.has_value() &&
(txTime_.value().clockid >= 0)) {
msg.msg_control = control;
msg.msg_controllen += CMSG_SPACE(sizeof(uint64_t));
if (cm) {
cm = CMSG_NXTHDR(&msg, cm);
} else {
cm = CMSG_FIRSTHDR(&msg);
}
cm->cmsg_level = SOL_SOCKET;
cm->cmsg_type = SCM_TXTIME;
cm->cmsg_len = CMSG_LEN(sizeof(uint64_t));
......@@ -534,7 +538,7 @@ ssize_t AsyncUDPSocket::writeChain(
}
return ret;
}
} // namespace folly
ssize_t AsyncUDPSocket::write(
const folly::SocketAddress& address,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment