Fix sample PQF
[yaz-moved-to-github.git] / odr / ber_bool.c
index 289d681..7ce8dc2 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * Copyright (c) 1995-2002, Index Data
+ * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: ber_bool.c,v 1.12 2002-07-25 12:51:08 adam Exp $
+ * $Id: ber_bool.c,v 1.14 2003-03-11 11:03:31 adam Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -29,17 +29,17 @@ int ber_boolean(ODR o, int *val)
 #endif
         return 1;
     case ODR_DECODE:
-        if ((res = ber_declen(o->bp, &len)) < 0)
+        if ((res = ber_declen(o->bp, &len, odr_max(o))) < 0)
         {
-            o->error = OPROTO;
+            odr_seterror(o, OPROTO, 9);
             return 0;
         }
-        if (len != 1)
+        o->bp+= res;
+        if (len != 1 || odr_max(o) < len)
         {
-            o->error = OPROTO;
+            odr_seterror(o, OPROTO, 10);
             return 0;
         }
-        o->bp+= res;
         *val = *o->bp;
         o->bp++;
 #ifdef ODR_DEBUG
@@ -48,6 +48,6 @@ int ber_boolean(ODR o, int *val)
         return 1;
     case ODR_PRINT:
         return 1;
-    default: o->error = OOTHER; return 0;
+    default: odr_seterror(o, OOTHER, 11); return 0;
     }
 }