projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Moved .h files to include directory
[yaz-moved-to-github.git]
/
odr
/
ber_bool.c
diff --git
a/odr/ber_bool.c
b/odr/ber_bool.c
index
205854a
..
6161b33
100644
(file)
--- a/
odr/ber_bool.c
+++ b/
odr/ber_bool.c
@@
-4,7
+4,13
@@
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ber_bool.c,v $
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ber_bool.c,v $
- * Revision 1.2 1995-02-09 15:51:45 quinn
+ * Revision 1.4 1995-03-21 10:17:27 quinn
+ * Fixed little bug in decoder.
+ *
+ * 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
* Works better now.
*
* Revision 1.1 1995/02/02 16:21:51 quinn
@@
-18,14
+24,21
@@
int ber_boolean(ODR o, int *val)
{
int ber_boolean(ODR o, int *val)
{
- unsigned char *b = o->bp;
int res, len;
switch (o->direction)
{
case ODR_ENCODE:
int res, len;
switch (o->direction)
{
case ODR_ENCODE:
+ if (!o->left)
+ {
+ o->error = OSPACE;
+ return 0;
+ }
if (ber_enclen(o->bp, 1, 1, 1) != 1)
if (ber_enclen(o->bp, 1, 1, 1) != 1)
+ {
+ o->error = OOTHER;
return 0;
return 0;
+ }
o->bp++;
o->left--;
*(o->bp++) = (unsigned char) *val;
o->bp++;
o->left--;
*(o->bp++) = (unsigned char) *val;
@@
-35,13
+48,19
@@
int ber_boolean(ODR o, int *val)
o->left--;
return 1;
case ODR_DECODE:
o->left--;
return 1;
case ODR_DECODE:
- if ((res = ber_declen(b, &len)) < 0)
+ if ((res = ber_declen(o->bp, &len)) < 0)
+ {
+ o->error = OPROTO;
return 0;
return 0;
+ }
if (len != 1)
if (len != 1)
+ {
+ o->error = OPROTO;
return 0;
return 0;
+ }
o->bp+= res;
o->left -= res;
o->bp+= res;
o->left -= res;
- *val = *b;
+ *val = *o->bp;
o->bp++;
o->left--;
#ifdef ODR_DEBUG
o->bp++;
o->left--;
#ifdef ODR_DEBUG
@@
-50,6
+69,6
@@
int ber_boolean(ODR o, int *val)
return 1;
case ODR_PRINT:
return 1;
return 1;
case ODR_PRINT:
return 1;
- default: return 0;
+ default: o->error = OOTHER; return 0;
}
}
}
}