From 39ca3ae4a5a291d6bdca54d5c25414edbb26e09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 7 Sep 2006 10:58:17 +0000 Subject: [PATCH] Sprinkle error messages. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18052 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/ks_file.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/hx509/ks_file.c b/lib/hx509/ks_file.c index ef8fe24a4..34fa71a3b 100644 --- a/lib/hx509/ks_file.c +++ b/lib/hx509/ks_file.c @@ -232,8 +232,8 @@ parse_rsa_private_key(hx509_context context, struct hx509_collector *c, if (ret <= 0) { free(key); free(ivdata); - hx509_clear_error_string(context); - + hx509_set_error_string(context, 0, EINVAL, + "Failed to do string2key for RSA key"); return EINVAL; } @@ -327,6 +327,9 @@ parse_pem_file(hx509_context context, type = strdup(buf + 11); if (type == NULL) break; + p = strchr(type, '-'); + if (p) + *p = '\0'; *found_data = 1; where = SEARCHHEADER; } @@ -374,11 +377,18 @@ parse_pem_file(hx509_context context, if (where == DONE) { int j; - ret = EINVAL; for (j = 0; j < sizeof(formats)/sizeof(formats[0]); j++) { const char *q = formats[j].name; - if (strncmp(type, q, strlen(q)) == 0) + if (strcasecmp(type, q) == 0) { ret = (*formats[j].func)(context, c, headers, data, len); + break; + } + } + if (j == sizeof(formats)/sizeof(formats[0])) { + ret = EINVAL; + hx509_set_error_string(context, 0, ret, + "Found no matching PEM format for %s", + type); } free(data); data = NULL;