Avoid shadowing.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17577 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-05-13 20:58:18 +00:00
parent a848124aa0
commit 1da0ea830b

View File

@@ -62,16 +62,16 @@ struct hx509_revoke_ctx_data {
}; };
int int
hx509_revoke_init(hx509_context context, hx509_revoke_ctx *revoke) hx509_revoke_init(hx509_context context, hx509_revoke_ctx *ctx)
{ {
*revoke = calloc(1, sizeof(**revoke)); *ctx = calloc(1, sizeof(**ctx));
if (*revoke == NULL) if (*ctx == NULL)
return ENOMEM; return ENOMEM;
(*revoke)->crls.len = 0; (*ctx)->crls.len = 0;
(*revoke)->crls.val = NULL; (*ctx)->crls.val = NULL;
(*revoke)->ocsps.len = 0; (*ctx)->ocsps.len = 0;
(*revoke)->ocsps.val = NULL; (*ctx)->ocsps.val = NULL;
return 0; return 0;
} }
@@ -86,26 +86,26 @@ free_ocsp(struct revoke_ocsp *ocsp)
} }
void void
hx509_revoke_free(hx509_revoke_ctx *revoke) hx509_revoke_free(hx509_revoke_ctx *ctx)
{ {
size_t i ; size_t i ;
if (revoke == NULL || *revoke == NULL) if (ctx == NULL || *ctx == NULL)
return; return;
for (i = 0; i < (*revoke)->crls.len; i++) { for (i = 0; i < (*ctx)->crls.len; i++) {
free((*revoke)->crls.val[i].path); free((*ctx)->crls.val[i].path);
free_CRLCertificateList(&(*revoke)->crls.val[i].crl); free_CRLCertificateList(&(*ctx)->crls.val[i].crl);
} }
for (i = 0; i < (*revoke)->ocsps.len; i++) for (i = 0; i < (*ctx)->ocsps.len; i++)
free_ocsp(&(*revoke)->ocsps.val[i]); free_ocsp(&(*ctx)->ocsps.val[i]);
free((*revoke)->crls.val); free((*ctx)->crls.val);
memset(*revoke, 0, sizeof(**revoke)); memset(*ctx, 0, sizeof(**ctx));
free(*revoke); free(*ctx);
*revoke = NULL; *ctx = NULL;
} }
static int static int
@@ -310,7 +310,7 @@ load_ocsp(hx509_context context, struct revoke_ocsp *ocsp)
int int
hx509_revoke_add_ocsp(hx509_context context, hx509_revoke_add_ocsp(hx509_context context,
hx509_revoke_ctx revoke, hx509_revoke_ctx ctx,
const char *path) const char *path)
{ {
void *data; void *data;
@@ -322,31 +322,31 @@ hx509_revoke_add_ocsp(hx509_context context,
path += 5; path += 5;
for (i = 0; i < revoke->ocsps.len; i++) { for (i = 0; i < ctx->ocsps.len; i++) {
if (strcmp(revoke->ocsps.val[0].path, path) == 0) if (strcmp(ctx->ocsps.val[0].path, path) == 0)
return 0; return 0;
} }
data = realloc(revoke->ocsps.val, data = realloc(ctx->ocsps.val,
(revoke->ocsps.len + 1) * sizeof(revoke->ocsps.val[0])); (ctx->ocsps.len + 1) * sizeof(ctx->ocsps.val[0]));
if (data == NULL) if (data == NULL)
return ENOMEM; return ENOMEM;
revoke->ocsps.val = data; ctx->ocsps.val = data;
memset(&revoke->ocsps.val[revoke->ocsps.len], 0, memset(&ctx->ocsps.val[ctx->ocsps.len], 0,
sizeof(revoke->ocsps.val[0])); sizeof(ctx->ocsps.val[0]));
revoke->ocsps.val[revoke->ocsps.len].path = strdup(path); ctx->ocsps.val[ctx->ocsps.len].path = strdup(path);
if (revoke->ocsps.val[revoke->ocsps.len].path == NULL) if (ctx->ocsps.val[ctx->ocsps.len].path == NULL)
return ENOMEM; return ENOMEM;
ret = load_ocsp(context, &revoke->ocsps.val[revoke->ocsps.len]); ret = load_ocsp(context, &ctx->ocsps.val[ctx->ocsps.len]);
if (ret) { if (ret) {
free(revoke->ocsps.val[revoke->ocsps.len].path); free(ctx->ocsps.val[ctx->ocsps.len].path);
return ret; return ret;
} }
revoke->ocsps.len++; ctx->ocsps.len++;
return ret; return ret;
} }
@@ -454,7 +454,7 @@ load_crl(const char *path, time_t *t, CRLCertificateList *crl)
int int
hx509_revoke_add_crl(hx509_context context, hx509_revoke_add_crl(hx509_context context,
hx509_revoke_ctx revoke, hx509_revoke_ctx ctx,
const char *path) const char *path)
{ {
void *data; void *data;
@@ -466,33 +466,33 @@ hx509_revoke_add_crl(hx509_context context,
path += 5; path += 5;
for (i = 0; i < revoke->crls.len; i++) { for (i = 0; i < ctx->crls.len; i++) {
if (strcmp(revoke->crls.val[0].path, path) == 0) if (strcmp(ctx->crls.val[0].path, path) == 0)
return 0; return 0;
} }
data = realloc(revoke->crls.val, data = realloc(ctx->crls.val,
(revoke->crls.len + 1) * sizeof(revoke->crls.val[0])); (ctx->crls.len + 1) * sizeof(ctx->crls.val[0]));
if (data == NULL) if (data == NULL)
return ENOMEM; return ENOMEM;
revoke->crls.val = data; ctx->crls.val = data;
memset(&revoke->crls.val[revoke->crls.len], 0, sizeof(revoke->crls.val[0])); memset(&ctx->crls.val[ctx->crls.len], 0, sizeof(ctx->crls.val[0]));
revoke->crls.val[revoke->crls.len].path = strdup(path); ctx->crls.val[ctx->crls.len].path = strdup(path);
if (revoke->crls.val[revoke->crls.len].path == NULL) if (ctx->crls.val[ctx->crls.len].path == NULL)
return ENOMEM; return ENOMEM;
ret = load_crl(path, ret = load_crl(path,
&revoke->crls.val[revoke->crls.len].last_modfied, &ctx->crls.val[ctx->crls.len].last_modfied,
&revoke->crls.val[revoke->crls.len].crl); &ctx->crls.val[ctx->crls.len].crl);
if (ret) { if (ret) {
free(revoke->crls.val[revoke->crls.len].path); free(ctx->crls.val[ctx->crls.len].path);
return ret; return ret;
} }
revoke->crls.len++; ctx->crls.len++;
return ret; return ret;
} }
@@ -500,7 +500,7 @@ hx509_revoke_add_crl(hx509_context context,
int int
hx509_revoke_verify(hx509_context context, hx509_revoke_verify(hx509_context context,
hx509_revoke_ctx revoke, hx509_revoke_ctx ctx,
hx509_certs certs, hx509_certs certs,
time_t now, time_t now,
hx509_cert cert, hx509_cert cert,
@@ -511,8 +511,8 @@ hx509_revoke_verify(hx509_context context,
unsigned long i, j, k; unsigned long i, j, k;
int ret; int ret;
for (i = 0; i < revoke->ocsps.len; i++) { for (i = 0; i < ctx->ocsps.len; i++) {
struct revoke_ocsp *ocsp = &revoke->ocsps.val[i]; struct revoke_ocsp *ocsp = &ctx->ocsps.val[i];
struct stat sb; struct stat sb;
/* check this ocsp apply to this cert */ /* check this ocsp apply to this cert */
@@ -582,8 +582,8 @@ hx509_revoke_verify(hx509_context context,
} }
} }
for (i = 0; i < revoke->crls.len; i++) { for (i = 0; i < ctx->crls.len; i++) {
struct revoke_crl *crl = &revoke->crls.val[i]; struct revoke_crl *crl = &ctx->crls.val[i];
struct stat sb; struct stat sb;
/* check if cert.issuer == crls.val[i].crl.issuer */ /* check if cert.issuer == crls.val[i].crl.issuer */
@@ -594,12 +594,12 @@ hx509_revoke_verify(hx509_context context,
ret = stat(crl->path, &sb); ret = stat(crl->path, &sb);
if (ret == 0 && crl->last_modfied != sb.st_mtime) { if (ret == 0 && crl->last_modfied != sb.st_mtime) {
CRLCertificateList c; CRLCertificateList cl;
ret = load_crl(crl->path, &crl->last_modfied, &c); ret = load_crl(crl->path, &crl->last_modfied, &cl);
if (ret == 0) { if (ret == 0) {
free_CRLCertificateList(&crl->crl); free_CRLCertificateList(&crl->crl);
crl->crl = c; crl->crl = cl;
crl->verified = 0; crl->verified = 0;
} }
} }