ReFirmLabs / binwalk

Firmware Analysis Tool
MIT License
10.54k stars 1.51k forks source link

Broken implementation of lsb_release in deps.sh #552

Open AndrewFasano opened 3 years ago

AndrewFasano commented 3 years ago

On Ubuntu 20.04 (at least) /etc/os-release contains two lines which start with ID leading to an incorrect OS name being detected by the fallback implementation of lsb_release in deps.sh.

When os-release contains

ID=ubuntu
ID_LIKE=debian

the implementation of lsb_release will incorrectly return "ubuntu debian" when it should have returned "ubuntu".

Since deps.sh doesn't quote the $distro variable, this leads to a syntax error as $distro then contains a space.

The following minimal dockerfile will reproduce the issue:

FROM ubuntu:20.04
RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends git ca-certificates
RUN git clone https://github.com/ReFirmLabs/binwalk
WORKDIR /binwalk
RUN bash ./deps.sh --yes

Which leads to the following error:

./deps.sh: line 44: [: too many arguments