Commit Graph

159 Commits

Author SHA1 Message Date
Richard Röjfors 429a5a57da util: Fix implicit enum conversion
GCC10 complains about the following:

src/smsutil.c: In function ‘sms_text_prepare_with_alphabet’:
src/smsutil.c:3594:8: error: implicit conversion from ‘enum sms_alphabet’ to ‘enum gsm_dialect’ [-Werror=enum-conversion]
 3594 |        alphabet, &used_locking,

smsutil and util has an enum each for representing
the same thing; The SMS alphabet. They share the same
values, so an explicit type cast makes GCC happy.
2020-12-22 09:45:05 -06:00
Slava Monich cf4a4a7bd0 cbs: Allow the last CBS fragment to be truncated
That does happen in real life.
2020-06-18 15:34:20 -05:00
Denis Kenzior 4059d4226b util: Switch character conversions to ell
Switch various conversions from GSM/UCS2 to UTF8 from glib based
implementation over to ell.

This also converts all related g_free calls to l_free calls (though in
the end they are equivalent calls to free)
2018-12-27 18:18:51 -06:00
Denis Kenzior 44415e754b smsutil: Use l_utf8_from_utf16 instead of g_convert 2018-12-27 18:18:51 -06:00
Denis Kenzior 9c7a87673a util: Use l_utf8_to_ucs2be instead of g_convert 2018-12-27 18:18:51 -06:00
Denis Kenzior 5229080d92 util: Use ell in convert_utf8_to_gsm 2018-12-27 18:18:51 -06:00
Denis Kenzior d5f117be80 util: Convert pack7_bit / unpack_7bit to use l_malloc 2018-12-27 18:18:51 -06:00
Denis Kenzior 70c70a67b0 util: Use bool instead of gboolean 2018-12-27 18:18:51 -06:00
Nandini Rebello d984a59f3d util: adding 8 national sms alphabets
Adding national language tables for hindi,kannada,malayalam,
oriya,punjabi,tamil,telugu and urdu.
2018-10-15 14:07:27 -05:00
Nandini Rebello 7e82a2d940 util: add bengali and gujrati sms alphabets 2018-10-01 14:52:03 -05:00
Slava Monich a1df13a3bc smsutil: Prevent invalid access in cbs_decode_text
Valgrind was complaining about it like this:

==18099== Conditional jump or move depends on uninitialised value(s)
==18099==    at 0x4C32281: strspn
==18099==    by 0x41286B: cbs_decode_text (smsutil.c:4140)
==18099==    by 0x40675C: test_cbs_encode_decode (test-sms.c:1417)
2016-12-30 18:19:21 -06:00
Slava Monich 52c2c401b4 smsutil: Fix receiving UTF-16 encoded messages
The spec supports UCS2, but in reality UTF-16 is used, which supports
4-byte characters, which could be split into different message
fragments. Accumulate the entire UTF-16 message before converting to
UTF8.

Author: Martin Jones <martin.jones@jolla.com>
2016-11-18 09:34:33 -06:00
John Ernberg f6446d60f9 smsutil: Use g_slist_free_full 2016-04-22 15:32:43 -05:00
Alfonso Sanchez-Beato ac14de37ca smsutil: Do not check the origin port
Do not check if the origin port is reserved, as some operators use that
range of values.
2015-09-08 09:14:03 -05:00
Denis Kenzior e2398b4dfa smsutil: Add additional sanity check
We make sure that after performing the UTF8 -> GSM conversion, the
number of GSM bytes is not greater than 11, which is the maximum
payload.
2015-02-13 09:59:59 -06:00
Tommi Kenakkala 2af3c733b7 sms: Fix alphanumeric TP-OA handling
TP-OA max length comparisons were incorrect because TP-OA's 7-bit
coded octets transport eleven 8-bit chars.  The current code assumed
only 10 chars were possible.

The patch
- increases the array size to 23, (maximum of 22 bytes for UTF8
  encoding + null terminator)
- Updates the sanity check to account for the correct maximum
- For encoding, checks the maximum length in UTF8 characters instead of
  bytes
