[FL-2431, FL-2419] SubGhz: bugfixes (#1098)
* [FL-2431] SubGhz: fix Restart with an error (HardFault), while maintaining the RAW signal. * Stream: fix adding maximum string length to arguments * [FL-2419] SubGhz: fix flipper hang/Fatal Error when running edited Sub-GHz file. * SubGhz: remove replace strcpy with strncpy, smaller text buffer and canary * SubGhz: log key loading before load happen, rollback only rx message handling Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
24
applications/subghz/subghz_i.c
Executable file → Normal file
24
applications/subghz/subghz_i.c
Executable file → Normal file
@@ -208,7 +208,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
uint32_t version;
|
||||
uint32_t temp_data32;
|
||||
|
||||
do {
|
||||
stream_clean(fff_data_stream);
|
||||
@@ -217,25 +217,30 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_format_read_header(fff_data_file, temp_str, &version)) {
|
||||
if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) {
|
||||
FURI_LOG_E(TAG, "Missing or incorrect header");
|
||||
break;
|
||||
}
|
||||
|
||||
if(((!strcmp(string_get_cstr(temp_str), SUBGHZ_KEY_FILE_TYPE)) ||
|
||||
(!strcmp(string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE))) &&
|
||||
version == SUBGHZ_KEY_FILE_VERSION) {
|
||||
temp_data32 == SUBGHZ_KEY_FILE_VERSION) {
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Type or version mismatch");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_format_read_uint32(
|
||||
fff_data_file, "Frequency", (uint32_t*)&subghz->txrx->frequency, 1)) {
|
||||
if(!flipper_format_read_uint32(fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
|
||||
FURI_LOG_E(TAG, "Missing Frequency");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!furi_hal_subghz_is_frequency_valid(temp_data32)) {
|
||||
FURI_LOG_E(TAG, "Frequency not supported");
|
||||
break;
|
||||
}
|
||||
subghz->txrx->frequency = temp_data32;
|
||||
|
||||
if(!flipper_format_read_string(fff_data_file, "Preset", temp_str)) {
|
||||
FURI_LOG_E(TAG, "Missing Preset");
|
||||
break;
|
||||
@@ -267,6 +272,9 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
|
||||
if(subghz->txrx->decoder_result) {
|
||||
subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data);
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Protocol not found");
|
||||
break;
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
@@ -283,7 +291,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path) {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
bool subghz_get_next_name_file(SubGhz* subghz) {
|
||||
bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
|
||||
furi_assert(subghz);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
@@ -294,9 +302,9 @@ bool subghz_get_next_name_file(SubGhz* subghz) {
|
||||
if(strcmp(subghz->file_name, "")) {
|
||||
//get the name of the next free file
|
||||
storage_get_next_filename(
|
||||
storage, SUBGHZ_RAW_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION, temp_str);
|
||||
storage, SUBGHZ_RAW_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION, temp_str, max_len);
|
||||
|
||||
strcpy(subghz->file_name, string_get_cstr(temp_str));
|
||||
strncpy(subghz->file_name, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
res = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user