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