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>
This commit is contained in:
parent
4f02b98338
commit
6e8ca48cbb
|
@ -430,8 +430,13 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
||||||
|
|
||||||
if(!base64_sig) {
|
if(!base64_sig) {
|
||||||
sigpath = _alpm_sigpath(handle, path);
|
sigpath = _alpm_sigpath(handle, path);
|
||||||
/* this will just help debugging */
|
if(_alpm_access(handle, NULL, sigpath, R_OK) != 0
|
||||||
_alpm_access(handle, NULL, sigpath, R_OK);
|
|| (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? */
|
/* does the file we are verifying exist? */
|
||||||
|
@ -441,17 +446,6 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
||||||
goto error;
|
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)) {
|
if(init_gpgme(handle)) {
|
||||||
/* pm_errno was set in gpgme_init() */
|
/* pm_errno was set in gpgme_init() */
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue