8301279: update for deprecated sprintf for management components

Reviewed-by: kevinw, dholmes
This commit is contained in:
Xue-Lei Andrew Fan 2023-02-14 15:36:09 +00:00
parent 8933c2d06a
commit ec901f28c3
3 changed files with 3 additions and 3 deletions

View File

@ -44,7 +44,7 @@ Java_sun_management_VMManagementImpl_getVersion0
// for internal use
unsigned int micro = (unsigned int) jmm_version & 0xFF;
sprintf(buf, "%d.%d", major, minor);
snprintf(buf, sizeof(buf), "%d.%d", major, minor);
version_string = (*env)->NewStringUTF(env, buf);
return version_string;
}

View File

@ -57,6 +57,6 @@ JNIEXPORT jint JNICALL
void throw_internal_error(JNIEnv* env, const char* msg) {
char errmsg[128];
sprintf(errmsg, "errno: %d error: %s\n", errno, msg);
snprintf(errmsg, sizeof(errmsg), "errno: %d error: %s\n", errno, msg);
JNU_ThrowInternalError(env, errmsg);
}

View File

@ -57,6 +57,6 @@ JNIEXPORT jint JNICALL
void throw_internal_error(JNIEnv* env, const char* msg) {
char errmsg[128];
sprintf(errmsg, "errno: %d error: %s\n", errno, msg);
snprintf(errmsg, sizeof(errmsg), "errno: %d error: %s\n", errno, msg);
JNU_ThrowInternalError(env, errmsg);
}