2015-04-28 10:50:36 +02:00
|
|
|
Subject: restrict value range passed to isprint function
|
|
|
|
|
|
|
|
According to C standards isprint argument shall be representable as an
|
|
|
|
unsigned char or be equal to EOF, otherwise the behaviour is undefined.
|
|
|
|
|
|
|
|
Passing arbitrary ints leads to segfault in nm program from elfutils.
|
|
|
|
|
|
|
|
Restrict isprint argument range to values representable by unsigned char.
|
|
|
|
|
|
|
|
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
|
|
|
|
---
|
2015-05-01 16:19:03 +02:00
|
|
|
Index: b/argp.h
|
|
|
|
===================================================================
|
|
|
|
--- a/argp.h
|
|
|
|
+++ b/argp.h
|
|
|
|
@@ -23,6 +23,7 @@
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
+#include <limits.h>
|
|
|
|
|
|
|
|
#define __need_error_t
|
|
|
|
#include <errno.h>
|
|
|
|
@@ -577,7 +578,7 @@
|
2015-04-28 10:50:36 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
int __key = __opt->key;
|
|
|
|
- return __key > 0 && isprint (__key);
|
|
|
|
+ return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-01 16:19:03 +02:00
|
|
|
Index: b/argp-parse.c
|
|
|
|
===================================================================
|
|
|
|
--- a/argp-parse.c
|
|
|
|
+++ b/argp-parse.c
|
2015-04-28 10:50:36 +02:00
|
|
|
@@ -1292,7 +1292,7 @@
|
|
|
|
int __key = __opt->key;
|
|
|
|
/* FIXME: whether or not a particular key implies a short option
|
|
|
|
* ought not to be locale dependent. */
|
|
|
|
- return __key > 0 && isprint (__key);
|
|
|
|
+ return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|