Fix a problem in handling a failure to open an ELF file

This commit is contained in:
Petr Machata 2014-01-15 18:17:02 +01:00
parent 3eda79ec21
commit c1bce5fd6b
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,36 @@
diff -urp ltrace-0.7.91/libltrace.c master/libltrace.c
--- ltrace-0.7.91/libltrace.c 2014-01-14 16:31:37.696174464 +0100
+++ master/libltrace.c 2013-11-21 14:06:38.623701688 +0100
@@ -113,9 +117,13 @@ ltrace_init(int argc, char **argv) {
if (command) {
/* Check that the binary ABI is supported before
* calling execute_program. */
- struct ltelf lte;
- ltelf_init(&lte, command);
- ltelf_destroy(&lte);
+ {
+ struct ltelf lte;
+ if (ltelf_init(&lte, command) == 0)
+ ltelf_destroy(&lte);
+ else
+ exit(EXIT_FAILURE);
+ }
pid_t pid = execute_program(command, argv);
struct process *proc = open_program(command, pid);
diff -urp ltrace-0.7.91/ltrace-elf.c master/ltrace-elf.c
--- ltrace-0.7.91/ltrace-elf.c 2014-01-14 16:31:37.688174420 +0100
+++ master/ltrace-elf.c 2013-11-22 18:17:11.767721609 +0100
@@ -361,8 +361,11 @@ ltelf_init(struct ltelf *lte, const char
{
memset(lte, 0, sizeof *lte);
lte->fd = open(filename, O_RDONLY);
- if (lte->fd == -1)
+ if (lte->fd == -1) {
+ fprintf(stderr, "Can't open %s: %s\n", filename,
+ strerror(errno));
return 1;
+ }
elf_version(EV_CURRENT);

View File

@ -1,7 +1,7 @@
Summary: Tracks runtime library calls from dynamically linked executables
Name: ltrace
Version: 0.7.91
Release: 5%{?dist}
Release: 6%{?dist}
URL: http://ltrace.alioth.debian.org/
License: GPLv2+
Group: Development/Debuggers
@ -43,6 +43,9 @@ Patch7: ltrace-0.7.91-ppc64-unprelink.patch
# Man page nits. Backport of an upstream patch.
Patch8: ltrace-0.7.91-man.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1044766
Patch9: ltrace-0.7.91-cant_open.patch
%description
Ltrace is a debugging program which runs a specified command until the
command exits. While the command is executing, ltrace intercepts and
@ -64,6 +67,7 @@ execution of processes.
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%build
%configure --docdir=%{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}}
@ -88,6 +92,10 @@ echo ====================TESTING END=====================
%{_datadir}/ltrace
%changelog
* Tue Jan 14 2014 Petr Machata <pmachata@redhat.com> - 0.7.91-6
- Fix a problem when an invalid command has been found
(ltrace-0.7.91-cant_open.patch)
* Tue Jan 14 2014 Petr Machata <pmachata@redhat.com> - 0.7.91-5
- Fix interpretation of x86_64 PLT with IRELATIVE slots.
(ltrace-0.7.91-x86_64-irelative.patch)