On Tue, Dec 17, 2013 at 6:13 PM, Pascal Quantin
<pascal.quantin () gmail com> wrote:
in 3GPP world BCD encoding starts with the least significant nibble. That's
why tvb_bcd_dig_to_wmwm_packet_str() behaves like this. Changing it to
decode the most significant nibble first would break all the dissectors
currently using this function.
OK, just wondering.
The "stop condition" for the most significant nibble set to 0xf is just to
detect the filler digit in case you have an odd number of digits. In case of
even number, the length itself is sufficient and you do not need a filler,
so no "stop condition" is required.
In that case, what should the decoder do if it encounters a 0xf nibble
embedded in a value (ie due to a malformed packet instead of
indicating a stop condition)? Currently our behaviour is rather
- if 0xf is in the high nibble, decoding stops even though the whole
length has not yet been decoded (ie if we pass a len of 12 but the
very first nibble is 0xf then we don't decode anything at all)
- if 0xf is in the low nibble, we read past the end of the digit array
(dgt_set_t) and decode it as a garbage value
Throwing an exception seems a little extreme, but I'm not sure what else to do.