Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8252051: Make mlvmJvmtiUtils strncpy uses GCC 10.x friendly #475

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -45,11 +45,6 @@ void copyFromJString(JNIEnv * pEnv, jstring src, char ** dst) {
NSK_CPP_STUB3(ReleaseStringUTFChars, pEnv, src, pStr);
}

#if !defined(__clang_major__) && defined(__GNUC__) && (__GNUC__ >= 8)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wstringop-truncation\"")
#endif

struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
char * szName;
char * szSignature;
@@ -71,18 +66,16 @@ struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
}

mn = malloc(sizeof(MethodNameStruct));
strncpy(mn->methodName, szName, sizeof(mn->methodName));
strncpy(mn->classSig, szSignature, sizeof(mn->classSig));
strncpy(mn->methodName, szName, sizeof(mn->methodName) - 1);
mn->methodName[sizeof(mn->methodName) - 1] = '\0';
strncpy(mn->classSig, szSignature, sizeof(mn->classSig) - 1);
mn->classSig[sizeof(mn->classSig) - 1] = '\0';

NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, pJvmtiEnv, (void *) szName));
NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, pJvmtiEnv, (void *) szSignature));
return mn;
}

#if !defined(__clang_major__) && defined(__GNUC__) && (__GNUC__ >= 8)
_Pragma("GCC diagnostic pop")
#endif

char * locationToString(jvmtiEnv * pJvmtiEnv, jmethodID method, jlocation location) {
struct MethodName * pMN;
// gcc 7.3 claims that snprintf below can output between 6 and 531 bytes. Setting buffer size to 600.