History log of /external/squashfs-tools/squashfs-tools/pseudo.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
933026301cb9d41b4b8b8273d892ea71c1c3d04b 01-Apr-2016 Mohamad Ayyash <mkayyash@google.com> Make squashfs work on BSD and macOS

Based on https://github.com/vasi/squashfs-tools

Change-Id: Ia2b04541652ef4f0cf8d6ff1daf106d6db32e278
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
/external/squashfs-tools/squashfs-tools/pseudo.c
10274203a57f8d4d0b69f013f032f633bb785dc2 06-May-2015 Mohamad Ayyash <mkayyash@google.com> mksquashfs: Fix segfault when SQUASHFS_TRACE is enabled and no -pf flag

Segfault happens when attempting to dump pseudo files in SQUASHFS_TRACE
mode after attempting to dereference NULL pseudo pointer.

Change-Id: I48097cce9b7a7e57fea5411c7d1eb5b5de8dc053
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
/external/squashfs-tools/squashfs-tools/pseudo.c
a8c9ff255d558fc86cc38f814b8a5626fcc0d702 29-Apr-2014 Phillip Lougher <phillip@squashfs.org.uk> mksquashfs: fix limit on the number of dynamic pseudo files

Dynamic pseudo files exist to enable users to dynamically
create files which don't actually exist in the source filesystem,
where the contents of the file are obtained from running
a command or piece of shell.

For instance

"a_file f 0777 root root dmesg"

will create a file named "a_file", which has the output of "dmesg"
as its contents.

When I implemented "dynamic pseudo files" I anticipated they would
be used for a limited amount of files. As such, when I implemented
them, I had Mksquashfs at start-up run through the set of dynamic
pseudo files and fork and exec the commands/shell upfront, with
Mksquashfs later reading from the pipes connecting the forked processes
at file system generation when that part of the filesystem was generated.

Doing this ensured maximum parallelism, as it allowed the forked
processes to run and produce output in parallel with Mksquashfs. By
the time the output of the processes was needed in filesystem
generation it was anticipated the forked processes run in parallel
would have finished any computation, and would be waiting to output
(or if the output was small, it would already be buffered in the pipe).

But this strategy had a known defect. It relied on the fact that
the total number of dynamic pseudo files when kicked off in their
entirety at Mksquashfs startup would not exceed process limits or
open file limits (each pipe created uses fds, and there's normally
omly 1024 that can be open at the same time by the ultimate parent
Mksquashfs process). Due to the fact I assumed dynamic pesudo files
would be only used for a limited number of files, this seemed like
worrying about a defect that would never in practice occur.

But, quite unexpectedly, I received a bug report last year where
a user tried to do exactly that, a pseudo file with more than 1000
dynamic pseudo files, and of course Mksquashfs failed when the
maximum open file limit was reached.

So, this commit fixes that bug. Dynamic pseudo file process creation
has been moved to the reader thread, and the process is created when
the output from that process is needed in filesystem generation, ensuring
the reader thread can read the sub-process' output and wait for it to die
and reap the resources used (pipe fds etc.) before starting another
dynamic pseudo file process. This ensures the minimal amount of
processes/fds/memory is in use at any one time by the pseudo file
processes and therefore prevents users from "mis-using" the
dynamic pseudo facility to create a DOS (denial of service) situation
where system limits are exceeded.

Note, I do not suspect the user who reported the bug of trying to
deliberately exploit a weakness in Mksquashfs to generate a DOS
situation, this appears to be one of the cases where a user wanted
to create many dynamic pseudo files and came accross this bug
by accident.

