summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-11 19:04:34 +0100
committerDan McGee <dan@archlinux.org>2012-01-12 16:31:09 +0100
commit6e8ca48cbb22c328deab56b1740be04ea7ddba6e (patch)
treee4944fd3189209df20420816153695b56b8c2f17 /lib
parent4f02b98338437b9395addb29000893b91d1ae21e (diff)
downloadpacman-6e8ca48cbb22c328deab56b1740be04ea7ddba6e.tar.gz
pacman-6e8ca48cbb22c328deab56b1740be04ea7ddba6e.tar.xz
Reorder some operations in sig check for efficiency
We don't need to open the data to be checked if we don't have a signature to check against, so postpone that open until we know we have either the base64_data or a valid signature file. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/signing.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index c4cb077f..3ff83ba0 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -430,8 +430,13 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
if(!base64_sig) {
sigpath = _alpm_sigpath(handle, path);
- /* this will just help debugging */
- _alpm_access(handle, NULL, sigpath, R_OK);
+ if(_alpm_access(handle, NULL, sigpath, R_OK) != 0
+ || (sigfile = fopen(sigpath, "rb")) == NULL) {
+ _alpm_log(handle, ALPM_LOG_DEBUG, "sig path %s could not be opened\n",
+ sigpath);
+ handle->pm_errno = ALPM_ERR_SIG_MISSING;
+ goto error;
+ }
}
/* does the file we are verifying exist? */
@@ -441,17 +446,6 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
goto error;
}
- /* does the sig file exist (if we didn't get the data directly)? */
- if(!base64_sig) {
- sigfile = fopen(sigpath, "rb");
- if(sigfile == NULL) {
- _alpm_log(handle, ALPM_LOG_DEBUG, "sig path %s could not be opened\n",
- sigpath);
- handle->pm_errno = ALPM_ERR_SIG_MISSING;
- goto error;
- }
- }
-
if(init_gpgme(handle)) {
/* pm_errno was set in gpgme_init() */
goto error;