mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Remove incorrect recvfrom: unread data is lost per MS docs
This commit is contained in:
@@ -146,8 +146,6 @@ struct extended_overlapped {
|
||||
* can destroy them if the msp is deleted. This pointer makes it easy to
|
||||
* remove this struct extended_overlapped from the allocated list when necessary */
|
||||
gh_lnode_t nodeq;
|
||||
|
||||
int eov_received;
|
||||
};
|
||||
|
||||
/* --- INTERNAL PROTOTYPES --- */
|
||||
@@ -503,7 +501,6 @@ static struct extended_overlapped *new_eov(struct npool *nsp, struct nevent *nse
|
||||
eov->nse = nse;
|
||||
eov->nse_id = nse->id;
|
||||
eov->err = 0;
|
||||
eov->eov_received = false;
|
||||
gh_list_prepend(&iinfo->active_eovs, &eov->nodeq);
|
||||
|
||||
/* Make the read buffer equal to the size of the buffer in do_actual_read() */
|
||||
@@ -754,7 +751,6 @@ static int get_overlapped_result(struct npool *nsp, int fd, const void *buffer,
|
||||
char *buf = (char *)buffer;
|
||||
DWORD dwRes = 0;
|
||||
int err;
|
||||
static struct extended_overlapped *old_eov = NULL;
|
||||
struct iocp_engine_info *iinfo = (struct iocp_engine_info *)nsp->engine_data;
|
||||
|
||||
struct extended_overlapped *eov = iinfo->eov;
|
||||
@@ -769,30 +765,14 @@ static int get_overlapped_result(struct npool *nsp, int fd, const void *buffer,
|
||||
if (!GetOverlappedResult((HANDLE)fd, (LPOVERLAPPED)eov, &dwRes, FALSE)) {
|
||||
err = socket_errno();
|
||||
if (errcode_is_failure(err)) {
|
||||
eov->eov_received = true;
|
||||
SetLastError(map_faulty_errors(err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
eov->eov_received = true;
|
||||
|
||||
if (nse->type == NSE_TYPE_READ && buf)
|
||||
memcpy(buf, eov->wsabuf.buf, dwRes);
|
||||
|
||||
/* If the read buffer wasn't big enough, subsequent calls from do_actual_read will make us
|
||||
read with recvfrom the rest of the returned data */
|
||||
if (nse->type == NSE_TYPE_READ && dwRes == eov->wsabuf.len && old_eov == eov) {
|
||||
struct sockaddr_storage peer;
|
||||
socklen_t peerlen = sizeof(peer);
|
||||
dwRes = recvfrom(fd, buf, READ_BUFFER_SZ, 0, (struct sockaddr *)&peer, &peerlen);
|
||||
}
|
||||
|
||||
if (nse->type != NSE_TYPE_READ || (nse->type == NSE_TYPE_READ && dwRes < eov->wsabuf.len)) {
|
||||
old_eov = NULL;
|
||||
} else if (nse->type == NSE_TYPE_READ && dwRes == eov->wsabuf.len) {
|
||||
old_eov = eov;
|
||||
}
|
||||
|
||||
return dwRes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user