Skip to content

Commit

Permalink
avformat/ftp: do not break protocol on username or password with newl…
Browse files Browse the repository at this point in the history
…ines

Signed-off-by: Marton Balint <[email protected]>
  • Loading branch information
cus committed Feb 15, 2020
1 parent f204a38 commit 04f1d49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libavformat/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <string.h>

#include "libavutil/avstring.h"
#include "libavutil/internal.h"
#include "libavutil/parseutils.h"
Expand Down Expand Up @@ -246,10 +248,14 @@ static int ftp_auth(FTPContext *s)
static const int user_codes[] = {331, 230, 0};
static const int pass_codes[] = {230, 0};

if (strpbrk(s->user, "\r\n"))
return AVERROR(EINVAL);
snprintf(buf, sizeof(buf), "USER %s\r\n", s->user);
err = ftp_send_command(s, buf, user_codes, NULL);
if (err == 331) {
if (s->password) {
if (strpbrk(s->password, "\r\n"))
return AVERROR(EINVAL);
snprintf(buf, sizeof(buf), "PASS %s\r\n", s->password);
err = ftp_send_command(s, buf, pass_codes, NULL);
} else
Expand Down

0 comments on commit 04f1d49

Please sign in to comment.