X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=odr%2Fodr_cons.c;h=152134341f9a5f07db218cdf3d9d6b753581d9b1;hp=0bda85a94e6789ecf1dc2309273e329b5b6e2630;hb=ec1f815d5348cd21e393f76bc212c910c34bbc45;hpb=569f86b4615c2731727be2a0ff898d36f9725819 diff --git a/odr/odr_cons.c b/odr/odr_cons.c index 0bda85a..1521343 100644 --- a/odr/odr_cons.c +++ b/odr/odr_cons.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 1995-2002, Index Data + * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: odr_cons.c,v 1.23 2002-07-25 12:51:08 adam Exp $ + * $Id: odr_cons.c,v 1.26 2003-05-20 19:55:30 adam Exp $ * */ #if HAVE_CONFIG_H @@ -31,14 +31,14 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag, o->t_class = zclass; o->t_tag = tag; } - if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, 1)) < 0) + if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, 1, name)) < 0) return 0; if (!res || !cons) return 0; 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; @@ -52,15 +52,29 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag, 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) { @@ -70,7 +84,8 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag, } else { - o->error = OOTHER; + odr_seterror(o, OOTHER, 33); + --(o->op->stackp); return 0; } o->op->stack[o->op->stackp].base = o->bp; @@ -99,7 +114,7 @@ int odr_constructed_end(ODR o) return 0; if (o->op->stackp < 0) { - o->error = OOTHER; + odr_seterror(o, OOTHER, 34); return 0; } switch (o->direction) @@ -114,14 +129,14 @@ int odr_constructed_end(ODR o) } 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--; @@ -132,7 +147,7 @@ int odr_constructed_end(ODR o) 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); @@ -159,7 +174,7 @@ int odr_constructed_end(ODR o) fprintf(o->print, "}\n"); return 1; default: - o->error = OOTHER; + odr_seterror(o, OOTHER, 38); return 0; } }