wdoekes / asterisk-chan-dongle

chan_dongle channel driver for Huawei UMTS cards, works with Asterisk 14+
Other
296 stars 104 forks source link

fix Cannot parse UCS-2 error #131

Closed 129tyc closed 3 years ago

129tyc commented 3 years ago

Maybe I found the solution for parsing ucs-2 type SMS. After debugging the parsing code, I thought the function iconv in libconv need more buffer length to convert ucs-2 to utf-8. So I increase the output buffer length and the code just works! No more error, everything is fine. #93

wdoekes commented 3 years ago

Nice catch!

That res2+2 looks like the right length for conversion to ucs2, not from. It indeed makes sense to simply use the the max buffer size there (or res4+1, but there is not benefit to calculating it).

However, that 4096 should not just come out of nowhere. Where is msg defined? Should we pass the total size through *msg_len instead?

129tyc commented 3 years ago

Nice catch!

That res_2+2 looks like the right length for conversion to ucs2, not from. It indeed makes sense to simply use the the max buffer size there (or res_4+1, but there is not benefit to calculating it).

However, that 4096 should not just come out of nowhere. Where is msg defined? Should we pass the total size through *msg_len instead?

@wdoekes simply fix magic number because of my poor c++ skill... 😢

fangli commented 3 years ago

This issue happens to both of my K3765 as well: Bus 001 Device 008: ID 12d1:1465 Huawei Technologies Co., Ltd. K3765 HSPA Bus 001 Device 005: ID 12d1:1465 Huawei Technologies Co., Ltd. K3765 HSPA

It's totally reproduceable. And I've confirmed this CR fixed the issue, just like a magic.

It would be great if we can get this PR reviewed and merged soon.

hselasky commented 3 years ago

Similar to issue #140 .