aboutsummaryrefslogtreecommitdiffstats
path: root/src/csn1.c
AgeCommit message (Collapse)AuthorFilesLines
2020-03-30csn1: Remove code block from CSN_NEXT_EXIST_LHPau Espin Pedrol1-6/+0
It was removed in wireshark.git e8407dd6c1378427daee77e8de540d0b5f7a0b73 and it's not there anymore in current master. Change-Id: I73f4eeca3fd4f00a5bc4f06ef7a9bb9b8a70e37b
2020-03-30csn1: Properly verify CSN_BITMAP lengthPau Espin Pedrol1-4/+16
Change-Id: I9f7672b534f9345caff99095504749eebad25adb
2020-03-30csn1: verify enough bits present to decode whole CSN_UINT_ARRAYPau Espin Pedrol1-4/+4
Change-Id: I4a762a8fec4153b53e10df1ec8ba3708c1f47649
2020-03-30csn1: Fix Several typos & whitespacePau Espin Pedrol1-4/+3
Change-Id: Ibe31d52d4a5a4015196d73681082f68b99a80c77
2020-03-30rlcmac: support decode FDD_CELL_INFORMATION of "UTRAN FDD DescriptionPau Espin Pedrol1-1/+7
Port of patch (+ later fixes squashed) of wireshark.git commit dea5452b95dfaf18e38670a8e2b3b38f9175fdfd, from Lei Chen: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6856 Squashed wireshark.git fix commits: 774be29de0b4d93d01aecb1518c41d7d551071a9 51c31cd7bd3d8fc196a9f90a8af466ad84e9e6a8 6aca10831f86c562970b13efa811f46e25ee3091 c1ceac58cdb77051e9bd14c1f6f7669cf5779a86 Change-Id: I08523bc1bbdffde479ef974b4c7b56cfa5639591
2020-03-23csn1: Validate recursive array max size during decodingPau Espin Pedrol1-2/+16
This way if CSN1 encoded bitstream contains more elements than what the defintion expects it will fail instead of overflowing the decoded buffer. RA cap struct placed in unit test is taken from a real android phone sending the value when attaching to the network. Then SGSN sends it back and osmo-pcu would crash similar to unit test: *** stack smashing detected ***: terminated Process terminating with default action of signal 6 (SIGABRT): dumping core at 0x4C62CE5: raise (in /usr/lib/libc-2.31.so) by 0x4C4C856: abort (in /usr/lib/libc-2.31.so) by 0x4CA62AF: __libc_message (in /usr/lib/libc-2.31.so) by 0x4D36069: __fortify_fail (in /usr/lib/libc-2.31.so) by 0x4D36033: __stack_chk_fail (in /usr/lib/libc-2.31.so) by 0x124706: testRAcap2(void*) (RLCMACTest.cpp:468) Related: OS#4463 Change-Id: I9fe0e55e0a6a41ae2cc885fba490c1d4a186231e
2020-03-19csn1.c: Almost all of the logging is DEBUG, not NOTICEHarald Welte1-106/+106
low-level text decodes of CSN.1 messages certainly are not NOTICEable events, but rather something used for debugging. Right now we get various text CSN.1 log output of osmo-pcu in it's default configuration. Despite all log levels being relatively high (NOTICE), we still see those messages as they simply are logged at the wrong level. Related: OS#2577 Change-Id: I7b42c9e21ad8d8a5b54e7a3b68490934ce3d3198
2020-03-11csn1: fix: do not return 0 if no bits left in the bufferVadim Yanitskiy1-4/+4
Both csnStreamDecoder() and csnStreamEncoder() shall not return 0 prematurely if no more bits left in the input / output bit-vector. Returning CSN_ERROR_NEED_MORE_BITS_TO_UNPACK might make more sense, however we don't know in advance (i.e. without entering the loop) whether it's an error or not. Some CSN.1 definitions have names like 'M_*_OR_NULL', what basically means that they're optional and can be ignored or omitted. Most of the case statements do check whether the number of remaining bits is enough to unpack / pack a value, so let's leave it up to the current CSN_* handler (pointed by pDescr) if no bits left. Return CSN_ERROR_NEED_MORE_BITS_TO_UNPACK only if the number of remaining bits is negative as this is an error in any case. Change-Id: Ie3a15e210624599e39b1e70c8d34efc10c552f6c
2020-03-06csn1: fix csnStreamDecoder(): skip bits unhandled by serialize()Vadim Yanitskiy1-0/+7
This change fixes a bug that was reported by Keith Whyte and confirmed in [1]. The problem is that a user-defined handler in case of CSN_SERIALIZE may parse only a part of the given bit-stream, leaving some bits unhandled. This is expected because the sender (i.e. the MS) may use more recent RLC/MAC message definitions containing new fields at the end. Those bits that were left unhandled by serialize() shall not be interpreted as continuation of the message, they shall be skipped. Note that the encoded vector in the RLCMAC unit test still does not match the original one. That's a known bug explained in [2]. [1] If5873355d52d7ddb06c2716154a88d34100f6ab5 [2] Ic46d6e56768f516203d27d8e7a5adb77afdf32b7 Change-Id: Id4cc042fed68fc54aca0355dcb986cab3f6b49ea Related: OS#4338
2020-02-17csn1: use proper format specifier for unsigned integersVadim Yanitskiy1-20/+20
Change-Id: I33f86b79e72394bdb7d99762f8ec21d80e06dc30
2020-02-17csn1: bitvec_get_uint() may return a negative, use %dVadim Yanitskiy1-1/+1
Change-Id: I3cfd66643ec140150a4089b0e1c493d911d3d7d4
2020-02-17csn1: fix csnStreamDecoder(): update bit_offset in CSN_EXIST{_LH}Vadim Yanitskiy1-0/+1
Found while doing differential analysis (comparison against the original implementation from Wireshark). Change-Id: Ibd0b7400d78f7873c2a8d45267332f511b5c6fbb
2020-02-17csn1: fix csnStreamDecoder(): always keep remaining_bits_len updatedVadim Yanitskiy1-2/+4
Found while doing differential analysis (comparison against the original implementation from Wireshark). Change-Id: I9f7fa9c3f2f4ff5213dded930cee7ec509b9d799
2020-02-17csn1: fix csnStreamDecoder(): do not subtract no_of_bits twiceVadim Yanitskiy1-1/+0
Found while doing differential analysis (comparison against the original implementation from Wireshark). Change-Id: Id2a4f03035cd8354d3fba0ad37571453d3986d21
2020-02-17csn1: get rid of C++ specific code, compile with GCCVadim Yanitskiy1-0/+2680
The implementation of CSN.1 codec was taken from Wireshark, where it's implemented in pure C. For some reason it was mixed with C++ specific features, mostly using references in parameter declaration. Not sure what are the benefits. Change-Id: I56d8b7fbd2f9f4e0bdd6b09d0366fe7eb7aa327a