But, this bug needed to be fixed, both for the users who need to
create lots of dynamic pseudo files, and to close a "system resource
exhaustion" vulnerability.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
8ad956140d56720beb197b84e98bed2dab49301f 21-Apr-2014 Phillip Lougher <phillip@squashfs.org.uk> pseudo: only dump pseudos if SQUASHFS_TRACE defined

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
7a28f7a57b9b1fec0f6f1a0ab0cd94dd7881d673 21-Apr-2014 Phillip Lougher <phillip@squashfs.org.uk> pseudo: fix pseudo definition dumping and actually call it

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
ede4a94a61813de52fdb6f0cda7650d8c092a426 20-Apr-2014 Phillip Lougher <phillip@squashfs.org.uk> mksquashfs: pseudo files, fix handling of leaf name

If a pathname ended in "/" (i.e. "a/b/c/") the last pathname
component would not be recognised as a leaf name.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
1d6544e843c4bf07ad456a118ae3b1652a51f283 20-Apr-2014 Phillip Lougher <phillip@squashfs.org.uk> pseudo: add_pseudo(), fix use of freed variable

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
85776df7ba8c5a0bb56ddccfff2bf6a0fc48cac8 31-Jan-2014 Phillip Lougher <phillip@squashfs.org.uk> Mksquashfs: add new -exit-on-error option

Mksquashfs recognises two kinds of error:

- Fatal errors which cause it to abort, and
- Non fatal errors which it considers can be safely ignored

These "non-fatal" errors are generally failure to read files or
directories, when this happens Mksquashfs skips or stores an empty
file and continues (flagging up what it has done to stderr).

From early feedback from users, this is generally considered a better
option than aborting. Often-times users are aware that there are files
which cannot be read by Mksquashfs, and want Mksquashfs to automatically
ignore them without having to explicitly exclude them on the command line
(for instance it may be known that there are files owned by other users).
Or for instance archiving a filesystem which is known to be partially
corrupted, and it is expected it will generate I/O errors on one or more
files (which are obviously unknown beforehand and cannot be explicitly
excluded). Additionally, often-times users do not know that there are
files which cannot be read, but would rather Mksquashfs flag these
errors and continue, rather than aborting what may be many hours of
compression.

But I have got feedback which shows in some use-cases this
behaviour is undesireable, and would rather Mksquashfs abort at
the failure to read any files.

So add a new option -exit-on-error which makes Mksquashfs abort on
these errors.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
743e543c67ea13b556e55e43b692cc60125738da 21-Feb-2013 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Use MEM_ERROR() for out of space handling.

Replace all hand crafted BAD_ERROR() messages with MEM_ERROR()
which does the same thing.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
c8e7648be036ae006a320177dee22ca8c0db7945 31-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Get rid of ERROR statements in child process in exec_file()

ERROR() since commit 738570df60f65c10cd7fde4134f3af1e005b671a calls
progressbar_error() to synchronise with the progress bar output,
however, this function uses pthread mutexes which are meaningless/
useless in a child process.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
63589d2cd06137c44328eb942b97e8eed5c6f7c5 30-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Improve parse error messages in read_pseudo_def()

Plus add checking for trailing characters

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
3ece60e8d9b97a3533f44efe31c4f117c49fa113 24-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: add missing filename free

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
c4b044f565ba7882e73acf6132b9d4be59690910 24-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> read_file: Make pseudo read file implementation into a generic routine

Move routine into separate file, which can be used by multiple
callers, and change pseudo.c to use the generic routine.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
5ef2eba370311345600a0609175f08973e7510a0 24-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Move pseudo variable from mksquashfs.c to pseudo.c

Move and make pseudo variable mostly private to pseudo. This eliminates
the need to pass it to and from read_pseudo_def() and read_pseudo_file().

It is now only needed for dir_scan2() and so add an accessor get_pseudo()
for it in pseudo.c.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
83847c1beb852a7b3f5906a0f4c90be659e46794 23-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> mksquashfs/unsquashfs/pseudo/sort: Fix ERROR statement

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
03a26cc30b4a88463c81064b0e09ee7c478648c1 23-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Increase max line length to 16384

Increase max line length to bring it into line with
exclude/extract and sort files. Obviously longer
lines can be entered if split across multiple lines
with "\".

