diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-04-28 00:31:26 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-04-28 00:31:26 +0000 |
commit | 4b4b030e514b884aaa0d50ba2fe5df830e78f5b0 (patch) | |
tree | 8ef778e248c57fd65ce4fa8ebac4997c5fcd933e /asn1.c | |
parent | 4915f5e6a26bc3da6330f2251c979827b2bfa33e (diff) | |
download | wireshark-4b4b030e514b884aaa0d50ba2fe5df830e78f5b0.tar.gz wireshark-4b4b030e514b884aaa0d50ba2fe5df830e78f5b0.tar.bz2 wireshark-4b4b030e514b884aaa0d50ba2fe5df830e78f5b0.zip |
From Matthijs Melchior: fix "asn1_bits_decode()", and make its API more
closely resemble that of other decode routines.
svn path=/trunk/; revision=7589
Diffstat (limited to 'asn1.c')
-rw-r--r-- | asn1.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -1,7 +1,7 @@ /* asn1.c * Routines for ASN.1 BER dissection * - * $Id: asn1.c,v 1.17 2002/08/28 21:00:05 jmayer Exp $ + * $Id: asn1.c,v 1.18 2003/04/28 00:31:26 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -592,35 +592,37 @@ done: * ) * 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. - * unused: Number of unused bits in last character. + * asn1: pointer to ASN1 socket. + * enc_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; } |