From e06544fab7c58a3cda7d8a3c1efb8144a4a7b932 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 3 May 2012 20:25:12 +0200 Subject: [PATCH] Check -n argument for validity, fix memory errors, fix over-indentation --- ltrace-0.6.0-dash-n.patch | 26 ++++++++++++++++++++++ ltrace-0.6.0-libs-fixes-1.patch | 39 +++++++++++++++++++++++++++++++++ ltrace.spec | 13 ++++++++++- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 ltrace-0.6.0-dash-n.patch create mode 100644 ltrace-0.6.0-libs-fixes-1.patch diff --git a/ltrace-0.6.0-dash-n.patch b/ltrace-0.6.0-dash-n.patch new file mode 100644 index 0000000..d411434 --- /dev/null +++ b/ltrace-0.6.0-dash-n.patch @@ -0,0 +1,26 @@ +diff --git a/options.c b/options.c +index d5edc1a..8dce7f8 100644 +--- a/options.c ++++ b/options.c +@@ -494,9 +494,19 @@ process_options(int argc, char **argv) + case 'L': + options.libcalls = 0; + break; +- case 'n': +- options.indent = atoi(optarg); ++ case 'n': { ++ char *endptr; ++ long int l = strtol(optarg, &endptr, 0); ++ /* Arbitrary cut-off. Nobody needs to indent ++ * more than, say, 8, anyway. */ ++ if (l < 0 || l > 20 || *optarg == 0 || *endptr != 0) { ++ fprintf(stderr, "Invalid argument to -n: '%s'." ++ " Use integer 0..20.\n", optarg); ++ exit(1); ++ } ++ options.indent = (int)l; + break; ++ } + case 'o': + options.output = fopen(optarg, "w"); + if (!options.output) { diff --git a/ltrace-0.6.0-libs-fixes-1.patch b/ltrace-0.6.0-libs-fixes-1.patch new file mode 100644 index 0000000..f10c339 --- /dev/null +++ b/ltrace-0.6.0-libs-fixes-1.patch @@ -0,0 +1,39 @@ +diff --git a/output.c b/output.c +index ac8c9d0..db6e93e 100644 +--- a/output.c ++++ b/output.c +@@ -22,9 +22,10 @@ static int current_depth = 0; + static int current_column = 0; + + static void +-output_indent(Process *proc) { +- current_column += +- fprintf(options.output, "%*s", options.indent * proc->callstack_depth, ""); ++output_indent(struct Process *proc) ++{ ++ int d = options.indent * (proc->callstack_depth - 1); ++ current_column += fprintf(options.output, "%*s", d, ""); + } + + static void +diff --git a/proc.c b/proc.c +index 51833fe..54afbe0 100644 +--- a/proc.c ++++ b/proc.c +@@ -49,6 +49,7 @@ arch_dynlink_done(struct Process *proc) + #endif + + static void add_process(struct Process *proc, int was_exec); ++static void unlist_process(struct Process *proc); + + static int + process_bare_init(struct Process *proc, const char *filename, +@@ -96,7 +97,7 @@ process_bare_destroy(struct Process *proc, int was_exec) + dict_clear(proc->breakpoints); + if (!was_exec) { + free(proc->filename); +- remove_process(proc); ++ unlist_process(proc); + } + } + diff --git a/ltrace.spec b/ltrace.spec index ef83315..67fd381 100644 --- a/ltrace.spec +++ b/ltrace.spec @@ -1,7 +1,7 @@ Summary: Tracks runtime library calls from dynamically linked executables Name: ltrace Version: 0.6.0 -Release: 12%{?dist} +Release: 13%{?dist} URL: http://ltrace.alioth.debian.org/ License: GPLv2+ Group: Development/Debuggers @@ -31,6 +31,8 @@ Patch15: ltrace-0.6.0-detach-sleeping.patch Patch16: ltrace-0.6.0-tail-return.patch Patch17: ltrace-0.6.0-ppc-lwarx.patch Patch18: ltrace-0.6.0-libs.patch +Patch19: ltrace-0.6.0-libs-fixes-1.patch +Patch20: ltrace-0.6.0-dash-n.patch %description Ltrace is a debugging program which runs a specified command until the @@ -60,6 +62,8 @@ execution of processes. %patch16 -p1 %patch17 -p1 %patch18 -p1 +%patch19 -p1 +%patch20 -p1 sed -i -e 's/-o root -g root//' Makefile.in %build @@ -88,6 +92,13 @@ echo ====================TESTING END===================== %config(noreplace) %{_sysconfdir}/ltrace.conf %changelog +* Thu May 3 2012 Petr Machata - 0.6.0-13 +- Check -n argument for validity (ltrace-0.6.0-dash-n.patch) +- Resolves: #818529 +- ltrace-0.6.0-libs-fixes-1.patch + - Fix double free when process initialization fails for some reason + - Don't indent first level of calls + * Mon Apr 30 2012 Petr Machata - 0.6.0-12 - Fix 32-bit builds