aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>1999-03-30 16:12:25 +0000
committerTom Tromey <tromey@gcc.gnu.org>1999-03-30 16:12:25 +0000
commit4cc48683f65e236df8d246207c8958d42d3c069a (patch)
treefa04c5473f236523e039d0d8d90c7adbb9397355
parent85a0b07565f2c95a403df910f5d1ff7b2f9a462f (diff)
downloadgcc-4cc48683f65e236df8d246207c8958d42d3c069a.zip
gcc-4cc48683f65e236df8d246207c8958d42d3c069a.tar.gz
gcc-4cc48683f65e236df8d246207c8958d42d3c069a.tar.bz2
cplus-dem.c (consume_count): If `count' wraps, return 0 and don't advance input pointer.
* cplus-dem.c (consume_count): If `count' wraps, return 0 and don't advance input pointer. (demangle_class_name): If consume_count didn't find a count, do nothing. Don't bother with `strlen' sanity check; consume_count does it for us. From-SVN: r26068
-rw-r--r--libiberty/ChangeLog8
-rw-r--r--libiberty/cplus-dem.c14
2 files changed, 20 insertions, 2 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index f3234ea..8a1965b 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+1999-03-30 Tom Tromey <tromey@cygnus.com>
+
+ * cplus-dem.c (consume_count): If `count' wraps, return 0 and
+ don't advance input pointer.
+ (demangle_class_name): If consume_count didn't find a count, do
+ nothing. Don't bother with `strlen' sanity check; consume_count
+ does it for us.
+
Thu Mar 11 01:22:58 1999 Mumit Khan <khan@xraylith.wisc.edu>
* pexecute.c (__CYGWIN32__): Rename to
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index a3eb85f..ec05edf 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -428,12 +428,22 @@ static int
consume_count (type)
const char **type;
{
- int count = 0;
+ unsigned int count = 0;
+ char *save = *type;
while (isdigit ((unsigned char)**type))
{
count *= 10;
count += **type - '0';
+ /* A sanity check. Otherwise a symbol like
+ `_Utf390_1__1_9223372036854775807__9223372036854775'
+ can cause this function to return a negative value.
+ In this case we just consume until the end of the string. */
+ if (count > strlen (*type))
+ {
+ *type = save;
+ return 0;
+ }
(*type)++;
}
return (count);
@@ -1946,7 +1956,7 @@ demangle_class_name (work, mangled, declp)
int success = 0;
n = consume_count (mangled);
- if ((int) strlen (*mangled) >= n)
+ if (n > 0)
{
demangle_arm_hp_template (work, mangled, n, declp);
success = 1;