mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-12-18 04:14:25 -05:00
Be consistent and check for errors first
This commit is contained in:
parent
c0334a77da
commit
df67966d8f
@ -205,14 +205,14 @@ int main()
|
||||
case FW_CMD_RUN_APP:
|
||||
puts("request: run-app\n");
|
||||
|
||||
if (hdr.len != 1) {
|
||||
// Bad length
|
||||
if (hdr.len != 1 || *app_size == 0 || *app_addr == 0) {
|
||||
// Bad cmd length, or app_size and app_addr are
|
||||
// not both set
|
||||
rsp[0] = STATUS_BAD;
|
||||
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (*app_size > 0 && *app_addr != 0) {
|
||||
rsp[0] = STATUS_OK;
|
||||
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
||||
|
||||
@ -238,11 +238,7 @@ int main()
|
||||
"jalr x0,0(a0);"
|
||||
::: "memory");
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
rsp[0] = STATUS_BAD;
|
||||
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
||||
break;
|
||||
break; // This is never reached!
|
||||
|
||||
case FW_CMD_GET_APP_DIGEST:
|
||||
puts("request: get-app-digest\n");
|
||||
|
Loading…
Reference in New Issue
Block a user