Skip to content

Commit

Permalink
Subghz: Adding checks for get_upload functions (#1704)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Shmuma and skotopes authored Sep 20, 2022
1 parent 066da40 commit 3360f81
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/subghz/protocols/bett.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool subghz_protocol_encoder_bett_deserialize(void* context, FlipperFormat* flip
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/came.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool subghz_protocol_encoder_came_deserialize(void* context, FlipperFormat* flip
flipper_format_read_uint32(
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;

res = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/subghz/protocols/chamberlain_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static bool
break;

default:
furi_crash(TAG " unknown protocol.");
FURI_LOG_E(TAG, "Invalid bits count");
return false;
break;
}
Expand Down Expand Up @@ -224,7 +224,7 @@ bool subghz_protocol_encoder_chamb_code_deserialize(void* context, FlipperFormat
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/clemsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool subghz_protocol_encoder_clemsa_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/doitrand.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool subghz_protocol_encoder_doitrand_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/gate_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool subghz_protocol_encoder_gate_tx_deserialize(void* context, FlipperFormat* f
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/holtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ bool subghz_protocol_encoder_holtek_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/honeywell_wdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool subghz_protocol_encoder_honeywell_wdb_deserialize(
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/hormann.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool subghz_protocol_encoder_hormann_deserialize(void* context, FlipperFormat* f
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/intertechno_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ bool subghz_protocol_encoder_intertechno_v3_deserialize(
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/keeloq.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32(
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)) {
FURI_LOG_E(TAG, "Rewind error");
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bool subghz_protocol_encoder_linear_deserialize(void* context, FlipperFormat* fl
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/magellen.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ bool subghz_protocol_encoder_magellen_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/megacode.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool subghz_protocol_encoder_megacode_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/nero_radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ bool subghz_protocol_encoder_nero_radio_deserialize(void* context, FlipperFormat
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/nero_sketch.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ bool subghz_protocol_encoder_nero_sketch_deserialize(void* context, FlipperForma
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/nice_flo.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool subghz_protocol_encoder_nice_flo_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/phoenix_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool subghz_protocol_encoder_phoenix_v2_deserialize(void* context, FlipperFormat
flipper_format_read_uint32(
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;

res = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/subghz/protocols/princeton.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ bool subghz_protocol_encoder_princeton_deserialize(void* context, FlipperFormat*
flipper_format_read_uint32(
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;

res = true;
Expand Down

0 comments on commit 3360f81

Please sign in to comment.