2015-02-13 09:49:39 -06:00
Denis Kenzior d7ba153737 smsutil: Make sure to return 1/0
So the value might be used directly for D-Bus property emission.
Otherwise D-Bus asserts and screws itself with:
ofonod[7427]: src/sms.c:handle_mwi()
process 7427: arguments to dbus_message_iter_append_basic() were
incorrect, assertion "*bool_p == 0 || *bool_p == 1" failed in file
../../dbus/dbus-message.c line 2549.
2013-09-03 22:58:59 -05:00
Denis Kenzior 5249303423 smsutil: Fix warning
src/smsutil.c: In function ‘cbs_decode_text’:
src/smsutil.c:4116:16: error: comparison between signed and unsigned
integer expressions [-Werror=sign-compare]
2012-10-01 09:52:32 -05:00
Denis Kenzior af9951d5d0 smsutil: Fix up style issues from previous commit 2012-09-17 11:56:09 -05:00
Philippe Nunes 27b63a96c3 smsutil: <CR> is not necessarily a CBS padding character 2012-09-17 11:51:11 -05:00
Denis Kenzior 941257bec6 smsutil: Fix CR padding logic for 7-bit case 2012-09-17 11:48:03 -05:00
Philippe Nunes d31eba88c7 smsutil: Fix style issues 2012-09-17 11:27:51 -05:00
Marcel Holtmann 7e6afe37bf core: Update copyright information 2011-10-10 13:39:42 -07:00
Marcel Holtmann e861d1369a smsutil: Mark variable properly as unused 2011-05-29 11:55:48 -07:00
Marcel Holtmann f13bedd9dc smsutil: Fix missing error handling for strtol function 2011-05-27 09:48:45 -07:00
Bertrand Aygon 0403b341ca smsutil: fix a memory leak
This was reported by cppcheck.
2011-03-18 11:29:06 -05:00
Denis Kenzior b7f8fc6f83 smsutil: Fix compilation 2011-02-03 14:37:00 -06:00
Aki Niemi cd1e58bd20 smsutil: Add alphabet support to encoding 2011-02-03 14:24:00 -06:00
Lucas De Marchi f5b1c95490 smsutil: do not allow larger file names
If file name had anything in the name after addr-msgid, it would be
parsed as well. This is not what we want, since there could be temporary
files lying around.
2011-01-28 20:32:09 -06:00
Denis Kenzior 971bdfbe48 smsutil: Don't bother renaming to the same name
In sms_tx_queue_load, if the resulting file is the same (which is quite
often the case) then don't bother trying to rename it.
2011-01-28 20:27:58 -06:00
Denis Kenzior 31a4c0025d smsutil: Fix corner case during tx queue loading
If there are extraneous files in the directory when it is being loaded,
then the index used to rename the old file into the new file can get out
of sync with what the core expects.
2011-01-28 20:20:56 -06:00
Denis Kenzior b1acc3c2db smsutil: simplify tx backup loading
glib functions as a rule do not use g_try* variations.  They use
g_malloc instead, so there's no need to check for out of memory
conditions.
2011-01-28 19:51:32 -06:00
Lucas De Marchi bc0386cb23 sms: restore pending tx messages from backup
Based on patch from: Kristen Carlson Accardi <kristen@linux.intel.com>
2011-01-28 16:55:31 -06:00
Lucas De Marchi f55447a39e sms: delete sent sms messages from backup
Based on patch from Kristen Carlson Accardi <kristen@linux.intel.com>
2011-01-28 16:14:41 -06:00
Lucas De Marchi 8305ddf321 sms: store pending tx pdus on disk
Based on patch from Kristen Carlson Accardi <kristen@linux.intel.com>
2011-01-28 16:14:12 -06:00
Jeevaka Badrappan 819fb91144 smsutil: M15 coding style fix 2011-01-12 08:06:58 -08:00
Yang Gu f6b037661b smsutil: Make timezone an optional field 2010-12-08 07:53:30 -06:00
Yang Gu 173c6798d6 smsutil: Change the range of time zone 2010-12-07 12:16:20 -06:00
Denis Kenzior 353d1548bd smsutil: Minor style fix 2010-12-07 12:16:20 -06:00
Jeevaka Badrappan ef785f9373 smsutil: Fix issue in mwi dcs decoding 2010-12-02 08:08:54 -06:00
Denis Kenzior c5a42cfabe smsutil: Fix uninitialized optional elements
sms_decode was never memsetting the returned structure, so if any
optional elements were present in the SMS (e.g. status report) then the
structure was not completely initialized.
2010-12-02 07:53:54 -06:00
Lucas De Marchi 8e0f9aab9e smsutil: explicitly compare pointers to NULL
This patch was generated by the following semantic patch
(http://coccinelle.lip6.fr/)

// <smpl>
@fix disable is_null,isnt_null1@
expression *E;
@@

- !E
+ E == NULL
// </smpl>
2010-11-29 13:04:04 -06:00
Jeevaka Badrappan e6e27406ae smsutil: coding style fixes - rule M6 2010-11-22 05:05:31 -06:00
Denis Kenzior 78cac8472f smsutil: Use entire range of ref / port addresses 2010-11-04 11:09:11 -05:00
Denis Kenzior 8b54166523 smsutil: Remove traces of ref_offset variable 2010-11-02 15:56:30 -05:00
Denis Kenzior 2cc92d80e6 smsutil: Add sms_datagram_prepare 2010-11-02 14:58:21 -05:00
Denis Kenzior 57d847692c smsutil: Get rid of ref_offset in sms_text_prepare
The reason for this parameter has ceased to exist quite a while ago.
Namely when the API allowed multiple SMS recipients.  We prepared a
single set of segments and then reset the to address and reference.  We
no longer allow multiple recipients and none of this is now needed.
2010-11-02 14:58:21 -05:00
Denis Kenzior a05ebc93ab smsutil: Additional sanity checks for decode_scts 2010-11-02 12:15:53 -05:00
Denis Kenzior c12632dfef smsutil: Reflow the fuzzy matching code
Make a bit more readable
2010-09-22 16:27:30 -05:00
Petteri Tikander 6c1ec61603 smsutil: add fuzzy address check for status report 2010-09-22 12:20:52 -05:00