]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx: Handle negative returns on packet reads
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 30 Mar 2012 18:37:36 +0000 (19:37 +0100)
committerDerrick Brashear <shadow@dementix.org>
Mon, 9 Apr 2012 01:16:59 +0000 (18:16 -0700)
rxi_RecvMsg returns an int, because it can return a negative value upon
error. Don't store its return value as an unsigned int, because this may
hide the potential errors.

Modify the error handling loop so that errors get to where they are
intended.

Change-Id: I212e5881f83a2a95c177c23dbc2da2583155f1aa
Reviewed-on: http://gerrit.openafs.org/7087
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/rx/rx_packet.c

index 0f0513d42a5cf8e2b03c1c0ee6f25d6bf69debb2..78d2e5e81fc2b8c84e720d296949d1318dd1e418 100644 (file)
@@ -1407,7 +1407,7 @@ rxi_ReadPacket(osi_socket socket, struct rx_packet *p, afs_uint32 * host,
               u_short * port)
 {
     struct sockaddr_in from;
-    unsigned int nbytes;
+    int nbytes;
     afs_int32 rlen;
     afs_uint32 tlen, savelen;
     struct msghdr msg;
@@ -1446,7 +1446,7 @@ rxi_ReadPacket(osi_socket socket, struct rx_packet *p, afs_uint32 * host,
     p->wirevec[p->niovecs - 1].iov_len = savelen;
 
     p->length = (u_short)(nbytes - RX_HEADER_SIZE);
-    if ((nbytes > tlen) || (p->length & 0x8000)) {     /* Bogus packet */
+    if (nbytes < 0 || (nbytes > tlen) || (p->length & 0x8000)) { /* Bogus packet */
        if (nbytes < 0 && errno == EWOULDBLOCK) {
             if (rx_stats_active)
                 rx_atomic_inc(&rx_stats.noPacketOnRead);