[FFmpeg-devel] libavformat/rtsp.c: Avoids duplicated slashes in the RTSP URL Signed-off-by: Frederic Pillonel <fpi@gmx.ch>

Submitted by fpi@gmx.ch on Jan. 23, 2019, 8:11 a.m.

Details

Message ID 20190123081148.29388-1-fpi@gmx.ch
State New
Headers show

Commit Message

fpi@gmx.ch Jan. 23, 2019, 8:11 a.m.
From: Frederic Pillonel <fpi@gmx.ch>

---
 libavformat/rtsp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Jan. 24, 2019, 9:47 p.m.
On Wed, Jan 23, 2019 at 08:11:48AM +0000, fpi@gmx.ch wrote:
> From: Frederic Pillonel <fpi@gmx.ch>
> 
> ---
>  libavformat/rtsp.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index ceb770a..3cc9012f 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -548,9 +548,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
>                               NULL, NULL, 0, p);
>                  if (proto[0] == '\0') {
>                      /* relative control URL */
> -                    if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/')
> -                    av_strlcat(rtsp_st->control_url, "/",
> -                               sizeof(rtsp_st->control_url));
> +                    if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/' &&
> +                                (strlen(p) > 0 && p[0]!='/'))
> +                        av_strlcat(rtsp_st->control_url, "/",
> +                                    sizeof(rtsp_st->control_url));

is this actually correct ?
if the added path starts with a / shouldnt it be an absolute path ?
IIUC https://tools.ietf.org/html/rfc1808 needs to be followed here

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index ceb770a..3cc9012f 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -548,9 +548,10 @@  static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
                              NULL, NULL, 0, p);
                 if (proto[0] == '\0') {
                     /* relative control URL */
-                    if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/')
-                    av_strlcat(rtsp_st->control_url, "/",
-                               sizeof(rtsp_st->control_url));
+                    if (rtsp_st->control_url[strlen(rtsp_st->control_url)-1]!='/' &&
+                                (strlen(p) > 0 && p[0]!='/'))
+                        av_strlcat(rtsp_st->control_url, "/",
+                                    sizeof(rtsp_st->control_url));
                     av_strlcat(rtsp_st->control_url, p,
                                sizeof(rtsp_st->control_url));
                 } else