summaryrefslogtreecommitdiff
path: root/cmd/p7content
diff options
context:
space:
mode:
authorTim Taubert <ttaubert@mozilla.com>2016-07-06 14:14:55 +0200
committerTim Taubert <ttaubert@mozilla.com>2016-07-06 14:14:55 +0200
commit8a90fef3d7fb293e2b83c6e21131cfb1bb8203dd (patch)
treef4922184c5efd9edc76eac8427bfc80f9bd186f4 /cmd/p7content
parenta19dbbd6b407e9a41c0a53bd05d040c8c28e444a (diff)
downloadnss-hg-8a90fef3d7fb293e2b83c6e21131cfb1bb8203dd.tar.gz
Bug 1284828 - Enable S/MIME tests on LSan runs r=franziskus
Diffstat (limited to 'cmd/p7content')
-rw-r--r--cmd/p7content/p7content.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/cmd/p7content/p7content.c b/cmd/p7content/p7content.c
index a396c70bf..d8c4d6524 100644
--- a/cmd/p7content/p7content.c
+++ b/cmd/p7content/p7content.c
@@ -155,6 +155,7 @@ DecodeAndPrintFile(FILE *out, PRFileDesc *in, char *progName)
fprintf(out, "There were%s certs or crls included.\n",
SEC_PKCS7ContainsCertsOrCrls(cinfo) ? "" : " no");
+ SECITEM_FreeItem(&derdata, PR_FALSE);
SEC_PKCS7DestroyContentInfo(cinfo);
return 0;
}
@@ -172,6 +173,7 @@ main(int argc, char **argv)
PLOptState *optstate;
PLOptStatus status;
SECStatus rv;
+ int error = 0;
progName = strrchr(argv[0], '/');
progName = progName ? progName + 1 : argv[0];
@@ -194,7 +196,8 @@ main(int argc, char **argv)
if (!inFile) {
fprintf(stderr, "%s: unable to open \"%s\" for reading\n",
progName, optstate->value);
- return -1;
+ error = -1;
+ goto done;
}
break;
@@ -203,7 +206,8 @@ main(int argc, char **argv)
if (!outFile) {
fprintf(stderr, "%s: unable to open \"%s\" for writing\n",
progName, optstate->value);
- return -1;
+ error = -1;
+ goto done;
}
break;
@@ -222,6 +226,8 @@ main(int argc, char **argv)
break;
}
}
+ PL_DestroyOptState(optstate);
+
if (status == PL_OPT_BAD)
Usage(progName);
@@ -235,19 +241,29 @@ main(int argc, char **argv)
rv = NSS_Init(SECU_ConfigDirectory(NULL));
if (rv != SECSuccess) {
SECU_PrintPRandOSError(progName);
- return -1;
+ error = -1;
+ goto done;
}
PK11_SetPasswordFunc(SECU_GetModulePassword);
if (DecodeAndPrintFile(outFile, inFile, progName)) {
SECU_PrintError(progName, "problem decoding data");
- return -1;
+ error = -1;
+ goto done;
+ }
+
+done:
+ if (inFile && inFile != PR_STDIN) {
+ PR_Close(inFile);
+ }
+ if (outFile && outFile != stdout) {
+ fclose(outFile);
}
if (NSS_Shutdown() != SECSuccess) {
- exit(1);
+ error = -1;
}
- return 0;
+ return error;
}