Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

type_eq problem #5

Open
galiptopcu opened this issue Dec 6, 2019 · 1 comment
Open

type_eq problem #5

galiptopcu opened this issue Dec 6, 2019 · 1 comment

Comments

@galiptopcu
Copy link

I'm using win10 64 bit.
when "token->type.encoding =TYPE_ENCODING(*parser->current);" used to assigne "type.encoding" below code always returns false. "type.encoding" must be at least two bit. (one for signe).

static bool type_eq(const asn1_type_t *type, asn1_class_t class, asn1_tag_t tag,
asn1_encoding_t encoding) {
return (type->class == class) && (type->tag == tag) &&
(type->encoding == encoding);
}

@lmb
Copy link
Owner

lmb commented Dec 15, 2019

Hi, thanks for the bug report. I tried adding the following test:

diff --git a/src/tests/asn1-tests.c b/src/tests/asn1-tests.c
index 7822033..06173f3 100644
--- a/src/tests/asn1-tests.c
+++ b/src/tests/asn1-tests.c
@@ -526,6 +526,17 @@ test_asn1_parse_invalid_int(void) {
        return 0;
 }

+static char *
+test_asn1_type_eq(void) {
+       const uint8_t data[] = {0x01};
+       const asn1_token_t token =
+           TOKEN(ASN1_TAG_INT, data, ASN1_ENCODING_PRIMITIVE);
+
+       check(asn1_is(&token, ASN1_CLASS_UNIVERSAL, ASN1_TAG_INT, ASN1_ENCODING_PRIMITIVE) == true);
+
+       return 0;
+}
+
 int
 test_asn1_all(int *tests_run) {
        declare_set;
@@ -549,6 +560,7 @@ test_asn1_all(int *tests_run) {
        run_test(test_asn1_parse_time);
        run_test(test_asn1_parse_invalid_time);
        run_test(test_asn1_parse_invalid_int);
+       run_test(test_asn1_type_eq);

        end_set;
 }

This works fine on my machine. Seems like I'm missing something?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants