Added better error checking.
authorSebastian Hammer <quinn@indexdata.com>
Wed, 8 Mar 1995 12:11:59 +0000 (12:11 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Wed, 8 Mar 1995 12:11:59 +0000 (12:11 +0000)
21 files changed:
odr/Makefile
odr/ber_any.c
odr/ber_bit.c
odr/ber_bool.c
odr/ber_int.c
odr/ber_null.c
odr/ber_oct.c
odr/ber_oid.c
odr/ber_tag.c
odr/odr.c
odr/odr_any.c
odr/odr_bit.c
odr/odr_bool.c
odr/odr_choice.c
odr/odr_cons.c
odr/odr_int.c
odr/odr_null.c
odr/odr_oct.c
odr/odr_oid.c
odr/odr_seq.c
odr/odr_tag.c

index b17aa3d..7c391e6 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.4 1995-03-07 09:23:12 quinn Exp $
+# $Id: Makefile,v 1.5 1995-03-08 12:11:59 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
@@ -14,7 +14,7 @@ PO = odr_bool.o ber_bool.o ber_len.o ber_tag.o odr_util.o odr_null.o \
        odr_choice.o odr_any.o ber_any.o odr.o
 CPP=cc -E
 
-all: $(LIB) test
+all: $(LIB)
 
 test: test.o $(LIB)
        $(CC) $(CFLAGS) $(INCLUDE) -o test test.o $(LIB)
index 35c0a83..6492398 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_any.c,v $
- * Revision 1.5  1995-02-14 20:39:54  quinn
+ * Revision 1.6  1995-03-08 12:12:02  quinn
+ * Added better error checking.
+ *
+ * Revision 1.5  1995/02/14  20:39:54  quinn
  * Fixed bugs in completeBER and (serious one in) ber_oid.
  *
  * Revision 1.4  1995/02/14  11:54:33  quinn
@@ -30,8 +33,11 @@ int ber_any(ODR o, Odr_any **p)
     switch (o->direction)
     {
        case ODR_DECODE:
-           if ((res = completeBER(o->bp, 1000)) <= 0)        /* FIX THIS */
+           if ((res = completeBER(o->bp, o->left)) <= 0)        /* FIX THIS */
+           {
+               o->error = OPROTO;
                return 0;
+           }
            (*p)->buf = nalloc(o, res);
            memcpy((*p)->buf, o->bp, res);
            (*p)->len = (*p)->size = res;
@@ -40,12 +46,15 @@ int ber_any(ODR o, Odr_any **p)
            return 1;
        case ODR_ENCODE:
            if ((*p)->len > o->left)
+           {
+               o->error = OSPACE;
                return 0;
+           }
            memcpy(o->bp , (*p)->buf, (*p)->len);
            o->bp += (*p)->len;
            o->left -= (*p)->len;
            return 1;
-       default: return 0;
+       default: o->error = OOTHER; return 0;
     }
 }
 
index 31b528f..4549f74 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_bit.c,v $
- * Revision 1.2  1995-02-03 17:04:31  quinn
+ * Revision 1.3  1995-03-08 12:12:04  quinn
+ * Added better error checking.
+ *
+ * Revision 1.2  1995/02/03  17:04:31  quinn
  * *** empty log message ***
  *
  * Revision 1.1  1995/02/02  20:38:49  quinn
@@ -24,7 +27,10 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
     {
        case ODR_DECODE:
            if ((res = ber_declen(o->bp, &len)) < 0)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            if (cons)       /* fetch component strings */
@@ -37,11 +43,17 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
            }
            /* primitive bitstring */
            if (len < 0)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            if (len == 0)
                return 1;
            if (len - 1 > ODR_BITMASK_SIZE)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            o->bp++;      /* silently ignore the unused-bits field */
            o->left--;
            len--;
@@ -52,11 +64,17 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
            return 1;
        case ODR_ENCODE:
            if ((res = ber_enclen(o->bp, p->top + 2, 5, 0)) < 0)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            if (p->top + 2 > o->left)
+           {
+               o->error = OSPACE;
                return 0;
+           }
            *(o->bp++) = 0;    /* no unused bits here */
            o->left--;
            if (p->top < 0)
