From: Henrik Ginstmark Date: Fri, 11 Mar 2022 23:33:54 +0000 (+0100) Subject: uqmi: corrected too short received SMS X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=44dd095794a5327611d0ee1a58b0a6333d397b64;p=project%2Fuqmi.git uqmi: corrected too short received SMS When characters with ascii values bigger than 0x7f are used, the length of the received text message is too short. Test message sent: 123äÄ123 Before correction: root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20 Raw text: 31 32 33 7b 5b 31 32 33 { "smsc": "+46724400001", "sender": "+46xxxxxxxxx", "timestamp": "2022-03-11 18:48:10", "text": "123äÄ1" } after correction: root@OpenWrt:/tmp# uqmi -d /dev/cdc-wdm0 --get-message 20 Raw text: 31 32 33 7b 5b 31 32 33 { "smsc": "+46724400001", "sender": "+46xxxxxxxxx", "timestamp": "2022-03-11 18:48:10", "text": "123äÄ123" } Signed-off-by: Henrik Ginstmark --- diff --git a/commands-wms.c b/commands-wms.c index 700d79f..a58fd6a 100644 --- a/commands-wms.c +++ b/commands-wms.c @@ -222,8 +222,8 @@ static int decode_udh(const unsigned char *data) static void decode_7bit_field(char *name, const unsigned char *data, int data_len, int bit_offset) { char *dest = blobmsg_alloc_string_buffer(&status, name, 3 * data_len + 2); - pdu_decode_7bit_str(dest, data, CEILDIV(data_len * 7, 8), bit_offset); - dest[data_len] = 0; + int out_len = pdu_decode_7bit_str(dest, data, CEILDIV(data_len * 7, 8), bit_offset); + dest[out_len] = 0; blobmsg_add_string_buffer(&status); }