summaryrefslogtreecommitdiff
path: root/rpmio/rpmpgp.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-11-02 10:26:34 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-11-04 11:50:08 +0200
commit3decf7b0988126f9309af296887fe4c7f0ca322e (patch)
tree039618e1f7fc1d97bd74373db82973222f554684 /rpmio/rpmpgp.c
parentb284ce833d79b13e51bfee835846d7857fadb961 (diff)
downloadrpm-3decf7b0988126f9309af296887fe4c7f0ca322e.tar.gz
rpm-3decf7b0988126f9309af296887fe4c7f0ca322e.tar.bz2
rpm-3decf7b0988126f9309af296887fe4c7f0ca322e.zip
Split digest parameter freeing into a separate helper function
- The data is all the same except for rsa/dsa specific bits, to me this calls for a function. We might want to export pgpCleanDigParams() or such later on but for now keep it static. No functional changes.
Diffstat (limited to 'rpmio/rpmpgp.c')
-rw-r--r--rpmio/rpmpgp.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 838b2f60c..cb1b59803 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -1104,32 +1104,30 @@ pgpDig pgpNewDig(void)
return dig;
}
-void pgpCleanDig(pgpDig dig)
+static void pgpCleanDigParams(pgpDigParams digp)
{
- if (dig != NULL) {
- int i;
- dig->signature.userid = _free(dig->signature.userid);
- dig->pubkey.userid = _free(dig->pubkey.userid);
- dig->signature.hash = _free(dig->signature.hash);
- dig->pubkey.hash = _free(dig->pubkey.hash);
- /* FIX: double indirection */
- for (i = 0; i < 4; i++) {
- dig->signature.params[i] = _free(dig->signature.params[i]);
- dig->pubkey.params[i] = _free(dig->pubkey.params[i]);
- }
-
- memset(&dig->signature, 0, sizeof(dig->signature));
- memset(&dig->pubkey, 0, sizeof(dig->pubkey));
-
- if (dig->pubkey.data != NULL) {
- SECKEY_DestroyPublicKey(dig->pubkey.data);
- dig->pubkey.data = NULL;
+ if (digp) {
+ free(digp->userid);
+ free(digp->hash);
+ for (int i = 0; i < 4; i++)
+ free(digp->params[i]);
+
+ if (digp->data != NULL) {
+ if (digp->tag == PGPTAG_SIGNATURE) {
+ SECITEM_ZfreeItem(digp->data, PR_TRUE);
+ } else {
+ SECKEY_DestroyPublicKey(digp->data);
+ }
}
+ memset(digp, 0, sizeof(*digp));
+ }
+}
- if (dig->signature.data != NULL) {
- SECITEM_ZfreeItem(dig->signature.data, PR_TRUE);
- dig->signature.data = NULL;
- }
+void pgpCleanDig(pgpDig dig)
+{
+ if (dig != NULL) {
+ pgpCleanDigParams(&dig->signature);
+ pgpCleanDigParams(&dig->pubkey);
}
return;
}