@@ -66,6 +84,6 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
            o->left -= p->top +1;
            return 1;
        case ODR_PRINT: return 1;
-       default: return 0;
+       default: o->error = OOTHER; return 0;
     }
 }
index 205854a..d7f749e 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_bool.c,v $
- * Revision 1.2  1995-02-09 15:51:45  quinn
+ * Revision 1.3  1995-03-08 12:12:06  quinn
+ * Added better error checking.
+ *
+ * Revision 1.2  1995/02/09  15:51:45  quinn
  * Works better now.
  *
  * Revision 1.1  1995/02/02  16:21:51  quinn
@@ -24,8 +27,16 @@ int ber_boolean(ODR o, int *val)
     switch (o->direction)
     {
        case ODR_ENCODE:
+           if (!o->left)
+           {
+               o->error = OSPACE;
+               return 0;
+           }
            if (ber_enclen(o->bp, 1, 1, 1) != 1)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            o->bp++;
            o->left--;
            *(o->bp++) = (unsigned char) *val;
@@ -36,9 +47,15 @@ int ber_boolean(ODR o, int *val)
            return 1;
        case ODR_DECODE:
            if ((res = ber_declen(b, &len)) < 0)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            if (len != 1)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            o->bp+= res;
            o->left -= res;
            *val = *b;
@@ -50,6 +67,6 @@ int ber_boolean(ODR o, int *val)
            return 1;
        case ODR_PRINT:
            return 1;
-       default: return 0;
+       default: o->error = OOTHER; return 0;
     }
 }
index a5a8805..e8e50cf 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_int.c,v $
- * Revision 1.3  1995-02-09 15:51:46  quinn
+ * Revision 1.4  1995-03-08 12:12:07  quinn
+ * Added better error checking.
+ *
+ * Revision 1.3  1995/02/09  15:51:46  quinn
  * Works better now.
  *
  * Revision 1.2  1995/02/07  17:52:58  quinn
@@ -30,18 +33,24 @@ int ber_integer(ODR o, int *val)
     {
        case ODR_DECODE:
            if ((res = ber_decinteger(o->bp, val)) <= 0)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            return 1;
        case ODR_ENCODE:
            if ((res = ber_encinteger(o->bp, *val, o->left)) <= 0)
+           {
+               o->error = OSPACE;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            return 1;
        case ODR_PRINT: return 1;
-       default:  return 0;
+       default: o->error = OOTHER;  return 0;
     }
 }
 
index 8543f7f..2fbaf6d 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_null.c,v $
- * Revision 1.2  1995-02-09 15:51:46  quinn
+ * Revision 1.3  1995-03-08 12:12:09  quinn
+ * Added better error checking.
+ *
+ * Revision 1.2  1995/02/09  15:51:46  quinn
  * Works better now.
  *
  * Revision 1.1  1995/02/02  16:21:52  quinn
@@ -22,6 +25,11 @@ int ber_null(ODR o, int *val)
     switch (o->direction)
     {
        case ODR_ENCODE:
+           if (!o->left)
+           {
+               o->error = OSPACE;
+               return 0;
+           }
            *(o->bp++) = 0X00;
            o->left--;
 #ifdef ODR_DEBUG
@@ -30,13 +38,16 @@ int ber_null(ODR o, int *val)
            return 1;
        case ODR_DECODE:
            if (*(o->bp++) != 0X00)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            o->left--;
 #ifdef ODR_DEBUG
            fprintf(stderr, "[NULL]\n");
 #endif
            return 1;
        case ODR_PRINT: return 1;
-       default: return 0;
+       default: o->error = OOTHER; return 0;
     }
 }
index a8f6e07..2169842 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_oct.c,v $
- * Revision 1.4  1995-02-10 15:55:28  quinn
+ * Revision 1.5  1995-03-08 12:12:10  quinn
+ * Added better error checking.
+ *
+ * Revision 1.4  1995/02/10  15:55:28  quinn
  * Bug fixes, mostly.
  *
  * Revision 1.3  1995/02/03  17:04:34  quinn
