Fixed serious stack-bug in odr_cons_begin
authorSebastian Hammer <quinn@indexdata.com>
Fri, 10 Mar 1995 11:44:40 +0000 (11:44 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Fri, 10 Mar 1995 11:44:40 +0000 (11:44 +0000)
odr/Makefile
odr/ber_tag.c
odr/odr.c
odr/odr_cons.c

index 7c391e6..deb99e4 100644 (file)
@@ -1,11 +1,11 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.5 1995-03-08 12:11:59 quinn Exp $
+# $Id: Makefile,v 1.6 1995-03-10 11:44:40 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
-#CFLAGS= -g -Wall -pedantic -ansi -DODR_DEBUG
+CFLAGS= -g -Wall -pedantic -ansi -DODR_DEBUG
 DEFS=$(INCLUDE)
 LIB=odr.a
 PO = odr_bool.o ber_bool.o ber_len.o ber_tag.o odr_util.o odr_null.o \
index fb16296..64c15e0 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_tag.c,v $
- * Revision 1.7  1995-03-08 12:12:13  quinn
+ * Revision 1.8  1995-03-10 11:44:40  quinn
+ * Fixed serious stack-bug in odr_cons_begin
+ *
+ * Revision 1.7  1995/03/08  12:12:13  quinn
  * Added better error checking.
  *
  * Revision 1.6  1995/02/14  11:54:33  quinn
@@ -73,8 +76,8 @@ int ber_tag(ODR o, void *p, int class, int tag, int *constructed, int opt)
            o->bp += rd;
            o->left -= rd;
 #ifdef ODR_DEBUG
-           fprintf(stderr, "\n[class=%d,tag=%d,cons=%d]", class, tag,
-               *constructed);
+           fprintf(stderr, "\n[class=%d,tag=%d,cons=%d,stackp=%d]", class, tag,
+               *constructed, o->stackp);
 #endif
            return 1;
        case ODR_DECODE:
@@ -92,8 +95,8 @@ int ber_tag(ODR o, void *p, int class, int tag, int *constructed, int opt)
                    return 0;
                }
 #ifdef ODR_DEBUG
-               fprintf(stderr, "\n[class=%d,tag=%d,cons=%d]", lclass, ltag,
-                   lcons);
+               fprintf(stderr, "\n[class=%d,tag=%d,cons=%d,stackp=%d]", lclass, ltag,
+                   lcons, o->stackp);
 #endif
            }
            if (class == lclass && tag == ltag)
index bea667c..bfa8334 100644 (file)
--- a/odr/odr.c
+++ b/odr/odr.c
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr.c,v $
- * Revision 1.6  1995-03-08 12:12:15  quinn
+ * Revision 1.7  1995-03-10 11:44:41  quinn
+ * Fixed serious stack-bug in odr_cons_begin
+ *
+ * Revision 1.6  1995/03/08  12:12:15  quinn
  * Added better error checking.
  *
  * Revision 1.5  1995/03/07  13:28:57  quinn
@@ -40,7 +43,8 @@ char *odr_errlist[] =
     "Unexpected tag",
     "Other error",
     "Protocol error",
-    "Malformed data"
+    "Malformed data",
+    "Stack overflow"
 };
 
 void odr_perror(ODR o, char *message)
index 00c6f51..85735dc 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_cons.c,v $
- * Revision 1.6  1995-03-08 12:12:23  quinn
+ * Revision 1.7  1995-03-10 11:44:41  quinn
+ * Fixed serious stack-bug in odr_cons_begin
+ *
+ * Revision 1.6  1995/03/08  12:12:23  quinn
  * Added better error checking.
  *
  * Revision 1.5  1995/02/10  18:57:25  quinn
@@ -43,6 +46,11 @@ int odr_constructed_begin(ODR o, void *p, int class, int tag)
     if (!res || !cons)
        return 0;
 
+    if (o->stackp == ODR_MAX_STACK - 1)
+    {
+       o->error = OSTACK;
+       return 0;
+    }
     o->stack[++(o->stackp)].lenb = o->bp;
     if (o->direction == ODR_ENCODE || o->direction == ODR_PRINT)
     {
@@ -95,6 +103,7 @@ int odr_constructed_end(ODR o)
                if (*o->bp++ == 0 && *(o->bp++) == 0)
                {
                    o->left -= 2;
+                   o->stackp--;
                    return 1;
                }
                else