From 8ffe6943f04d42314f81eb8b5e3350d4ccc41895 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 17 Oct 2012 15:26:23 -0400 Subject: [PATCH 17/42] Use PORT_ArenaStrdup() where appropriate. Signed-off-by: Peter Jones --- src/daemon.c | 15 ++++++--------- src/pesign.c | 12 ++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index 07aaf6c..73fd924 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -205,9 +205,8 @@ malformed: "unlocking token \"%s\"", tn->value); /* authenticating with nss frees this ... best API ever. */ - ctx->cms->tokenname = PORT_ArenaZAlloc(ctx->cms->arena, - strlen((char *)tn->value)); - strcpy(ctx->cms->tokenname, (char *)tn->value); + ctx->cms->tokenname = PORT_ArenaStrdup(ctx->cms->arena, + (char *)tn->value); if (!ctx->cms->tokenname) goto oom; @@ -397,9 +396,8 @@ malformed: n -= tn->size; /* authenticating with nss frees these ... best API ever. */ - ctx->cms->tokenname = PORT_ArenaZAlloc(ctx->cms->arena, - strlen((char *)tn->value)); - strcpy(ctx->cms->tokenname, (char *)tn->value); + ctx->cms->tokenname = PORT_ArenaStrdup(ctx->cms->arena, + (char *)tn->value); if (!ctx->cms->tokenname) goto oom; @@ -410,9 +408,8 @@ malformed: if (n < cn->size) goto malformed; - ctx->cms->certname = PORT_ArenaZAlloc(ctx->cms->arena, - strlen((char *)cn->value)); - strcpy(ctx->cms->certname, (char *)cn->value); + ctx->cms->certname = PORT_ArenaStrdup(ctx->cms->arena, + (char *)cn->value); if (!ctx->cms->certname) goto oom; diff --git a/src/pesign.c b/src/pesign.c index c7b23cf..819cee0 100644 --- a/src/pesign.c +++ b/src/pesign.c @@ -551,17 +551,17 @@ main(int argc, char *argv[]) exit(!is_help); } - ctx.cms_ctx->tokenname = tokenname ? - PORT_ArenaStrdup(ctx.cms_ctx->arena, tokenname) : NULL; - if (tokenname && !ctx.cms_ctx->tokenname) { + ctxp->cms_ctx->tokenname = tokenname ? + PORT_ArenaStrdup(ctxp->cms_ctx->arena, tokenname) : NULL; + if (tokenname && !ctxp->cms_ctx->tokenname) { fprintf(stderr, "could not allocate token name: %s\n", PORT_ErrorToString(PORT_GetError())); exit(1); } - ctx.cms_ctx->certname = certname ? - PORT_ArenaStrdup(ctx.cms_ctx->arena, certname) : NULL; - if (certname && !ctx.cms_ctx->certname) { + ctxp->cms_ctx->certname = certname ? + PORT_ArenaStrdup(ctxp->cms_ctx->arena, certname) : NULL; + if (certname && !ctxp->cms_ctx->certname) { fprintf(stderr, "could not allocate certificate name: %s\n", PORT_ErrorToString(PORT_GetError())); exit(1); -- 1.7.12.1