@@ -29,7 +32,10 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons)
     {
        case ODR_DECODE:
            if ((res = ber_declen(o->bp, &len)) < 0)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            if (cons)       /* fetch component strings */
@@ -42,7 +48,10 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons)
            }
            /* primitive octetstring */
            if (len < 0)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            if (len + 1 > p->size - p->len)
            {
                c = nalloc(o, p->size += len + 1);
@@ -58,18 +67,24 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons)
            return 1;
        case ODR_ENCODE:
            if ((res = ber_enclen(o->bp, p->len, 5, 0)) < 0)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            if (p->len == 0)
                return 1;
            if (p->len > o->left)
+           {
+               o->error = OSPACE;
                return 0;
+           }
            memcpy(o->bp, p->buf, p->len);
            o->bp += p->len;
            o->left -= p->len;
            return 1;
        case ODR_PRINT: return 1;
-       default: return 0;
+       default: o->error = OOTHER; return 0;
     }
 }
index 20bff00..dd4fd82 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_oid.c,v $
- * Revision 1.3  1995-03-01 08:40:56  quinn
+ * Revision 1.4  1995-03-08 12:12:11  quinn
+ * Added better error checking.
+ *
+ * Revision 1.3  1995/03/01  08:40:56  quinn
  * Smallish changes.
  *
  * Revision 1.2  1995/02/14  20:39:55  quinn
@@ -28,9 +31,15 @@ int ber_oidc(ODR o, Odr_oid *p)
     {
        case ODR_DECODE:
            if ((res = ber_declen(o->bp, &len)) < 1)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            if (len < 0)
+           {
+               o->error = OPROTO;
                return 0;
+           }
            o->bp += res;
            o->left -= res;
            if (len == 0)
@@ -52,7 +61,10 @@ int ber_oidc(ODR o, Odr_oid *p)
                do
                {
                    if (!len)
+                   {
+                       o->error = OPROTO;
                        return 0;
+                   }
                    p[pos] <<= 7;
                    p[pos] |= *o->bp & 0X7F;
                    len--;
@@ -70,7 +82,10 @@ int ber_oidc(ODR o, Odr_oid *p)
             o->bp++;
             o->left--;
             if (p[0] < 0 && p[1] <= 0)
+           {
+               o->error = ODATA;
                return 0;
+           }
            p[1] = p[0] * 40 + p[1];
            for (pos = 1; p[pos] >= 0; pos++)
            {
@@ -83,14 +98,20 @@ int ber_oidc(ODR o, Odr_oid *p)
                }
                while (id);
                if (n > o->left)
+               {
+                   o->error = OSPACE;
                    return 0;
+               }
                o->left -= n;
                while (n--)
                    *(o->bp++) = octs[n] | ((n > 0) << 7);
            }
            if (ber_enclen(lenp, (o->bp - lenp) - 1, 1, 1) != 1)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            return 1;
-       default: return 0;
+       default: o->error = OOTHER; return 0;
     }
 }
index c5ec9eb..fb16296 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_tag.c,v $
- * Revision 1.6  1995-02-14 11:54:33  quinn
+ * Revision 1.7  1995-03-08 12:12:13  quinn
+ * Added better error checking.
+ *
+ * Revision 1.6  1995/02/14  11:54:33  quinn
  * Adjustments.
  *
  * Revision 1.5  1995/02/10  18:57:24  quinn
@@ -37,7 +40,7 @@
  *
  * Should perhaps be odr_tag?
 */
