summaryrefslogtreecommitdiffstats
path: root/kbx
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2001-12-20 17:50:13 +0100
committerWerner Koch <wk@gnupg.org>2001-12-20 17:50:13 +0100
commitb65e1cf90a0564569602c00406908a1780fc055c (patch)
treedcdfb79670f26bfe4e417e6837deedc45ed2e57c /kbx
parent* maperror.c (map_gcry_err): Add some mappings. (diff)
downloadgnupg2-b65e1cf90a0564569602c00406908a1780fc055c.tar.xz
gnupg2-b65e1cf90a0564569602c00406908a1780fc055c.zip
* keybox-blob.c (_keybox_create_x509_blob): Skip the leading
parenthesis of the serial number's S-exp. (_keybox_create_x509_blob): And fixed length calculation. (create_blob_header): Don't add an offset when writing the serial.
Diffstat (limited to 'kbx')
-rw-r--r--kbx/ChangeLog2
-rw-r--r--kbx/keybox-blob.c20
2 files changed, 15 insertions, 7 deletions
diff --git a/kbx/ChangeLog b/kbx/ChangeLog
index 22448c1e6..9ad6c3c38 100644
--- a/kbx/ChangeLog
+++ b/kbx/ChangeLog
@@ -2,6 +2,8 @@
* keybox-blob.c (_keybox_create_x509_blob): Skip the leading
parenthesis of the serial number's S-exp.
+ (_keybox_create_x509_blob): And fixed length calculation.
+ (create_blob_header): Don't add an offset when writing the serial.
2001-12-18 Werner Koch <wk@gnupg.org>
diff --git a/kbx/keybox-blob.c b/kbx/keybox-blob.c
index 764372c01..2c80a10ad 100644
--- a/kbx/keybox-blob.c
+++ b/kbx/keybox-blob.c
@@ -555,7 +555,7 @@ create_blob_header (KEYBOXBLOB blob, int blobtype)
put16 (a, blob->seriallen); /*fixme: check that it fits into 16 bits*/
if (blob->serial)
- put_membuf (a, blob->serial+4, blob->seriallen);
+ put_membuf (a, blob->serial, blob->seriallen);
put16 ( a, blob->nuids );
put16 ( a, 4 + 4 + 2 + 1 + 1 ); /* size of uid info */
@@ -821,20 +821,26 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, KsbaCert cert,
p = ksba_cert_get_serial (cert);
if (p)
{
- size_t n;
+ size_t n, len;
n = gcry_sexp_canon_len (p, 0, NULL, NULL);
- if (!n)
+ if (n < 2)
{
xfree (p);
return KEYBOX_General_Error;
}
blob->serialbuf = p;
+ p++; n--; /* skip '(' */
+ for (len=0; n && *p && *p != ':' && digitp (p); n--, p++)
+ len = len*10 + atoi_1 (p);
+ if (*p != ':')
+ {
+ xfree (blob->serialbuf);
+ blob->serialbuf = NULL;
+ return KEYBOX_General_Error;
+ }
p++;
- for (; n && *p != ':'; n--, p++)
- ;
- p++;
- blob->seriallen = n;
blob->serial = p;
+ blob->seriallen = len;
}
blob->nkeys = 1;