1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
From: Andrew Shadura <andrew@shadura.me>
Subject: Fix +CSMS response parsing: an argument can be zero-length (Closes: #602739).
diff --git a/gsmlib/gsm_me_ta.cc b/gsmlib/gsm_me_ta.cc
--- a/gsmlib/gsm_me_ta.cc
+++ b/gsmlib/gsm_me_ta.cc
@@ -88,7 +88,17 @@ void MeTa::init() throw(GsmException)
// find out whether we are supposed to send an acknowledgment
Parser p(_at->chat("+CSMS?", "+CSMS:"));
- _capabilities._sendAck = p.parseInt() >= 1;
+ try {
+ _capabilities._sendAck = p.parseInt() >= 1;
+ }
+ catch (GsmException &e)
+ {
+ if (e.getErrorClass() == ParserError) {
+ _capabilities._sendAck = 0;
+ } else {
+ throw e;
+ }
+ }
// set GSM default character set
try
@@ -1002,8 +1012,18 @@ void MeTa::setMessageService(int service
unsigned int MeTa::getMessageService() throw(GsmException)
{
- Parser p(_at->chat("+CSMS?", "+CSMS:"));
- return p.parseInt();
+ try {
+ Parser p(_at->chat("+CSMS?", "+CSMS:"));
+ return p.parseInt();
+ }
+ catch (GsmException &e)
+ {
+ if (e.getErrorClass() == ParserError) {
+ return 0;
+ } else {
+ throw e;
+ }
+ }
}
void MeTa::getSMSRoutingToTA(bool &smsRouted,
|