diff options
author | hylee <none@none> | 2007-08-08 11:26:31 -0700 |
---|---|---|
committer | hylee <none@none> | 2007-08-08 11:26:31 -0700 |
commit | fbcec90110655a00a2d5c9bdfaf87c7b476a4902 (patch) | |
tree | fdb0e931ace1a4f634c686c8148e78485af34712 /usr/src/lib/libkmf | |
parent | 35b1ab9964f57b69ba8f03d2962f94036aa78c57 (diff) | |
download | illumos-gate-fbcec90110655a00a2d5c9bdfaf87c7b476a4902.tar.gz |
6585894 pktool import usage shows bogus nickname parameter
6585913 pktool import keystore=nss does not work for PEM encoded certs
Diffstat (limited to 'usr/src/lib/libkmf')
-rw-r--r-- | usr/src/lib/libkmf/libkmf/common/pem_encode.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/usr/src/lib/libkmf/libkmf/common/pem_encode.c b/usr/src/lib/libkmf/libkmf/common/pem_encode.c index 123174f583..f514e4aa9a 100644 --- a/usr/src/lib/libkmf/libkmf/common/pem_encode.c +++ b/usr/src/lib/libkmf/libkmf/common/pem_encode.c @@ -292,13 +292,10 @@ PEM_DecodeBlock(unsigned char *t, const unsigned char *f, int n) b = conv_ascii2bin(*(f++)); c = conv_ascii2bin(*(f++)); d = conv_ascii2bin(*(f++)); - if ((a & 0x80) || (b & 0x80) || - (c & 0x80) || (d & 0x80)) + if ((a & 0x80) || (b & 0x80) || (c & 0x80) || (d & 0x80)) return (-1); - l = ((((unsigned long)a)<<18L)| - (((unsigned long)b)<<12L)| - (((unsigned long)c)<< 6L)| - (((unsigned long)d))); + l = ((((unsigned long)a)<<18L) | (((unsigned long)b)<<12L) | + (((unsigned long)c)<< 6L) | (((unsigned long)d))); *(t++) = (unsigned char)(l>>16L)&0xff; *(t++) = (unsigned char)(l>> 8L)&0xff; *(t++) = (unsigned char)(l)&0xff; @@ -491,7 +488,7 @@ Pem2Der(unsigned char *in, int inlen, { int kmf_rv = 0; PEM_ENCODE_CTX ctx; - int i, k, bl = 0; + int i, j, k, bl = 0; char buf[2048]; char *nameB; unsigned char *dataB; @@ -507,16 +504,18 @@ Pem2Der(unsigned char *in, int inlen, * get a line (ended at '\n'), which returns * number of bytes in the line */ - i = get_line(in, buf); + i = get_line(in + total, buf); if (i <= 0) { kmf_rv = KMF_ERR_ENCODING; goto err; } - while ((i >= 0) && (buf[i] <= ' ')) i--; - buf[++i] = '\n'; - buf[++i] = '\0'; - total += i; + j = i; + while ((j >= 0) && (buf[j] <= ' ')) j--; + buf[++j] = '\n'; + buf[++j] = '\0'; + + total += i + 1; if (strncmp(buf, "-----BEGIN ", 11) == 0) { i = strlen(&(buf[11])); @@ -549,15 +548,16 @@ Pem2Der(unsigned char *in, int inlen, if (i <= 0) break; - while ((i >= 0) && (buf[i] <= ' ')) - i--; + j = i; + while ((j >= 0) && (buf[j] <= ' ')) + j--; - buf[++i] = '\n'; - buf[++i] = '\0'; - total += i; + buf[++j] = '\n'; + buf[++j] = '\0'; + total += i + 1; if (buf[0] == '\n') break; - if ((dataB = realloc(dataB, bl+i+9)) == NULL) { + if ((dataB = realloc(dataB, bl+j+9)) == NULL) { kmf_rv = KMF_ERR_MEMORY; goto err; } @@ -566,22 +566,22 @@ Pem2Der(unsigned char *in, int inlen, break; } - (void) memcpy(&(dataB[bl]), buf, i); - dataB[bl+i] = '\0'; - bl += i; + (void) memcpy(&(dataB[bl]), buf, j); + dataB[bl+j] = '\0'; + bl += j; } i = strlen(nameB); if ((strncmp(buf, "-----END ", 9) != 0) || - (strncmp(nameB, &(buf[9]), i) != 0) || - (strncmp(&(buf[9+i]), "-----", 5) != 0)) { + (strncmp(nameB, &(buf[9]), i) != 0) || + (strncmp(&(buf[9+i]), "-----", 5) != 0)) { kmf_rv = KMF_ERR_ENCODING; goto err; } PEM_DecodeInit(&ctx); i = PEM_DecodeUpdate(&ctx, - (unsigned char *)dataB, &bl, (unsigned char *)dataB, bl); + (unsigned char *)dataB, &bl, (unsigned char *)dataB, bl); if (i < 0) { kmf_rv = KMF_ERR_ENCODING; |