+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
/* 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
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 (unlikely (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)
{
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;