Ethereal-dev: [Ethereal-dev] asn1.c patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Matthijs Melchior <mmelchior@xxxxxxxxx>
Date: Mon, 23 Jun 2003 21:28:10 +0200
After moving my asn1 dissector from 0.9.12 to 0.9.13 I found a
problem.

The changes in asn1.c from 1.18 to 1.19 contain a serious mistake.
Version 1.19 cannot correctly read bit strings any more. It does
not count the byte with the number of unused bits towards the
encoded length.  Thus after handling a bitstring, the datastream
is not synchronized any more.

Please apply the following patch.

--
Regards,
----------------------------------------------------------------  -o)
Matthijs Melchior                                       Maarssen  /\\
mmelchior@xxxxxxxxx                                  Netherlands _\_v
---------------------------------------------------------------- ----

--- asn1.c-ORG	2003-05-11 17:06:34.000000000 +0200
+++ asn1.c	2003-06-23 14:01:22.000000000 +0200
@@ -607,6 +607,7 @@
     int eoc;
     guchar *ptr;
 
+    eoc = asn1->offset + enc_len;
     *bits = NULL;
     ret = asn1_octet_decode (asn1, unused);
     if (ret != ASN1_ERR_NOERROR)
@@ -634,7 +635,6 @@
 	*bits = g_malloc (1);
     }
 
-    eoc = asn1->offset + enc_len;
     ptr = *bits;
     while (asn1->offset < eoc) {
         ret = asn1_octet_decode (asn1, (guchar *)ptr++);