]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Correct nested asprintf result check in report_kernel_archive.
authorMark Wielaard <mjw@redhat.com>
Fri, 20 Dec 2013 23:04:21 +0000 (00:04 +0100)
committerMark Wielaard <mjw@redhat.com>
Sat, 21 Dec 2013 16:03:11 +0000 (17:03 +0100)
Because of wrongly placed parens the result of only one asprintf call
was checked correctly. Causing dwfl_linux_kernel_report_offline to return
ENOMEM. Rewrite nested if unlikely check into separate if statements to
make clear what is actually being checked and what the actual unlikely
condition is.

Reported against systemtap "build-id difficulties with hand-built kernels"
https://sourceware.org/bugzilla/show_bug.cgi?id=16358

Reported-by: Crestez Dan Leonard <lcrestez@ixiacom.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/linux-kernel-modules.c

index c3569aa4b7faa89f4ed4f2736d34cb6ecc530a40..fa605bd859a00411c4d38140f9d4e50c2753a7d7 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-20  Mark Wielaard  <mjw@redhat.com>
+
+       * linux-kernel-modules.c (report_kernel_archive): Correct nested
+       asprintf result check for debug.a.
+
 2013-12-18  Mark Wielaard  <mjw@redhat.com>
 
        * derelocate.c (__libdwfl_find_section_ndx): New internal function.
index fe0102829e66485b2e7092f9b52e87c8b4684c7f..530751836539c6bbcd28caa0d170951d509ed856 100644 (file)
@@ -1,5 +1,5 @@
 /* Standard libdwfl callbacks for debugging the running Linux kernel.
-   Copyright (C) 2005-2011 Red Hat, Inc.
+   Copyright (C) 2005-2011, 2013 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -251,9 +251,10 @@ report_kernel_archive (Dwfl *dwfl, const char **release,
     return result;
 
   char *archive;
-  if (unlikely ((*release)[0] == '/'
-               ? asprintf (&archive, "%s/debug.a", *release)
-               : asprintf (&archive, MODULEDIRFMT "/debug.a", *release) < 0))
+  int res = (((*release)[0] == '/')
+            ? asprintf (&archive, "%s/debug.a", *release)
+            : asprintf (&archive, MODULEDIRFMT "/debug.a", *release));
+  if (unlikely (res < 0))
     return ENOMEM;
 
   int fd = try_kernel_name (dwfl, &archive, false);