summaryrefslogtreecommitdiff
path: root/libgammu/phone
diff options
context:
space:
mode:
Diffstat (limited to 'libgammu/phone')
-rw-r--r--libgammu/phone/at/at-sms.c2
-rw-r--r--libgammu/phone/at/atgen.c29
-rw-r--r--libgammu/phone/nokia/dct3/dct3func.c3
-rw-r--r--libgammu/phone/nokia/dct3/n7110.c3
-rw-r--r--libgammu/phone/nokia/nfuncold.c2
-rw-r--r--libgammu/phone/nokia/wd2/n3650.c65
-rw-r--r--libgammu/phone/obex/obexgen.c1
7 files changed, 80 insertions, 25 deletions
diff --git a/libgammu/phone/at/at-sms.c b/libgammu/phone/at/at-sms.c
index 7cccfb1..7953616 100644
--- a/libgammu/phone/at/at-sms.c
+++ b/libgammu/phone/at/at-sms.c
@@ -889,6 +889,7 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
}
break;
}
+ FALLTHROUGH;
case SMS_Coding_Unicode_No_Compression:
case SMS_Coding_8bit:
if ((firstbyte & 0x40)==0x40 && GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SMS_UTF8_ENCODED)) {
@@ -1716,6 +1717,7 @@ GSM_Error ATGEN_MakeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *message, unsig
}
break;
}
+ FALLTHROUGH;
case SMS_Coding_Unicode_No_Compression:
case SMS_Coding_8bit:
error = PHONE_EncodeSMSFrame(s,message,buffer,PHONE_SMSDeliver,current,TRUE);
diff --git a/libgammu/phone/at/atgen.c b/libgammu/phone/at/atgen.c
index 29ee97e..8d9ac36 100644
--- a/libgammu/phone/at/atgen.c
+++ b/libgammu/phone/at/atgen.c
@@ -1618,7 +1618,7 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
{
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_USSDMessage ussd;
- GSM_Error error;
+ GSM_Error error = ERR_NONE;
unsigned char *pos = NULL;
int code = 0;
int dcs = 0;
@@ -1676,10 +1676,12 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
break;
case 4:
ussd.Status = USSD_NotSupported;
- return ERR_NETWORK_ERROR;
+ error = ERR_NETWORK_ERROR;
+ goto done;
case 5:
ussd.Status = USSD_Timeout;
- return ERR_TIMEOUT;
+ error = ERR_TIMEOUT;
+ goto done;
default:
ussd.Status = USSD_Unknown;
}
@@ -1699,7 +1701,7 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
hex_encoded, sizeof(hex_encoded));
}
if (error != ERR_NONE) {
- return error;
+ goto done;
}
if ((dcs & 0xc0) == 0) {
@@ -1731,7 +1733,10 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_UnpackEightBitsToSeven(0, strlen(hex_encoded), sizeof(decoded), packed, decoded);
DecodeDefault(ussd.Text, decoded, strlen(decoded), TRUE, NULL);
} else {
- DecodeDefault(ussd.Text, hex_encoded, strlen(hex_encoded), TRUE, NULL);
+ error = ATGEN_DecodeText(s, hex_encoded, strlen(hex_encoded), ussd.Text, sizeof(ussd.Text) - 1, FALSE, FALSE);
+ if (error != ERR_NONE) {
+ return error;
+ }
}
} else if (coding == SMS_Coding_Unicode_No_Compression) {
DecodeHexUnicode(ussd.Text, hex_encoded + offset, strlen(hex_encoded));
@@ -1749,17 +1754,18 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
&code,
ussd.Text, sizeof(ussd.Text));
if (error != ERR_NONE) {
- return error;
+ goto done;
}
}
+done:
/* Notify application */
if (s->User.IncomingUSSD != NULL) {
s->User.IncomingUSSD(s, &ussd, s->User.IncomingUSSDUserData);
}
}
- return ERR_NONE;
+ return error;
}
GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, gboolean enable)
@@ -4405,7 +4411,11 @@ GSM_Error ATGEN_DialService(GSM_StateMachine *s, char *number)
return ERR_MOREMEMORY;
}
/* Prefer unicode to be able to deal with unicode response */
- error = ATGEN_SetCharset(s, AT_PREF_CHARSET_UNICODE);
+ if (GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_USSD_GSM_CHARSET)) {
+ error = ATGEN_SetCharset(s, AT_PREF_CHARSET_GSM);
+ } else {
+ error = ATGEN_SetCharset(s, AT_PREF_CHARSET_UNICODE);
+ }
if (error != ERR_NONE) {
free(req);
@@ -4496,7 +4506,7 @@ GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode *Code)
{
GSM_Error error;
GSM_SecurityCodeType Status;
- unsigned char req[GSM_SECURITY_CODE_LEN + 12] = {'\0'};
+ unsigned char req[GSM_SECURITY_CODE_LEN + 30] = {'\0'};
size_t len;
if (Code->Type == SEC_Pin2 &&
@@ -6229,6 +6239,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReplyIgnore, "+ZEND" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+CDSI:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+CLCC:" ,0x00,0x00,ID_IncomingFrame },
+{ATGEN_GenericReplyIgnore, "#STN:" ,0x00,0x00,ID_IncomingFrame },
/* Sony Ericsson screenshot */
{SONYERICSSON_Reply_Screenshot, "AT*ZISI=?\r", 0x00,0x00,ID_Screenshot },
diff --git a/libgammu/phone/nokia/dct3/dct3func.c b/libgammu/phone/nokia/dct3/dct3func.c
index ccf1d36..3fa4501 100644
--- a/libgammu/phone/nokia/dct3/dct3func.c
+++ b/libgammu/phone/nokia/dct3/dct3func.c
@@ -1450,6 +1450,7 @@ GSM_Error N71_92_ReplyPhoneSetting(GSM_Protocol_Message *msg, GSM_StateMachine *
smprintf(s, "Startup text set\n");
return ERR_NONE;
}
+ return ERR_UNKNOWNRESPONSE;
case 0x15:
if (Data->RequestID == ID_GetBitmap || Data->RequestID == ID_EachFrame) {
smprintf(s, "Startup logo received\n");
@@ -1463,6 +1464,7 @@ GSM_Error N71_92_ReplyPhoneSetting(GSM_Protocol_Message *msg, GSM_StateMachine *
smprintf(s, "Startup logo set\n");
return ERR_NONE;
}
+ return ERR_UNKNOWNRESPONSE;
case 0x17:
if (Data->RequestID == ID_GetBitmap || Data->RequestID == ID_EachFrame) {
smprintf(s, "Dealer note text received\n");
@@ -1474,6 +1476,7 @@ GSM_Error N71_92_ReplyPhoneSetting(GSM_Protocol_Message *msg, GSM_StateMachine *
smprintf(s, "Dealer text set\n");
return ERR_NONE;
}
+ return ERR_UNKNOWNRESPONSE;
}
return ERR_UNKNOWNRESPONSE;
}
diff --git a/libgammu/phone/nokia/dct3/n7110.c b/libgammu/phone/nokia/dct3/n7110.c
index 0807a4b..4a26597 100644
--- a/libgammu/phone/nokia/dct3/n7110.c
+++ b/libgammu/phone/nokia/dct3/n7110.c
@@ -268,6 +268,7 @@ static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMa
DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg->Buffer+9);
return ERR_NONE;
}
+ FALLTHROUGH;
case 0x02:
smprintf(s, "SMS template\n");
if (Data->RequestID == ID_GetSMSMessage) {
@@ -277,6 +278,7 @@ static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMa
GSM_DecodeSMSFrame(&(s->di), &Data->GetSMSMessage->SMS[0],msg->Buffer+9,N7110_SMSTemplate);
return ERR_NONE;
}
+ FALLTHROUGH;
case 0x07:
smprintf(s, "Picture Image\n");
switch (Data->RequestID) {
@@ -352,6 +354,7 @@ static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMa
return ERR_EMPTY;
default:
smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
+ return ERR_UNKNOWNRESPONSE;
}
case 0x6F:
smprintf(s, "SMS message info received\n");
diff --git a/libgammu/phone/nokia/nfuncold.c b/libgammu/phone/nokia/nfuncold.c
index 2f4a46e..a235d8c 100644
--- a/libgammu/phone/nokia/nfuncold.c
+++ b/libgammu/phone/nokia/nfuncold.c
@@ -36,11 +36,13 @@ static void N71_65_GetCalendarAlarm(GSM_StateMachine *s, unsigned char *buffer,
GetTimeDifference(diff, &entry->Entries[entry->EntriesNum].Date, FALSE, 60);
break;
}
+ FALLTHROUGH;
case GSM_CAL_CALL:
if (!GSM_IsPhoneFeatureAvailable(Data->ModelInfo, F_CAL35)) {
GetTimeDifference(diff, &entry->Entries[entry->EntriesNum].Date, FALSE, 60);
break;
}
+ FALLTHROUGH;
default:
GetTimeDifference(diff, &entry->Entries[entry->EntriesNum].Date, FALSE, 1);
}
diff --git a/libgammu/phone/nokia/wd2/n3650.c b/libgammu/phone/nokia/wd2/n3650.c
index e0ba708..ac6594e 100644
--- a/libgammu/phone/nokia/wd2/n3650.c
+++ b/libgammu/phone/nokia/wd2/n3650.c
@@ -47,7 +47,8 @@ static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Han
{
unsigned int len=10,i;
GSM_Error error;
- unsigned char StartReq[500] = {
+ unsigned char *req;
+ unsigned const char StartReq[11] = {
N7110_FRAME_HEADER, 0x0D, 0x10, 0x01, 0x07,
0x24, /* len1 */
0x12, /* len2 */
@@ -58,31 +59,36 @@ static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Han
0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00};
if (File->Used == 0) {
+ req = malloc(strlen(File->ID_FullName) + 30);
+ if (req == NULL) {
+ return ERR_MOREMEMORY;
+ }
+ memcpy(req, StartReq, sizeof(StartReq));
(*Size) = 0;
- sprintf(StartReq+10,"%s",File->ID_FullName);
+ sprintf(req+10,"%s",File->ID_FullName);
len+=strlen(File->ID_FullName)-1;
- StartReq[7] = strlen(File->ID_FullName) + 3;
+ req[7] = strlen(File->ID_FullName) + 3;
- StartReq[8] = strlen(File->ID_FullName);
- StartReq[9] = 0;
- while (File->ID_FullName[StartReq[8]] != '\\') {
- StartReq[8]--;
- StartReq[9]++;
+ req[8] = strlen(File->ID_FullName);
+ req[9] = 0;
+ while (File->ID_FullName[req[8]] != '\\') {
+ req[8]--;
+ req[9]++;
}
- for (i=StartReq[8];i<strlen(File->ID_FullName);i++) {
- StartReq[i+10] = StartReq[i+1+10];
+ for (i=req[8];i<strlen(File->ID_FullName);i++) {
+ req[i+10] = req[i+1+10];
}
- StartReq[9]--;
+ req[9]--;
- EncodeUnicode(File->Name,File->ID_FullName+StartReq[8]+1,StartReq[9]);
+ EncodeUnicode(File->Name,File->ID_FullName+req[8]+1,req[9]);
File->Folder = FALSE;
error = DCT4_SetPhoneMode(s, DCT4_MODE_TEST);
if (error != ERR_NONE) return error;
s->Phone.Data.File = File;
- return GSM_WaitFor (s, StartReq, len, 0x58, 4, ID_GetFile);
+ return GSM_WaitFor (s, req, len, 0x58, 4, ID_GetFile);
}
s->Phone.Data.File = File;
@@ -125,8 +131,28 @@ static GSM_Error N3650_ReplyGetFolderInfo(GSM_Protocol_Message *msg, GSM_StateMa
EncodeUnicode(Priv->Files[Priv->FilesLocationsCurrent+i]->Name,msg->Buffer+pos+9,msg->Buffer[pos+8]);
smprintf(s,"%s\n",DecodeUnicodeString(Priv->Files[Priv->FilesLocationsCurrent+i]->Name));
Priv->Files[Priv->FilesLocationsCurrent+i]->Level = File->Level+1;
- sprintf(Priv->Files[Priv->FilesLocationsCurrent+i]->ID_FullName,"%s\\%s",File->ID_FullName,msg->Buffer+pos+9);
- pos+=msg->Buffer[pos+1];
+#ifdef __GNUC__
+#ifndef __clang__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-overflow"
+#endif
+#endif
+ /* Here we check limits before doing sprintf */
+ if (strlen(File->ID_FullName) + strlen(msg->Buffer+pos+9) + 20 >= sizeof(File->ID_FullName)) {
+ return ERR_MOREMEMORY;
+ }
+ sprintf(
+ Priv->Files[Priv->FilesLocationsCurrent+i]->ID_FullName,
+ "%s\\%s",
+ File->ID_FullName,
+ msg->Buffer + pos + 9
+ );
+#ifdef __GNUC__
+#ifndef __clang__
+#pragma GCC diagnostic pop
+#endif
+#endif
+ pos += msg->Buffer[pos+1];
}
smprintf(s, "\n");
return ERR_NONE;
@@ -135,13 +161,20 @@ static GSM_Error N3650_ReplyGetFolderInfo(GSM_Protocol_Message *msg, GSM_StateMa
static GSM_Error N3650_GetFolderInfo(GSM_StateMachine *s, GSM_File *File)
{
int len=10;
- unsigned char req[500] = {
+ unsigned char *req;
+ unsigned const char template[11] = {
N7110_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x07,
0x18, /* folder name length + 6 */
0x12, /* folder name length */
0x00,
0x00}; /* folder name */
+ req = malloc(strlen(File->ID_FullName) + 30);
+ if (req == NULL) {
+ return ERR_MOREMEMORY;
+ }
+ memcpy(req, template, sizeof(template));
+
/* FIXME: I doubt this works */
sprintf(req+10,"%s", File->ID_FullName);
len +=strlen(File->ID_FullName);
diff --git a/libgammu/phone/obex/obexgen.c b/libgammu/phone/obex/obexgen.c
index a9c47ad..c7a66ef 100644
--- a/libgammu/phone/obex/obexgen.c
+++ b/libgammu/phone/obex/obexgen.c
@@ -733,6 +733,7 @@ static GSM_Error OBEXGEN_ReplyAddFilePart(GSM_Protocol_Message *msg, GSM_StateMa
/* ID of newly created m-obex entry */
Priv->m_obex_newid = msg->Buffer[Pos+3]*256 + msg->Buffer[Pos+4];
Pos += 5;
+ break;
case 0xcb:
/* Skip Connection ID (we ignore this for now) */
Pos += 5;