Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/ota_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
case ARGP_KEY_END:
if (!arguments->update_file)
argp_usage(state);
if (!arguments->input)
argp_usage(state);
if (!arguments->output)
argp_usage(state);
break;
Expand Down Expand Up @@ -112,12 +110,15 @@ void launch_apply(char *partition) {

if (partition == NULL || strcmp(partition_name, partition) == 0) {

int in = open_img_file(args.input, partition_name, O_RDONLY);
if (in < 0) {
if (partition != NULL) {
log_err(partition, "Could not open the source image for reading");
int in = -1;
if (args.input) {
in = open_img_file(args.input, partition_name, O_RDONLY);
if (in < 0) {
if (partition != NULL) {
log_err(partition, "Could not open the source image for reading");
}
continue;
}
continue;
}
int out = open_img_file(args.output, partition_name, O_WRONLY | O_CREAT | O_TRUNC);
if (out < 0) {
Expand Down
9 changes: 6 additions & 3 deletions src/payload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ char* get_src(int in, unsigned int *size,
*size += b2o(src_extent.num_blocks());
}

if (*size == 0) {
if (*size == 0 || in < 0) {
return (char*)0;
}

Expand Down Expand Up @@ -131,6 +131,11 @@ void apply_section(payload *update, section *section, FILE *data_file) {
size_t next = 0;
size_t out = 0;

if (src_size && !src) {
log_err(part_name, "Incremental OTA package, requiring a base image. Either none was given, or it is inaccessible.");
goto end;
}

if (op.has_src_sha256_hash()) {
sha256_bytes(src, src_size, hash);
if (memcmp(hash, op.src_sha256_hash().data(), 32) != 0) {
Expand Down Expand Up @@ -197,5 +202,3 @@ void apply_section(payload *update, section *section, FILE *data_file) {
}
}
}