X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=odr%2Fber_oid.c;h=905a4821da80484bd79ab6e7e5f98e5ea208974c;hb=8bccad6217bd2ba078106a531a9e73e7f3aae4a9;hp=0f48b31128a6e1758dea1613e6f0409b76972d4f;hpb=569f86b4615c2731727be2a0ff898d36f9725819;p=yaz-moved-to-github.git diff --git a/odr/ber_oid.c b/odr/ber_oid.c index 0f48b31..905a482 100644 --- a/odr/ber_oid.c +++ b/odr/ber_oid.c @@ -1,9 +1,9 @@ /* - * Copyright (c) 1995-2002, Index Data + * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: ber_oid.c,v 1.13 2002-07-25 12:51:08 adam Exp $ + * $Id: ber_oid.c,v 1.15 2003-03-11 11:03:31 adam Exp $ */ #if HAVE_CONFIG_H #include @@ -20,14 +20,14 @@ int ber_oidc(ODR o, Odr_oid *p) 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; @@ -36,6 +36,11 @@ int ber_oidc(ODR o, Odr_oid *p) *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; @@ -50,7 +55,7 @@ int ber_oidc(ODR o, Odr_oid *p) { if (!len) { - o->error = OPROTO; + odr_seterror(o, OPROTO, 21); return 0; } p[pos] <<= 7; @@ -70,7 +75,7 @@ int ber_oidc(ODR o, Odr_oid *p) 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++) @@ -96,12 +101,13 @@ int ber_oidc(ODR o, Odr_oid *p) 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; } }