changeset 2698:d8df26f08486

[xemacs-hg @ 2005-03-29 02:52:42 by james] Fix off-by-one error possibly causing backtrace overflow. See xemacs-patches message with ID <psbr954s83.fsf@diannao.ittc.ku.edu>.
author james
date Tue, 29 Mar 2005 02:52:50 +0000
parents 6bc1f2c5c30e
children 96036853a107
files src/ChangeLog src/dumper.c
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Mar 28 21:51:30 2005 +0000
+++ b/src/ChangeLog	Tue Mar 29 02:52:50 2005 +0000
@@ -1,3 +1,10 @@
+2005-03-26  Jerry James  <james@xemacs.org>
+
+	* dumper.c (BACKTRACE_MAX): New constant defining length of static
+	backtrace array.
+	* dumper.c (pdump_bump_depth): Use it, and avoid buffer overflow
+	by fixing comparison.
+
 2005-02-24  Andrey Slusar  <anrays@gmail.com>
 
         * unexelf.c: define `Elfw(type)' for FreeBSD alpha and amd64. 
--- a/src/dumper.c	Mon Mar 28 21:51:30 2005 +0000
+++ b/src/dumper.c	Tue Mar 29 02:52:50 2005 +0000
@@ -520,12 +520,14 @@
   return 0;
 }
 
+#define BACKTRACE_MAX 65536
+
 static struct
 {
   struct lrecord_header *obj;
   int position;
   int offset;
-} backtrace[65536];
+} backtrace[BACKTRACE_MAX];
 
 static int pdump_depth;
 
@@ -568,7 +570,7 @@
 pdump_bump_depth (void)
 {
   int me = pdump_depth++;
-  if (me > 65536)
+  if (me >= BACKTRACE_MAX)
     {
       stderr_out ("Backtrace overflow, loop ?\n");
       ABORT ();