Fix sample PQF
[yaz-moved-to-github.git] / odr / ber_bool.c
index 20a8a35..7ce8dc2 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: ber_bool.c,v 1.13 2003-01-06 08:20:27 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;
     }
 }