Skip to content

Commit 3360f81

Browse files
Shmumaskotopes
andauthored
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: あく <[email protected]>
1 parent 066da40 commit 3360f81

File tree

19 files changed

+20
-20
lines changed

19 files changed

+20
-20
lines changed

lib/subghz/protocols/bett.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool subghz_protocol_encoder_bett_deserialize(void* context, FlipperFormat* flip
173173
flipper_format_read_uint32(
174174
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
175175

176-
subghz_protocol_encoder_bett_get_upload(instance);
176+
if(!subghz_protocol_encoder_bett_get_upload(instance)) break;
177177
instance->encoder.is_running = true;
178178

179179
res = true;

lib/subghz/protocols/came.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bool subghz_protocol_encoder_came_deserialize(void* context, FlipperFormat* flip
162162
flipper_format_read_uint32(
163163
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
164164

165-
subghz_protocol_encoder_came_get_upload(instance);
165+
if(!subghz_protocol_encoder_came_get_upload(instance)) break;
166166
instance->encoder.is_running = true;
167167

168168
res = true;

lib/subghz/protocols/chamberlain_code.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static bool
155155
break;
156156

157157
default:
158-
furi_crash(TAG " unknown protocol.");
158+
FURI_LOG_E(TAG, "Invalid bits count");
159159
return false;
160160
break;
161161
}
@@ -224,7 +224,7 @@ bool subghz_protocol_encoder_chamb_code_deserialize(void* context, FlipperFormat
224224
flipper_format_read_uint32(
225225
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
226226

227-
subghz_protocol_encoder_chamb_code_get_upload(instance);
227+
if(!subghz_protocol_encoder_chamb_code_get_upload(instance)) break;
228228
instance->encoder.is_running = true;
229229

230230
res = true;

lib/subghz/protocols/clemsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool subghz_protocol_encoder_clemsa_deserialize(void* context, FlipperFormat* fl
173173
flipper_format_read_uint32(
174174
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
175175

176-
subghz_protocol_encoder_clemsa_get_upload(instance);
176+
if(!subghz_protocol_encoder_clemsa_get_upload(instance)) break;
177177
instance->encoder.is_running = true;
178178

179179
res = true;

lib/subghz/protocols/doitrand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bool subghz_protocol_encoder_doitrand_deserialize(void* context, FlipperFormat*
154154
flipper_format_read_uint32(
155155
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
156156

157-
subghz_protocol_encoder_doitrand_get_upload(instance);
157+
if(!subghz_protocol_encoder_doitrand_get_upload(instance)) break;
158158
instance->encoder.is_running = true;
159159

160160
res = true;

lib/subghz/protocols/gate_tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ bool subghz_protocol_encoder_gate_tx_deserialize(void* context, FlipperFormat* f
147147
flipper_format_read_uint32(
148148
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
149149

150-
subghz_protocol_encoder_gate_tx_get_upload(instance);
150+
if(!subghz_protocol_encoder_gate_tx_get_upload(instance)) break;
151151
instance->encoder.is_running = true;
152152

153153
res = true;

lib/subghz/protocols/holtek.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ bool subghz_protocol_encoder_holtek_deserialize(void* context, FlipperFormat* fl
160160
flipper_format_read_uint32(
161161
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
162162

163-
subghz_protocol_encoder_holtek_get_upload(instance);
163+
if(!subghz_protocol_encoder_holtek_get_upload(instance)) break;
164164
instance->encoder.is_running = true;
165165

166166
res = true;

lib/subghz/protocols/honeywell_wdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bool subghz_protocol_encoder_honeywell_wdb_deserialize(
162162
flipper_format_read_uint32(
163163
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
164164

165-
subghz_protocol_encoder_honeywell_wdb_get_upload(instance);
165+
if(!subghz_protocol_encoder_honeywell_wdb_get_upload(instance)) break;
166166
instance->encoder.is_running = true;
167167

168168
res = true;

lib/subghz/protocols/hormann.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bool subghz_protocol_encoder_hormann_deserialize(void* context, FlipperFormat* f
163163
flipper_format_read_uint32(
164164
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
165165

166-
subghz_protocol_encoder_hormann_get_upload(instance);
166+
if(!subghz_protocol_encoder_hormann_get_upload(instance)) break;
167167
instance->encoder.is_running = true;
168168

169169
res = true;

lib/subghz/protocols/intertechno_v3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ bool subghz_protocol_encoder_intertechno_v3_deserialize(
179179
flipper_format_read_uint32(
180180
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
181181

182-
subghz_protocol_encoder_intertechno_v3_get_upload(instance);
182+
if(!subghz_protocol_encoder_intertechno_v3_get_upload(instance)) break;
183183
instance->encoder.is_running = true;
184184

185185
res = true;

0 commit comments

Comments
 (0)