Skip to content

test for issue #507 always passes #561

@jamuir

Description

@jamuir

Description

There is a test vector for issue #507 in tests/der_test.c. However, if you revert the fix for #507, the test still passes (so the test in its current form doesn't really tell us much).

Steps to Reproduce

One way is to reset to d2027d6, revert 25c26a3 and then run the tests.

Another way is to revert the fix for #507 manually:

diff --git a/src/pk/asn1/der/utf8/der_decode_utf8_string.c b/src/pk/asn1/der/utf8/der_decode_utf8_string.c
index 93a5e5ed..c2b6bb6b 100644
--- a/src/pk/asn1/der/utf8/der_decode_utf8_string.c
+++ b/src/pk/asn1/der/utf8/der_decode_utf8_string.c
@@ -77,7 +77,7 @@ int der_decode_utf8_string(const unsigned char *in,  unsigned long inlen,
       for (z = 0; (tmp & 0x80) && (z <= 4); z++, tmp = (tmp << 1) & 0xFF);
 
       /* z should be in {0,2,3,4} */
-      if (z == 1 || z > 4) {
+      if (z > 4) {
          return CRYPT_INVALID_PACKET;
       }
 
@@ -85,7 +85,7 @@ int der_decode_utf8_string(const unsigned char *in,  unsigned long inlen,
       tmp >>= z;
 
       /* now update z so it equals the number of additional bytes to read */
-      if (z > 0) { --z; }
+      if (z > 1) { --z; }
 
       if (x + z > inlen) {
          return CRYPT_INVALID_PACKET;

To run the der test, I do this:

CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" make test && ./test der

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions