-
Notifications
You must be signed in to change notification settings - Fork 305
Open
Description
Hi,
I found that the enum_unpack in lib/asn1/asn1_utils.cpp has some issues.
SRSASN_CODE pack_enum(bit_ref& bref, uint32_t enum_val, uint32_t nbits, uint32_t nof_noext)
{
bool ext = enum_val >= nof_noext;
HANDLE_CODE(bref.pack((bool)ext, 1));
SRSASN_CODE ret;
if (not ext) {
ret = bref.pack(enum_val, nbits);
// Potential fix: add some checks if enum_val is within the root
} else {
ret = pack_norm_small_non_neg_whole_number(bref, enum_val - nof_noext);
}
return ret;
}The issue can be explained with this small example,
S1 ::= ENUMERATED { e1, e2, e3, ..., e4 }
The correct encoding of e4 should be [ 1 | 0000000 ] in binary.
However, here the code would accept [ 0 | 11 ] as e4 instead of rejecting it.
To fix it, simply add a check to see if enum_val is within the root.
Metadata
Metadata
Assignees
Labels
No labels