diff options
Diffstat (limited to 'libgammu/phone/nokia')
-rw-r--r-- | libgammu/phone/nokia/dct3/dct3func.c | 3 | ||||
-rw-r--r-- | libgammu/phone/nokia/dct3/n7110.c | 3 | ||||
-rw-r--r-- | libgammu/phone/nokia/nfuncold.c | 2 | ||||
-rw-r--r-- | libgammu/phone/nokia/wd2/n3650.c | 65 |
4 files changed, 57 insertions, 16 deletions
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); |