Skip to content

Lua HTTP interface killed by link circles

Steps to reproduce

Open the preferences dialog, switch from Simple to All settings, Navigate to Interface / Main interfaces / Lua.

In the Lua HTTP panel, set Source directory to some directory you have write permissions to. For example, /home/john/Videos and make sure the Directory index checkbox is checked.

In a sub-directory of that directory, create a circular symbolic link. For example:

$ cd /home/john/Videos
$ mkdir dir-with-circle
$ cd dir-with-circle
$ ln -s ../dir-with-circle cilcular-link-2

Now start vlc with http:

$ vlc -extraintf=http --http-host 0.0.0.0 --http-port 8081

The result is an error message:

[0000560c57902610] [http] lua interface error: Error loading script /usr/lib/x86_64-linux-gnu/vlc/lua/intf/http.lua: /usr/lib/x86_64-linux-gnu/vlc/lua/intf/http.lua:304: attempt to index local 's' (a nil value)

Port 8081 is not opened, as can be verified using

$ lsof -i4 -n | grep LISTEN

Adding a print statement before the offending line tells the whole story:

if s == nil then print("===> s is nil; dir: " .. dir .. "; f: " .. f) end

which prints, just before the error message:

===> s is nil; dir: /home/john/Videos/dir-with-circle/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2/cilcular-link-2; f: cilcular-link-2

Suggested fix

A patch against this is trivial: just change "if s.type == ..." to "if s ~= nil and s.type == ..." on line 301 (or a few lines below - it depends on the vlc version), and then again on (or a bit after) line 316.

A better fix would be to add a check against circles (skipping symbolic links altogether would break some very useful use cases).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information