* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: odr.h,v 1.8 2003-02-12 15:06:43 adam Exp $
+ * $Id: odr.h,v 1.9 2003-03-11 11:03:30 adam Exp $
*/
#ifndef ODR_H
extern char *odr_errlist[];
YAZ_EXPORT int odr_geterror(ODR o);
+YAZ_EXPORT int odr_geterrorx(ODR o, int *x);
+YAZ_EXPORT void odr_seterror(ODR o, int errorno, int errorid);
YAZ_EXPORT void odr_perror(ODR o, char *message);
YAZ_EXPORT void odr_setprint(ODR o, FILE *file);
YAZ_EXPORT ODR odr_createmem(int direction);
int *constructed, int opt);
YAZ_EXPORT int ber_enctag(ODR o, int zclass, int tag, int constructed);
YAZ_EXPORT int ber_dectag(const unsigned char *buf, int *zclass,
- int *tag, int *constructed);
+ int *tag, int *constructed, int max);
YAZ_EXPORT int odr_bool(ODR o, int **p, int opt, const char *name);
YAZ_EXPORT int odr_integer(ODR o, int **p, int opt, const char *name);
YAZ_EXPORT int odr_enum(ODR o, int **p, int opt, const char *name);
YAZ_EXPORT int odr_implicit_settag(ODR o, int zclass, int tag);
YAZ_EXPORT int ber_enclen(ODR o, int len, int lenlen, int exact);
-YAZ_EXPORT int ber_declen(const unsigned char *buf, int *len);
+YAZ_EXPORT int ber_declen(const unsigned char *buf, int *len, int max);
YAZ_EXPORT void odr_prname(ODR o, const char *name);
YAZ_EXPORT int ber_null(ODR o);
YAZ_EXPORT int odr_null(ODR o, Odr_null **p, int opt, const char *name);
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: ber_any.c,v 1.23 2003-02-21 12:08:58 adam Exp $
+ * $Id: ber_any.c,v 1.24 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
int ber_any(ODR o, Odr_any **p)
{
int res;
- int left = o->size - (o->bp - o->buf);
switch (o->direction)
{
case ODR_DECODE:
- if ((res = completeBER(o->bp, left)) <= 0) /* FIX THIS */
+ if ((res = completeBER(o->bp, odr_max(o))) <= 0) /* FIX THIS */
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 2);
return 0;
}
(*p)->buf = (unsigned char *)odr_malloc(o, res);
if (odr_write(o, (*p)->buf, (*p)->len) < 0)
return 0;
return 1;
- default: o->error = OOTHER; return 0;
+ default: odr_seterror(o, OOTHER, 3); return 0;
}
}
return 0;
if (!buf[0] && !buf[1])
return 0;
- if ((res = ber_dectag(b, &zclass, &tag, &cons)) <= 0)
+ if ((res = ber_dectag(b, &zclass, &tag, &cons, len)) <= 0)
return 0;
if (res > len)
return 0;
b += res;
len -= res;
- if ((res = ber_declen(b, &ll)) <= 0)
+ if ((res = ber_declen(b, &ll, len)) <= 0)
return 0;
if (res > len)
return 0;
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_bit.c,v 1.14 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_bit.c,v 1.15 2003-03-11 11:03:31 adam Exp $
*
*/
#if HAVE_CONFIG_H
switch (o->direction)
{
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, 4);
return 0;
}
o->bp += res;
/* primitive bitstring */
if (len < 0)
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 5);
return 0;
}
if (len == 0)
return 1;
if (len - 1 > ODR_BITMASK_SIZE)
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 6);
return 0;
}
+ if (len > odr_max(o))
+ {
+ odr_seterror(o, OOTHER, 7);
+ return 0;
+ }
o->bp++; /* silently ignore the unused-bits field */
len--;
memcpy(p->bits + p->top + 1, o->bp, len);
return 0;
return 1;
case ODR_PRINT: return 1;
- default: o->error = OOTHER; return 0;
+ default: odr_seterror(o, OOTHER, 8); return 0;
}
}
* 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
#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
return 1;
case ODR_PRINT:
return 1;
- default: o->error = OOTHER; return 0;
+ default: odr_seterror(o, OOTHER, 11); return 0;
}
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_int.c,v 1.21 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_int.c,v 1.22 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
#include "odr-priv.h"
static int ber_encinteger(ODR o, int val);
-static int ber_decinteger(const unsigned char *buf, int *val);
+static int ber_decinteger(const unsigned char *buf, int *val, int max);
int ber_integer(ODR o, int *val)
{
switch (o->direction)
{
case ODR_DECODE:
- if ((res = ber_decinteger(o->bp, val)) <= 0)
+ if ((res = ber_decinteger(o->bp, val, odr_max(o))) <= 0)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 50);
return 0;
}
o->bp += res;
return 0;
return 1;
case ODR_PRINT: return 1;
- default: o->error = OOTHER; return 0;
+ default: odr_seterror(o, OOTHER, 51); return 0;
}
}
*/
int ber_encinteger(ODR o, int val)
{
- int lenpos;
int a, len;
union { int i; unsigned char c[sizeof(int)]; } tmp;
- lenpos = odr_tell(o);
- if (odr_putc(o, 0) < 0) /* dummy */
- return -1;
tmp.i = htonl(val); /* ensure that that we're big-endian */
for (a = 0; a < (int) sizeof(int) - 1; a++) /* skip superfluous octets */
if (!((tmp.c[a] == 0 && !(tmp.c[a+1] & 0X80)) ||
(tmp.c[a] == 0XFF && (tmp.c[a+1] & 0X80))))
break;
len = sizeof(int) - a;
- if (odr_write(o, (unsigned char*) tmp.c + a, len) < 0)
- return -1;
- odr_seek(o, ODR_S_SET, lenpos);
if (ber_enclen(o, len, 1, 1) != 1)
return -1;
- odr_seek(o, ODR_S_END, 0);
+ if (odr_write(o, (unsigned char*) tmp.c + a, len) < 0)
+ return -1;
#ifdef ODR_DEBUG
fprintf(stderr, "[val=%d]", val);
#endif
/*
* Returns: Number of bytes read or 0 if no match, -1 if error.
*/
-int ber_decinteger(const unsigned char *buf, int *val)
+int ber_decinteger(const unsigned char *buf, int *val, int max)
{
const unsigned char *b = buf;
unsigned char fill;
int res, len, remains;
union { int i; unsigned char c[sizeof(int)]; } tmp;
- if ((res = ber_declen(b, &len)) < 0)
+ if ((res = ber_declen(b, &len, max)) < 0)
return -1;
- if (len > (int) sizeof(int)) /* let's be reasonable, here */
+ if (len+res > max || len < 0) /* out of bounds or indefinite encoding */
+ return -1;
+ if (len > (int) sizeof(int)) /* let's be reasonable, here */
return -1;
b+= res;
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_len.c,v 1.11 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_len.c,v 1.12 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
* len = -1 indefinite.
* len >= 0 Length.
*/
-int ber_declen(const unsigned char *buf, int *len)
+int ber_declen(const unsigned char *buf, int *len, int max)
{
const unsigned char *b = buf;
int n;
+ if (max < 1)
+ return -1;
if (*b == 0X80) /* Indefinite */
{
*len = -1;
return -1;
/* indefinite long form */
n = *b & 0X7F;
+ if (n >= max)
+ return -1;
*len = 0;
b++;
- while (n--)
+ while (--n >= 0)
{
*len <<= 8;
*len |= *(b++);
}
+ if (*len < 0)
+ return -1;
#ifdef ODR_DEBUG
fprintf(stderr, "[len=%d]", *len);
#endif
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_null.c,v 1.13 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_null.c,v 1.14 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
return 1;
case ODR_DECODE:
+ if (odr_max(o) < 1)
+ {
+ odr_seterror(o, OPROTO, 39);
+ return 0;
+ }
if (*(o->bp++) != 0X00)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 12);
return 0;
}
#ifdef ODR_DEBUG
#endif
return 1;
case ODR_PRINT: return 1;
- default: o->error = OOTHER; return 0;
+ default: odr_seterror(o, OOTHER, 13); return 0;
}
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_oct.c,v 1.20 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_oct.c,v 1.21 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
switch (o->direction)
{
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, 14);
return 0;
}
o->bp += res;
/* primitive octetstring */
if (len < 0)
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 15);
return 0;
}
+ if (len > odr_max(o))
+ {
+ odr_seterror(o, OOTHER, 16);
+ return 0;
+ }
if (len + 1 > p->size - p->len)
{
c = (unsigned char *)odr_malloc(o, p->size += len + 1);
return 0;
return 1;
case ODR_PRINT: return 1;
- default: o->error = OOTHER; return 0;
+ default: odr_seterror(o, OOTHER, 17); return 0;
}
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_oid.c,v 1.14 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_oid.c,v 1.15 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
switch (o->direction)
{
case ODR_DECODE:
- if ((res = ber_declen(o->bp, &len)) < 1)
+ if ((res = ber_declen(o->bp, &len, odr_max(o))) < 1)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 18);
return 0;
}
if (len < 0)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 19);
return 0;
}
o->bp += res;
*p = -1;
return 1;
}
+ if (len > odr_max(o))
+ {
+ odr_seterror(o, OPROTO, 20);
+ return 0;
+ }
p[0] = *o->bp / 40;
if (p[0] > 2)
p[0] = 2;
{
if (!len)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 21);
return 0;
}
p[pos] <<= 7;
return 0;
if (p[0] < 0 && p[1] <= 0)
{
- o->error = ODATA;
+ odr_seterror(o, ODATA, 23);
return 0;
}
for (pos = 1; p[pos] >= 0; pos++)
odr_seek(o, ODR_S_SET, lenp);
if (ber_enclen(o, (end - lenp) - 1, 1, 1) != 1)
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 52);
return 0;
}
odr_seek(o, ODR_S_END, 0);
return 1;
default:
- o->error = OOTHER; return 0;
+ odr_seterror(o, OOTHER, 22);
+ return 0;
}
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: ber_tag.c,v 1.24 2003-01-06 08:20:27 adam Exp $
+ * $Id: ber_tag.c,v 1.25 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
if (!*pp)
{
if (!opt)
- o->error = OREQUIRED;
+ odr_seterror(o, OREQUIRED, 24);
return 0;
}
if ((rd = ber_enctag(o, zclass, tag, *constructed)) < 0)
if (o->op->stackp > -1 && !odr_constructed_more(o))
{
if (!opt)
- o->error = OREQUIRED;
+ odr_seterror(o, OREQUIRED, 25);
return 0;
}
if (odr_ber_tag->lclass < 0)
{
- if ((odr_ber_tag->br = ber_dectag(o->bp, &odr_ber_tag->lclass,
- &odr_ber_tag->ltag, &odr_ber_tag->lcons)) <= 0)
+ if ((odr_ber_tag->br =
+ ber_dectag(o->bp, &odr_ber_tag->lclass,
+ &odr_ber_tag->ltag, &odr_ber_tag->lcons,
+ odr_max(o))) <= 0)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 26);
return 0;
}
#ifdef ODR_DEBUG
else
{
if (!opt)
- o->error = OREQUIRED;
+ odr_seterror(o, OREQUIRED, 27);
return 0;
}
case ODR_PRINT:
if (!*pp && !opt)
- o->error = OREQUIRED;
+ odr_seterror(o,OREQUIRED, 28);
return *pp != 0;
default:
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 29);
return 0;
}
}
/* ber_dectag
* Decode BER identifier octets. Return number of bytes read or -1 for error.
*/
-int ber_dectag(const unsigned char *buf, int *zclass, int *tag, int *constructed)
+int ber_dectag(const unsigned char *b, int *zclass, int *tag,
+ int *constructed, int max)
{
- const unsigned char *b = buf;
+ int l = 1;
+
+ if (l > max)
+ return -1;
*zclass = *b >> 6;
*constructed = (*b >> 5) & 0X01;
if ((*tag = *b & 0x1F) <= 30)
return 1;
- b++;
*tag = 0;
do
{
+ if (l >= max)
+ return -1;
*tag <<= 7;
- *tag |= *b & 0X7F;
- if (b - buf >= 5) /* Precaution */
- return -1;
+ *tag |= b[l] & 0X7F;
}
- while (*(b++) & 0X80);
- return b - buf;
+ while (b[l++] & 0X80);
+ return l;
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: dumpber.c,v 1.14 2003-01-06 08:20:27 adam Exp $
+ * $Id: dumpber.c,v 1.15 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
return 0;
if (!buf[0] && !buf[1])
return 0;
- if ((res = ber_dectag((unsigned char*)b, &zclass, &tag, &cons)) <= 0)
+ if ((res = ber_dectag((unsigned char*)b, &zclass, &tag, &cons, len)) <= 0)
return 0;
if (res > len)
{
"GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", "[UNIV 28]"
};
- if (tag < 28)
+ if (tag >= 0 && tag < 28)
fprintf(f, "%s", nl[tag]);
else
fprintf(f, "[UNIV %d]", tag);
taglen = res;
len -= res;
bp = b;
- if ((res = ber_declen((unsigned char*)b, &ll)) <= 0)
+ if ((res = ber_declen((unsigned char*)b, &ll, len)) <= 0)
{
- fprintf(f, "bad length\n");
- return 0;
- }
- if (res > len)
- {
- fprintf(f, "Unexpected end of buffer\n");
+ fprintf(f, "\n%*sBad length\n", level*4+5, "");
return 0;
}
lenlen = res;
fprintf(f, " tl=%d, ll=%d\n", taglen, lenlen);
if (!cons)
{
- if (ll < 0)
+ if (ll < 0 || ll > len)
{
- fprintf(f, "Bad length on primitive type.\n");
+ fprintf(f, "%*sBad length on primitive type. ll=%d len=%d\n",
+ level*4+5, "", ll, len);
return 0;
}
return ll + (b - buf);
}
if (ll >= 0)
+ {
+ if (ll > len)
+ {
+ fprintf(f, "%*sBad length of constructed type ll=%d len=%d.\n",
+ level*4+5, "", ll, len);
+ return 0;
+ }
len = ll;
+ }
/* constructed - cycle through children */
while ((ll == -1 && len >= 2) || (ll >= 0 && len))
{
break;
if (!(res = do_dumpBER(f, b, len, level + 1, offset + (b - buf))))
{
- fprintf(f, "Dump of content element failed.\n");
+ fprintf(f, "%*sDump of content element failed.\n", level*4+5, "");
return 0;
}
b += res;
len -= res;
+ if (len < 0)
+ {
+ fprintf(f, "%*sBad length\n", level*4+5, "");
+ return 0;
+ }
}
if (ll == -1)
{
if (len < 2)
{
- fprintf(f, "Buffer too short in indefinite lenght.\n");
+ fprintf(f, "%*sBuffer too short in indefinite length.\n",
+ level*4+5, "");
return 0;
}
return (b - buf) + 2;
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: odr-priv.h,v 1.3 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr-priv.h,v 1.4 2003-03-11 11:03:31 adam Exp $
*/
#ifndef ODR_PRIV_H
int lcons;
};
+#define odr_max(o) ((o)->size - ((o)->bp - (o)->buf))
+#define odr_offset(o) ((o)->bp - (o)->buf)
+
struct Odr_private {
/* stack for constructed types */
#define ODR_MAX_STACK 50
struct Odr_ber_tag odr_ber_tag;
yaz_iconv_t iconv_handle;
+ int error_id;
};
/* Private macro.
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: odr.c,v 1.40 2003-02-12 15:06:43 adam Exp $
+ * $Id: odr.c,v 1.41 2003-03-11 11:03:31 adam Exp $
*
*/
#if HAVE_CONFIG_H
return o->error;
}
+int odr_geterrorx(ODR o, int *x)
+{
+ if (x)
+ *x = o->op->error_id;
+ return o->error;
+}
+
+void odr_seterror(ODR o, int error, int id)
+{
+ o->error = error;
+ o->op->error_id = id;
+}
+
void odr_setprint(ODR o, FILE *file)
{
o->print = file;
void odr_reset(ODR o)
{
- o->error = ONONE;
+ odr_seterror(o, ONONE, 0);
o->bp = o->buf;
odr_seek(o, ODR_S_SET, 0);
o->top = 0;
*size = o->size;
return (char*) o->buf;
}
+
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_any.c,v 1.12 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_any.c,v 1.13 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
return 1;
*p = 0;
if (!opt)
- o->error = OREQUIRED;
+ odr_seterror(o, OREQUIRED, 53);
return opt;
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_choice.c,v 1.21 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_choice.c,v 1.22 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
{
if (o->op->stackp > -1 && !odr_constructed_more(o))
return 0;
- if (ber_dectag(o->bp, &cl, &tg, &cn) <= 0)
+ if (ber_dectag(o->bp, &cl, &tg, &cn, odr_max(o)) <= 0)
return 0;
}
else if (o->direction != ODR_DECODE)
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: odr_cons.c,v 1.24 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_cons.c,v 1.25 2003-03-11 11:03:31 adam Exp $
*
*/
#if HAVE_CONFIG_H
if (o->op->stackp == ODR_MAX_STACK - 1)
{
- o->error = OSTACK;
+ odr_seterror(o, OSTACK, 30);
return 0;
}
o->op->stack[++(o->op->stackp)].lenb = o->bp;
o->op->stack[o->op->stackp].lenlen = lenlen;
- if (odr_write(o, dummy, lenlen) < 0) /* dummy */
+ if (odr_write(o, dummy, lenlen) < 0) /* dummy */
+ {
+ --(o->op->stackp);
return 0;
+ }
}
else if (o->direction == ODR_DECODE)
{
- if ((res = ber_declen(o->bp, &o->op->stack[o->op->stackp].len)) < 0)
+ if ((res = ber_declen(o->bp, &o->op->stack[o->op->stackp].len,
+ odr_max(o))) < 0)
+ {
+ odr_seterror(o, OOTHER, 31);
+ --(o->op->stackp);
return 0;
+ }
o->op->stack[o->op->stackp].lenlen = res;
o->bp += res;
+ if (o->op->stack[o->op->stackp].len > odr_max(o))
+ {
+ odr_seterror(o, OOTHER, 32);
+ --(o->op->stackp);
+ return 0;
+ }
}
else if (o->direction == ODR_PRINT)
{
}
else
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 33);
+ --(o->op->stackp);
return 0;
}
o->op->stack[o->op->stackp].base = o->bp;
return 0;
if (o->op->stackp < 0)
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 34);
return 0;
}
switch (o->direction)
}
else
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 35);
return 0;
}
}
else if (o->bp - o->op->stack[o->op->stackp].base !=
o->op->stack[o->op->stackp].len)
{
- o->error = OCONLEN;
+ odr_seterror(o, OCONLEN, 36);
return 0;
}
o->op->stackp--;
if ((res = ber_enclen(o, pos - o->op->stack[o->op->stackp].base_offset,
o->op->stack[o->op->stackp].lenlen, 1)) < 0)
{
- o->error = OLENOV;
+ odr_seterror(o, OLENOV, 37);
return 0;
}
odr_seek(o, ODR_S_END, 0);
fprintf(o->print, "}\n");
return 1;
default:
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 38);
return 0;
}
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_enum.c,v 1.7 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_enum.c,v 1.8 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
}
if (cons)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 54);
return 0;
}
if (o->direction == ODR_DECODE)
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_int.c,v 1.17 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_int.c,v 1.18 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
}
if (cons)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 1);
return 0;
}
if (o->direction == ODR_DECODE)
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: odr_mem.c,v 1.21 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_mem.c,v 1.22 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
{
if (o->pos + bytes >= o->size && odr_grow_block(o, bytes))
{
- o->error = OSPACE;
+ odr_seterror(o, OSPACE, 40);
return -1;
}
memcpy(o->buf + o->pos, buf, bytes);
offset += o->top;
if (offset > o->size && odr_grow_block(o, offset - o->size))
{
- o->error = OSPACE;
+ odr_seterror(o, OSPACE, 41);
return -1;
}
o->pos = offset;
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_null.c,v 1.15 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_null.c,v 1.16 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
if (cons)
{
#ifdef ODR_STRICT_NULL
- o->error = OPROTO;
+ odr_seterror(OPROTO, 42);
return 0;
#else
fprintf(stderr, "odr: Warning: Bad NULL\n");
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_oct.c,v 1.20 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_oct.c,v 1.21 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
}
if (ber_octetstring(o, *p, cons))
return 1;
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 43);
return 0;
}
&outbuf, &outleft);
if (ret == (size_t)(-1))
{
- o->error = ODATA;
+ odr_seterror(o, ODATA, 44);
return 0;
}
t->size = t->len = outbuf - (char*) t->buf;
&outbuf, &outleft);
if (ret == (size_t)(-1))
{
- o->error = ODATA;
+ odr_seterror(o, ODATA, 45);
return 0;
}
inleft = outbuf - (char*) *p;
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_oid.c,v 1.18 2003-01-06 08:20:28 adam Exp $
+ * $Id: odr_oid.c,v 1.19 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
return opt;
if (cons)
{
- o->error = OPROTO;
+ odr_seterror(o, OPROTO, 46);
return 0;
}
if (o->direction == ODR_PRINT)
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_seq.c,v 1.29 2003-01-06 08:20:28 adam Exp $
+ * $Id: odr_seq.c,v 1.30 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
}
break;
default:
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 47);
return 0;
}
return odr_sequence_end(o);
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: odr_tag.c,v 1.13 2003-01-06 08:20:28 adam Exp $
+ * $Id: odr_tag.c,v 1.14 2003-03-11 11:03:31 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
{
if (o->direction != ODR_DECODE)
{
- o->error = OOTHER;
+ odr_seterror(o, OOTHER, 48);
return 0;
}
if (o->op->stackp > -1 && !odr_constructed_more(o))
return 0;
- if (ber_dectag(o->bp, zclass, tag, cons) <= 0)
+ if (ber_dectag(o->bp, zclass, tag, cons, odr_max(o)) <= 0)
{
- o->error = OREQUIRED;
+ odr_seterror(o, OREQUIRED, 49);
return 0;
}
return 1;