Skip to contentSkip to conversation

Fix write retry loop for nonblocking mode

PATCH Steve Dickson 1 participant 1 message Nov 6, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 23 lines · On 09/30/2014 09:17 AM, [email protected] wrote:

Hello,

while testing with rpcbind, I stumbled across a small bug in libtirpc. I didn't test the patch below, but I think it's quite obvious.

Please CC me, I'm not on the list.

Best regards
Bodo

----------

From: Bodo Stroesser <[email protected]>
Date: Tue, 30 Sep 2014 14:01:17 +0200
Subject: [PATCH] fix write retry loop for nonblocking mode

This is a simple fix for the write retry loop that is used on non-blocking connections if write() failed with -EAGAIN.

Additionally it removes a redundant if () {}

Quoted 7 lines

Erroneously at each cycle of the loop the length of the data to send is incremented and the buffer pointer is decremented. Thus, it might happen that:
* the application crashes
* data from the memory before the buffer is sent

Committed....

steved.

Quoted 49 lines

---------

src/svc_vc.c +12 -14
@@ -559,20 +559,19 @@ write_vc(xprtp, buf, len)
 				cd->strm_stat = XPRT_DIED;
 				return (-1);
 			}
-			if (cd->nonblock && i != cnt) {
-				/*
-				 * For non-blocking connections, do not
-				 * take more than 2 seconds writing the
-				 * data out.
-				 *
-				 * XXX 2 is an arbitrary amount.
-				 */
-				gettimeofday(&tv1, NULL);
-				if (tv1.tv_sec - tv0.tv_sec >= 2) {
-					cd->strm_stat = XPRT_DIED;
-					return (-1);
-				}
+			/*
+			 * For non-blocking connections, do not
+			 * take more than 2 seconds writing the
+			 * data out.
+			 *
+			 * XXX 2 is an arbitrary amount.
+			 */
+			gettimeofday(&tv1, NULL);
+			if (tv1.tv_sec - tv0.tv_sec >= 2) {
+				cd->strm_stat = XPRT_DIED;
+				return (-1);
 			}
+			i = 0; /* Don't change buf and cnt */
 		}
 	}
 
------------------------------------------------------------------------------

Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Libtirpc-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/libtirpc-devel