Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk15u-dev Public archive

Commit 753becc

Browse files
author
Yuri Nesterenko
committed
8252051: Make mlvmJvmtiUtils strncpy uses GCC 10.x friendly
Backport-of: 51a3b25d71e0e5875ac4bd2e76dfc2f9595dd83f
1 parent 1daf5c5 commit 753becc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -96,8 +96,11 @@ struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
9696
return NULL;
9797
}
9898

99-
strncpy(mn->methodName, szName, sizeof(mn->methodName));
100-
strncpy(mn->classSig, szSignature, sizeof(mn->classSig));
99+
strncpy(mn->methodName, szName, sizeof(mn->methodName) - 1);
100+
mn->methodName[sizeof(mn->methodName) - 1] = '\0';
101+
102+
strncpy(mn->classSig, szSignature, sizeof(mn->classSig) - 1);
103+
mn->classSig[sizeof(mn->classSig) - 1] = '\0';
101104

102105
return mn;
103106
}

0 commit comments

Comments
 (0)