diff options
author | Tim Taubert <ttaubert@mozilla.com> | 2016-07-06 14:14:55 +0200 |
---|---|---|
committer | Tim Taubert <ttaubert@mozilla.com> | 2016-07-06 14:14:55 +0200 |
commit | 8a90fef3d7fb293e2b83c6e21131cfb1bb8203dd (patch) | |
tree | f4922184c5efd9edc76eac8427bfc80f9bd186f4 | |
parent | a19dbbd6b407e9a41c0a53bd05d040c8c28e444a (diff) | |
download | nss-hg-8a90fef3d7fb293e2b83c6e21131cfb1bb8203dd.tar.gz |
Bug 1284828 - Enable S/MIME tests on LSan runs r=franziskus
-rw-r--r-- | automation/taskcluster/graph/linux/build64-lsan.yml | 1 | ||||
-rw-r--r-- | cmd/p7content/p7content.c | 28 | ||||
-rw-r--r-- | cmd/p7env/p7env.c | 24 | ||||
-rw-r--r-- | cmd/p7sign/p7sign.c | 2 | ||||
-rw-r--r-- | cmd/p7verify/p7verify.c | 8 | ||||
-rw-r--r-- | cmd/smimetools/cmsutil.c | 18 |
6 files changed, 67 insertions, 14 deletions
diff --git a/automation/taskcluster/graph/linux/build64-lsan.yml b/automation/taskcluster/graph/linux/build64-lsan.yml index 9a62f362a..10ed41853 100644 --- a/automation/taskcluster/graph/linux/build64-lsan.yml +++ b/automation/taskcluster/graph/linux/build64-lsan.yml @@ -34,4 +34,5 @@ - merge - ocsp - sdr + - smime - tools 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; } diff --git a/cmd/p7env/p7env.c b/cmd/p7env/p7env.c index b798101ef..1cf17540b 100644 --- a/cmd/p7env/p7env.c +++ b/cmd/p7env/p7env.c @@ -190,12 +190,13 @@ main(int argc, char **argv) progName); return -1; } - rcpt->nickname = strdup(optstate->value); + rcpt->nickname = PORT_Strdup(optstate->value); rcpt->cert = NULL; rcpt->next = NULL; break; } } + PL_DestroyOptState(optstate); if (!recipients) Usage(progName); @@ -235,5 +236,26 @@ main(int argc, char **argv) return -1; } + /* free certs */ + for (rcpt = recipients; rcpt != NULL; ) { + struct recipient *next = rcpt->next; + CERT_DestroyCertificate(rcpt->cert); + PORT_Free(rcpt->nickname); + PORT_Free(rcpt); + rcpt = next; + } + + if (inFile && inFile != stdin) { + fclose(inFile); + } + if (outFile && outFile != stdout) { + fclose(outFile); + } + + if (NSS_Shutdown() != SECSuccess) { + SECU_PrintError(progName, "NSS shutdown:"); + return -1; + } + return 0; } diff --git a/cmd/p7sign/p7sign.c b/cmd/p7sign/p7sign.c index 605eee415..3ac462006 100644 --- a/cmd/p7sign/p7sign.c +++ b/cmd/p7sign/p7sign.c @@ -132,6 +132,7 @@ SignFile(FILE *outFile, PRFileDesc *inFile, CERTCertificate *cert, rv = SEC_PKCS7Encode(cinfo, SignOut, outFile, NULL, NULL, &pwdata); + SECITEM_FreeItem(&data2sign, PR_FALSE); SEC_PKCS7DestroyContentInfo(cinfo); if (rv != SECSuccess) @@ -212,6 +213,7 @@ main(int argc, char **argv) break; } } + PL_DestroyOptState(optstate); if (!keyName) Usage(progName); diff --git a/cmd/p7verify/p7verify.c b/cmd/p7verify/p7verify.c index bb92f990f..ba38e1158 100644 --- a/cmd/p7verify/p7verify.c +++ b/cmd/p7verify/p7verify.c @@ -171,6 +171,7 @@ HashDecodeAndVerify(FILE *out, FILE *content, PRFileDesc *signature, fprintf(out, "invalid (Reason: %s).\n", SECU_Strerror(PORT_GetError())); + SECITEM_FreeItem(&derdata, PR_FALSE); SEC_PKCS7DestroyContentInfo(cinfo); return 0; } @@ -245,6 +246,7 @@ main(int argc, char **argv) } } } + PL_DestroyOptState(optstate); if (!contentFile) Usage(progName); @@ -267,6 +269,12 @@ main(int argc, char **argv) return -1; } + fclose(contentFile); + PR_Close(signatureFile); + if (outFile && outFile != stdout) { + fclose(outFile); + } + if (NSS_Shutdown() != SECSuccess) { exit(1); } diff --git a/cmd/smimetools/cmsutil.c b/cmd/smimetools/cmsutil.c index 9a52a872d..e01fc4c7b 100644 --- a/cmd/smimetools/cmsutil.c +++ b/cmd/smimetools/cmsutil.c @@ -1251,7 +1251,7 @@ main(int argc, char **argv) SECU_ConfigDirectory(optstate->value); break; case 'e': - envFileName = strdup(optstate->value); + envFileName = PORT_Strdup(optstate->value); encryptOptions.envFile = PR_Open(envFileName, PR_RDONLY, 00660); break; @@ -1379,9 +1379,6 @@ main(int argc, char **argv) SECU_PrintError(progName, "unable to read infile"); exit(1); } - if (inFile != PR_STDIN) { - PR_Close(inFile); - } } if (cms_verbose) { fprintf(stderr, "received commands\n"); @@ -1461,9 +1458,6 @@ main(int argc, char **argv) } } else { exitstatus = doBatchDecode(outFile, inFile, &decodeOptions); - if (inFile != PR_STDIN) { - PR_Close(inFile); - } } break; case SIGN: /* -S */ @@ -1611,6 +1605,16 @@ main(int argc, char **argv) if (outFile != stdout) fclose(outFile); + if (inFile != PR_STDIN) { + PR_Close(inFile); + } + if (envFileName) { + PORT_Free(envFileName); + } + if (encryptOptions.envFile) { + PR_Close(encryptOptions.envFile); + } + SECITEM_FreeItem(&decodeOptions.content, PR_FALSE); SECITEM_FreeItem(&envmsg, PR_FALSE); SECITEM_FreeItem(&input, PR_FALSE); |