[MPlayer-dev-eng] [PATCH 1/7] stream ftp: readline: Fix off-by-one error

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Nov 12 20:27:59 CET 2012


On Sun, Nov 11, 2012 at 10:00:50PM +0100, Alexander Strasser wrote:
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c
> index 6e431a9..0bb0711 100644
> --- a/stream/stream_ftp.c
> +++ b/stream/stream_ftp.c
> @@ -114,7 +114,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 = (max > ctl->cavail) ? ctl->cavail : max-1;

I'd recommend using FFMIN


More information about the MPlayer-dev-eng mailing list