* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: ber_oid.c,v 1.5 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_oid.c,v 1.6 2005-05-26 21:46:40 adam Exp $
*/
/**
#include "odr-priv.h"
-int ber_oidc(ODR o, Odr_oid *p)
+int ber_oidc(ODR o, Odr_oid *p, int max_oid_size)
{
int len, lenp, end;
int pos, n, res, id;
odr_seterror(o, OPROTO, 18);
return 0;
}
- if (len <= 0)
+ if (len < 0)
{
odr_seterror(o, OPROTO, 19);
return 0;
p[1] = id - p[0] * 40;
pos = 2;
}
+ if (pos >= max_oid_size)
+ {
+ odr_seterror(o, OPROTO, 55);
+ return 0;
+ }
}
p[pos] = -1;
return 1;
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: odr_oid.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_oid.c,v 1.6 2005-05-26 21:46:40 adam Exp $
*/
/**
* \file odr_oid.c
}
if (o->direction == ODR_DECODE)
*p = (int *)odr_malloc(o, OID_SIZE * sizeof(**p));
- return ber_oidc(o, *p);
+ return ber_oidc(o, *p, OID_SIZE);
}
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: oid.c,v 1.7 2005-01-15 19:47:14 adam Exp $
+ * $Id: oid.c,v 1.8 2005-05-26 21:46:41 adam Exp $
*/
/**
nmem_mutex_enter (oid_mutex);
if (!oident)
{
- char desc_str[200];
struct oident_list *oident_list;
oident_list = (struct oident_list *)
nmem_malloc (oid_nmem, sizeof(*oident_list));
if (!desc)
{
+ char desc_str[OID_SIZE*10];
int i;
- sprintf (desc_str, "%d", *oid);
- for (i = 1; i < 12 && oid[i] >= 0; i++)
- sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
- desc = desc_str;
+ *desc_str = '\0';
+ if (*oid >= 0)
+ {
+ sprintf (desc_str, "%d", *oid);
+ for (i = 1; i < OID_SIZE && oid[i] >= 0; i++)
+ sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
+ }
+ oident->desc = nmem_strdup(oid_nmem, desc_str);
}
- oident->desc = nmem_strdup (oid_nmem, desc);
+ else
+ oident->desc = nmem_strdup(oid_nmem, desc);
if (value == VAL_DYNAMIC)
oident->value = (enum oid_value) (++oid_value_dynamic);
else