Commit c5a855ce by Jim Blandy

Fix from Dale Hawkins:

* cplus-dem.c (mop_up): Set typevec_size to zero, so it'll be
reallocated properly if we use it again.
* cplus-dem.c (demangle_fund_type): Check for buffer overrun.  Be
stricter about syntax.  Always null-terminate string.

From-SVN: r26562
parent 296967fe
...@@ -880,6 +880,7 @@ mop_up (work, declp, success) ...@@ -880,6 +880,7 @@ mop_up (work, declp, success)
{ {
free ((char *) work -> typevec); free ((char *) work -> typevec);
work -> typevec = NULL; work -> typevec = NULL;
work -> typevec_size = 0;
} }
if (work->tmpl_argvec) if (work->tmpl_argvec)
{ {
...@@ -3377,14 +3378,22 @@ demangle_fund_type (work, mangled, result) ...@@ -3377,14 +3378,22 @@ demangle_fund_type (work, mangled, result)
{ {
int i; int i;
++(*mangled); ++(*mangled);
for (i = 0; **mangled && **mangled != '_'; ++(*mangled), ++i) for (i = 0;
(i < sizeof (buf) - 1 && **mangled && **mangled != '_');
++(*mangled), ++i)
buf[i] = **mangled; buf[i] = **mangled;
if (**mangled != '_')
{
success = 0;
break;
}
buf[i] = '\0'; buf[i] = '\0';
++(*mangled); ++(*mangled);
} }
else else
{ {
strncpy (buf, *mangled, 2); strncpy (buf, *mangled, 2);
buf[2] = '\0';
*mangled += 2; *mangled += 2;
} }
sscanf (buf, "%x", &dec); sscanf (buf, "%x", &dec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment