History log of /external/squashfs-tools/squashfs-tools/read_xattrs.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/read_xattrs.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/read_xattrs.c
3dbea5763e6ed097819a801aaa591999de6ef661 17-Mar-2013 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: Use MEM_ERROR() in get_xattrs()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
7f93de2c834aa491467864f46a7c6a835d6309c5 17-Mar-2013 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: Use MEM_ERROR() in read_xattrs_from_disk()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
446e8eedfd0c6066532c8a9282d3d6cc68f0c85d 17-Mar-2013 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: Use MEM_ERROR() in read_xattr_entry()

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
e781b6f3e84a9469ebb4441b78d22d1a5d134482 17-Mar-2013 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: save_xattr_block() no longer returns failure

Use MEM_ERROR() for malloc failure.

Now MEM_ERROR deals with out of memory, save_xattr_block()
no longer needs to return failure. Remove failure return
and checks for failure.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
e187beaec0595ba323ea5dbadda390786403d539 14-Mar-2013 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: Use error.h for read_xattrs as well

and get rid of the separate error macro implementations
in read_xattrs. This finally unifies all the error handling
into error.h

Read_xattrs.c has for a long time been an annoying special
case because it is used by both Mksquashfs and Unsquashfs,
it couldn't use the error.h infrastructure used by Mksquashfs
because that pulled in dependencies on Mksquashfs that don't
exist in Unsquashs, and it couldn't use the unsquashfs.h
infrastructure used by Unsquashfs because that pulled in
dependencies on Unsquashfs that don't exist in Mksquashfs,
and so it had to define its own macros. But this has meant
it has not benefited from the improvements in error handling
added to the Mksquashfs/Unsquashfs error infrastructure.

The previous commits have finally broken the conflicting
dependencies introduced by error.h, unnecessary dependencies
have been removed and both Mksquashfs and Unsquashfs now
provide the necessary functions used by error.h...

So we can finally drop the read_xattrs.c only error macro
implemenation :-)

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
ceb3eabae205516dc6f91eda3a217c577049d925 28-Jan-2013 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: harden xattr data reading against corrupted filesystems

Harden xattr data 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/read_xattrs.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/read_xattrs.c
1bfe70795da28679fcb5305da586ce6d8118d6bb 28-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> Unsquashfs: don't treat unrecognised xattr prefixes as xattr read failure

There are two users for get_xattr(), Mksquashfs uses it to read the
xattrs from the filesystem on appending, and Unsquashfs uses it
to retrieve the xattrs for writing to disk.

Unfortunately, the two users disagree on what to do with unknown
xattr prefixes, Mksquashfs wants to treat this as fatal otherwise
this will cause xattrs to be be lost on appending. Unsquashfs
on the otherhand should want to retrieve the xattrs which are known and
to ignore the rest, this allows Unsquashfs to cope more gracefully
with future versions which may have unknown xattrs, as long as the
general xattr structure is adhered to, Unsquashfs should be able
to safely ignore unknown xattrs, and to write the ones it knows about,
this is better than completely refusing to retrieve all the xattrs.

So add ignore parameter. If ignore is TRUE then don't treat unknown
xattr prefixes as a failure to read the xattr.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
f43368c59e722b618c5b0f7b2b2f54f34197e894 28-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> read_xattrs: fix xattr free in get_xattr() in error path

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.c
ea0eb6395ebf08dd4d84bf24561330d9d79a6f8f 28-Dec-2012 Phillip Lougher <phillip@squashfs.org.uk> unsquashfs_xattr: fix memory leak in write_xattr()

Fix memory leak in write_xattr() where the xattr_list was
not freed after use.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
/external/squashfs-tools/squashfs-tools/read_xattrs.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/read_xattrs.c
f25a97dc4ba98debc223096be21d6624ae59063e 31-Dec-2010 plougher <plougher> get rid of global.h include
/external/squashfs-tools/squashfs-tools/read_xattrs.c
64e83fda63a1b8408ffbfa466e6c67b0de7a8c99 31-Dec-2010 plougher <plougher> get rid of squashfs_super_block typedef
/external/squashfs-tools/squashfs-tools/read_xattrs.c
1ebb6e9932d448097d769f1366d8adaae797ea64 22-Jul-2010 plougher <plougher> Wrap some lines
/external/squashfs-tools/squashfs-tools/read_xattrs.c
a053b3524f74fe27f83fb28f789f5e80c3a8a7dc 21-Jul-2010 plougher <plougher> Check for read_xattr_failure, and print error messages in read_xattr_failure
/external/squashfs-tools/squashfs-tools/read_xattrs.c
e7b9ec3aee7a10240ad2e17a5c3dd5cf0f5ca092 21-Jul-2010 plougher <plougher> Check return result of save_xattr_block.
/external/squashfs-tools/squashfs-tools/read_xattrs.c
353c6252b9b24ee40d52217b514738ceafe72b83 17-Jul-2010 plougher <plougher> Move prefix_table definition from xattr.h to read_xattrs.c removing
unused definition warning.
/external/squashfs-tools/squashfs-tools/read_xattrs.c
218740042bd6feeda6a281b82d5ea42128e1533d 04-Jul-2010 plougher <plougher> fix copyright dates
/external/squashfs-tools/squashfs-tools/read_xattrs.c
8935dc25479321709c74c2f8214cf5365669100e 02-Jul-2010 plougher <plougher> Add initial support for reading xattrs in unsquashfs using the shared code in
read_xattrs.c. Currently this does nothing as unsquashfs does nothing with
the xattr data...

Plus move get_xattrs out of read_xattrs.c into read_fs.c. It is only used
by mksquashfs, and having it in read_xattrs.c causes link failure in
unsquashfs as generate_xattr is missing.
/external/squashfs-tools/squashfs-tools/read_xattrs.c
71bd4a77a60ceb5e8c1619f8e67e467f55f93560 20-Jun-2010 plougher <plougher> Add some more comments
/external/squashfs-tools/squashfs-tools/read_xattrs.c
ddfc3cb888fdc22552030fa34f9b7c2b55dc1d3d 18-Jun-2010 plougher <plougher> Refactor xattr read code so it can be used by unsquashfs
/external/squashfs-tools/squashfs-tools/read_xattrs.c
923b301e304637fd5e587eb05a6f44558abae2bd 18-Jun-2010 plougher <plougher> Change unsquashfs read_block() to take a void * rather than a char *.
Plus remove obsolete sBlk parameter in mksquashfs read_block() - thereby
unifying the signatures.
/external/squashfs-tools/squashfs-tools/read_xattrs.c
3306cb2b54a60a32664617118336ac141e1471b6 18-Jun-2010 plougher <plougher> change read_fs_bytes() from taking char * to taking void *
/external/squashfs-tools/squashfs-tools/read_xattrs.c
1d065e9f3c6d22a629134837a55538fb8619cfb4 18-Jun-2010 plougher <plougher> Rename read_destination() to read_fs_bytes(). Also don't abort on
I/O error inside read_fs_bytes and instead correctly pass the error up to
higher levels.
/external/squashfs-tools/squashfs-tools/read_xattrs.c
fe5f98e044ce6efb083355d15cef45f4815940c9 18-Jun-2010 plougher <plougher> add new read_xattrs.c file
/external/squashfs-tools/squashfs-tools/read_xattrs.c