Public bug reported:

If you connect to a stream that redirects using a "location:" header
rather than "Location:", the redirect is not recognized.

I used the -a and -A options (just save as one file, no splitting by
song), and in that case many 0-byte MP3 files are created, about 4 or 5
per second.

With the attached patch, the redirect is followed and only one MP3 file
is created containing the streamed data, as expected.

The HTTP specification, RFC 9112, specifies in section 5 "Field Syntax"
that field names are case-insensitive.


Versions:

$ lsb_release -rd
No LSB modules are available.
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
$ apt-cache policy streamripper 
streamripper:
  Installed: 1.64.6-1build3
  Candidate: 1.64.6-1build3
  Version table:
 *** 1.64.6-1build3 500
        500 http://nl.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 
Packages
        100 /var/lib/dpkg/status
$ 


To reproduce:

$ streamripper 'https://streaming.live365.com/a78846' -A -a 'out_%d' -l 5
Connecting...
stream: Streamripper_rips
server name: 

Time to stop is here, bailing
shutting down
bye..
$ ls -l out_*.mp3 |wc -l
21
$ find . -name 'out_*.mp3' -size 0 |wc -l
21
$ # Patched version:
$ ~/src/streamripper/streamripper 'https://streaming.live365.com/a78846' -A -a 
'outnew_%d' -l 5 
Connecting...
stream: Radio stratford
server name: DAS
declared bitrate: 192
meta interval: 8192

[skipping...   ]  - Unknown [  577kb]
Time to stop is here, bailing
shutting down
bye..
$ ls -l outnew_*.mp3 |wc -l
1
$ find . -name 'outnew_*.mp3' -size 0 |wc -l
0
$ 


Additional notes regarding my patch:

I patched the function "extract_header_value", which is used for all
HTTP headers, to use strcasestr() instead of strstr(), and removed a now
redundant call.

Note that in the reproduction above, my patched version recognizes
several other headers as well. I consider that an improvement.

The function "extract_header_value" is, however, also used to parse PLS
files. The PLS format appears to be specified only by reverse-
engineering, but almost all sources I could find say field names in it
are case-sensitive, so this may necessitate further changes.

Additionally, I'd like to note that this function does not require fields to 
start at the beginning of a line, which one may even see as a security issue; 
it may be a good idea to either fix that in the function (but also think about 
the PLS parsing!), or call it with an extra \n like
     extract_header_value(header, info->http_location, "\nLocation:",
                         sizeof(info->http_location));
etc...

** Affects: streamripper (Ubuntu)
     Importance: Undecided
         Status: New

** Patch added: "streamripper-httpheadercasesensitivity.patch"
   
https://bugs.launchpad.net/bugs/2131037/+attachment/5925951/+files/streamripper-httpheadercasesensitivity.patch

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2131037

Title:
  streamripper does not follow redirect if location header is in
  lowercase

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/streamripper/+bug/2131037/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to