summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2018-09-05 10:21:22 +0300
committerTimo Teräs <timo.teras@iki.fi>2018-09-06 14:47:02 +0300
commitd214c18ac51adb7317284f8f65173494cc726814 (patch)
treeaefcc2ffb4c8ad9ea187f3a193167215ac2c7bd4
parentabe925f864e38a095ab26b0cbcb4b74d60d667ee (diff)
downloadapk-tools-d214c18ac51adb7317284f8f65173494cc726814.tar.bz2
apk-tools-d214c18ac51adb7317284f8f65173494cc726814.tar.xz
apk: sanitize return value
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> (cherry picked from commit 7b654e125461b00bc26e52b25e6a7be3a32c11b9) (cherry picked from commit 7c90fd0529c0358dd04cab0fce506e8a8b191506)
-rw-r--r--src/apk.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/apk.c b/src/apk.c
index 1dab55d..53ab248 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -587,5 +587,8 @@ err:
free(ctx);
fetchConnectionCacheClose();
+
+ if (r < 0) r = 250;
+ if (r > 99) r = 99;
return r;
}