summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/NEWS3
-rw-r--r--src/option.cc5
-rw-r--r--test/regress/1222.test7
3 files changed, 15 insertions, 0 deletions
diff --git a/doc/NEWS b/doc/NEWS
index a7c9bbb5..39fce3d6 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -48,6 +48,9 @@
- Fix use-after-free issue with deferred postings (bug #1723, TALOS-2017-0304,
CVE-2017-2808)
+- Fix possible stack overflow in option parsing routine (bug #1222,
+ CVE-2017-12481)
+
- Fix possible stack overflow in date parsing routine (bug #1224,
CVE-2017-12482)
diff --git a/src/option.cc b/src/option.cc
index ab6c37e0..81f9af5b 100644
--- a/src/option.cc
+++ b/src/option.cc
@@ -42,6 +42,11 @@ namespace {
{
char buf[128];
char * p = buf;
+
+ if (name.length() > 127) {
+ throw_(option_error, _f("Illegal option --%1%") % name);
+ }
+
foreach (char ch, name) {
if (ch == '-')
*p++ = '_';
diff --git a/test/regress/1222.test b/test/regress/1222.test
new file mode 100644
index 00000000..535a0e32
--- /dev/null
+++ b/test/regress/1222.test
@@ -0,0 +1,7 @@
+--fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
+
+test reg -> 1
+__ERROR__
+While parsing file "$FILE", line 1:
+Error: Illegal option --fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
+end test