plougher / squashfs-tools

tools to create and extract Squashfs filesystems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What does each unsquash file represent?

maiziyi opened this issue · comments

Hi, when I'm checking the source code of squashfs-tools, I find that unsquashfs is made by 8 files, which are unsquash-1.c, unsquash-2.c etc. I have no idea that what do these files' names represent. But I have a guess that these files'suffix represents the version of squashfs. For example, unsqaush-3, unsqaush-123 and unsqaush-1234 are used to uncompress squashfs image whose version is 3.x. Could you please answer my question? Best regards.
P.S. I'm not a native English speaker, so please forgive me if I sound rude or impolite. Sorry!

Correct.

Unsquash-1.c has the routines to read a version 1.x filesystem.
Unsquash-2.c has the routines to read a version 2.x filesystem.
Unsquash-3c has the routines to read a version 3.x filesystem.
Unsquash-4.c has the routines to read a version 4.x filesystem.

The files with more than one number (i.e. Unsquash-123.c) have functions which are shared between the filesystem versions, either because that part of the filesystem format didn't change between the versions, or because they contain helper functions for things which didn't change between the versions.

Unsquash-12.c implements a sort function. This is only needed for v1.x and v2.0 filesystems because from V2.1 directories are sorted in the filesystem. Directories need to be sorted to check for (malicious) duplicate files that try to trick Unsquashfs into doing something unexpected or unsafe (CVE-2021-41072).

Unsquash-123.c has code to read ids (uids and gids) from the filesystem. This didn't change between V1.x, V2.x and V3.x filesystems. But the ids format was changed for V4.0.

Unsquash-34.c had helpers to handle hard links and to detect directory loops. Hard-links are not supported in V1.x or V2.x filesystems.

Unsquash-1234.c has helpers which are used across all the filesystem versions. They check for (malicious) corruption that try to trick Unsquashfs into doing something unexpected or unsafe ( CVE-2021-40153 and CVE-2021-41072).

Thank you very much for your answer! This really cleared my doubts.