bin/xbps-remove/clean-cache.c: CID 62747 (toctou)

This commit is contained in:
Juan RP 2014-10-08 10:09:58 +02:00
parent 513f8a2bae
commit b157407684

View File

@ -76,11 +76,13 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj,
} else {
printf("Removed %s from cachedir (sha256 mismatch)\n", binpkg);
}
if ((access(binpkgsig, R_OK) == 0) && (unlink(binpkgsig) == -1)) {
if (unlink(binpkgsig) == -1) {
if (errno != ENOENT) {
fprintf(stderr, "Failed to remove "
"`%s': %s\n", binpkgsig, strerror(errno));
}
}
}
free(binpkgsig);
return 0;
}
@ -90,10 +92,12 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj,
} else {
printf("Removed %s from cachedir (obsolete)\n", binpkg);
}
if ((access(binpkgsig, R_OK) == 0) && (unlink(binpkgsig) == -1)) {
if (unlink(binpkgsig) == -1) {
if (errno != ENOENT) {
fprintf(stderr, "Failed to remove `%s': %s\n",
binpkgsig, strerror(errno));
}
}
free(binpkgsig);
return 0;