-int ber_tag(ODR o, void *p, int class, int tag, int *constructed)
+int ber_tag(ODR o, void *p, int class, int tag, int *constructed, int opt)
 {
     static int lclass = -1, ltag, br, lcons; /* save t&c rather than
                                                decoding twice */
@@ -56,10 +59,17 @@ int ber_tag(ODR o, void *p, int class, int tag, int *constructed)
     {
        case ODR_ENCODE:
            if (!*pp)
+           {
+               if (!opt)
+                   o->error = OREQUIRED;
                return 0;
+           }
            if ((rd = ber_enctag(o->bp, class, tag, *constructed, o->left))
                <=0)
+           {
+               o->error = OSPACE;
                return -1;
+           }
            o->bp += rd;
            o->left -= rd;
 #ifdef ODR_DEBUG
@@ -69,11 +79,18 @@ int ber_tag(ODR o, void *p, int class, int tag, int *constructed)
            return 1;
        case ODR_DECODE:
            if (o->stackp > -1 && !odr_constructed_more(o))
+           {
+               if (!opt)
+                   o->error = OREQUIRED;
                return 0;
+           }
            if (lclass < 0)
            {
                if ((br = ber_dectag(o->bp, &lclass, &ltag, &lcons)) <= 0)
+               {
+                   o->error = OPROTO;
                    return 0;
+               }
 #ifdef ODR_DEBUG
                fprintf(stderr, "\n[class=%d,tag=%d,cons=%d]", lclass, ltag,
                    lcons);
@@ -88,9 +105,16 @@ int ber_tag(ODR o, void *p, int class, int tag, int *constructed)
                return 1;
            }
            else
+           {
+               if (!opt)
+                   o->error = OREQUIRED;
                return 0;
-       case ODR_PRINT: return *pp != 0;
-       default: return 0;
+           }
+       case ODR_PRINT:
+               if (!*pp && !opt)
+                   o->error = OREQUIRED;
+               return *pp != 0;
+       default: o->error = OOTHER; return 0;
     }
 }
 
index d728ed2..bea667c 100644 (file)
--- a/odr/odr.c
+++ b/odr/odr.c
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr.c,v $
- * Revision 1.5  1995-03-07 13:28:57  quinn
+ * Revision 1.6  1995-03-08 12:12:15  quinn
+ * Added better error checking.
+ *
+ * Revision 1.5  1995/03/07  13:28:57  quinn
  * *** empty log message ***
  *
  * Revision 1.4  1995/03/07  13:16:13  quinn
 char *odr_errlist[] =
 {
     "No (unknown) error",
-    "Memoy allocation failed",
+    "Memory allocation failed",
     "System error",
     "No space in buffer",
     "Required data element missing",
     "Unexpected tag",
-    "Other error"
+    "Other error",
+    "Protocol error",
+    "Malformed data"
 };
 
 void odr_perror(ODR o, char *message)
index 018c8e5..bb9effd 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_any.c,v $
- * Revision 1.1  1995-02-09 15:51:47  quinn
+ * Revision 1.2  1995-03-08 12:12:18  quinn
+ * Added better error checking.
+ *
+ * Revision 1.1  1995/02/09  15:51:47  quinn
  * Works better now.
  *
  */
