aboutsummaryrefslogtreecommitdiff
path: root/lib/common
AgeCommit message (Collapse)Author
2019-12-12Fix out of bounds writes in lzo compressorDavid Oberhollenzer
The liblzo compression functions don't do any bounds checking, instead they expect the destination buffer to be large enough to hold the worst case encoding. This commit modifies the lzo compressor to use a scratch buffer for compression (with worst case size) and only copy to the actual destination if the result fits. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-12-09Only check for OS specific bad filenames when unpackingDavid Oberhollenzer
When converting a SquashFS image to a tarball, it makes no sense to refuse conversion if the filename is considered evil by the OS. This patch adds an option to is_filename_sane to check if the OS has a problem with the given file name. sqfs2tar sets it to false and converts everything while rdsquashfs sets it to true when unpacking. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-25Cleanup: move overflow safe alloc code into libsquashfsDavid Oberhollenzer
There were only a hand full of instances outside libsquashfs that used the alloc code. In most cases, the thing allocated hat its size derived from something already in memory anyway, so it is safe to assume its size fits into a size_t. At the same time, the opencoded Windows path conversion functions are all unified into a single helper function. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-24Cleanup libsquashfs invalid argument error codesDavid Oberhollenzer
- Add an explicit "you're holding it wrong" error code. - Consistently return error codes and not have some special places where -1 is returned. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-24Fix: Move LZO compressor from libsquashfs to libcommonDavid Oberhollenzer
The liblzo2 library is licensed under GPLv2, so it is not possible to distribute binaries of libsquashfs that link against liblzo2 under LGPL. This commit moves the LZO compressor implementation to libcommon, where this isn't a problem, since the tools themselves are licensed under GPLv3. It removes the ability of libsquashfs to read or generate LZO compressed SquashFS images, but the tools still can. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Move some unix header inclusions to compat.hDavid Oberhollenzer
In most cases, including unistd.h and fcntl.h was a left over anyway. In the cases where it was not, move it to compat.h. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-22Ensure that tar2sqfs & sqfs2tar set stdin/out to binary modeDavid Oberhollenzer
As usual, Windows has things different and is the platform where the problem was actually discovered. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-18Add Windows implementation for mkdir_pDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-18Convert the remaining size_t printf format specifiers in libcommonDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-18Remove directory stack codeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-15Extend is_filename_sane reserved character/name checkDavid Oberhollenzer
- Instead of an open coded version, check against a list of bad names. On windows, the comparison needs to be done case insensitive. - If compiling for Windows, include the magic DOS device names in that list. - Also classify filenames as 'insane' if they contain back slashes, on all platforms. - If compiling for Windows, check for reserved characters. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-15Fix build on BSD systemsAlyssa Ross
I tested FreeBSD, DragonflyBSD, NetBSD and OpenBSD and the endian macros weren't necessary (and in fact caused errors) on all of them. Because OpenBSD ships with an ancient GCC that doesn't support the checked addition/multiplication builtins, the build there would fail unless built with CC=cc or CC=clang. I changed configure.ac to prefer cc over gcc, so that the distribution's compiler preference is respected. (The default is [gcc cc]). I had to move AC_PROG_CC above LT_INIT because otherwise LT_INIT would run AC_PROG_CC first, and we wouldn't have a chance to use non-default parameters.
2019-11-06Cleanup: remove some no longer needed header inclusionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Cleanup: remove BSD style __prognameDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Cleanup: remove unused stdout sqfs_file_t wrapperDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Remove raw file descriptors from tar read pathDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Remove raw file descriptors from unpack write pathsDavid Oberhollenzer
Instead, use stdio FILE pointers. On POSIX systems, use fileno to get the file descriptor and hopefully create sparase files. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-23bugfix: Check no_xattr flagUzi Erdenebileg
2019-10-08Remove maximum queue backlog guestimation.David Oberhollenzer
Partially revers 2b7df394057c013fd042b85a4d5fd0104ba4a9be. Making the queue fill the entire RAM had some unintended side effects that need further investigation. For now, revert back to the old behaviour. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Make sure the statistics counters are initialized to 0David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Do an explicit "is filename sane" checkDavid Oberhollenzer
Until now, filenames containing '/' or being equal to '..' or '.' where not handled explicitly, because they are canonicalized later, which will then fail. This commit adds an explicit check to make those fail immediately with a clear, specific error message. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move libutil related headers to "util" sub directoryDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Replace write_data in libcommon with less generic, opencoded oneDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Move print_version declaration from util.h to common.hDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move directory handling code to libcommonDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Add an implementation for an sqfs_file_t writing to stdoutDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Rename libsqfshelper to libcommonDavid Oberhollenzer
That is IMO less confusing and express what it is (i.e. what it has become) more clearly, i.e. common code shared by the utilities. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>