[MPlayer-dev-eng] [PATCHv2 1/8] stream ftp: readline: Fix off-by-one error
Alexander Strasser
eclipse7 at gmx.net
Sat Nov 17 01:01:30 CET 2012
Even if max bytes are available read at most max - 1 bytes.
Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
stream/stream_ftp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c
index 6e431a9..6874e7b 100644
--- a/stream/stream_ftp.c
+++ b/stream/stream_ftp.c
@@ -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,struct stream_priv_s *ctl)
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;
--
1.7.10.2.552.gaa3bb87
More information about the MPlayer-dev-eng
mailing list