fixed asn1_oid_to_string() conversion
This commit is contained in:
@@ -183,36 +183,30 @@ char *asn1_oid_to_string(chunk_t oid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
val = oid.ptr[0] / 40;
|
val = oid.ptr[0] / 40;
|
||||||
len = snprintf(buf, sizeof(buf), "%d.%d", val, oid.ptr[0] - val * 40);
|
len = snprintf(buf, sizeof(buf), "%u.%u", val, oid.ptr[0] - val * 40);
|
||||||
oid = chunk_skip(oid, 1);
|
oid = chunk_skip(oid, 1);
|
||||||
if (len < 0 || len >= sizeof(buf))
|
if (len < 0 || len >= sizeof(buf))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pos += len;
|
pos += len;
|
||||||
|
val = 0;
|
||||||
|
|
||||||
while (oid.len)
|
while (oid.len)
|
||||||
{
|
{
|
||||||
|
val = (val << 7) + (u_int)(oid.ptr[0] & 0x7f);
|
||||||
|
|
||||||
if (oid.ptr[0] < 128)
|
if (oid.ptr[0] < 128)
|
||||||
{
|
{
|
||||||
len = snprintf(pos, sizeof(buf) + buf - pos, ".%d", oid.ptr[0]);
|
len = snprintf(pos, sizeof(buf) + buf - pos, ".%u", val);
|
||||||
oid = chunk_skip(oid, 1);
|
if (len < 0 || len >= sizeof(buf) + buf - pos)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (oid.len == 1)
|
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
val = ((u_int)(oid.ptr[0] & 0x7F) << 7) + oid.ptr[1];
|
pos += len;
|
||||||
len = snprintf(pos, sizeof(buf) + buf - pos, ".%d", val);
|
val = 0;
|
||||||
oid = chunk_skip(oid, 2);
|
|
||||||
}
|
}
|
||||||
if (len < 0 || len >= sizeof(buf) + buf - pos)
|
oid = chunk_skip(oid, 1);
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pos += len;
|
|
||||||
}
|
}
|
||||||
return strdup(buf);
|
return strdup(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user