Also replace bare constants with the MAX_LINE definition.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
59ff862cc048d240530af6467ab66c94532e1629 23-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: handle filenames with spaces in pseudo file definitions

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
f78a35c0b7d3d21c257ea5160a6179ff88ac6a28 22-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Rewrite pseudo file processing

The previous version suffered from a number of nasty problems.

1. It couldn't handle pseudo files starting with one or more
newlines.

2. If a line exceeded the line limit (2048 bytes), the line would be
silently truncated.

3. If file reading failed for any other reason than EOF this was
not reported.

Plus there were the following problems with continuation line
(lines with \ at the end of the line) processing

4. Lines ending with backslashed backslash ("\\") were
incorrectly parsed as having continuation lines, even though
the continuating "\" was backslashed.

5. Leading whitespace in continuation lines was incorrectly stripped.

6. Continuation lines starting with # (after whitespace stripping) were
incorrectly treated as comment lines and stripped.

7. If EOF was encountered whilst parsing continuation lines, the
file parsing would finished, and the entire line would be ignored.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
2ac157ef4ba167c9074aabc1ec590aa5f4ad597c 12-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: dynamically allocate filename in exec_file()

rather than allocating it on the stack.

This code is only compiled if USE_TMP_FILE is defined, by
default Mksquashfs uses a pipe rather than a temporary
file to capture the output.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
7f802b94f954abd7a0db84cb4d4792bd819b43c1 11-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Mark fallthrough in case statement as intended

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
bee3be5daed730863ce44accb0b7b47bbc73c36e 11-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: avoid buffer overflow in read_pseudo_def() using sscanf()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
28a643d6c7aab5c8215151bf6397f76978118745 11-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: fix potential stack overflow in get_component()

This fix is similar to the fix for CVE-2012-4024 raised against
unsquashfs, except mksquashfs was not covered by CVE-2012-4024

Fix potential stack overflow in get_component() where an individual
pathname component in a pseudo file (specified on the command line
or in a pseudo file) could exceed the 1024 byte sized targname
allocated on the stack.

Fix by dynamically allocating targname rather than storing it as
a fixed size on the stack.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
06cbcbb61b9ed06aeda39b22ace1b50ecce6dd51 30-Nov-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: dynamically allocate path in dump_pseudo()

rather than allocating it on the stack.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
0e22683cc568631c9f781350cc66ec9d156a3fa9 30-Nov-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: fix memory leak in read_pseudo_def() if exec_file() fails

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
db774e929be5e34d67bb794ca67db0c4a46a55d9 30-Nov-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: Mark fallthrough in case statement as intended

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
c9809c780c288a3a700e831c23606293277d8780 14-Nov-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: move malloc out of if

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
83d42a3fc898962aa1f1e8387f2ccb1114e0d294 01-Nov-2012 Phillip Lougher <phillip@squashfs.org.uk> Update email address

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
2477d0defc9d6dade582bb36596eed2e3cfddf8c 24-Oct-2012 Phillip Lougher <phillip@squashfs.org.uk> error.h: consolidate the various error macros into one header file

This eliminates the multiple separate implementations and brings
all the files into line with respect to synchronising with the
progress bar and exiting squashfs calling prep_exit_mksquashfs().

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
8db6d288d01afc5464965b0bde8106cd7360c543 16-Oct-2012 Phillip Lougher <phillip@squashfs.org.uk> Update copyright dates

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
e4a020b94a099a9259ca4e8a0b6ef5c323e228e6 16-Oct-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: error messages should use ERROR()

and not be output on STDOUT using printf.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
c84386812b714baf60ff5930ec8141cdba7ca2b5 11-Oct-2012 Phillip Lougher <phillip@squashfs.org.uk> pseudo: fix handling of modify pseudo files

