Giter Site home page Giter Site logo

Incorrect DER output about asn1c HOT 4 CLOSED

pzb avatar pzb commented on July 23, 2024
Incorrect DER output

from asn1c.

Comments (4)

sleevi avatar sleevi commented on July 23, 2024 2

@vlm I had initially hoped it'd be more expedient to highlight the bug (from casual reading). When @pzb pointed out it'd been open for over a year and a half, I decided it was worth the hassle to go through our internal open-source licensing process if it would help get it merged :)

from asn1c.

sleevi avatar sleevi commented on July 23, 2024

@vlm - This looks like an easy fix, as the SEQUENCE skeleton for uper already appears to handle this logic, since it has to handle the presence bitmap & encoding.

It looks like if

/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
if(!*memb_ptr2) {
ASN_DEBUG("Element %s %d not present",
elm->name, edx);
if(elm->optional)
continue;
/* Mandatory element is missing */
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
memb_ptr2 = &memb_ptr;
}
/* Eliminate default values */
if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
continue;
was uplifted to
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) {
if(elm->optional) continue;
/* Mandatory element is missing */
_ASN_ENCODE_FAILED;
}
} else {
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
and to
if(elm->flags & ATF_POINTER) {
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
if(!memb_ptr) continue;
} else {
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
}
this would address @pzb 's issue

(Unfortunately, I cannot contribute that patch myself)

from asn1c.

sleevi avatar sleevi commented on July 23, 2024

@vlm Turns out it was messier than I realized - for BOOLEANS with DEFAULT values (ATV_TRUE, ATV_FALSE as literals), no default function was being associated at all. This would also affect cases of PER/XER.

I created #181 to try and fix this, with tests. I'm not terribly thrilled with the tests, but they do highlight the issue and cover both SEQUENCEs and SETs. Could you take a look?

from asn1c.

vlm avatar vlm commented on July 23, 2024

Merged, thank you!

@sleevi if you don't mind me asking, I am curious why couldn't you create a patch yourself and then ended up creating it anyway?

from asn1c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.