pmlogextract with unknown arguments segfaults:
$ gdb --args pmlogextract --help
Segmentation fault (core dumped)
(gdb) bt
#0 __strncmp_ssse3 () at ../sysdeps/x86_64/strcmp.S:209
#1 0x00007ffff7da818f in pmgetopt_r (argc=argc@entry=2,
argv=argv@entry=0x7fffffffdbb8, d=d@entry=0x60d2e0 <opts>)
at getopt.c:1101
#2 0x0000000000405389 in parseargs (argc=argc@entry=2,
argv=argv@entry=0x7fffffffdbb8) at pmlogextract.c:1222
#3 0x0000000000402a05 in main (argc=2, argv=0x7fffffffdbb8) at
pmlogextract.c:1635 at getopt.c:1101
Make sure we signal the end of the options list to pmgetopt via
PMAPI_OPTIONS_END
so that it won't segfault any longer:
./src/pmlogextract/pmlogextract --help
pmlogextract: unrecognized option '--help'
Usage: pmlogextract [options] input-archive output-archive
...
Signed-off-by: Michele Baldessari <michele@xxxxxxxxxx>
---
src/pmlogextract/pmlogextract.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/pmlogextract/pmlogextract.c b/src/pmlogextract/pmlogextract.c
index f0513180eaa9..7c202925f3e2 100644
--- a/src/pmlogextract/pmlogextract.c
+++ b/src/pmlogextract/pmlogextract.c
@@ -40,7 +40,8 @@ static pmLongOptions longopts[] = {
{ "", 1, 'v', "SAMPLES", "switch log volumes after this many samples" },
{ "", 0, 'w', 0, "ignore day/month/year" },
PMOPT_TIMEZONE,
- PMOPT_HOSTZONE
+ PMOPT_HOSTZONE,
+ PMAPI_OPTIONS_END
};
static pmOptions opts = {
--
1.9.0
|