Subghz: Adding checks for get_upload functions (#1704)

* Adding checks for get_upload functions
  Almost in every protocol, function which generates upload might fail and return false.
  But we don't check this result, which might end up sending random memory contents to the air.
* Format sources and fix crash on ivalid bit count in chamberlain

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Max Lapan 2022-09-20 07:29:10 +02:00 committed by GitHub
parent 066da4080b
commit 3360f818a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 20 additions and 20 deletions

View file

@ -173,7 +173,7 @@ bool subghz_protocol_encoder_bett_deserialize(void* context, FlipperFormat* flip
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_bett_get_upload(instance); if(!subghz_protocol_encoder_bett_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -162,7 +162,7 @@ bool subghz_protocol_encoder_came_deserialize(void* context, FlipperFormat* flip
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_came_get_upload(instance); if(!subghz_protocol_encoder_came_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -155,7 +155,7 @@ static bool
break; break;
default: default:
furi_crash(TAG " unknown protocol."); FURI_LOG_E(TAG, "Invalid bits count");
return false; return false;
break; break;
} }
@ -224,7 +224,7 @@ bool subghz_protocol_encoder_chamb_code_deserialize(void* context, FlipperFormat
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_chamb_code_get_upload(instance); if(!subghz_protocol_encoder_chamb_code_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -173,7 +173,7 @@ bool subghz_protocol_encoder_clemsa_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_clemsa_get_upload(instance); if(!subghz_protocol_encoder_clemsa_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -154,7 +154,7 @@ bool subghz_protocol_encoder_doitrand_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_doitrand_get_upload(instance); if(!subghz_protocol_encoder_doitrand_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -147,7 +147,7 @@ bool subghz_protocol_encoder_gate_tx_deserialize(void* context, FlipperFormat* f
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_gate_tx_get_upload(instance); if(!subghz_protocol_encoder_gate_tx_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -160,7 +160,7 @@ bool subghz_protocol_encoder_holtek_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_holtek_get_upload(instance); if(!subghz_protocol_encoder_holtek_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -162,7 +162,7 @@ bool subghz_protocol_encoder_honeywell_wdb_deserialize(
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_honeywell_wdb_get_upload(instance); if(!subghz_protocol_encoder_honeywell_wdb_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -163,7 +163,7 @@ bool subghz_protocol_encoder_hormann_deserialize(void* context, FlipperFormat* f
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_hormann_get_upload(instance); if(!subghz_protocol_encoder_hormann_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -179,7 +179,7 @@ bool subghz_protocol_encoder_intertechno_v3_deserialize(
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_intertechno_v3_get_upload(instance); if(!subghz_protocol_encoder_intertechno_v3_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -280,7 +280,7 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_keeloq_get_upload(instance, instance->generic.btn); if(!subghz_protocol_encoder_keeloq_get_upload(instance, instance->generic.btn)) break;
if(!flipper_format_rewind(flipper_format)) { if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error"); FURI_LOG_E(TAG, "Rewind error");

View file

@ -165,7 +165,7 @@ bool subghz_protocol_encoder_linear_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_linear_get_upload(instance); if(!subghz_protocol_encoder_linear_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -168,7 +168,7 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_magellen_get_upload(instance); if(!subghz_protocol_encoder_magellen_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -193,7 +193,7 @@ bool subghz_protocol_encoder_megacode_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_megacode_get_upload(instance); if(!subghz_protocol_encoder_megacode_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -172,7 +172,7 @@ bool subghz_protocol_encoder_nero_radio_deserialize(void* context, FlipperFormat
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_nero_radio_get_upload(instance); if(!subghz_protocol_encoder_nero_radio_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -166,7 +166,7 @@ bool subghz_protocol_encoder_nero_sketch_deserialize(void* context, FlipperForma
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_nero_sketch_get_upload(instance); if(!subghz_protocol_encoder_nero_sketch_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -149,7 +149,7 @@ bool subghz_protocol_encoder_nice_flo_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_nice_flo_get_upload(instance); if(!subghz_protocol_encoder_nice_flo_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -150,7 +150,7 @@ bool subghz_protocol_encoder_phoenix_v2_deserialize(void* context, FlipperFormat
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_phoenix_v2_get_upload(instance); if(!subghz_protocol_encoder_phoenix_v2_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;

View file

@ -167,7 +167,7 @@ bool subghz_protocol_encoder_princeton_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
subghz_protocol_encoder_princeton_get_upload(instance); if(!subghz_protocol_encoder_princeton_get_upload(instance)) break;
instance->encoder.is_running = true; instance->encoder.is_running = true;
res = true; res = true;