Hi,
   Here is a patch to ensure that 'asn1_string_value_decode' will
return a '\0' terminated string, as opposed to just a byte array of
the requested length. This makes further processing, such as filtering,
much simpler [no more realloc required...].

Please apply

Thanks.

--
Regards,
----------------------------------------------------------------  -o)
Matthijs Melchior                                       Maarssen  /\\
[EMAIL PROTECTED]                                  Netherlands _\_v
---------------------------------------------------------------- ----


--- asn1.c-ORG  2003-06-28 18:07:56.000000000 +0200
+++ asn1.c      2003-08-28 22:29:48.000000000 +0200
@@ -661,7 +661,8 @@
  *              Parameters:
  *              asn1:    pointer to ASN1 socket.
  *              enc_len: length of encoding of value.
- *              octets:  pointer to variable we set to point to string.
+ *              octets:  pointer to variable we set to point to string,
+ *                      which is '\0' terminated for ease of use as C-string
  * RETURNS:     ASN1_ERR value (ASN1_ERR_NOERROR on success)
  */
 int
@@ -681,7 +682,7 @@
      */
     if (enc_len != 0) {
        tvb_ensure_bytes_exist(asn1->tvb, asn1->offset, enc_len);
-       *octets = g_malloc (enc_len);
+       *octets = g_malloc (enc_len+1);
     } else {
        /*
         * If the length is 0, we allocate a 1-byte buffer, as
@@ -702,6 +703,7 @@
            return ret;
        }
     }
+    (guchar *)ptr = '\0';
     return ASN1_ERR_NOERROR;
 }
 

Reply via email to