Fix return without clean

This commit is contained in:
Zhi Guan
2026-06-17 16:06:11 +08:00
parent 4831f5a549
commit ea35a8cea3
13 changed files with 22 additions and 17 deletions

View File

@@ -819,7 +819,7 @@ endif()
#
set(CPACK_PACKAGE_NAME "GmSSL")
set(CPACK_PACKAGE_VENDOR "GmSSL develop team")
set(CPACK_PACKAGE_VERSION "3.2.0-dev.1078")
set(CPACK_PACKAGE_VERSION "3.2.0-dev.1079")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/README.md)
set(CPACK_NSIS_MODIFY_PATH ON)
include(CPack)

View File

@@ -18,7 +18,7 @@ extern "C" {
#define GMSSL_VERSION_NUM 30200
#define GMSSL_VERSION_STR "GmSSL 3.2.0-dev.1078"
#define GMSSL_VERSION_STR "GmSSL 3.2.0-dev.1079"
int gmssl_version_num(void);
const char *gmssl_version_str(void);

View File

@@ -144,12 +144,15 @@ bad:
goto end;
}
fwrite(crl, crl_len, 1, outfp);
if (fwrite(crl, crl_len, 1, outfp) != 1) {
error_print();
goto end;
}
ret = 0;
end:
if (cert) free(cert);
if (crl) free(crl);
if (outfile && outfp) fclose(outfp);
return ret;
}

View File

@@ -77,6 +77,7 @@ int hsskeygen_main(int argc, char **argv)
if (--argc < 1) goto bad;
lms_types = *(++argv);
strncpy(lms_types_str, lms_types, sizeof(lms_types_str));
lms_types_str[sizeof(lms_types_str) - 1] = 0;
tok = strtok(lms_types_str, ":");
while (tok) {

View File

@@ -103,11 +103,11 @@ bad:
if (x509_key_generate(&key, OID_ec_public_key, &curve_oid, sizeof(curve_oid)) != 1) {
fprintf(stderr, "gmssl %s: inner failure\n", prog);
return -1;
goto end;
}
if (x509_private_key_info_encrypt_to_pem(&key, pass, outfp) != 1) {
fprintf(stderr, "gmssl %s: inner failure\n", prog);
return -1;
goto end;
}
if (x509_public_key_info_to_pem(&key, puboutfp) != 1) {
fprintf(stderr, "gmssl %s: inner failure\n", prog);

View File

@@ -178,6 +178,7 @@ bad:
if ((ret = sdf_sign(&key, dgst, sig, &siglen)) != 1) {
fprintf(stderr, "%s: inner error\n", prog);
ret = -1;
goto end;
}
if (fwrite(sig, 1, siglen, outfp) != siglen) {

View File

@@ -96,7 +96,7 @@ int sm9decrypt_main(int argc, char **argv)
} else {
bad:
fprintf(stderr, "gmssl %s: illegal option '%s'\n", prog, *argv);
return 1;
goto end;
}
argc--;

View File

@@ -90,7 +90,7 @@ int sm9encrypt_main(int argc, char **argv)
} else {
bad:
fprintf(stderr, "gmssl %s: illegal option '%s'\n", prog, *argv);
return 1;
goto end;
}
argc--;
@@ -103,7 +103,7 @@ bad:
}
if (sm9_enc_master_public_key_from_pem(&mpk, mpkfp) != 1) {
error_print();
return -1;
goto end;
}
if ((inlen = fread(inbuf, 1, sizeof(inbuf), infp)) <= 0) {
error_print();

View File

@@ -101,7 +101,7 @@ int sm9keygen_main(int argc, char **argv)
} else {
bad:
fprintf(stderr, "%s: illegal option '%s'\n", prog, *argv);
return 1;
goto end;
}
@@ -147,5 +147,5 @@ end:
gmssl_secure_clear(&enc_key, sizeof(enc_key));
if (infile && infp) fclose(infp);
if (outfile && outfp) fclose(outfp);
return 1;
return ret;
}

View File

@@ -90,7 +90,7 @@ int sm9setup_main(int argc, char **argv)
} else {
bad:
fprintf(stderr, "gmssl %s: illegal option '%s'\n", prog, *argv);
return 1;
goto end;
}
argc--;
@@ -142,7 +142,7 @@ end:
gmssl_secure_clear(&enc_msk, sizeof(enc_msk));
if (outfile && outfp) fclose(outfp);
if (puboutfile && puboutfp) fclose(puboutfp);
return 1;
return ret;
}

View File

@@ -93,7 +93,7 @@ int sm9sign_main(int argc, char **argv)
} else {
bad:
fprintf(stderr, "gmssl %s: illegal option '%s'\n", prog, *argv);
return 1;
goto end;
}
argc--;
@@ -107,7 +107,7 @@ bad:
if (sm9_sign_key_info_decrypt_from_pem(&key, pass, keyfp) != 1) {
error_print();
return -1;
goto end;
}
if (sm9_sign_init(&ctx) != 1) {

View File

@@ -92,7 +92,7 @@ int sm9verify_main(int argc, char **argv)
} else {
bad:
fprintf(stderr, "gmssl %s: illegal option '%s'\n", prog, *argv);
return 1;
goto end;
}
argc--;

View File

@@ -151,7 +151,7 @@ bad:
ret = 0;
end:
//xmss_key_cleanup(&key);
xmss_key_cleanup(&key);
if (out) {
gmssl_secure_clear(out, outlen);
free(out);