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:
|
case FW_CMD_RUN_APP:
|
||||||
puts("request: run-app\n");
|
puts("request: run-app\n");
|
||||||
|
|
||||||
if (hdr.len != 1) {
|
if (hdr.len != 1 || *app_size == 0 || *app_addr == 0) {
|
||||||
// Bad length
|
// Bad cmd length, or app_size and app_addr are
|
||||||
|
// not both set
|
||||||
rsp[0] = STATUS_BAD;
|
rsp[0] = STATUS_BAD;
|
||||||
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*app_size > 0 && *app_addr != 0) {
|
|
||||||
rsp[0] = STATUS_OK;
|
rsp[0] = STATUS_OK;
|
||||||
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
||||||
|
|
||||||
@ -238,11 +238,7 @@ int main()
|
|||||||
"jalr x0,0(a0);"
|
"jalr x0,0(a0);"
|
||||||
::: "memory");
|
::: "memory");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
break; // This is never reached!
|
||||||
|
|
||||||
rsp[0] = STATUS_BAD;
|
|
||||||
fwreply(hdr, FW_RSP_RUN_APP, rsp);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FW_CMD_GET_APP_DIGEST:
|
case FW_CMD_GET_APP_DIGEST:
|
||||||
puts("request: get-app-digest\n");
|
puts("request: get-app-digest\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user