From 2eb3243de06f1589991da47bfde6271e0d80abe6 Mon Sep 17 00:00:00 2001 From: alee Date: Tue, 27 Jul 2010 19:03:40 +0000 Subject: merge 8.1 -> tip, multiple bugs (base) git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@1134 c9f7a03b-bd48-0410-a16d-cbbf54688b0b --- pki/base/tps/src/main/ObjectSpec.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pki/base/tps/src/main/ObjectSpec.cpp') diff --git a/pki/base/tps/src/main/ObjectSpec.cpp b/pki/base/tps/src/main/ObjectSpec.cpp index b53ced3ad..2896a85f0 100644 --- a/pki/base/tps/src/main/ObjectSpec.cpp +++ b/pki/base/tps/src/main/ObjectSpec.cpp @@ -244,6 +244,16 @@ void ObjectSpec::ParseAttributes(char *objectID, ObjectSpec *ObjectSpec, Buffer curpos += 4 + 2 + attribute_size; } + //Here the objectID fixed attribute gets massaged. Here's how: + // The objectID becomes the cert container id, ex: 01 + // Each key pair associated with the cert must have the same ID. + // This is done by math using the following formula: + // Given a cert id of "2", the keyAttrIds of the keys are originally + // configured as k4 and k5. Note that one is twice the cert id, and + // the other is twice the cert id plus 1. In order to map the key ids + // down to the cert's id, the code below changes both "4" and "5" back + // to "2". + int val = (objectID[1] - '0'); switch (objectID[0]) { case 'c': @@ -361,12 +371,17 @@ ObjectSpec *ObjectSpec::Parse(Buffer *b, int offset, int *nread) { int sum = 0; + + if((b->size() - offset) < 10) + return NULL; + ObjectSpec *o = new ObjectSpec(); unsigned long id = (((unsigned char *)*b)[offset + 0] << 24) + (((unsigned char *)*b)[offset + 1] << 16) + (((unsigned char *)*b)[offset + 2] << 8) + (((unsigned char *)*b)[offset + 3]); + o->SetObjectID(id); unsigned long attribute = (((unsigned char *)*b)[offset + 4] << 24) + -- cgit