]> 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)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 29 Jan 2014 19:16:11 +0000 (11:16 -0800)
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.

Reviewed-on: http://gerrit.openafs.org/7087
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 438d6ba63cda7d7484c545a4fd181803e84d68eb)

Change-Id: I4f479a4e722b5f298ba2be4e86816ebddede701d
Reviewed-on: http://gerrit.openafs.org/10733
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/rx/rx_packet.c

index 7ac3a571013ebd648788ba769f89cdcd285a8d8d..1a5f4df7a193b2d0fbe6c716dd2a7fef6bcb4911 100644 (file)
@@ -1427,7 +1427,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;
@@ -1466,7 +1466,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_MutexIncrement(rx_stats.noPacketOnRead, rx_stats_mutex);