mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Rename gpgsig struct fields for clarity
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
3c5661ec3c
commit
442e1420f9
@ -471,7 +471,7 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
|
||||
/* we don't do anything with this value right now */
|
||||
READ_NEXT(line);
|
||||
} else if(strcmp(line, "%PGPSIG%") == 0) {
|
||||
READ_AND_STORE(pkg->pgpsig.encdata);
|
||||
READ_AND_STORE(pkg->pgpsig.base64_data);
|
||||
} else if(strcmp(line, "%REPLACES%") == 0) {
|
||||
READ_AND_STORE_ALL(pkg->replaces);
|
||||
} else if(strcmp(line, "%DEPENDS%") == 0) {
|
||||
|
@ -321,7 +321,7 @@ const pmpgpsig_t *_alpm_db_pgpsig(pmdb_t *db)
|
||||
/* Sanity checks */
|
||||
ASSERT(db != NULL, return(NULL));
|
||||
|
||||
if(db->pgpsig.rawdata == NULL) {
|
||||
if(db->pgpsig.data == NULL) {
|
||||
const char *dbfile;
|
||||
int ret;
|
||||
|
||||
@ -343,8 +343,8 @@ void _alpm_db_free(pmdb_t *db)
|
||||
_alpm_db_free_pkgcache(db);
|
||||
/* cleanup server list */
|
||||
FREELIST(db->servers);
|
||||
/* only need to free rawdata */
|
||||
FREE(db->pgpsig.rawdata);
|
||||
/* only need to free data */
|
||||
FREE(db->pgpsig.data);
|
||||
FREE(db->_path);
|
||||
FREE(db->treename);
|
||||
FREE(db);
|
||||
|
@ -198,25 +198,26 @@ const char SYMEXPORT *alpm_pkg_get_md5sum(pmpkg_t *pkg)
|
||||
}
|
||||
|
||||
static int decode_pgpsig(pmpkg_t *pkg) {
|
||||
int len = strlen(pkg->pgpsig.encdata);
|
||||
const unsigned char *usline = (const unsigned char *)pkg->pgpsig.encdata;
|
||||
int destlen = 0;
|
||||
const int len = strlen(pkg->pgpsig.base64_data);
|
||||
const unsigned char *usline = (const unsigned char *)pkg->pgpsig.base64_data;
|
||||
int ret, destlen = 0;
|
||||
/* get the necessary size for the buffer by passing 0 */
|
||||
int ret = base64_decode(NULL, &destlen, usline, len);
|
||||
ret = base64_decode(NULL, &destlen, usline, len);
|
||||
/* alloc our memory and repeat the call to decode */
|
||||
MALLOC(pkg->pgpsig.rawdata, (size_t)destlen, goto error);
|
||||
ret = base64_decode(pkg->pgpsig.rawdata, &destlen, usline, len);
|
||||
pkg->pgpsig.rawlen = destlen;
|
||||
MALLOC(pkg->pgpsig.data, (size_t)destlen, goto error);
|
||||
ret = base64_decode(pkg->pgpsig.data, &destlen, usline, len);
|
||||
pkg->pgpsig.len = destlen;
|
||||
if(ret != 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
FREE(pkg->pgpsig.encdata);
|
||||
/* we no longer have a need for this */
|
||||
FREE(pkg->pgpsig.base64_data);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
FREE(pkg->pgpsig.rawdata);
|
||||
pkg->pgpsig.rawlen = 0;
|
||||
FREE(pkg->pgpsig.data);
|
||||
pkg->pgpsig.len = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -227,7 +228,7 @@ const pmpgpsig_t SYMEXPORT *alpm_pkg_get_pgpsig(pmpkg_t *pkg)
|
||||
/* Sanity checks */
|
||||
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL));
|
||||
|
||||
if(pkg->pgpsig.rawdata == NULL && pkg->pgpsig.encdata != NULL) {
|
||||
if(pkg->pgpsig.data == NULL && pkg->pgpsig.base64_data != NULL) {
|
||||
decode_pgpsig(pkg);
|
||||
}
|
||||
return &(pkg->pgpsig);
|
||||
@ -467,8 +468,8 @@ void _alpm_pkg_free(pmpkg_t *pkg)
|
||||
FREE(pkg->url);
|
||||
FREE(pkg->packager);
|
||||
FREE(pkg->md5sum);
|
||||
FREE(pkg->pgpsig.encdata);
|
||||
FREE(pkg->pgpsig.rawdata);
|
||||
FREE(pkg->pgpsig.base64_data);
|
||||
FREE(pkg->pgpsig.data);
|
||||
FREE(pkg->arch);
|
||||
FREELIST(pkg->licenses);
|
||||
FREELIST(pkg->replaces);
|
||||
|
@ -109,7 +109,7 @@ int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig)
|
||||
|
||||
ALPM_LOG_FUNC;
|
||||
|
||||
if(!sig || !sig->rawdata) {
|
||||
if(!sig || !sig->data) {
|
||||
RET_ERR(PM_ERR_SIG_UNKNOWN, -1);
|
||||
}
|
||||
if(!path || access(path, R_OK) != 0) {
|
||||
@ -140,7 +140,7 @@ int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig)
|
||||
CHECK_ERR();
|
||||
|
||||
/* next create data object for the signature */
|
||||
err = gpgme_data_new_from_mem(&sigdata, (char *)sig->rawdata, sig->rawlen, 0);
|
||||
err = gpgme_data_new_from_mem(&sigdata, (char *)sig->data, sig->len, 0);
|
||||
CHECK_ERR();
|
||||
|
||||
/* here's where the magic happens */
|
||||
@ -227,18 +227,18 @@ int _alpm_load_signature(const char *file, pmpgpsig_t *pgpsig) {
|
||||
free(sigfile);
|
||||
return ret;
|
||||
}
|
||||
CALLOC(pgpsig->rawdata, st.st_size, sizeof(unsigned char),
|
||||
CALLOC(pgpsig->data, st.st_size, sizeof(unsigned char),
|
||||
RET_ERR(PM_ERR_MEMORY, -1));
|
||||
bytes_read = fread(pgpsig->rawdata, sizeof(char), st.st_size, f);
|
||||
bytes_read = fread(pgpsig->data, sizeof(char), st.st_size, f);
|
||||
if(bytes_read == (size_t)st.st_size) {
|
||||
pgpsig->rawlen = bytes_read;
|
||||
pgpsig->len = bytes_read;
|
||||
_alpm_log(PM_LOG_DEBUG, "loaded gpg signature file, location %s\n",
|
||||
sigfile);
|
||||
ret = 0;
|
||||
} else {
|
||||
_alpm_log(PM_LOG_WARNING, _("Failed reading PGP signature file %s"),
|
||||
sigfile);
|
||||
FREE(pgpsig->rawdata);
|
||||
FREE(pgpsig->data);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
@ -26,9 +26,9 @@ struct __pmpgpsig_t {
|
||||
* this way we can decode on an as-needed basis since most
|
||||
* operations won't require the overhead of base64 decodes
|
||||
* on all packages in a sync repository. */
|
||||
char *encdata;
|
||||
size_t rawlen;
|
||||
unsigned char *rawdata;
|
||||
char *base64_data;
|
||||
unsigned char *data;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig);
|
||||
|
Loading…
Reference in New Issue
Block a user