help-libtasn1
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: issue with octet string when tag is encoded to multiple bytes


From: Nikos Mavrogiannopoulos
Subject: Re: issue with octet string when tag is encoded to multiple bytes
Date: Mon, 1 Jun 2015 09:21:34 +0200

Thanks. Do you have a test case for these strings we can add in Test_strings.c?

On Sun, May 31, 2015 at 9:38 PM, Tomas Petrilak
<address@hidden> wrote:
> hi,
>
> I played with libtasn1 and observed issue when trying decode OCTET STRING
> parameter with tag which is encoded to multiple bytes.
> for example: parameter [200] IMPLICIT OCTET STRING
>
> Problem seems to be in lib/decoding.c in function _asn1_get_octet_string
> which assumes that tag is always only 1 byte.
> Following change did fix it for me:
>
> address@hidden libtasn1-4.5]# diff -Naur lib/decoding.c.orig lib/decoding.c
> --- lib/decoding.c.orig 2015-05-31 21:54:15.484839103 +0200
> +++ lib/decoding.c      2015-05-31 22:02:18.941502144 +0200
> @@ -777,7 +777,7 @@
>
>  static int
>  _asn1_get_octet_string (asn1_node node, const unsigned char *der, int
> der_len,
> -                        int *len, unsigned flags)
> +                        int *len, unsigned flags, int tag_len)
>  {
>    int len2, len3, counter, tot_len, indefinite;
>    int result;
> @@ -785,7 +785,7 @@
>
>    counter = 0;
>
> -  if (*(der - 1) & ASN1_CLASS_STRUCTURED)
> +  if (*(der - tag_len) & ASN1_CLASS_STRUCTURED)
>      {
>        tot_len = 0;
>
> @@ -1262,7 +1262,7 @@
>               move = RIGHT;
>               break;
>             case ASN1_ETYPE_OCTET_STRING:
> -             result = _asn1_get_octet_string (p, der + counter, ider_len,
> &len3, flags);
> +             result = _asn1_get_octet_string (p, der + counter, ider_len,
> &len3, flags, tag_len);
>               if (result != ASN1_SUCCESS)
>                 {
>                    warn();
>
>
>
>
> Tomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]