[SATYR PATCH 2/2] abrt: make dso_list parse the correct install time

Martin Milata mmilata at redhat.com
Mon Jun 3 10:45:45 UTC 2013


Previously, all resulting packages had the install time of the last
package in dso_list.

Signed-off-by: Martin Milata <mmilata at redhat.com>
---
 lib/abrt.c    |  5 ++++-
 tests/abrt.at | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/abrt.c b/lib/abrt.c
index 5c721df..87d25b2 100644
--- a/lib/abrt.c
+++ b/lib/abrt.c
@@ -157,11 +157,13 @@ sr_abrt_parse_dso_list(const char *text)
             break;
         }
 
-        pos = strrchr(pos, ' ');
+        char *line = sr_strndup(pos, eol - pos);
+        pos = strrchr(line, ' ');
         if (!pos)
         {
             pos = eol;
             sr_rpm_package_free(dso_package, true);
+            free(line);
             continue;
         }
 
@@ -170,6 +172,7 @@ sr_abrt_parse_dso_list(const char *text)
         // Parse the package install time.
         int len = sr_parse_uint64((const char**)&pos,
                                   &dso_package->install_time);
+        free(line);
 
         if (len <= 0)
         {
diff --git a/tests/abrt.at b/tests/abrt.at
index 4e4d324..8f16c98 100644
--- a/tests/abrt.at
+++ b/tests/abrt.at
@@ -48,6 +48,26 @@ main(void)
     sr_abrt_parse_dso_list(dso_list);
 
   assert(packages);
+
+  struct sr_rpm_package *p = packages;
+  assert(0 == strcmp(p->name, "bzip2-libs"));
+  assert(0 == strcmp(p->version, "1.0.5"));
+  assert(0 == strcmp(p->release, "7.el6_0"));
+  assert(0 == strcmp(p->architecture, "x86_64"));
+  assert(0 == p->epoch);
+  assert(p->install_time == 1342032228);
+
+  /* last package */
+  while(p->next)
+    p = p->next;
+
+  assert(0 == strcmp(p->name, "glibc"));
+  assert(0 == strcmp(p->version, "2.12"));
+  assert(0 == strcmp(p->release, "1.80.el6_3.5"));
+  assert(0 == strcmp(p->architecture, "x86_64"));
+  assert(0 == p->epoch);
+  assert(p->install_time == 1346116822);
+
   sr_rpm_package_free(packages, true);
   return 0;
 }
-- 
1.7.11.7



More information about the Crash-catcher mailing list