some websites append a newline character to a DER-encoded binary blob

This commit is contained in:
Andreas Steffen
2008-02-05 19:27:05 +00:00
parent 5bbac9ffff
commit 298c9c8eed
2 changed files with 30 additions and 10 deletions
+13 -3
View File
@@ -677,14 +677,24 @@ bool is_asn1(chunk_t blob)
DBG2(" file content is not binary ASN.1"); DBG2(" file content is not binary ASN.1");
return FALSE; return FALSE;
} }
len = asn1_length(&blob); len = asn1_length(&blob);
if (len != blob.len)
/* exact match */
if (len == blob.len)
{ {
return TRUE;
}
/* some websites append a surplus newline character to the blob */
if (len + 1 == blob.len && *(blob.ptr + len) == '\n')
{
return TRUE;
}
DBG2(" file size does not match ASN.1 coded length"); DBG2(" file size does not match ASN.1 coded length");
return FALSE; return FALSE;
} }
return TRUE;
}
/** /**
* codes ASN.1 lengths up to a size of 16'777'215 bytes * codes ASN.1 lengths up to a size of 16'777'215 bytes
+13 -3
View File
@@ -758,13 +758,23 @@ is_asn1(chunk_t blob)
) )
return FALSE; return FALSE;
} }
len = asn1_length(&blob); len = asn1_length(&blob);
if (len != blob.len)
/* exact match */
if (len == blob.len)
{ {
return TRUE;
}
/* some websites append a surplus newline character to the blob */
if (len + 1 == blob.len && *(blob.ptr + len) == '\n')
{
return TRUE;
}
DBG(DBG_PARSING, DBG(DBG_PARSING,
DBG_log(" file size does not match ASN.1 coded length"); DBG_log(" file size does not match ASN.1 coded length");
) )
return FALSE; return FALSE;
} }
return TRUE;
}