diff mbox series

[FFmpeg-devel] avformat/http: prevent truncation of sanitized_path

Message ID 20210609200102.4900-1-jamrial@gmail.com
State Accepted
Commit b46817d9c3fe620ba02f2b3144444c431c6ba552
Headers show
Series [FFmpeg-devel] avformat/http: prevent truncation of sanitized_path | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer June 9, 2021, 8:01 p.m. UTC
path1 and sanitized_path are both MAX_URL_SIZE bytes long, yet the latter is
copied from the former with the addition of one extra character.

Should fix a -Wformat-truncation warning.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/http.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anton Khirnov Nov. 25, 2021, 11:26 a.m. UTC | #1
Quoting James Almer (2021-06-09 22:01:02)
> path1 and sanitized_path are both MAX_URL_SIZE bytes long, yet the latter is
> copied from the former with the addition of one extra character.
> 
> Should fix a -Wformat-truncation warning.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/http.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 1fc95c768c..1e7d97a027 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -192,7 +192,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
>      char *hashmark;
>      char hostname[1024], hoststr[1024], proto[10];
>      char auth[1024], proxyauth[1024] = "";
> -    char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE];
> +    char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE + 1];

Looks ok, was about to write the same patch.
diff mbox series

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index 1fc95c768c..1e7d97a027 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -192,7 +192,7 @@  static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
     char *hashmark;
     char hostname[1024], hoststr[1024], proto[10];
     char auth[1024], proxyauth[1024] = "";
-    char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE];
+    char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE + 1];
     char buf[1024], urlbuf[MAX_URL_SIZE];
     int port, use_proxy, err, location_changed = 0;
     HTTPContext *s = h->priv_data;