From: Adam Dickmeiss Date: Mon, 8 May 2006 19:45:29 +0000 (+0000) Subject: Define max length of OID dot string: OID_STR_MAX. X-Git-Tag: YAZ.2.1.20~54 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=750bc4f7094d6de74c64cfd028d66ae1261be1d1;p=yaz-moved-to-github.git Define max length of OID dot string: OID_STR_MAX. --- diff --git a/include/yaz/oid.h b/include/yaz/oid.h index 05849fe..d59209f 100644 --- a/include/yaz/oid.h +++ b/include/yaz/oid.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: oid.h,v 1.27 2005-06-25 15:46:03 adam Exp $ + * $Id: oid.h,v 1.28 2006-05-08 19:45:29 adam Exp $ */ /** @@ -42,6 +42,7 @@ YAZ_BEGIN_CDECL #define OID_SIZE 20 +#define OID_STR_MAX 256 typedef enum oid_proto { diff --git a/src/oid.c b/src/oid.c index b5cafbe..c54798a 100644 --- a/src/oid.c +++ b/src/oid.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: oid.c,v 1.11 2005-06-25 15:46:04 adam Exp $ + * $Id: oid.c,v 1.12 2006-05-08 19:45:29 adam Exp $ */ /** @@ -504,7 +504,7 @@ struct oident *oid_addent (int *oid, enum oid_proto proto, if (!desc) { - char desc_str[OID_SIZE*10]; + char desc_str[OID_STR_MAX]; int i; *desc_str = '\0'; @@ -599,7 +599,8 @@ void oid_trav (void (*func)(struct oident *oidinfo, void *vp), void *vp) (*func)(&ol->oident, vp); } -int *oid_name_to_oid(oid_class oclass, const char *name, int *oid) { +int *oid_name_to_oid(oid_class oclass, const char *name, int *oid) +{ struct oident ent; /* Translate syntax to oid_val */ @@ -614,21 +615,24 @@ int *oid_name_to_oid(oid_class oclass, const char *name, int *oid) { return oid_ent_to_oid(&ent, oid); } -char *oid_to_dotstring(const int *oid, char *oidbuf) { +char *oid_to_dotstring(const int *oid, char *oidbuf) +{ char tmpbuf[20]; int i; oidbuf[0] = '\0'; - for (i = 0; oid[i] != -1; i++) { + for (i = 0; oid[i] != -1 && i < OID_SIZE; i++) + { sprintf(tmpbuf, "%d", oid[i]); - if (i > 0) strcat(oidbuf, "."); + if (i > 0) + strcat(oidbuf, "."); strcat(oidbuf, tmpbuf); } - return oidbuf; } -char *oid_name_to_dotstring(oid_class oclass, const char *name, char *oidbuf) { +char *oid_name_to_dotstring(oid_class oclass, const char *name, char *oidbuf) +{ int oid[OID_SIZE]; (void) oid_name_to_oid(oclass, name, oid);