Skip to content

Conversation

@1223421
Copy link

@1223421 1223421 commented Sep 18, 2025

If a Counter64 has 1 in the first bit, an IntegerNegative error is raised. For unsigned values, this check is not needed. The bug is in the decode_array_uint function — why check the first bit for an unsigned value?

@chifflier
Copy link
Member

Hi,
Counter64 is defined as (IMPLICIT) INTEGER with constraints, and INTEGER is encoded as following (in X.590):
The contents octets shall be a two’s complement binary number equal to the integer value [...]
This means that encoding an unsigned int with the first bit set is an invalid encoding, because this is reserved to encode negative numbers. Since this is invalid, this PR will be marked as wontfix.
That said, I also encountered some applications using this wrong encoding. One solution (more a workaround) is to force conversion to unsigned if bit 1 is set. Maybe we can also add a helper function to the API to force reading as unsigned?
If you are interested in this addition, please open a new PR, or just tell me and I will have a look.

@chifflier chifflier added the wontfix This will not be worked on label Sep 18, 2025
@1223421
Copy link
Author

1223421 commented Sep 18, 2025

I’m not a good enough programmer to add the described fix myself.
So basically, should it be a signed counter there?

Most likely, D-Link isn’t aware of this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants