From df189505332f627b17f603626e24cd7dcfeba94c Mon Sep 17 00:00:00 2001
From: rmacklem <rmacklem@FreeBSD.org>
Date: Sun, 10 Apr 2011 14:11:07 +0000
Subject: Fix a bug in the userland rpc library, where it would use a negative
 return value from write to update its position in a buffer. The patch,
 courtesy of Andrey Simonenko, also simplifies a conditional by removing the
 "i != cnt" clause, since it is always true at this point in the code. The bug
 caused problems for mountd, when it generated a large reply to an exports RPC
 request.

Submitted by:	simon at comsys.ntu-kpi.kiev.ua
MFC after:	2 weeks
---
 lib/libc/rpc/svc_vc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'lib/libc')

diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c
index 3fd8b7e..aded6b1 100644
--- a/lib/libc/rpc/svc_vc.c
+++ b/lib/libc/rpc/svc_vc.c
@@ -546,7 +546,7 @@ write_vc(xprtp, buf, len)
 				cd->strm_stat = XPRT_DIED;
 				return (-1);
 			}
-			if (cd->nonblock && i != cnt) {
+			if (cd->nonblock) {
 				/*
 				 * For non-blocking connections, do not
 				 * take more than 2 seconds writing the
@@ -560,6 +560,7 @@ write_vc(xprtp, buf, len)
 					return (-1);
 				}
 			}
+			i = 0;
 		}
 	}
 
-- 
cgit v1.1