@@ -19,8 +22,8 @@
  */
 int odr_any(ODR o, Odr_any **p, int opt)
 {
-    if (o->direction == ODR_ENCODE && !*p)
-       return opt;
+    if (o->error)
+       return 0;
     if (o->direction == ODR_PRINT)
     {
        fprintf(o->print, "%sANY (len=%d)\n", odr_indent(o), (*p)->len);
@@ -31,5 +34,7 @@ int odr_any(ODR o, Odr_any **p, int opt)
     if (ber_any(o, p))
        return 1;
     *p = 0;
+    if (!opt)
+       o->error = OREQUIRED;
     return opt;
 }    
index f20a252..25edfa0 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_bit.c,v $
- * Revision 1.5  1995-02-10 18:57:25  quinn
+ * Revision 1.6  1995-03-08 12:12:19  quinn
+ * Added better error checking.
+ *
+ * Revision 1.5  1995/02/10  18:57:25  quinn
  * More in the way of error-checking.
  *
  * Revision 1.4  1995/02/09  15:51:47  quinn
@@ -33,18 +36,21 @@ int odr_bitstring(ODR o, Odr_bitmask **p, int opt)
 {
     int res, cons = 0;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_BITSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
     if (!res)
        return opt;
     if (o->direction == ODR_PRINT)
     {
-       fprintf(o->print, "%sBITSTRING(len=%d)\n", odr_indent(o), (*p)->top + 1);
+       fprintf(o->print, "%sBITSTRING(len=%d)\n", odr_indent(o),
+           (*p)->top + 1);
        return 1;
     }
     if (o->direction == ODR_DECODE)
index 7a09f96..13c2d3a 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_bool.c,v $
- * Revision 1.3  1995-02-10 18:57:25  quinn
+ * Revision 1.4  1995-03-08 12:12:20  quinn
+ * Added better error checking.
+ *
+ * Revision 1.3  1995/02/10  18:57:25  quinn
  * More in the way of error-checking.
  *
  * Revision 1.2  1995/02/09  15:51:47  quinn
@@ -26,12 +29,14 @@ int odr_bool(ODR o, int **p, int opt)
 {
     int res, cons = 0;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_BOOLEAN;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
     if (!res)
        return opt;
index f54711a..8faf925 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_choice.c,v $
- * Revision 1.2  1995-02-09 15:51:48  quinn
+ * Revision 1.3  1995-03-08 12:12:22  quinn
+ * Added better error checking.
+ *
+ * Revision 1.2  1995/02/09  15:51:48  quinn
  * Works better now.
  *
  * Revision 1.1  1995/02/07  17:52:59  quinn
@@ -18,6 +21,8 @@ int odr_choice(ODR o, Odr_arm arm[], void *p, int *which)
 {
     int i, cl = -1, tg, cn;
 
+    if (o->error)
+       return 0;
     if (o->direction != ODR_DECODE && !*(char**)p)
        return 0;
     for (i = 0; arm[i].fun; i++)
index f85d817..00c6f51 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_cons.c,v $
- * Revision 1.5  1995-02-10 18:57:25  quinn
+ * Revision 1.6  1995-03-08 12:12:23  quinn
+ * Added better error checking.
+ *
+ * Revision 1.5  1995/02/10  18:57:25  quinn
  * More in the way of error-checking.
  *
  * Revision 1.4  1995/02/10  15:55:29  quinn
@@ -28,12 +31,14 @@ int odr_constructed_begin(ODR o, void *p, int class, int tag)
     int res;
     int cons = 1;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = class;
        o->t_tag = tag;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, 1)) < 0)
        return 0;
     if (!res || !cons)
        return 0;
@@ -61,6 +66,8 @@ int odr_constructed_begin(ODR o, void *p, int class, int tag)
 
 int odr_constructed_more(ODR o)
 {
+    if (o->error)
+       return 0;
     if (o->stackp < 0)
        return 0;
     if (o->stack[o->stackp].len >= 0)
@@ -73,8 +80,13 @@ int odr_constructed_end(ODR o)
 {
     int res;
 
+    if (o->error)
+       return 0;
     if (o->stackp < 0)
+    {
+       o->error = OOTHER;
        return 0;
+    }
     switch (o->direction)
     {
        case ODR_DECODE:
@@ -86,18 +98,27 @@ int odr_constructed_end(ODR o)
                    return 1;
                }
                else
+               {
+                   o->error = OOTHER;
                    return 0;
+               }
            }
            else if (o->bp - o->stack[o->stackp].base !=
                o->stack[o->stackp].len)
+           {
+               o->error = OOTHER;
                return 0;
+           }
            o->stackp--;
            return 1;
        case ODR_ENCODE:
            if ((res = ber_enclen(o->stack[o->stackp].lenb,
                o->bp - o->stack[o->stackp].base,
                o->stack[o->stackp].lenlen, 1)) < 0)
-                   return 0;
+           {
+               o->error = OSPACE;
+               return 0;
+           }
            if (res == 0)   /* indefinite encoding */
            {
                *(o->bp++) = *(o->bp++) = 0;
@@ -106,6 +127,8 @@ int odr_constructed_end(ODR o)
            o->stackp--;
            return 1;
        case ODR_PRINT: return 1;
-       default: return 0;
+       default:
+           o->error = OOTHER;
+           return 0;
     }
 }
index d617ea8..686aa63 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_int.c,v $
- * Revision 1.4  1995-02-10 18:57:25  quinn
+ * Revision 1.5  1995-03-08 12:12:25  quinn
+ * Added better error checking.
+ *
+ * Revision 1.4  1995/02/10  18:57:25  quinn
  * More in the way of error-checking.
  *
  * Revision 1.3  1995/02/09  15:51:48  quinn
@@ -28,12 +31,14 @@ int odr_integer(ODR o, int **p, int opt)
 {
     int res, cons = 0;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_INTEGER;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
     if (!res)
        return opt;
@@ -43,7 +48,10 @@ int odr_integer(ODR o, int **p, int opt)
        return 1;
     }
     if (cons)
+    {
+       o->error = OPROTO;
        return 0;
+    }
     if (o->direction == ODR_DECODE)
        *p = nalloc(o, sizeof(int));
     return ber_integer(o, *p);
index a80a2ac..d9ed423 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_null.c,v $
- * Revision 1.3  1995-02-10 18:57:25  quinn
+ * Revision 1.4  1995-03-08 12:12:26  quinn
+ * Added better error checking.
+ *
+ * Revision 1.3  1995/02/10  18:57:25  quinn
  * More in the way of error-checking.
  *
  * Revision 1.2  1995/02/09  15:51:49  quinn
@@ -26,12 +29,14 @@ int odr_null(ODR o, int **p, int opt)
     int res, cons = 0;
     static int nullval = 0;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_NULL;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
     if (!res)
        return opt;
@@ -41,7 +46,10 @@ int odr_null(ODR o, int **p, int opt)
        return 1;
     }
     if (cons)
