* Re: [PATCH 09/17] libdwfl: Minimize stack usage in dwfl_linux_kernel_report_offline.
@ 2015-05-26 19:38 Roland McGrath
0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2015-05-26 19:38 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 45 bytes --]
OK with unlikely for malloc failure checks.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 09/17] libdwfl: Minimize stack usage in dwfl_linux_kernel_report_offline.
@ 2015-05-23 21:10 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-05-23 21:10 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 2695 bytes --]
Don't stack allocate module name. Also fixes a latent bug (if the module
file didn't have a suffix - which is very unlikely) and an inefficiency.
We only need to substitue chars up to the suffix.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libdwfl/ChangeLog | 5 +++++
libdwfl/linux-kernel-modules.c | 25 +++++++++++++++++--------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 7fbb914..d06d34d 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-19 Mark Wielaard <mjw@redhat.com>
+
+ * linux-kernel-modules.c (dwfl_linux_kernel_report_offline): Don't
+ stack allocate name. Only change chars up to suffix.
+
2015-05-18 Mark Wielaard <mjw@redhat.com>
* dwfl_module_getdwarf.c (find_prelink_address_sync): Allocate
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index e4065d8..66b3ab6 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -1,5 +1,5 @@
/* Standard libdwfl callbacks for debugging the running Linux kernel.
- Copyright (C) 2005-2011, 2013, 2014 Red Hat, Inc.
+ Copyright (C) 2005-2011, 2013, 2014, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -379,13 +379,16 @@ dwfl_linux_kernel_report_offline (Dwfl *dwfl, const char *release,
names. To handle that, we would have to look at the
__this_module.name contents in the module's text. */
- char name[f->fts_namelen - suffix + 1];
- for (size_t i = 0; i < f->fts_namelen - 3U; ++i)
- if (f->fts_name[i] == '-' || f->fts_name[i] == ',')
+ char *name = strndup (f->fts_name, f->fts_namelen - suffix);
+ if (name == NULL)
+ {
+ __libdwfl_seterrno (DWFL_E_NOMEM);
+ result = -1;
+ break;
+ }
+ for (size_t i = 0; i < f->fts_namelen - suffix; ++i)
+ if (name[i] == '-' || name[i] == ',')
name[i] = '_';
- else
- name[i] = f->fts_name[i];
- name[f->fts_namelen - suffix] = '\0';
if (predicate != NULL)
{
@@ -394,17 +397,23 @@ dwfl_linux_kernel_report_offline (Dwfl *dwfl, const char *release,
if (want < 0)
{
result = -1;
+ free (name);
break;
}
if (!want)
- continue;
+ {
+ free (name);
+ continue;
+ }
}
if (dwfl_report_offline (dwfl, name, f->fts_path, -1) == NULL)
{
+ free (name);
result = -1;
break;
}
+ free (name);
}
continue;
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-26 19:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-26 19:38 [PATCH 09/17] libdwfl: Minimize stack usage in dwfl_linux_kernel_report_offline Roland McGrath
-- strict thread matches above, loose matches on Subject: below --
2015-05-23 21:10 Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).