VirtualBox

Changeset 51974 in vbox for trunk/src


Ignore:
Timestamp:
Jul 10, 2014 2:45:05 PM (11 years ago)
Author:
vboxsync
Message:

NAT/Net: Careful with that DWORD... It's unsigned, so assigning
negative values to it is a bad idea, especially when a coercion to a
wider signed type is about to happen. While here, don't test that
DWORD values are <= 0, just test for zero instead.

In particulat this fixes returning socket errors from
pxtcp_sock_recv() and pxtcp_sock_send() wrappers on Windows.

Location:
trunk/src/VBox/NetworkServices/NAT
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/proxy.c

    r51597 r51974  
    201201                                (LPSTR)&msg, 0,
    202202                                NULL);
    203         if (nchars <= 0 || msg == NULL) {
     203        if (nchars == 0 || msg == NULL) {
    204204            cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL,
    205205                              "Unknown error: %d", error);
     
    528528#else
    529529    DWORD nsent;
     530#endif
    530531    int rc;
    531 #endif
    532532    IOVEC fixiov[8];     /* fixed size (typical case) */
    533533    const size_t fixiovsize = sizeof(fixiov)/sizeof(fixiov[0]);
     
    573573
    574574    nsent = sendmsg(sock, &mh, 0);
     575    rc = (nsent >= 0) ? 0 : SOCKET_ERROR;
    575576#else
    576577    rc = WSASendTo(sock, iov, (DWORD)clen, &nsent, 0,
    577578                   name, (int)namelen, NULL, NULL);
     579#endif
    578580    if (rc == SOCKET_ERROR) {
    579         nsent = -1;
    580     }
    581 #endif
    582     if (nsent < 0) {
    583581        error = SOCKERRNO();
    584582        DPRINTF(("%s: socket %d: sendmsg: %R[sockerr]\n",
  • trunk/src/VBox/NetworkServices/NAT/pxping_win.c

    r51574 r51974  
    303303
    304304    nreplies = IcmpParseReplies(pong->buf, (DWORD)pong->bufsize);
    305     if (nreplies <= 0) {
     305    if (nreplies == 0) {
    306306        DWORD error = GetLastError();
    307307        if (error == IP_REQ_TIMED_OUT) {
     
    582582
    583583    nreplies = Icmp6ParseReplies(pong->buf, (DWORD)pong->bufsize);
    584     if (nreplies <= 0) {
     584    if (nreplies == 0) {
    585585        DWORD error = GetLastError();
    586586        if (error == IP_REQ_TIMED_OUT) {
  • trunk/src/VBox/NetworkServices/NAT/pxtcp.c

    r51681 r51974  
    15831583                     0, NULL, NULL);
    15841584    if (status == SOCKET_ERROR) {
    1585         nsent = -SOCKERRNO();
     1585        return -SOCKERRNO();
    15861586    }
    15871587
     
    18671867                     &flags, NULL, NULL);
    18681868    if (status == SOCKET_ERROR) {
    1869         nread = -SOCKERRNO();
     1869        return -SOCKERRNO();
    18701870    }
    18711871
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette