summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2018-05-03libdpkg: Move filesystem nodename hash implementation into a new moduleGuillem Jover5-0/+501
2018-03-26Use internerr() or BUG() instead of assert()Guillem Jover10-47/+90
The problem with assert() is that it does not print the contents of the variables. It also can be disabled on NDEBUG. But we always want these consistency checks no matter what, and they are not performance sensitive anyway. Enable -Wno-nonnull-compare so that we can keep doing run-time non-NULL checks in functions, instead of just compile-time checks.
2018-03-26libdpkg: Make pkg_name() and pkgbin_name() get const structsGuillem Jover4-27/+17
Modifying the struct pkginfo and struct pkgbin complicates how the code is used, and when the function can be called. Let's just initialize the pkgname_archqual variable at parse time, so that we can use it at any time, simplifying the overall code.
2018-03-26libdpkg: Add new str_concat() functionGuillem Jover4-1/+54
2018-03-25libcompat: Convert md5 module to use C99 int typesGuillem Jover2-16/+18
In commit 1f4d0354fc4a8c80c6463b9aaebd93822247341b we opted to map the BSD int types to the C99 to avoid modifying the imported code. But we had to modify it anyway, those types are legacy and we require the C99 ones for the rest of the codebase. So let's just switch to them, and get rid of the type compatibility mapping.
2018-03-25libcompat: Add md5 module to the libcompat-test libraryGuillem Jover1-0/+1
We have slightly modified the source and might continue to do so in the future, we should thus test that it builds correctly, even if we are not needing it on the current build.
2018-01-16libdpkg: Include <sys/sysmacros.h> for makedev()Guillem Jover1-0/+3
The glibc implementation provides this macro in <sys/sysmacros.h> and optionally the BSD variants in <sys/types.h>, although the latter are being deprecated and emit a warning with newer glibc. Conditionally include <sys/sysmacros.h> to prepare for the future removal from glibc.
2017-11-19Merge git://anonscm.debian.org/dpkg/dpkgIgor Pashev114-557/+2902
2017-10-17libdpkg: Clarify subprocess error message by shuffling it aroundGuillem Jover1-5/+5
For command-names the current message was more or less fine. But for command descriptions the message made little sense.
2017-09-24dpkg-deb: Sanity check config maintainer script file type and permissionsGuillem Jover1-0/+2
This is a well-known executable maintainer script, that ideally should be handled by dpkg itself. But for now we will at least sanity check its file type and permissions.
2017-09-07libdpkg: Fix integer overflow in unit testJakub Wilk1-1/+1
Fixes: commit 59f63342b9121b9d941d3dbd09487c953a113f6e Signed-off-by: Guillem Jover <guillem@debian.org>
2017-08-26libdpkg: Fix integer overflow in deb(5) version parserGuillem Jover2-7/+42
The previous code was both not checking for overflows, and triggering undefined behavior as it was overflowing a signed integer. Closes: #868356
2017-05-20build: Do not override the default DEPENDENCIES for libdpkgGuillem Jover1-1/+1
Extend it instead, to make sure that we preserve the libcompat dependency generated from LIBADD.
2017-05-17libdpkg: Improve tar metadata parsingGuillem Jover6-16/+300
Make the existing octal parser more robust, by checking for the expected format of leading zeros or spaces, followed by any ASCII octal characters (0-7), followed by zero or more space or NULs. Even though POSIX specifies that numerical fields should end with at least one space or NUL, we still support this extension which has been present in other implementations for a long time. Add support for base-256 encoded numeric fields, to support large values, for UID/GID, device number, size and even negative timestamps. This is necessary not only to be able to store larger values, but to cover packages that can already be generated by dpkg-deb, given that it uses the system GNU tar when building. Closes: #850834
2017-05-17libdpkg: Do not parse device number for non block nor char tar entry objectsGuillem Jover1-2/+6
We should not try to parse these fields if the tar entry is neither a block nor a char device. On older tar entries these fields will be all NULs, so it would make a parser expecting a somewhat strictly formatted octal value to error out.
2017-05-17libdpkg: Handle files with non-zero sizes in c-tarextract test codeGuillem Jover1-0/+14
The test suite only handles empty files, so it never had any problem with not skipping those objects. But when testing it on common data, and to make the code future-proof, we should just skip the file objects when parsing them.
2017-05-07libdpkg: Add missing symbols to the map fileGuillem Jover1-0/+11
This causes build failures when enabling the shared library.
2017-05-06doc: Spelling fixesJosh Soref11-14/+14
Signed-off-by: Guillem Jover <guillem@debian.org>
2017-02-26libdpkg: Use snprintf() instead of sprintf()Guillem Jover1-4/+5
The field width in a format string does not limit the number of bytes emitted, so we can overflow, even if we are checking the number of bytes written. Use snprintf() to limit the amount written. Warned-by: gcc-7
2017-02-26libcompat: Do not redeclare sys_siglist when the system does soThomas Klausner1-1/+0
This can cause issues if the declaration is not exactly the same, and declaring it when the system already does is bogus no matter what. Signed-off-by: Guillem Jover <guillem@debian.org>
2017-02-01libdpkg: Turn status file parser errors on field blank lines into warningsGuillem Jover2-5/+11
Regression introduced in commit e4cb12a710457b103a7544c4de5e9fc1b2bd24d8. This has caused issues at least on Cydia installations. And it should have been introduced as a lax parsing error, only failing for new packages, and warn on already installed ones. Otherwise one cannot easily recover after upgrading to a new dpkg on an affected system. Reported-by: Jay Freeman <saurik@saurik.com> Stable-Candidate: 1.17.x
2017-01-26build: Disable disk pre-allocation by defaultGuillem Jover1-0/+9
Contrary to what one would expect, this seems to be causing major issues in several "modern" filesystems, as it collides with the heuristics and optimizations that these try to perform. Disable this by default, but let the builder enable it again in case this is not a problem on certain systems.
2017-01-23libdpkg, Dpkg::Version: Do not allow empty epochs and revisionsGuillem Jover2-5/+16
When there's at least one colon or one dash, we should expect epoch and revision numbers.
2017-01-22doc: Fix typos in documentation and code commentsGuillem Jover2-2/+2
Warned-by: codespell, spellintian
2016-12-17libdpkg: Add virtual source:Upstream-Version fieldGuillem Jover1-0/+14
Closes: #844348
2016-12-17libdpkg: Add a new source version accessorGuillem Jover3-0/+20
2016-12-17libdpkg: Refactor varbuf_add_source_version() out from virt_source_version()Guillem Jover4-17/+40
2016-12-17libdpkg: Decrease xz encoder threads to not exceed memory limitsGuillem Jover1-0/+21
Automatically decrease xz encoder threads to try to not exceed available memory limits. This should alleviated the insane requirements of memory needed on 32-bit architectures with many cores, which results in more than the userspace addressable memory, when using settings such as -z9 and/or -Sextreme in dpkg-deb. Closes: #846564
2016-12-17libdpkg: Use lzma_cputhreads() instead of sysconf(_SC_NPROCESSORS_ONLN)Guillem Jover1-1/+5
The former is way more portable than the latter.
2016-12-17libdpkg, Dpkg::Version: Reject empty upstream versionsGuillem Jover2-1/+9
These are not permitted by deb-version(5), but the code was letting those through.
2016-11-16libdpkg: Only preallocate disk size for files bigger than 16 KiBGuillem Jover1-1/+3
Preallocating for very small fails causes some filesystems to degrade performance. Do so only for "big enough" files. Closes: #824636
2016-11-11libdpkg, scripts: Change default color behavior to autoGuillem Jover1-1/+1
Our test run with the setting activated by apt, has not shown any signs of pitch forks nor angry mobs. Let's switch this by default to auto, so that the more clear but still hopefully unobtrusive colors can help people deal with interesting messages, warnings or error conditions.
2016-11-05dpkg: Do not fail when removing non-existent files on read-only filesystemsGuillem Jover1-0/+7
Trying to rmdir(2) or unlink(2) a non-existent pathname on at least Linux returns with EROFS. Handle this case specifically to check if the pathname exists with access(2). Closes: #838877
2016-10-30libdpkg: Simplify and trim-down dlist.h macrosGuillem Jover3-27/+20
Remove unused macros and simplify remaining ones given the current usage in the code base.
2016-10-30libdpkg: Fix free() on uninitialized pointer in error_context_errmsg_format()Guillem Jover1-2/+1
When erroring out inside a recursive error handler the error context errmsg field was not initialized, which meant the a free() was being done on a garbage pointer, crashing the program. Regression introduced in commit 4e1e0e78412060de420d2fa7f8a24231d6eff9bb.
2016-10-30libdpkg: Add new unit test for error handlingGuillem Jover3-0/+131
2016-10-30libdpkg: Improve comment in error_context_errmsg_format()Guillem Jover1-3/+4
The wording was quite confusing on the code flow.
2016-10-30libdpkg: Return error in error_context_errmsg_format() only if truncatedGuillem Jover1-1/+5
In case we have to use the emergency buffer because the previous vasprintf() call failed, we should only return an error code if the vsnprintf() call on the emergency buffer truncates the output.
2016-10-30libdpkg: Only set error context message if it has been formatted correctlyGuillem Jover1-1/+2
We should not be adding junk to the error context message.
2016-10-30libcompat: Disable gettext support in getopt moduleGuillem Jover1-8/+3
We do not carry translations for this module, and it makes it pull libintl for programs that might not use it otherwise.
2016-10-30libcompat: Include getopt module when we need getopt_longGuillem Jover1-0/+4
The latter requires the local getopt implementation, so we need to include it even if the system provides a getopt implementation.
2016-10-30libcompat: Add missing <errno.h> includeGuillem Jover1-0/+1
Warned-by: gcc on AIX
2016-10-30libdpkg: Add <sys/sysmacros.h> on AIX for major() and minor()Guillem Jover1-0/+4
2016-10-30libdpkg: Use our own dpkg_ar_hdr instead of relying on the system oneGuillem Jover3-12/+25
The ar format is not standardized and some systems might provide a different format than the one used by dpkg. For example on AIX.
2016-10-30Dpkg: Add new Dpkg::PROGTAR variable to store GNU tar command nameGuillem Jover2-2/+7
2016-10-30libdpkg: Cast strlen() return value to ssize_t to match write() return typeGuillem Jover1-1/+1
Warned-by: clang
2016-10-30libdpkg: Add missing <string.h> includeGuillem Jover1-0/+1
Warned-by: clang
2016-10-30Cast off_t variables to intmax_t when printing them with %jdGuillem Jover2-4/+5
Warned-by: clang
2016-10-30libdpkg: Rename test suite commands to be prefixed with c- instead of t-Guillem Jover6-11/+10
This should make it more clear that these are not intended to be used directly by the TAP test runner. In addition now we can use the proper name for the .t perl scripts.
2016-10-30libdpkg: Make test main function a TEST_ENTRY macroGuillem Jover22-60/+38
This avoids confusing coverage programs, as the file that actually contains the main function is the test itself.