changeset 35333:701e78689c07

stream ftp: readline: Fix off-by-one error Even if max bytes are available read at most max - 1 bytes.
author al
date Tue, 20 Nov 2012 22:13:57 +0000
parents d6b957072297
children 3397976a029b
files stream/stream_ftp.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_ftp.c	Tue Nov 20 19:43:53 2012 +0000
+++ b/stream/stream_ftp.c	Tue Nov 20 22:13:57 2012 +0000
@@ -32,6 +32,7 @@
 #include <winsock2.h>
 #endif
 
+#include "libavutil/avutil.h"
 #include "mp_msg.h"
 #include "network.h"
 #include "stream.h"
@@ -114,7 +115,7 @@
 
     do {
       if (ctl->cavail > 0) {
-	x = (max >= ctl->cavail) ? ctl->cavail : max-1;
+	x = FFMIN(ctl->cavail, max-1);
 	end = memccpy(bp,ctl->cget,'\n',x);
 	if (end != NULL)
 	  x = end - bp;