gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnokii 0.6.31 problem with german umlauts


From: Daniele Forsi
Subject: Re: gnokii 0.6.31 problem with german umlauts
Date: Sat, 18 Aug 2012 13:07:00 +0200

2012/8/17 lsg:

> Maybe use something like that will help with foreign characters

thank you but glib is supposed to handle encodings for us

Pawel, I have a fix for the wrong encoding which is due to
gn_sms_send() converting in place the buffer to UTF-8 while later code
assumes it's still in the system locale, which for the OP is
ISO-8859-15 but my fix segfaults because str is NULL if the input
can't be converted, eg. with UTF-8 locale this segfaults after my
"fix" while it sends an empty SMS without my fix:
echo -e "\xdf" | gnokii --phone fake --sendsms 123
it doesn't matter if there are valid chars before or after the invalid one

the easier fix would be to exit with an error from gn_sms_send() if
g_locale_to_utf8() fails sending an empty SMS makes no sense to me,
but IIRC when libgnokii was using only iconv() invalid chars where
replaced with question marks which was at least an hint of where the
things went wrong

diff --git a/common/gsm-sms.c b/common/gsm-sms.c
index 77ab16d..669f3c7 100644
--- a/common/gsm-sms.c
+++ b/common/gsm-sms.c
@@ -1642,14 +1642,12 @@ GNOKII_API gn_error gn_sms_send(gn_data *data,
struct gn_statemachine *state)
                            data->sms->user_data[i].type ==
GN_SMS_DATA_NokiaText) {
                                str =
g_locale_to_utf8(data->sms->user_data[i].u.text, -1, &inlen, &outlen,
NULL);
                                data->sms->user_data[i].chars =
g_utf8_strlen(str, outlen);
-                               memset(data->sms->user_data[i].u.text,
0, sizeof(data->sms->user_data[i].u.text));
-
g_utf8_strncpy(data->sms->user_data[i].u.text, str,
data->sms->user_data[i].chars);
-                               g_free(str);
                                /* Let's make sure the encoding is correct */
-                               enc =
char_def_alphabet_string_stats(data->sms->user_data[i].u.text,
&enc_chars, &ext_chars);
+                               enc =
char_def_alphabet_string_stats(str, &enc_chars, &ext_chars);
                                if (enc == GN_SMS_DCS_UCS2)
                                        data->sms->dcs.u.general.alphabet = enc;
                                data->sms->user_data[i].chars = enc_chars;
+                               g_free(str);
                        } else {
                                /* FIXME: that's wrong for Nokia
Multipart Picture Message, does anybody still use it? */
                                data->sms->dcs.u.general.alphabet =
GN_SMS_DCS_8bit;


this is the segfault:
#0  0xb7d47ef0 in g_utf8_validate () from /lib/i386-linux-gnu/libglib-2.0.so.0
#1  0x08079877 in char_def_alphabet_string_stats (address@hidden,
address@hidden,
address@hidden)
    at ../../gnokii/common/gsm-encoding.c:516
#2  0x08076071 in gn_sms_send (address@hidden,
address@hidden) at ../../gnokii/common/gsm-sms.c:1646
#3  0x0805a4dd in sendsms (address@hidden, argv=0xbffff4c4,
data=0xb78815c4, state=0xb7881008) at
../../gnokii/gnokii/gnokii-sms.c:333
#4  0x0804da6f in parse_options (address@hidden, argv=<optimized
out>) at ../../gnokii/gnokii/gnokii.c:890
#5  0x0804d1e9 in parse_options (address@hidden,
address@hidden) at ../../gnokii/gnokii/gnokii.c:857
#6  0x0804c697 in main (argc=5, argv=0xbffff4c4) at
../../gnokii/gnokii/gnokii.c:1234

-- 
Daniele Forsi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]