diff --git a/app/dtmf.c b/app/dtmf.c index 45aa198..6ea401d 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -55,7 +55,7 @@ bool gDTMF_IsGroupCall; bool DTMF_ValidateCodes(char *pCode, uint8_t Size) { - uint8_t i; + unsigned int i; if (pCode[0] == 0xFF || pCode[0] == 0) return false; @@ -75,19 +75,26 @@ bool DTMF_ValidateCodes(char *pCode, uint8_t Size) return true; } -bool DTMF_GetContact(uint8_t Index, char *pContact) +bool DTMF_GetContact(const int Index, char *pContact) { - EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16); - return ((pContact[0] - ' ') >= 0x5F) ? false : true; + int i = -1; + if (Index >= 0 && Index < 16 && pContact != NULL) // max 16 DTMF contacts + { + EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16); + i = (int)pContact[0] - ' '; + } + return (i < 0 || i >= 95) ? false : true; } bool DTMF_FindContact(const char *pContact, char *pResult) { char Contact [16]; - uint8_t i, j; + unsigned int i; for (i = 0; i < 16; i++) { + unsigned int j; + if (!DTMF_GetContact(i, Contact)) return false; @@ -139,7 +146,7 @@ char DTMF_GetCharacter(uint8_t Code) bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup) { - uint8_t i; + unsigned int i; for (i = 0; i < Size; i++) { diff --git a/app/dtmf.h b/app/dtmf.h index 2227e7b..02c1a6c 100644 --- a/app/dtmf.h +++ b/app/dtmf.h @@ -77,7 +77,7 @@ extern bool gDTMF_IsTx; extern uint8_t gDTMF_TxStopCountdown; bool DTMF_ValidateCodes(char *pCode, uint8_t Size); -bool DTMF_GetContact(uint8_t Index, char *pContact); +bool DTMF_GetContact(const int Index, char *pContact); bool DTMF_FindContact(const char *pContact, char *pResult); char DTMF_GetCharacter(uint8_t Code); bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, uint8_t Size, bool bFlag); diff --git a/firmware b/firmware index 034580a..7763c96 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 9d02dfd..882bd6d 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 48c43b9..26effc7 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/ui/menu.c b/ui/menu.c index 6ca8af8..3bfe237 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -509,10 +509,9 @@ void UI_DisplayMenu(void) break; case MENU_D_LIST: - gIsDtmfContactValid = DTMF_GetContact((uint8_t)gSubMenuSelection - 1, Contact); + gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact); if (!gIsDtmfContactValid) - // Ghidra being weird again... - memcpy(String, "NULL\0\0\0", 8); + strcpy(String, "NULL"); else memcpy(String, Contact, 8); break;