Use MESSAGE_LIST_ITEM_FIELD_MAX_SIZE

This commit is contained in:
Alexander Batalov 2022-12-06 12:37:59 +03:00
parent cd51e0cdd7
commit 9d9e09e80f
1 changed files with 7 additions and 6 deletions

View File

@ -206,9 +206,9 @@ bool messageListLoad(MessageList* messageList, const char* path)
{ {
char localized_path[COMPAT_MAX_PATH]; char localized_path[COMPAT_MAX_PATH];
File* file_ptr; File* file_ptr;
char num[1024]; char num[MESSAGE_LIST_ITEM_FIELD_MAX_SIZE];
char audio[1024]; char audio[MESSAGE_LIST_ITEM_FIELD_MAX_SIZE];
char text[1024]; char text[MESSAGE_LIST_ITEM_FIELD_MAX_SIZE];
int rc; int rc;
bool success; bool success;
MessageListItem entry; MessageListItem entry;
@ -460,14 +460,15 @@ static bool _message_parse_number(int* out_num, const char* str)
return success; return success;
} }
// Read next message file field, the `str` should be at least 1024 bytes long. // Read next message file field, the `str` should be at least
// `MESSAGE_LIST_ITEM_FIELD_MAX_SIZE` bytes long.
// //
// Returns: // Returns:
// 0 - ok // 0 - ok
// 1 - eof // 1 - eof
// 2 - mismatched delimeters // 2 - mismatched delimeters
// 3 - unterminated field // 3 - unterminated field
// 4 - limit exceeded (> 1024) // 4 - limit exceeded (> `MESSAGE_LIST_ITEM_FIELD_MAX_SIZE`)
// //
// 0x484FB4 // 0x484FB4
static int _message_load_field(File* file, char* str) static int _message_load_field(File* file, char* str)
@ -510,7 +511,7 @@ static int _message_load_field(File* file, char* str)
*(str + len) = ch; *(str + len) = ch;
len++; len++;
if (len >= 1024) { if (len >= MESSAGE_LIST_ITEM_FIELD_MAX_SIZE) {
debugPrint("\nError reading message file - text exceeds limit.\n"); debugPrint("\nError reading message file - text exceeds limit.\n");
return 4; return 4;
} }