* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ber_any.c,v $
- * Revision 1.2 1995-02-10 15:55:28 quinn
+ * Revision 1.3 1995-02-10 18:57:24 quinn
+ * More in the way of error-checking.
+ *
+ * Revision 1.2 1995/02/10 15:55:28 quinn
* Bug fixes, mostly.
*
* Revision 1.1 1995/02/09 15:51:45 quinn
unsigned char *b = buf;
if (!buf[0] && !buf[1])
- return -1;
+ return 0;
if ((res = ber_dectag(b, &class, &tag, &cons)) <= 0)
return 0;
if (res > len)
- return -1;
+ return 0;
b += res;
len -= res;
if ((res = ber_declen(b, &ll)) <= 0)
- return -1;
+ return 0;
if (res > len)
- return -1;
+ return 0;
b += res;
len -= res;
if (ll >= 0)
return (len >= ll ? ll + (b-buf) : -1);
if (!cons)
- return -1;
+ return 0;
while (1)
{
if ((res = completeBER(b, len)) < 0)
- return -1;
+ return 0;
b += res;
len -= res;
if (len < 2)
- return -1;
+ return 0;
if (*b == 0 && *(b + 1) == 0)
return (b - buf) + 2;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ber_tag.c,v $
- * Revision 1.4 1995-02-10 15:55:28 quinn
+ * Revision 1.5 1995-02-10 18:57:24 quinn
+ * More in the way of error-checking.
+ *
+ * Revision 1.4 1995/02/10 15:55:28 quinn
* Bug fixes, mostly.
*
* Revision 1.3 1995/02/09 15:51:46 quinn
* On decoding:
* if tag && class match up, advance pointer and return 1. set cons.
* else leave pointer unchanged. Return 0.
+ *
+ * Should perhaps be odr_tag?
*/
-int ber_tag(ODR o, const void *p, int class, int tag, int *constructed)
+int ber_tag(ODR o, void *p, int class, int tag, int *constructed)
{
static int lclass = -1, ltag, br, lcons; /* save t&c rather than
decoding twice */
int rd;
+ char **pp = p;
+ if (o->direction == ODR_DECODE)
+ *pp = 0;
o->t_class = -1;
if (o->buf == o->bp) /* This is insurance. It shouldn't be necessary */
lclass = -1;
switch (o->direction)
{
case ODR_ENCODE:
- if (!p)
+ if (!*pp)
return 0;
if ((rd = ber_enctag(o->bp, class, tag, *constructed, o->left))
<=0)
if (lclass < 0)
{
if ((br = ber_dectag(o->bp, &lclass, <ag, &lcons)) <= 0)
- return -1;
+ return 0;
#ifdef ODR_DEBUG
fprintf(stderr, "\n[class=%d,tag=%d,cons=%d]", lclass, ltag,
lcons);
}
else
return 0;
- case ODR_PRINT: return p != 0;
+ case ODR_PRINT: return *pp != 0;
default: return 0;
}
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_bit.c,v $
- * Revision 1.4 1995-02-09 15:51:47 quinn
+ * 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
* Works better now.
*
* Revision 1.3 1995/02/07 14:13:45 quinn
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_BITSTRING;
}
- if (o->direction == ODR_DECODE)
- *p = 0;
- 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)) < 0)
return 0;
if (!res)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
fprintf(o->print, "%sBITSTRING(len=%d)\n", odr_indent(o), (*p)->top + 1);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_bool.c,v $
- * Revision 1.2 1995-02-09 15:51:47 quinn
+ * 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
* Works better now.
*
* Revision 1.1 1995/02/02 16:21:53 quinn
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_BOOLEAN;
}
- if (o->direction == ODR_DECODE)
- *p = 0;
- 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)) < 0)
return 0;
if (!res)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
fprintf(o->print, "%s%s\n", odr_indent(o), (**p ? "TRUE" : "FALSE"));
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_cons.c,v $
- * Revision 1.4 1995-02-10 15:55:29 quinn
+ * 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
* Bug fixes, mostly.
*
* Revision 1.3 1995/02/09 15:51:48 quinn
o->t_class = class;
o->t_tag = tag;
}
- if (o->direction == ODR_DECODE)
- *(char**)p = 0;
- if ((res = ber_tag(o, *(char**)p, o->t_class, o->t_tag, &cons)) < 0)
+ if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
return 0;
if (!res || !cons)
return 0;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_int.c,v $
- * Revision 1.3 1995-02-09 15:51:48 quinn
+ * 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
* Works better now.
*
* Revision 1.2 1995/02/07 14:13:45 quinn
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_INTEGER;
}
- if (o->direction == ODR_DECODE)
- *p =0;
- if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
- {
- *p = 0;
+ if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
return 0;
- }
if (!res)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
fprintf(o->print, "%s%d\n", odr_indent(o), **p);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_null.c,v $
- * Revision 1.2 1995-02-09 15:51:49 quinn
+ * 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
* Works better now.
*
* Revision 1.1 1995/02/02 16:21:54 quinn
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_NULL;
}
- if (o->direction == ODR_DECODE)
- *p =0;
- 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)) < 0)
return 0;
if (!res)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
fprintf(o->print, "%sNULL\n", odr_indent(o));
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_oct.c,v $
- * Revision 1.5 1995-02-09 15:51:49 quinn
+ * 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
* Works better now.
*
* Revision 1.4 1995/02/07 14:13:46 quinn
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_OCTETSTRING;
}
- if (o->direction == ODR_DECODE)
- *p = 0;
- if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
- {
- *p = 0;
+ if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
return 0;
- }
if (!res)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
fprintf(o->print, "%sOCTETSTRING(len=%d)\n", odr_indent(o), (*p)->len);
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_OCTETSTRING;
}
- if (o->direction == ODR_DECODE)
- *p = 0;
- 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)) < 0)
return 0;
if (!res)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
fprintf(o->print, "%s'%s'\n", odr_indent(o), *p);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: odr_oid.c,v $
- * Revision 1.4 1995-02-10 15:55:29 quinn
+ * Revision 1.5 1995-02-10 18:57:26 quinn
+ * More in the way of error-checking.
+ *
+ * Revision 1.4 1995/02/10 15:55:29 quinn
* Bug fixes, mostly.
*
* Revision 1.3 1995/02/09 15:51:49 quinn
o->t_class = ODR_UNIVERSAL;
o->t_tag = ODR_OID;
}
- if (o->direction == ODR_DECODE)
- *p =0;
- if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
- {
- *p = 0;
+ if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
return 0;
- }
if (!res || cons)
- {
- *p = 0;
return opt;
- }
if (o->direction == ODR_PRINT)
{
int i;