History log of /external/squashfs-tools/squashfs-tools/unsquash-4.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ef15e43b707f22d64c13e9b2ca0eae8b165a1690 19-Apr-2013 Phillip Lougher <phillip@squashfs.org.uk> Move SQUASHFS_LEXX and SQUASHFS_SWAP_{SHORTS:INTS:LONGS} into squashfs_swap.h

Plus move definition of SQUASHFS_MEMCPY as well into squashfs_swap.h

Now that the separate implementations in mksquashfs.h and read_fs.h
are identical we can have one implementation, and we can
put it with the other swap macros.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.c
690d91306e8b20400ae8c36fd558604189b70bdc 18-Apr-2013 Phillip Lougher <phillip@squashfs.org.uk> Swap source and destination in macros in disk -> host reading code

Many years ago when Squashfs used bitfields the copying swap
macros relied on s(source) (the first parameter) to be a pointer
to the appropriate structure type.

When swapping from the host order to disk order, source was a
pointer to the appropriate type, and destination was an unaligned
pointer. However, when swapping from disk order to host order in
code that read from disk, it was the destination that was a pointer
to the appropriate type, and source was an unaligned pointer. To
accomodate this, the sense of the parameters was swapped, so the
destination pointer was given first, and then the source pointer.

This was a fairly horrible hack. Now that the rewritten swap
macros no longer require either the source or destination pointer
to be of the appropriate type, we can swap the parameters around
in the disk -> host reading code, so that all code uses
source then destination order.

Note: the Unsquashfs code that reads legacy 1.x, 2.x and 3.x
filesystems still uses the original bitfield swapping macros,
and the requirement that the first parameter is of the appropriate
type remains, this could be changed too (as there's no longer
any code which uses the macros to swap from host -> disk order)
but the swapping code is fossilised and in deep maintenance mode, and
only essential changes are made. This largely cosmetic change
(especially as the code isn't developed anymore and so any
additional swapping macros is unlikely) isn't considered sufficiently
essential to risk adding inadvertant bugs.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.c
e1542da6a3f99db8dc60b5cad891547e047861b7 01-Feb-2013 Phillip Lougher <phillip@squashfs.org.uk> unsquashfs: fix read_directory_table() parameter

sBlk.s.fragment_table_start isn't the end of the
directory table, it instead points to the
fragment_index_table, in which the first index of that
points to the end of the directory table. The only exception
to that is where fragments == 0, where fragment_table_start
does represent the end of the directory table.

The upshot of this is that for years Unsquashfs has been
reading and decompressing the directory_table and the
table after it. Not a major bug, but a waste of memory
all the same.

It has shown up now because of the additional sanity checks
when reading metadata blocks that have been added recently,
where all metadata blocks in the directory table bar the last one
should be SQUASHFS_METADATA_SIZE in size.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.c
fba58384220f2bdbfa27aaa32469a7085fb225c4 28-Jan-2013 Phillip Lougher <phillip@squashfs.org.uk> unsquash-4.c: harden uid/gid and fragment table reading against corrupted data

Harden uid/gid and fragment table reading, checking against
unexpected metadata block length, ensuring no buffer
overflow/underflow occurs.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.c
cf5c8b43f14bad020372fe55fb237eb2ae2b28d4 25-Jan-2013 Phillip Lougher <phillip@squashfs.org.uk> unsquashfs: prevent buffer {over|under}flow in read_block() with corrupted filesystems

Prevent buffer overflow and underflow in read_block() with corrupted
filesystems.

Overflow is easy to understand, read_block() is called to read the next
metadata block pointed to by <start>... Often the buffer passed in is
large enough to hold the expected return bytes, which can be less than
SQUASHFS_METADATA_SIZE. For example filesystem tables are compressed
in SQUASHFS_METADATA_SIZEd chunks, the last compressed chunk will normally
be smaller than SQUASHFS_METADATA_SIZE, so when read_block() is called,
the passed buffer is only large enough to hold the expected size.

Underflow is rather more subtle, when read_block() is called, it is
expected that the returned block will fill the expected amount of
bytes in the filesystem table (stored as an array). If the returned
block is smaller than expected, then there will be uninitialised
data in the filesystem table which will cause unexpected behaviour later.

Fix both cases by passing in an additional parameter <expected>
which contains the expected number of bytes in the metadata block.
Refuse to read blocks which are larger than expected to avoid
buffer overflow and also return error if the block proves to be
smaller than expected, to avoid using unitialised data.