Matthieu CASTET reported a bug with modify pseudo files where if
a directory was modified, it would be subsequently treated as
a non-directory for further pseudo modify files.

His provided patch was unfortunately only a partial fix.

This is a full fix for the bug.

Thanks to Matthieu CASTET for reporting the bug.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/pseudo.c
362d59add7a97e9210f844606ffb4f88dcfae8bb 16-Sep-2010 plougher <plougher> Pseudo files: allow the command to be split across multiple lines using '\'
/external/squashfs-tools/squashfs-tools/pseudo.c
e80f5c85abc4160f60a384fffec759900147f494 25-Aug-2010 plougher <plougher> Fix copyright dates - these files didn't exist before 2009!
/external/squashfs-tools/squashfs-tools/pseudo.c
1ebb6e9932d448097d769f1366d8adaae797ea64 22-Jul-2010 plougher <plougher> Wrap some lines
/external/squashfs-tools/squashfs-tools/pseudo.c
8d4404d1f63a558f4903eb8c939bd4306a805d0f 21-Jul-2010 plougher <plougher> Update copyright
/external/squashfs-tools/squashfs-tools/pseudo.c
dc60b1e76d592c97586b2a7cfec46d51d5dd6584 19-May-2010 plougher <plougher> Allow comments in pseudo files
/external/squashfs-tools/squashfs-tools/pseudo.c
c1497d22f2f246fa94a486c4cf0e15c3d8ead4a8 20-Apr-2010 plougher <plougher> Allow S_ISUID, S_ISGID and S_ISVTX flags to be specified in mode.
Thanks to Per Dalén for the bug report.
/external/squashfs-tools/squashfs-tools/pseudo.c
620b717b90536c4de94303ec90c1b0f080817349 10-Sep-2009 plougher <plougher> Fix pseudo file error message and remove superfluous error messages
/external/squashfs-tools/squashfs-tools/pseudo.c
d87d8d1646fcf99bddf4182aab21f282b591b5f8 10-Sep-2009 plougher <plougher> Fix waitpid() exit status check
/external/squashfs-tools/squashfs-tools/pseudo.c
ba674e80dcf875e17ce5eedd057f530ae07a0ab4 10-Sep-2009 plougher <plougher> Various improvements to dynamic pseudo file code. Plus add a waitpid()
when reading dynamic files using a pipe
/external/squashfs-tools/squashfs-tools/pseudo.c
d63f166656cb908337900f53f5332d2b1bd09496 09-Sep-2009 plougher <plougher> Refactor #ifdef USE_TMP_FILE code
/external/squashfs-tools/squashfs-tools/pseudo.c
00d08177d2d5d1b8a5ea3f56459006ba9501335e 03-Sep-2009 plougher <plougher> Don't use temporary file in dynamic pseudo files
/external/squashfs-tools/squashfs-tools/pseudo.c
71b160b831e721311a19da9e7584dd80b4a1abab 06-May-2009 plougher <plougher> Print dynamic pseudo file being run to console
/external/squashfs-tools/squashfs-tools/pseudo.c
124632fcba0bbb99f18d1ef49c563774f6fc9f81 05-May-2009 plougher <plougher> Add new dynamic pseudo file
/external/squashfs-tools/squashfs-tools/pseudo.c
b34f9f606369f564e2824960f80ebd864dfc9e52 26-Apr-2009 plougher <plougher> Add new pseudo set file (file s mode uid gid), which allows you to
change the mode, uid and gid of a file being squashed.
/external/squashfs-tools/squashfs-tools/pseudo.c
ecec62e252167b22c99dd492a7b7440e50cd8892 21-Apr-2009 plougher <plougher> Correct -Wall warnings
/external/squashfs-tools/squashfs-tools/pseudo.c
888885a8f21fc7fa0fc12fcd5037d2862bddbc0a 05-Apr-2009 plougher <plougher> First checkin of pseudo file support files
/external/squashfs-tools/squashfs-tools/pseudo.c