1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00

Rename gpgsig struct fields for clarity

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-04-15 19:30:11 -05:00
parent 3c5661ec3c
commit 442e1420f9
5 changed files with 27 additions and 26 deletions

View File

@ -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 */ /* we don't do anything with this value right now */
READ_NEXT(line); READ_NEXT(line);
} else if(strcmp(line, "%PGPSIG%") == 0) { } 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) { } else if(strcmp(line, "%REPLACES%") == 0) {
READ_AND_STORE_ALL(pkg->replaces); READ_AND_STORE_ALL(pkg->replaces);
} else if(strcmp(line, "%DEPENDS%") == 0) { } else if(strcmp(line, "%DEPENDS%") == 0) {

View File

@ -321,7 +321,7 @@ const pmpgpsig_t *_alpm_db_pgpsig(pmdb_t *db)
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return(NULL)); ASSERT(db != NULL, return(NULL));
if(db->pgpsig.rawdata == NULL) { if(db->pgpsig.data == NULL) {
const char *dbfile; const char *dbfile;
int ret; int ret;
@ -343,8 +343,8 @@ void _alpm_db_free(pmdb_t *db)
_alpm_db_free_pkgcache(db); _alpm_db_free_pkgcache(db);
/* cleanup server list */ /* cleanup server list */
FREELIST(db->servers); FREELIST(db->servers);
/* only need to free rawdata */ /* only need to free data */
FREE(db->pgpsig.rawdata); FREE(db->pgpsig.data);
FREE(db->_path); FREE(db->_path);
FREE(db->treename); FREE(db->treename);
FREE(db); FREE(db);

View File

@ -198,25 +198,26 @@ const char SYMEXPORT *alpm_pkg_get_md5sum(pmpkg_t *pkg)
} }
static int decode_pgpsig(pmpkg_t *pkg) { static int decode_pgpsig(pmpkg_t *pkg) {
int len = strlen(pkg->pgpsig.encdata); const int len = strlen(pkg->pgpsig.base64_data);
const unsigned char *usline = (const unsigned char *)pkg->pgpsig.encdata; const unsigned char *usline = (const unsigned char *)pkg->pgpsig.base64_data;
int destlen = 0; int ret, destlen = 0;
/* get the necessary size for the buffer by passing 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 */ /* alloc our memory and repeat the call to decode */
MALLOC(pkg->pgpsig.rawdata, (size_t)destlen, goto error); MALLOC(pkg->pgpsig.data, (size_t)destlen, goto error);
ret = base64_decode(pkg->pgpsig.rawdata, &destlen, usline, len); ret = base64_decode(pkg->pgpsig.data, &destlen, usline, len);
pkg->pgpsig.rawlen = destlen; pkg->pgpsig.len = destlen;
if(ret != 0) { if(ret != 0) {
goto error; goto error;
} }
FREE(pkg->pgpsig.encdata); /* we no longer have a need for this */
FREE(pkg->pgpsig.base64_data);
return 0; return 0;
error: error:
FREE(pkg->pgpsig.rawdata); FREE(pkg->pgpsig.data);
pkg->pgpsig.rawlen = 0; pkg->pgpsig.len = 0;
return 1; return 1;
} }
@ -227,7 +228,7 @@ const pmpgpsig_t SYMEXPORT *alpm_pkg_get_pgpsig(pmpkg_t *pkg)
/* Sanity checks */ /* Sanity checks */
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); 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); decode_pgpsig(pkg);
} }
return &(pkg->pgpsig); return &(pkg->pgpsig);
@ -467,8 +468,8 @@ void _alpm_pkg_free(pmpkg_t *pkg)
FREE(pkg->url); FREE(pkg->url);
FREE(pkg->packager); FREE(pkg->packager);
FREE(pkg->md5sum); FREE(pkg->md5sum);
FREE(pkg->pgpsig.encdata); FREE(pkg->pgpsig.base64_data);
FREE(pkg->pgpsig.rawdata); FREE(pkg->pgpsig.data);
FREE(pkg->arch); FREE(pkg->arch);
FREELIST(pkg->licenses); FREELIST(pkg->licenses);
FREELIST(pkg->replaces); FREELIST(pkg->replaces);

View File

@ -109,7 +109,7 @@ int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig)
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
if(!sig || !sig->rawdata) { if(!sig || !sig->data) {
RET_ERR(PM_ERR_SIG_UNKNOWN, -1); RET_ERR(PM_ERR_SIG_UNKNOWN, -1);
} }
if(!path || access(path, R_OK) != 0) { if(!path || access(path, R_OK) != 0) {
@ -140,7 +140,7 @@ int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig)
CHECK_ERR(); CHECK_ERR();
/* next create data object for the signature */ /* 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(); CHECK_ERR();
/* here's where the magic happens */ /* here's where the magic happens */
@ -227,18 +227,18 @@ int _alpm_load_signature(const char *file, pmpgpsig_t *pgpsig) {
free(sigfile); free(sigfile);
return ret; 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)); 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) { 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", _alpm_log(PM_LOG_DEBUG, "loaded gpg signature file, location %s\n",
sigfile); sigfile);
ret = 0; ret = 0;
} else { } else {
_alpm_log(PM_LOG_WARNING, _("Failed reading PGP signature file %s"), _alpm_log(PM_LOG_WARNING, _("Failed reading PGP signature file %s"),
sigfile); sigfile);
FREE(pgpsig->rawdata); FREE(pgpsig->data);
} }
fclose(f); fclose(f);

View File

@ -26,9 +26,9 @@ struct __pmpgpsig_t {
* this way we can decode on an as-needed basis since most * this way we can decode on an as-needed basis since most
* operations won't require the overhead of base64 decodes * operations won't require the overhead of base64 decodes
* on all packages in a sync repository. */ * on all packages in a sync repository. */
char *encdata; char *base64_data;
size_t rawlen; unsigned char *data;
unsigned char *rawdata; size_t len;
}; };
int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig); int _alpm_gpgme_checksig(const char *path, const pmpgpsig_t *sig);