aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* ar: switch from alloca to mallocMike Frysinger2024-01-251-1/+4
| | | | | | | | | | | | | If alloca allocates too much stack space, program behavior is undefined, and basically we segfault. There is no way to check whether this will happen ahead of time, so our only choice is to switch to malloc. If we try to allocate too much memory from the heap, we'll get a NULL pointer, and we can diagnose & exit ourselves. Kind of sucks as alloca was a perfect fit here, but since the size is coming directly from user input, we can't trust it is always "reasonable". Bug: https://bugs.gentoo.org/890579 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* ar: handle invalid extended filename offsetsMike Frysinger2024-01-241-2/+8
| | | | | | | | Check the extended filename offset doesn't exceed the size of the extended filename section. Bug: https://bugs.gentoo.org/890579 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* ar: handle invalid ascii numbers betterMike Frysinger2024-01-241-8/+45
| | | | | | | | | | | | | | | | The atoi helper handles signed 32-bit integers, and expects the input strings to be NUL terminated. Some of the fields are larger than what signed 32-bit can handle, and none of them are NUL terminated. The code currently works because it stops processing once it reaches text that is not numeric, and the content that follows each field is always non-numeric (e.g. a space). Add a helper function that leverages strtoll as all of the fields can fit into a signed 64-bit number. If the number is invalid, flag it as such, and normalize it to 0 so the rest of the code can continue on. Bug: https://bugs.gentoo.org/890577 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* unify usage() output across all the toolsMike Frysinger2024-01-241-0/+50
| | | | | | | The scanelf --help output is the best & most flexible, so move that to common code so the rest of the tools can benefit from it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* update copyright headersMike Frysinger2024-01-011-2/+2
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Revert "paxinc: include <alloca.h> for alloca"Mike Frysinger2023-12-141-1/+0
| | | | | | | | | | | This reverts commit 781a3856ae53df051563645b45d8ff7033aea113. The header is already included in porting.h. We want to keep all system headers centralized in porting.h and not sprinkle across the other modules. Signed-off-by: Mike Frysinger <vapier@chromium.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* paxinc: include <alloca.h> for allocaSam James2023-01-291-0/+1
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* Undo IWYU fixesSam James2023-01-291-8/+0
| | | | | | | | | | | | I wasn't paying enough attention, it's better to just fold the needed bits into porting.h. This reverts commit ffedc60fa41d307bda28fd108e6ff1b8da1fc2ee. This reverts commit f8287200aec0ca33ef07fafcdd5aef0aa6eb1306. This reverts commit aa907a42d89ddfd5a7e64d8182a1da35277f2f6e. Bug: https://github.com/gentoo/pax-utils/pull/11#issuecomment-1407566344 Signed-off-by: Sam James <sam@gentoo.org>
* *: IWYU fixes deuxSam James2023-01-291-0/+1
| | | | Signed-off-by: Sam James <sam@gentoo.org>
* *: IWYU fixesSam James2023-01-281-0/+7
| | | | | | | Separate from the first commit as this one was done programmatically with dev-util/include-what-you-use. Signed-off-by: Sam James <sam@gentoo.org>
* split out fs related helper funcs as lib codeMike Frysinger2016-11-121-0/+31
| | | | | This way we can use the funcs in other modules. It makes scanelf a little bigger (~1k), but shouldn't be a big deal overall.
* ar: make sure file name is always NUL terminatedMike Frysinger2016-06-201-1/+2
|
* ar: make sure name is always NUL terminatedMike Frysinger2016-06-191-0/+1
|
* scanelf: do not warn about invalid archive entries by defaultv1.0.4Mike Frysinger2015-07-131-4/+8
| | | | | | | | | It's not uncommon for embedded toolchains or random targets to create their own spin on the archive format. Rather than complain about all of these by default, put it behind the -v flag. It's not like people can do anything about this normally anyways. URL: https://bugs.gentoo.org/428464
* scanelf: include filename/details in all ar related messagesMike Frysinger2015-07-131-4/+4
| | | | | | When scanelf runs on a directory tree, it might issue an error message about invalid data because of one of the files in there. Trying to then track down that file is kind of a pain, so make things more explicit.
* migrate to gitv1.0Mike Frysinger2015-03-021-1/+0
|
* ar_next: fix signed warnings from gcc, and clean up memory when closing archivesMike Frysinger2013-04-101-4/+6
|
* update copyright yearsMike Frysinger2012-11-041-4/+4
|
* add a -C/--nocolor option and respect env $NOCOLOR #332289Mike Frysinger2010-12-081-1/+18
|
* check return value of read() since gcc whines about it nowMike Frysinger2009-03-151-2/+3
|
* convert getstr_perms() to strfileperms() and share it among all filesMike Frysinger2008-12-301-1/+15
|
* use xmalloc() rather than malloc()Mike Frysinger2008-12-301-2/+2
|
* Now I had the specs here anyway, implemented GNU extended filenames as well.Fabian Groffen2008-10-191-3/+23
|
* Made reading archives work.Fabian Groffen2008-10-191-11/+19
| | | | | | | | | | | The Darwin linker creates BSD ar archives, which (stupidly) always use the "extended filename" method to store filenames. For this reason I implemented the BSD extended filename method in paxinc's ar_next. Next to some fixes in the macho code not to free and unmap when this is not desired, this yields in a working scanmacho on static archives. The change has been checked with scanelf against a GNU ELF static archive not to break anything.
* split xfuncs off into a sep file for all utils to use, cleanup misc things, ↵Mike Frysinger2007-08-201-14/+12
| | | | and add some more comments
* - update copyright headersNed Ludd2007-06-091-2/+2
|
* - update copyright headersNed Ludd2007-05-231-3/+3
|
* - single zero byte outside array bounds. Fix from Ludwig Nussel ↵Ned Ludd2007-01-261-2/+2
| | | | <ludwig.nussel@suse.de> Ref: https://bugzilla.novell.com/show_bug.cgi?id=239172
* refactor code a bit to allow to improve support for archive scanningMike Frysinger2006-01-141-19/+30
|
* initial support for reading archive files (*.a)Mike Frysinger2006-01-131-1/+78
|
* update copyright years and unify headers in porting.hMike Frysinger2006-01-051-10/+6
|
* split common non-elf features into paxinc.[ch]Mike Frysinger2005-10-131-0/+20