For the callers where the expected number of bytes is unknown support
<expected> containing 0, in which case the metadata block is checked to
ensure it doesn't overflow a SQUASHFS_METADATA_SIZEd buffer. Callers of
read_block() with <expected> == 0 are expected to pass in a
SQUASHFS_METADATA_SIZEd buffer. For instance with compressor specific
options data, the correct length is only known by the compressor specific
code, and this is later called to check the length.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.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/unsquash-4.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/unsquash-4.c
916c28e94a1e7c16e06811ba0f8b23e428597bcb 19-Jan-2012 Phillip Lougher <phillip@squashfs.org.uk> unsquashfs: completely empty filesystems incorrectly generate an error

In squashfs_opendir() if the directory is empty, skip the
unnecessary lookup_entry, this fixes the corner case with
completely empty filesystems where lookup_entry correctly
returning -1 is incorrectly treated as an error

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.c
cc7cea5b0d004fbaaf5e1060e6ed0fa9367e7ef0 13-Mar-2011 Phillip Lougher <phillip@lougher.demon.co.uk> unsquashfs: add checks for corrupted data in opendir functions

Add checks for corrupted data in squashfs_opendir (squashfs_opendir_1,
squashfs_opendir_3 and squashfs_opendir_4), and check for this in
pre_scan() and dir_scan().

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
/external/squashfs-tools/squashfs-tools/unsquash-4.c
9b393553bbca1d7efc755a4b73e64407a526ef11 31-Dec-2010 plougher <plougher> get rid of squashfs_dir_entry typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
2611d39a5fcea87d4d5160d3d9bfe1c6aa92729c 31-Dec-2010 plougher <plougher> get rid of squashfs_ldir_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
9d80a6074011ca775b99c2ca2466ef077f6d1157 31-Dec-2010 plougher <plougher> get rid of squashfs_dir_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
5ae6e956cc5d10aee13744cef8c0caa4208a169e 31-Dec-2010 plougher <plougher> get rid of squashfs_symlink_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
1e6ac4a05f89feba7b41571ef0936aa1a3d445df 31-Dec-2010 plougher <plougher> get rid of squashfs_lreg_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
8701ed64d3241ac3c86db2b6e303769450eac867 31-Dec-2010 plougher <plougher> get rid of squashfs_reg_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
0b4ee5b4b390a9c2c92dfaa3eec9bdee1182e061 31-Dec-2010 plougher <plougher> get rid of squashfs_ldev_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
c70c63397c3d8117c9f24ec29fa52ba401ea1608 31-Dec-2010 plougher <plougher> get rid of squashfs_dev_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
aa0d122348bd8ec500bee33654caf5f34f6644d6 31-Dec-2010 plougher <plougher> get rid of squashfs_lipc_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
520e1a144c9a6c957754f93dc8830f884fe5669b 31-Dec-2010 plougher <plougher> get rid of squashfs_dir_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
8ed84b96ca36da8147993935b951918359d8f20a 31-Dec-2010 plougher <plougher> get rid of squashfs_fragment_entry typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
2625a3d8f39b94c4841bd605361f4b575b0dc1a5 31-Dec-2010 plougher <plougher> get rid of squashfs_fragment_index typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
8973a12943b86e759a6391995271fa620d73483f 31-Dec-2010 plougher <plougher> get rid of squashfs_inode_header typedef
/external/squashfs-tools/squashfs-tools/unsquash-4.c
b3bc96cfe1fb6d566ba8cb79aa30a72d298181bd 16-Dec-2010 plougher <plougher> Move dir assignment out of if in squashfs_opendir_4()
/external/squashfs-tools/squashfs-tools/unsquash-4.c
9f421ce84c39563c4b7f53601e45bf809c5b8641 16-Dec-2010 plougher <plougher> Move fragment_table assignment out of if in read_fragment_table_4()
/external/squashfs-tools/squashfs-tools/unsquash-4.c
f2c8b3ecba4b9bdb74f3a178bf7c32a67ec90511 24-Oct-2010 plougher <plougher> Fix block calculation error with regular files when file size is
between 2^32-block_size+1 and 2^32-1
/external/squashfs-tools/squashfs-tools/unsquash-4.c
3c13c3362c168c1106c98b271f557bf02ff6ebc1 25-Aug-2010 plougher <plougher> Fix copyright dates - these files didn't exist before 2009, although
strictly speaking some of the code did in unsquashfs.c
/external/squashfs-tools/squashfs-tools/unsquash-4.c
3bd47f3d63465bc99a476b1912571747b4466676 22-Jul-2010 plougher <plougher> Wrap some lines
/external/squashfs-tools/squashfs-tools/unsquash-4.c
1fe336854a7799b2ea1f70747f2b6cf38b6ca9cb 22-Jul-2010 plougher <plougher> Make opendir_4 fail on malloc and realloc failure
/external/squashfs-tools/squashfs-tools/unsquash-4.c
1c19618b8016d1c35528c77eebc5fde8fc36309c 22-Jul-2010 plougher <plougher> Abort if the mapping from deirectory start block to uncompressed block in
memory cannot be found. This is indicative of a corrupt filesystem and it
is pointless to continue
/external/squashfs-tools/squashfs-tools/unsquash-4.c
366afb0f46069111985689e2c134f10837586be4 22-Jul-2010 plougher <plougher> read_inode no longer returns error, and so delete the checks in the
filesystem specific files
/external/squashfs-tools/squashfs-tools/unsquash-4.c
a3bbedd581c7022ae2a7b940e967ada58ca47d03 22-Jul-2010 plougher <plougher> Abort if the mapping from on disk block location to locatiion of uncompressed
block in memory cannot be found. This is indicative of a corrupt filesystem
and it is pointless to continue
/external/squashfs-tools/squashfs-tools/unsquash-4.c
eca8d438c9b00aaf191de7c79f845ca5122f09b2 22-Jul-2010 plougher <plougher> Abort on unknown inode, rather than just ignore it. An unknown inode is
indicative of a corrupt filesystem, and it is pointless to continue.
/external/squashfs-tools/squashfs-tools/unsquash-4.c
8d4404d1f63a558f4903eb8c939bd4306a805d0f 21-Jul-2010 plougher <plougher> Update copyright
/external/squashfs-tools/squashfs-tools/unsquash-4.c
fdbbd7d7e595a227e0c259fa4afc872098c9e471 04-Jul-2010 plougher <plougher> Record the xattr in struct dir and struct squashfs_file, and pass to
set_attributes.
/external/squashfs-tools/squashfs-tools/unsquash-4.c
12c899489159bbf0b30054b970a96c45fa2a1035 04-Jul-2010 plougher <plougher> Add xattr field to struct inode, and add support for reading xattr in
read_inode_4. All other read_inode_x functions also now set xattr to the
invalid value.
/external/squashfs-tools/squashfs-tools/unsquash-4.c
27c4b6f7f6a33bf7711c0ee8cd563e4604dc5861 02-Jul-2010 plougher <plougher> Replace fields in struct super_block copied from struct squashfs_super_block
with a nested struct squashfs_super_block
/external/squashfs-tools/squashfs-tools/unsquash-4.c
176b325add10f6b9846f771f75d8543364d4c121 18-Jun-2010 plougher <plougher> change unsquashfs read_block to take an fd
/external/squashfs-tools/squashfs-tools/unsquash-4.c
3306cb2b54a60a32664617118336ac141e1471b6 18-Jun-2010 plougher <plougher> change read_fs_bytes() from taking char * to taking void *
/external/squashfs-tools/squashfs-tools/unsquash-4.c
86561909d9ca51a4e4ce4efcfea30b41d1d08275 18-Jun-2010 plougher <plougher> rename read_bytes() to read_fs_bytes() to be consistent with mksquashfs.
Also pass fd explicitly into function, again to be consistent with mksquashfs.
/external/squashfs-tools/squashfs-tools/unsquash-4.c
c067c39e29519a34de591b9d849eddc4d4309bf3 01-Mar-2010 plougher <plougher> Fix alignment issues with memcpy and char buffers
/external/squashfs-tools/squashfs-tools/unsquash-4.c
c34d1aab6bda93bca9dbd82a7fed8358018f8af0 21-Apr-2009 plougher <plougher> Fix return in read_fragment_table_4
/external/squashfs-tools/squashfs-tools/unsquash-4.c
3e23745c113c8e94aed1a84c1a06f407e8efa0a5 31-Mar-2009 plougher <plougher> More code tidying
/external/squashfs-tools/squashfs-tools/unsquash-4.c
62c03d065d9e53557248a1db83a0e1e162fc872f 30-Mar-2009 plougher <plougher> Code tidy
/external/squashfs-tools/squashfs-tools/unsquash-4.c
a48e06d754e712a9f5a8a08dde6bc98f3e1c7a13 27-Mar-2009 plougher <plougher> Change read_uids_guids_4() to return an error condition
/external/squashfs-tools/squashfs-tools/unsquash-4.c
c124cfce9dfab623547c2bfd8bf6ca148273b09c 27-Mar-2009 plougher <plougher> read_fragment_table_4() now returns error condition
/external/squashfs-tools/squashfs-tools/unsquash-4.c
8e0f7a2c4f925edeac572c3fc4135164f23b1445 26-Mar-2009 plougher <plougher> More TRACE statements
/external/squashfs-tools/squashfs-tools/unsquash-4.c
72e046b38bb6d0c28e84f12788c295b9396b3ed5 26-Mar-2009 plougher <plougher> Add TRACE statement and an extra ERROR statement
/external/squashfs-tools/squashfs-tools/unsquash-4.c
194a8453c43bd64806cd322dcf98b546ddfaa851 24-Mar-2009 plougher <plougher> Add sparse field
/external/squashfs-tools/squashfs-tools/unsquash-4.c
217007850275c69a56ab4789aa189730d58f7f34 24-Mar-2009 plougher <plougher> Alloc symlink as necessary
/external/squashfs-tools/squashfs-tools/unsquash-4.c
d54f4121ee9097bf400710def311dca5abf310e2 19-Mar-2009 plougher <plougher> Implement read_ids_guids_4()
/external/squashfs-tools/squashfs-tools/unsquash-4.c
9c9bbf2cb86159b10f822e294408f815d0ab87ec 19-Mar-2009 plougher <plougher> Add #include "read_fs.h" which defines definitions needed by squashfs_swap.h
/external/squashfs-tools/squashfs-tools/unsquash-4.c
dd4ef637b857d0faa21ecbea96d1356bb656b441 19-Mar-2009 plougher <plougher> Fix typo, inodep should be inode
/external/squashfs-tools/squashfs-tools/unsquash-4.c
e5343097e6c5e5a03c220c19638565d62306c199 19-Mar-2009 plougher <plougher> Temporarily make uids and gids owned by root in read_inode_4 (the
proper read_uids_guids_4 function doesn't exist yet)
/external/squashfs-tools/squashfs-tools/unsquash-4.c
d9b7f93722d2ae4bf576169384f3912ee5e17c55 18-Mar-2009 plougher <plougher> Oops fix typo
/external/squashfs-tools/squashfs-tools/unsquash-4.c
d0294121789264f704ec49101e2857f449a6b249 18-Mar-2009 plougher <plougher> Add empty read_uids_guids_4
/external/squashfs-tools/squashfs-tools/unsquash-4.c
3fdd79864856232f3a4252323014a85fc829d848 18-Mar-2009 plougher <plougher> Fixup squashfs_opendir_4
/external/squashfs-tools/squashfs-tools/unsquash-4.c
f873c6f3d64f4daa019b0b17b5074ddb4688e4f4 18-Mar-2009 plougher <plougher> Fixup read_inode_4
/external/squashfs-tools/squashfs-tools/unsquash-4.c
c632367dbaa66289a70d2fe08c24c5f29cdeb2bc 17-Mar-2009 plougher <plougher> Fixup read_fragment_table_4 for 4.0 layout, replacing copying swap macros with
new inswap swap macros, and adding static local fragment_table definition
/external/squashfs-tools/squashfs-tools/unsquash-4.c
4b6ab629b67f61aead81bc3a3b91eb07ce23d94d 17-Mar-2009 plougher <plougher> Rename all xxx_3 functions to xxx_4
/external/squashfs-tools/squashfs-tools/unsquash-4.c
d3be83e248458fc8b1b6c8a304b833a7e18a6183 17-Mar-2009 plougher <plougher> Rename all xxx_3 structures to xxx
/external/squashfs-tools/squashfs-tools/unsquash-4.c
8d4c333a95fd042e2e926b91857939d88379c8d5 16-Mar-2009 plougher <plougher> First checkin of unsquash-4.c. Currently mostly just a copy of
unsquash-3.c
/external/squashfs-tools/squashfs-tools/unsquash-4.c