Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#3336 closed defect (fixed)

When trying to play an HLS playlist that requires cookies, (null) is sent in the Cookie header for cookies that specify sub-domain

Reported by: voguemaster Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: HLS cookie
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

There is a problem when trying to play an m3u8 (HLS) playlist
that requires cookies to be sent. Specifically, when the
server sets cookies that are valid for all sub-domains but
the URL to be played is of the top-level domain.
For example:

domain in URL: bar.com/segments.m3u8
Cookie set domain: .bar.com
(leading dot in cookie cdomain = valid for all sub-domains
AND the master domain).

The bug is in http.c get_cookies function, when matching
the domain.

There are 3 scenarios with cookies:

  1. Specific domain set by cookie. i.e: foo.bar.com - WORKS.
  2. Cookie specifies sub-domain and the URL to play is in a

sub-domain. i.e: URL points to foo.bar.com, cookie sets .bar.com - WORKS.

  1. Cookie specifies sub-domain and the URL to play is at the

master domain level. i.e: URL is bar.com, cookie sets .bar.com - NOT WORKING.

How to reproduce:

ffmpeg version N-60023-g13e0109 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan 20 2014 22:02:00 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 63.100 / 52. 63.100
  libavcodec     55. 48.102 / 55. 48.102
  libavformat    55. 25.100 / 55. 25.100
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  1.100 /  4.  1.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-cookies' ... matched as AVOption 'cookies' with argument 'HDEA_S=exp=1390236715~acl=%2F%2A~hmac=ad0fc5c2fa683e9aca5cac6dbc77455b572b15e79d65f695e704d4e57def7fbd; path=/; domain=.233492reshet.pmd.applicaster.com\nHDEA_L=exp=1390305115~acl=%2f*~hmac=12e3a47d79a9c297feca6038421fdb4bb2ddf61d55711de7e23fde2a44af6af9; path=/; domain=.233492reshet.pmd.applicaster.com'.
Reading option '-i' ... matched as input file with argument 'http://233492reshet.pmd.applicaster.com/accounts/32/broadcasters/1/vod_items/1155754/3ed9bddadcd889128275/640x480-634k/segments.m3u8'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file http://233492reshet.pmd.applicaster.com/accounts/32/broadcasters/1/vod_items/1155754/3ed9bddadcd889128275/640x480-634k/segments.m3u8.
Successfully parsed a group of options.
Opening an input file: http://233492reshet.pmd.applicaster.com/accounts/32/broadcasters/1/vod_items/1155754/3ed9bddadcd889128275/640x480-634k/segments.m3u8.
[http @ 02782f20] request: GET /accounts/32/broadcasters/1/vod_items/1155754/3ed9bddadcd889128275/640x480-634k/segments.m3u8 HTTP/1.1

User-Agent: Lavf/55.25.100

Accept: */*

Range: bytes=0-

Connection: close

Host: 233492reshet.pmd.applicaster.com

Cookie: (null)




[http @ 02782f20] header='HTTP/1.1 403 Forbidden'
[http @ 02782f20] http_code=403
[http @ 02782f20] HTTP error 403 Forbidden
http://233492reshet.pmd.applicaster.com/accounts/32/broadcasters/1/vod_items/1155754/3ed9bddadcd889128275/640x480-634k/segments.m3u8: Input/output error

May be related to #2180.

I want to note I have a working fix for this. I'm using
libavformat from within XBMC. I fixed http.c and compiled
ffmpeg's libs and it works.

XBMC 13.0 Gotham uses ffmpeg 1.2 but the code hasn't changed
at all in newer versions.
(how do I submit a patch?)

Attachments (1)

0001-Properly-handle-cookies-that-specify-sub-domain-wher.patch (1.5 KB) - added by voguemaster 6 years ago.
Patch to http.c get_cookies() function

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by voguemaster

Patch to http.c get_cookies() function

comment:1 Changed 6 years ago by voguemaster

I've submitted a better patch to ffmpeg-devel. How do I delete this attachment?

comment:2 Changed 6 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from new to closed
  • Version changed from unspecified to git-master

Fixed by you in da25a657
Thank you for the report and the patch!

comment:3 Changed 6 years ago by cehoyos

  • Keywords cookie added; cookies removed
Note: See TracTickets for help on using tickets.