libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libunwind] Re: src/os-linux.h: scan_dec() and scan_char() may step past


From: David Mosberger
Subject: [libunwind] Re: src/os-linux.h: scan_dec() and scan_char() may step past null ter minator
Date: Wed, 9 Jun 2004 16:03:25 -0700

>>>>> On Tue, 8 Jun 2004 18:18:01 -0700 , Mark Young <address@hidden> said:

  Mark> scan_dec() should probably not advance cp beyond any non-digit
  Mark> character it encounters.

Yes, that was a typo.

  Mark> scan_char() should not advance cp past a null character.

I don't think this can happen with the MAPS file, but I do agree that it's
better to be on the defensive side here.

Can you confirm that the attached patch cures the problems you were seeing?

Thanks,

        --david

===== src/os-linux.h 1.5 vs edited =====
--- 1.5/src/os-linux.h  Wed Apr 21 00:24:34 2004
+++ edited/src/os-linux.h       Wed Jun  9 16:01:47 2004
@@ -139,9 +139,12 @@
 
   while (1)
     {
-      digit = *cp++;
+      digit = *cp;
       if ((digit - '0') <= 9)
-       digit -= '0';
+       {
+         digit -= '0';
+         ++cp;
+       }
       else
        break;
       val = (10 * val) + digit;
@@ -159,7 +162,11 @@
   if (!cp)
     return NULL;
 
-  *valp = *cp++;
+  *valp = *cp;
+
+  /* don't step over NUL terminator */
+  if (*cp)
+    ++cp;
   return cp;
 }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]