aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSansar Choinyambuu <schoinya@hsr.ch>2011-10-24 12:43:38 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2011-11-28 14:39:52 +0100
commit954be9f5e456bf586bbebc6d4ea4d588a9fca7f0 (patch)
tree78d96441aedf6b99ecca4ce97a1345e6c9dd450e /src
parentb532c454ad5f4ba48f9eb676002c5c23ae31bc27 (diff)
downloadstrongswan-954be9f5e456bf586bbebc6d4ea4d588a9fca7f0.tar.bz2
strongswan-954be9f5e456bf586bbebc6d4ea4d588a9fca7f0.tar.xz
Sort the pcr entries list everytime new entry is added
Diffstat (limited to 'src')
-rw-r--r--src/libpts/pts/pts.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libpts/pts/pts.c b/src/libpts/pts/pts.c
index a4dda7f28..ec5d3030c 100644
--- a/src/libpts/pts/pts.c
+++ b/src/libpts/pts/pts.c
@@ -934,6 +934,20 @@ METHOD(pts_t, quote_tpm, bool,
return FALSE;
}
+/**
+ * Comparison function for pcr_entry_t struct
+ */
+static int pcr_entry_compare(const pcr_entry_t *a, const pcr_entry_t *b)
+{
+ return (a->pcr_number - b->pcr_number);
+}
+
+static int pcr_entry_compare_qsort(const void *a, const void *b)
+{
+ return pcr_entry_compare(*(const pcr_entry_t *const *)a
+ , *(const pcr_entry_t *const *)b);
+}
+
METHOD(pts_t, add_pcr_entry, void,
private_pts_t *this, pcr_entry_t *new)
{
@@ -961,7 +975,8 @@ METHOD(pts_t, add_pcr_entry, void,
this->pcrs->insert_last(this->pcrs, new);
- /* TODO: Sort pcr entries with pcr index */
+ qsort(this->pcrs, this->pcrs->get_count(this->pcrs),
+ sizeof(pcr_entry_t *), pcr_entry_compare_qsort);
}
/**