summaryrefslogtreecommitdiffstats
path: root/src/ar.c
Commit message (Collapse)AuthorAgeFilesLines
* Move the #include <libintl.h> into eu-config.hYonggang Luo2022-10-161-1/+0
| | | | | | | | | | So we do not need include in each file. And indeed the macro #define _(Str) dgettext ("elfutils", Str) access libintl function dgettext, so it's make more sense #include <libintl.h> in file eu-config.h Signed-off-by: Yonggang Luo <[email protected]>
* ar: Correct -N COUNT off-by-oneMark Wielaard2022-09-141-2/+2
| | | | | | | | | | | | | When using instance [COUNT], the instance check is wrong. instance-- == 0 should be --instance == 0. Add a testcase run-ar-N.sh that uses -N COUNT with extract and delete operations checking the right instance was extracted and deleted. https://sourceware.org/bugzilla/show_bug.cgi?id=28725 Reported-by: panxiaohe <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Introduce error_exit as a noreturn variant of error (EXIT_FAILURE, ...)Mark Wielaard2022-03-301-22/+19
| | | | | | | | | | | | error (EXIT_FAILURE, ...) should be noreturn but on some systems it isn't. This may cause warnings about code that should not be reachable. So have an explicit error_exit wrapper that is noreturn (because it calls exit explicitly). Use error_exit in all tools under the src directory. https://bugzilla.redhat.com/show_bug.cgi?id=2068692 Signed-off-by: Mark Wielaard <[email protected]>
* ar: Always close newfd in do_oper_insert.Mark Wielaard2021-04-131-0/+3
| | | | | | | | | newfd is normally created by mkstemp given the original fd exists. Otherwise it will created by open from arfname. In the second case newfd might not get closed. Preventd this by always trying to close it after errout. Signed-off-by: Mark Wielaard <[email protected]>
* ar: Pull should_truncate_fname() into file scopeTimm Bäder2021-02-051-17/+17
| | | | | | Get rid of a nested function this way. Signed-off-by: Timm Bäder <[email protected]>
* src: consistently use _(Str) instead of gettext(Str)Dmitry V. Levin2020-12-161-42/+42
| | | | | | | | | Make use of the _(Str) macro provided by <config.h>. The change was made automatically using the following command: $ git grep -l '\<gettext *(' src |xargs sed -i 's/\<gettext *(/_(/g' Signed-off-by: Dmitry V. Levin <[email protected]>
* src: fix spelling typos in comments and ChangeLogDmitry V. Levin2020-12-121-2/+2
| | | | | | | | | | | | | | | | | | Indeces -> Indices adress -> address affort -> afford dont' -> don't futher -> further higest -> highest indeces -> indices interate -> iterate occured -> occurred overlow -> overflow sectin -> section succesful -> successful teminated -> terminated Signed-off-by: Dmitry V. Levin <[email protected]>
* ar, ranlib: Call fchown before fchmod, explicitly check and ignore errors.Mark Wielaard2020-06-191-26/+39
| | | | | | | | | | | | | In ar and ranlib we don't mind if the fchown call fails (it normally would, then the file simply gets own by the current user). We used to call fchown before fchmod, but that might ignore (or reset) some mode flags, so call fchown first, then try fchmod (like we already do in elfcompress). Also explicitly test and then ignore any errors for chown. We used to do some asm trick, but that confuses some static analyzers (and it is somewhat unreadable). Also split out the giant if statements to make them a little bit more understandable. Signed-off-by: Mark Wielaard <[email protected]>
* ar: Assume epoch if ar_date is bogus.Mark Wielaard2018-10-201-2/+8
| | | | | | | | | | If the ar header contains a bogus ar_date then in verbose mode we would get a NULL pointer from localtime. Just assume the entry was created during the epoch. https://sourceware.org/bugzilla/show_bug.cgi?id=23754 Signed-off-by: Mark Wielaard <[email protected]>
* Consolidate error.h inclusion in system.hRoss Burton2018-07-051-1/+0
| | | | | | | | | error.h isn't standard and so isn't part of the musl C library. To easy future porting, consolidate the inclusion of error.h into system.h. https://sourceware.org/bugzilla/show_bug.cgi?id=21008 Signed-off-by: Ross Burton <[email protected]>
* ar: Check whether ar header values fit.Mark Wielaard2017-09-201-20/+46
| | | | | | | | | | | | | | | | | When compiling with -O3 gcc finds an interesting error: src/ar.c: In function ‘do_oper_insert’: src/ar.c:1077:56: error: ‘%-*ld’ directive output may be truncated writing between 6 and 10 bytes into a region of size 7 [-Werror=format-truncation=] snprintf (tmpbuf, sizeof (tmpbuf), ofmt ? "%-*lo" : "%-*ld", bufsize, val); ^~~~~ The problem is that the ar header values have to fit in a limited (not zero terminated) string. We should check the snprintf return value to see if the values are representable. Also make ar valgrind and ubsan clean and add a minimal sanity test. Reported-by: Matthias Klose <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Move print_version into printversion.{h|c}Ulf Hermann2017-02-171-0/+1
| | | | | | | | Rename version.c so that the implementation is called after the header and the header doesn't clash with the toplevel version.h. print_version depends on argp and is only used in the tools. Signed-off-by: Ulf Hermann <[email protected]>
* http://elfutils.org/ is now hosted at http://sourceware.org/elfutils/Mark Wielaard2016-12-241-15/+0
| | | | | | | | | | | | | | | | | fedorahosted used to be our home, but we are now hosted at sourceware. Change the elfutils project home to http://elfutils.org/ Point hosted services (email, release, git, bug tracker and web pages) to https://sourceware.org/elfutils/ Move design notes from README to NOTES. Add URLs for home, releases, bugs, git and mailinglist to README. Make the --version output of all tools the same by using a common print_version function and update the publicly shown copyright holder to the elfutils developers. Signed-off-by: Mark Wielaard <[email protected]>
* ar: Fix GCC7 -Wformat-length issues.Mark Wielaard2016-11-111-4/+11
| | | | | | | | | | | | GCC7 adds warnings for snprintf formatting into too small buffers. Fix the two issues pointed out by the new warning. The ar header fields are fixed length containing left-justified strings without zero terminator. snprintf always adds a '\0' char at the end (which we then don't copy into the ar header field) and numbers are decimal strings of fixed 10 chars (-Wformat-length thinks formatting them as size_t might overflow the buffer on 64bit arches). Signed-off-by: Mark Wielaard <[email protected]>
* Replace futimes with futimens.Max Filippov2015-05-051-4/+4
| | | | | | | | futimes is not standard function, and it's not available in uClibc. Use futimens which is POSIX. Suggested-by: Mike Frysinger <[email protected]> Signed-off-by: Max Filippov <[email protected]>
* Drop mtrace calls.Max Filippov2015-05-041-4/+0
| | | | | | | mtrace is a GNU extension not supported by uClibc and it's believed to not be really used. Drop mtrace() calls and #include <mcheck.h>. Signed-off-by: Max Filippov <[email protected]>
* ar: Correct operation check when instance_specifed is set.Mark Wielaard2013-10-181-1/+1
| | | | | Reported-by: David Binderman <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* ar.c (do_oper_delete): Fix num passed to memset.David Abdurachmanov2013-01-131-1/+1
| | | | Signed-off-by: David Abdurachmanov <[email protected]>
* Update name, license and contributor policy.Mark Wielaard2012-06-051-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change name from "Red Hat elfutils" to "elfutils". * Update license of standalone tools and test from GPLv2 to GPLv3+. * Change license of libraries from GPLv2+exception to GPLv2/LGPLv3+. * Add Developer Certificate of Origin based contributor policy. top-level: - COPYING: Upgraded from GPLv2 to GPLv3. - CONTRIBUTING, COPYING-GPLv2, COPYING-LGPLv3: New files. - NEWS: Added note about new contribution and license policy. - Makefile.am: Updated to GPLv3, added new files to EXTRA_DIST. - configure.ac: Update to GPLv3, changed AC_INIT name to 'elfutils'. backends, lib, libasm, libcpu, libdw, libdwfl, libebl, libelf: - All files updated to GPLv2/LGPLv3+. Except some very small files (<5 lines) which didn't have any headers at all before, the linker .maps files and the libcpu/defs files which only contain data and libelf/elf.h which comes from glibc and is under LGPLv2+. config: - elfutils.spec.in: Add new License: headers and new %doc files. - Update all license headers to GPLv2/LGPLv3+ for files used by libs. src, tests: - All files updated to GPLv3+. Except for the test bz2 data files, the linker maps and script files and some very small files (<5 lines) that don't have any headers. Signed-off-by: Richard Fontana <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Update copyright yearUlrich Drepper2012-01-211-3/+3
|
* ar: Don't crash when given files but no command.Roland McGrath2012-01-201-0/+7
|
* Support -D in ranlib as in ar.Roland McGrath2012-01-201-13/+6
|
* ar: Implement -D.Roland McGrath2011-11-051-3/+10
|
* ar: Fix a return value check.Roland McGrath2011-11-051-1/+2
|
* Wire up -u option handling in ar.Roland McGrath2011-07-091-1/+5
|
* Fix sloppy #include use, breaks with latest glibc.Roland McGrath2010-01-151-1/+2
|
* ar.c (main): Fix typo in message format.Roland McGrath2009-09-081-1/+1
|
* Use pathconf instead of statfs.Roland McGrath2009-08-141-13/+23
|
* Fix argument handling in ar.Ulrich Drepper2009-02-011-9/+14
|
* Move argp_program_version_hook and argp_program_bug_address variablesUlrich Drepper2009-01-171-2/+3
| | | | in all programs into the .rodata section.
* Unpdate copyright in messages.Ulrich Drepper2009-01-011-2/+2
|
* propagate from branch 'com.redhat.elfutils.disasm' (head ↵Ulrich Drepper2008-01-021-0/+3
| | | | | | d15b4eb794e81e477f9896fe82a74cb5ecf4514c) to branch 'com.redhat.elfutils' (head eaacbf01f8cc89d043ec6eca9b5e35cb5c4cde06)
* Update copyright year.Ulrich Drepper2008-01-021-1/+1
|
* merge of '92c36bfdbc6468d1711c043b530e0dfe5abb6dec'Ulrich Drepper2007-10-161-31/+24
| | | | and 'c22c8c43f8f68b0bffd4d5ccdb2282c958268742'
* Prepare for 0.128 release.Ulrich Drepper2007-06-061-3/+3
| | | | | | Minor fixes. Update gettext files to 0.16.1.
* 2007-02-05 Roland McGrath <[email protected]>Roland McGrath2007-02-061-0/+1
| | | | | * ar.c: Include <limits.h>, since we use LONG_MAX.
* Fix warnings.elfutils-0.126Ulrich Drepper2007-02-051-4/+6
|
* Make symtab a global variable in arlib.c.Ulrich Drepper2007-02-051-29/+17
|
* Implement ar program.Ulrich Drepper2007-02-051-0/+1531
Relax elflint in GNU ld mode for latest idiosyncracies.