[MPlayer-cvslog] r35427 - trunk/stream/stream_ftp.c

al subversion at mplayerhq.hu
Tue Nov 20 23:13:58 CET 2012


Author: al
Date: Tue Nov 20 23:13:57 2012
New Revision: 35427

Log:
stream ftp: readline: Fix off-by-one error

Even if max bytes are available read at most max - 1 bytes.

Modified:
   trunk/stream/stream_ftp.c

Modified: trunk/stream/stream_ftp.c
==============================================================================
--- trunk/stream/stream_ftp.c	Tue Nov 20 20:43:53 2012	(r35426)
+++ trunk/stream/stream_ftp.c	Tue Nov 20 23:13:57 2012	(r35427)
@@ -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 @@ static int readline(char *buf,int max,st
 
     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;


More information about the MPlayer-cvslog mailing list