diff --git a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp index e02f5e3e419..8580d1e7cf7 100644 --- a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp +++ b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp @@ -1223,17 +1223,17 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_CSignature_verifyCngSignedHa #define DUMP_PROP(p) \ if (::NCryptGetProperty(hKey, p, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \ - sprintf(header, "%s %ls", #p, p); \ + snprintf(header, sizeof(header), "%s %ls", #p, p); \ dump(header, buffer, len); \ } #define EXPORT_BLOB(p) \ desc.cBuffers = 0; \ if (::NCryptExportKey(hKey, NULL, p, &desc, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \ - sprintf(header, "%s %ls (%ld)", #p, p, desc.cBuffers); \ + snprintf(header, sizeof(header), "%s %ls (%ld)", #p, p, desc.cBuffers); \ dump(header, buffer, len); \ for (int i = 0; i < (int)desc.cBuffers; i++) { \ - sprintf(header, "desc %ld", desc.pBuffers[i].BufferType); \ + snprintf(header, sizeof(header), "desc %ld", desc.pBuffers[i].BufferType); \ dump(header, (PBYTE)desc.pBuffers[i].pvBuffer, desc.pBuffers[i].cbBuffer); \ } \ } @@ -1310,7 +1310,7 @@ void showProperty(NCRYPT_HANDLE hKey) { bbd.pBuffers = &bb; if(::NCryptExportKey(hKey, NULL, NCRYPT_PKCS8_PRIVATE_KEY_BLOB, NULL, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { - sprintf(header, "NCRYPT_PKCS8_PRIVATE_KEY_BLOB %ls", NCRYPT_PKCS8_PRIVATE_KEY_BLOB); + snprintf(header, sizeof(header), "NCRYPT_PKCS8_PRIVATE_KEY_BLOB %ls", NCRYPT_PKCS8_PRIVATE_KEY_BLOB); dump(header, buffer, len); } EXPORT_BLOB(NCRYPT_PROTECTED_KEY_BLOB); @@ -1445,7 +1445,7 @@ JNIEXPORT jstring JNICALL Java_sun_security_mscapi_CKey_getKeyType } else { char buffer[64]; - if (sprintf(buffer, "%lu", dwAlgId)) { + if (snprintf(buffer, sizeof(buffer), "%lu", dwAlgId)) { return env->NewStringUTF(buffer); } }