+    {
+       o->error = OPROTO;
        return 0;
+    }
     if (o->direction == ODR_DECODE)
        *p = &nullval;
     return ber_null(o, *p);
index 1140648..ba38619 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_oct.c,v $
- * Revision 1.6  1995-02-10 18:57:26  quinn
+ * Revision 1.7  1995-03-08 12:12:27  quinn
+ * Added better error checking.
+ *
+ * Revision 1.6  1995/02/10  18:57:26  quinn
  * More in the way of error-checking.
  *
  * Revision 1.5  1995/02/09  15:51:49  quinn
@@ -34,12 +37,14 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt)
 {
     int res, cons = 0;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
     if (!res)
        return opt;
@@ -57,7 +62,7 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt)
     }
     if (ber_octetstring(o, *p, cons))
        return 1;
-    *p = 0;
+    o->error = OOTHER;
     return 0;
 }
 
@@ -69,12 +74,14 @@ int odr_cstring(ODR o, char **p, int opt)
     int cons = 0, res;
     Odr_oct *t;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
     if (!res)
        return opt;
index 641e117..633101b 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_oid.c,v $
- * Revision 1.6  1995-03-01 08:40:56  quinn
+ * Revision 1.7  1995-03-08 12:12:29  quinn
+ * Added better error checking.
+ *
+ * Revision 1.6  1995/03/01  08:40:56  quinn
  * Smallish changes.
  *
  * Revision 1.5  1995/02/10  18:57:26  quinn
@@ -35,15 +38,22 @@ int odr_oid(ODR o, Odr_oid **p, int opt)
 {
     int res, cons = 0;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OID;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
        return 0;
-    if (!res || cons)
+    if (!res)
        return opt;
+    if (cons)
+    {
+       o->error = OPROTO;
+       return 0;
+    }
     if (o->direction == ODR_PRINT)
     {
        int i;
index e08b958..df8e124 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_seq.c,v $
- * Revision 1.6  1995-02-10 15:55:29  quinn
+ * Revision 1.7  1995-03-08 12:12:30  quinn
+ * Added better error checking.
+ *
+ * Revision 1.6  1995/02/10  15:55:29  quinn
  * Bug fixes, mostly.
  *
  * Revision 1.5  1995/02/09  15:51:49  quinn
@@ -31,12 +34,13 @@ int odr_sequence_begin(ODR o, void *p, int size)
 {
     char **pp = (char**) p;
 
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_SEQUENCE;
     }
-
     if (o->direction == ODR_DECODE)
        *pp = 0;
     if (odr_constructed_begin(o, p, o->t_class, o->t_tag))
@@ -112,7 +116,9 @@ int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num)
                if (!(*type)(o, *pp + i, 0))
                    return 0;
            break;
-       default: return 0;
+       default:
+           o->error = OOTHER;
+           return 0;
     }
     return odr_sequence_end(o);
 }
index 06047be..f5e7d83 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_tag.c,v $
- * Revision 1.1  1995-02-02 16:21:54  quinn
+ * Revision 1.2  1995-03-08 12:12:31  quinn
+ * Added better error checking.
+ *
+ * Revision 1.1  1995/02/02  16:21:54  quinn
  * First kick.
  *
  */
@@ -13,6 +16,8 @@
 
 int odr_implicit_settag(ODR o, int class, int tag)
 {
+    if (o->error)
+       return 0;
     if (o->t_class < 0)
     {
        o->t_class = class;