Skip to content

Commit

Permalink
apk: sanitize return value
Browse files Browse the repository at this point in the history
Most applets return whatever apk_solver_commit() returns. It is the
number of errors found (or negative for hard error). Sanitize the
error value to not give false success exit code in the unlikely case
of errors % 256 == 0.

Reported-by: Max Justicz <max@justi.cz>
  • Loading branch information
fabled committed Sep 5, 2018
1 parent 13c534d commit 7b654e1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/apk.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,5 +689,7 @@ int main(int argc, char **argv)
apk_string_array_free(&args);
free(apk_argv);

if (r < 0) r = 250;
if (r > 99) r = 99;

This comment has been minimized.

Copy link
@rud

rud Oct 22, 2018

A thought: if r < 0 is true, the end result will be that r = 99 as both if statements will match. If the two lines are reversed you'd have both 250 and 99 as possible return values. Or am I reading this wrong?

This comment has been minimized.

Copy link
@fabled

fabled Oct 22, 2018

Author Contributor

Thanks. I think an else was intended for the second if.

return r;
}

0 comments on commit 7b654e1

Please sign in to comment.