git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19840 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-01-11 10:36:29 +00:00
parent 82a45c7036
commit 91a0892b93
4 changed files with 34 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006 Kungliga Tekniska H<>gskolan * Copyright (c) 2006 - 2007 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -87,7 +87,8 @@ hx509_set_error_stringv(hx509_context context, int flags, int code,
} }
void void
hx509_set_error_string(hx509_context context, int flags, int code, const char *fmt, ...) hx509_set_error_string(hx509_context context, int flags, int code,
const char *fmt, ...)
{ {
va_list ap; va_list ap;
@@ -125,7 +126,8 @@ hx509_get_error_string(hx509_context context, int error_code)
} }
void void
hx509_err(hx509_context context, int exit_code, int error_code, char *fmt, ...) hx509_err(hx509_context context, int exit_code,
int error_code, const char *fmt, ...)
{ {
va_list ap; va_list ap;
const char *msg; const char *msg;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004 - 2006 Kungliga Tekniska H<>gskolan * Copyright (c) 2004 - 2007 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -386,7 +386,7 @@ hx509_certs_info(hx509_context context,
void void
_hx509_pi_printf(int (*func)(void *, const char *), void *ctx, _hx509_pi_printf(int (*func)(void *, const char *), void *ctx,
char *fmt, ...) const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *str; char *str;

View File

@@ -41,7 +41,7 @@ RCSID("$Id$");
*/ */
static const struct { static const struct {
char *n; const char *n;
const heim_oid *(*o)(void); const heim_oid *(*o)(void);
} no[] = { } no[] = {
{ "C", oid_id_at_countryName }, { "C", oid_id_at_countryName },
@@ -92,14 +92,15 @@ quote_string(const char *f, size_t len, size_t *rlen)
static int static int
append_string(char **str, size_t *total_len, char *ss, size_t len, int quote) append_string(char **str, size_t *total_len, const char *ss,
size_t len, int quote)
{ {
char *s, *qs; char *s, *qs;
if (quote) if (quote)
qs = quote_string(ss, len, &len); qs = quote_string(ss, len, &len);
else else
qs = ss; qs = rk_UNCONST(ss);
s = realloc(*str, len + *total_len + 1); s = realloc(*str, len + *total_len + 1);
if (s == NULL) if (s == NULL)
@@ -200,11 +201,25 @@ _hx509_Name_to_string(const Name *n, char **str)
break; break;
} }
case choice_DirectoryString_teletexString: case choice_DirectoryString_teletexString:
ss = "teletex-string"; /* XXX */ ss = malloc(ds->u.teletexString.length + 1);
if (ss == NULL)
_hx509_abort("allocation failure"); /* XXX */
memcpy(ss, ds->u.teletexString.data, ds->u.teletexString.length);
ss[ds->u.teletexString.length] = '\0';
break; break;
case choice_DirectoryString_universalString: case choice_DirectoryString_universalString: {
ss = "universalString"; /* XXX */ uint32_t *uni = ds->u.universalString.data;
size_t unilen = ds->u.universalString.length;
size_t k;
ss = malloc(unilen + 1);
if (ss == NULL)
_hx509_abort("allocation failure"); /* XXX */
for (k = 0; k < unilen; k++)
ss[k] = uni[k] & 0xff; /* XXX */
ss[k] = '\0';
break; break;
}
default: default:
_hx509_abort("unknown directory type: %d", ds->element); _hx509_abort("unknown directory type: %d", ds->element);
exit(1); exit(1);
@@ -214,8 +229,12 @@ _hx509_Name_to_string(const Name *n, char **str)
append_string(str, &total_len, "=", 1, 0); append_string(str, &total_len, "=", 1, 0);
len = strlen(ss); len = strlen(ss);
append_string(str, &total_len, ss, len, 1); append_string(str, &total_len, ss, len, 1);
if (ds->element == choice_DirectoryString_bmpString) if (ds->element == choice_DirectoryString_universalString ||
ds->element == choice_DirectoryString_bmpString ||
ds->element == choice_DirectoryString_teletexString)
{
free(ss); free(ss);
}
if (j + 1 < n->u.rdnSequence.val[i].len) if (j + 1 < n->u.rdnSequence.val[i].len)
append_string(str, &total_len, "+", 1, 0); append_string(str, &total_len, "+", 1, 0);
} }

View File

@@ -922,7 +922,7 @@ hx509_revoke_ocsp_print(hx509_context context, const char *path, FILE *out)
fprintf(out, "replies: %d\n", ocsp.ocsp.tbsResponseData.responses.len); fprintf(out, "replies: %d\n", ocsp.ocsp.tbsResponseData.responses.len);
for (i = 0; i < ocsp.ocsp.tbsResponseData.responses.len; i++) { for (i = 0; i < ocsp.ocsp.tbsResponseData.responses.len; i++) {
char *status; const char *status;
switch (ocsp.ocsp.tbsResponseData.responses.val[i].certStatus.element) { switch (ocsp.ocsp.tbsResponseData.responses.val[i].certStatus.element) {
case choice_OCSPCertStatus_good: case choice_OCSPCertStatus_good:
status = "good"; status = "good";