Skip to content

Commit f14c164

Browse files
Fix version comparison in trusted name "not valid after" TLV field handler
1 parent ef08de1 commit f14c164

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src_features/provideTrustedName/cmd_provide_trusted_name.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,13 @@ static bool handle_not_valid_after(const s_tlv_data *data,
215215
s_trusted_name_info *trusted_name_info,
216216
s_sig_ctx *sig_ctx) {
217217
const uint8_t app_version[] = {MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION};
218-
int i = 0;
219218

220219
(void) trusted_name_info;
221220
(void) sig_ctx;
222221
if (data->length != ARRAYLEN(app_version)) {
223222
return false;
224223
}
225-
do {
224+
for (int i = 0; i < (int) ARRAYLEN(app_version); ++i) {
226225
if (data->value[i] < app_version[i]) {
227226
PRINTF("Expired trusted name : %u.%u.%u < %u.%u.%u\n",
228227
data->value[0],
@@ -233,8 +232,7 @@ static bool handle_not_valid_after(const s_tlv_data *data,
233232
app_version[2]);
234233
return false;
235234
}
236-
i += 1;
237-
} while ((i < (int) ARRAYLEN(app_version)) && (data->value[i] == app_version[i]));
235+
}
238236
return true;
239237
}
240238

0 commit comments

Comments
 (0)