]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4821 fixed core dump when received sms in UCS2 after having sent sms in UCS2
authorGiovanni Maruzzelli <gmaruzz@gmail.com>
Thu, 20 Jun 2013 21:58:28 +0000 (23:58 +0200)
committerGiovanni Maruzzelli <gmaruzz@gmail.com>
Thu, 20 Jun 2013 22:41:07 +0000 (00:41 +0200)
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp

index 0b1d9350dde65c3991566c2b35e3417ab180de5c..4fcf75cfa2987ea7f9f3eeb054fcf59f4bdd90ec 100644 (file)
@@ -1736,7 +1736,13 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
                                                        //Timestamp servicecentretimestamp;
                                                        //Address sender_recipient_address;
 
-                                                       sms = SMSMessage::decode(tech_pvt->line_array.result[i]);       // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
+                                                       try {
+                                                               sms = SMSMessage::decode(tech_pvt->line_array.result[i]);       // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
+                                                       }
+                                                       catch(...) {
+                                                               ERRORA("GsmException\n", GSMOPEN_P_LOG);
+                                                               return -1;
+                                                       }
 
                                                        DEBUGA_GSMOPEN("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str());
 
@@ -1775,8 +1781,9 @@ int gsmopen_serial_read_AT(private_t *tech_pvt, int look_for_ack, int timeout_us
                                                        //sender_recipient_address = sms->address();
 
                                                }
-                                               catch(GsmException & ge) {
-                                                       ERRORA("GsmException= |||%s|||\n", GSMOPEN_P_LOG, ge.what());
+                                                       catch(...) {
+                                                               ERRORA("GsmException\n", GSMOPEN_P_LOG);
+                                                               return -1;
                                                }
 
 
@@ -2487,7 +2494,7 @@ int utf8_to_iso_8859_1(private_t *tech_pvt, char *utf8_in, size_t inbytesleft, c
        iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 #endif // WIN32
        if (iconv_res == (size_t) -1) {
-               DEBUGA_GSMOPEN("cannot translate in iso_8859_1 error: %s %d\n", GSMOPEN_P_LOG, strerror(errno), errno);
+               DEBUGA_GSMOPEN("cannot translate in iso_8859_1 error: %s (errno: %d)\n", GSMOPEN_P_LOG, strerror(errno), errno);
                return -1;
        }
        DEBUGA_GSMOPEN
@@ -2854,10 +2861,16 @@ int gsmopen_sendsms(private_t *tech_pvt, char *dest, char *text)
 
                                        tech_pvt->no_ucs2 = 0;
                                        tech_pvt->sms_pdu_not_supported = 1;
+
                                        ok = gsmopen_sendsms(tech_pvt, dest, text);
+
                                        tech_pvt->no_ucs2 = 1;
                                        tech_pvt->sms_pdu_not_supported = 0;
 
+                                       err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
+                                       if (err) {
+                                               ERRORA("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT)  didn't get OK from the phone\n", GSMOPEN_P_LOG);
+                                       }
                                        return ok;
                                }
 
index 9816c7815597e08b40d6450e3af1c0d69fe63b7a..6eb6d865aaf9b7d1813df3a18b2abbc68e4c5f63 100644 (file)
@@ -3054,7 +3054,7 @@ int sms_incoming(private_t *tech_pvt)
                return -1;
        }
        //DEBUGA_GSMOPEN("received SMS on interface %s: %s\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_message);
-       DEBUGA_GSMOPEN("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s|\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender,
+       NOTICA("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=|%s|\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender,
                                        tech_pvt->sms_body);
 #ifdef NOTDEF
        if (!zstr(tech_pvt->session_uuid_str)) {
@@ -3158,6 +3158,12 @@ int sms_incoming(private_t *tech_pvt)
        }
        /* mod_sms end */
 
+       memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message));
+       memset(tech_pvt->sms_sender, '\0', sizeof(tech_pvt->sms_sender));
+       memset(tech_pvt->sms_date, '\0', sizeof(tech_pvt->sms_date));
+       memset(tech_pvt->sms_body, '\0', sizeof(tech_pvt->sms_body));
+       memset(tech_pvt->sms_datacodingscheme, '\0', sizeof(tech_pvt->sms_datacodingscheme));
+       memset(tech_pvt->sms_servicecentreaddress, '\0', sizeof(tech_pvt->sms_servicecentreaddress));
 
        //memset(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->chatmessages[which]) );
        //memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message));