Hi,
The attached patch corrects a fatal coding error in routine
'asn1_bits_decode'. It also changes the interface to be more in line
with all the other decode routines. I must have been the first one
to use it, so this change will not pose a problem....
Thanks.
--
Regards,
---------------------------------------------------------------- -o)
Matthijs Melchior Maarssen /\\
mmelchior@xxxxxxxxx Netherlands _\_v
---------------------------------------------------------------- ----
--- asn1.c-ORG Thu Aug 29 02:39:45 2002
+++ asn1.c Sun Apr 27 23:28:53 2003
@@ -593,34 +593,36 @@
* DESCRIPTION: Decodes Bit String.
* Parameters:
* asn1: pointer to ASN1 socket.
- * eoc: offset of end of encoding, or -1 if indefinite.
- * bits: pointer to begin of Bit String.
- * size: Size of Bit String in characters.
- * len: Length of Bit String in characters.
+ * eoc_len:length of value.
+ * bits: pointer to variable we set to point to strring
+ * len: Size of Bit String in characters.
* unused: Number of unused bits in last character.
* RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success)
*/
int
-asn1_bits_decode ( ASN1_SCK *asn1, int eoc, guchar **bits,
+asn1_bits_decode ( ASN1_SCK *asn1, int enc_len, guchar **bits,
guint *len, guchar *unused)
-
{
int ret;
+ int eoc;
+ guchar *ptr;
+ eoc = asn1->offset + enc_len;
*bits = NULL;
ret = asn1_octet_decode (asn1, unused);
if (ret != ASN1_ERR_NOERROR)
return ret;
*len = 0;
- *bits = g_malloc(eoc - asn1->offset);
+ ptr = *bits = g_malloc(enc_len);
while (asn1->offset < eoc) {
- ret = asn1_octet_decode (asn1, (guchar *)bits++);
+ ret = asn1_octet_decode (asn1, (guchar *)ptr++);
if (ret != ASN1_ERR_NOERROR) {
g_free(*bits);
*bits = NULL;
return ret;
}
}
+ *len = ptr - *bits;
return ASN1_ERR_NOERROR;
}
--- asn1.h-ORG Fri Oct 25 03:19:58 2002
+++ asn1.h Sun Apr 27 22:21:24 2003
@@ -127,7 +127,7 @@
int asn1_int32_decode (ASN1_SCK *asn1, gint32 *integer, guint *nbytes);
int asn1_uint32_value_decode (ASN1_SCK *asn1, int enc_len, guint *integer);
int asn1_uint32_decode (ASN1_SCK *asn1, guint32 *integer, guint *nbytes);
-int asn1_bits_decode (ASN1_SCK *asn1, int eoc, guchar **bits,
+int asn1_bits_decode (ASN1_SCK *asn1, int enc_len, guchar **bits,
guint *len, guchar *unused);
int asn1_string_value_decode (ASN1_SCK *asn1, int enc_len,
guchar **octets);