This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/8.0
in repository ffmpeg.

commit afdbf03027fc1f7b2ba9832b0cb25b3986027b12
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Tue May 19 22:05:29 2026 +0200
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Sun Jun 14 04:59:04 2026 +0200

    avformat/ftp: Check for Telnet IAC characters and other non printable ASCII 
chars
    
    Signed-off-by: Michael Niedermayer <[email protected]>
    (cherry picked from commit 090838497ccecb017e8ffd304dcef4b3ca929fa6)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavformat/ftp.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 7b0cf31492..6e6c8b9940 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -100,6 +100,16 @@ static const AVClass ftp_context_class = {
 
 static int ftp_close(URLContext *h);
 
+static int is_bad_string(const unsigned char *s)
+{
+    while(*s) {
+        if (*s < 0x20 || *s == 0x7F || *s == 0xFF)
+            return 1;
+        s++;
+    }
+    return 0;
+}
+
 static int ftp_getc(FTPContext *s)
 {
     int len;
@@ -250,7 +260,7 @@ 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"))
+    if (is_bad_string(s->user))
         return AVERROR(EINVAL);
     err = snprintf(buf, sizeof(buf), "USER %s\r\n", s->user);
     if (err >= sizeof(buf))
@@ -259,7 +269,7 @@ static int ftp_auth(FTPContext *s)
     err = ftp_send_command(s, buf, user_codes, NULL);
     if (err == 331) {
         if (s->password) {
-            if (strpbrk(s->password, "\r\n"))
+            if (is_bad_string(s->password))
                 return AVERROR(EINVAL);
             err = snprintf(buf, sizeof(buf), "PASS %s\r\n", s->password);
             if (err >= sizeof(buf))
@@ -746,8 +756,8 @@ static int ftp_connect(URLContext *h, const char *url)
     av_free(s->path);
     s->path = newpath;
 
-    if (strpbrk(s->path, "\r\n")) {
-        av_log(h, AV_LOG_ERROR, "Path contains CR/LF characters\n");
+    if (is_bad_string(s->path)) {
+        av_log(h, AV_LOG_ERROR, "Path contains non-printable characters\n");
         return AVERROR(EINVAL);
     }
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to