Skip to content

Commit 61bdb6e

Browse files
committed
Use snprintf instead of sprintf
1 parent a0e6a3a commit 61bdb6e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/LibManagementExtSupport.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.graalvm.nativeimage.c.function.CFunction;
3636
import org.graalvm.nativeimage.c.function.CLibrary;
3737
import org.graalvm.nativeimage.c.type.CCharPointer;
38+
import org.graalvm.word.UnsignedWord;
39+
import org.graalvm.word.WordFactory;
3840

3941
import com.oracle.svm.core.annotate.Uninterruptible;
4042
import com.oracle.svm.core.c.CGlobalData;
@@ -57,12 +59,12 @@ private static void throwInternalError(IsolateThread env, CCharPointer msg) {
5759
*/
5860
CCharPointer errmsg = StackValue.get(128);
5961

60-
sprintf(errmsg, ERRMSG_FORMAT.get(), LibC.errno(), msg);
62+
snprintf(errmsg, WordFactory.unsigned(128), ERRMSG_FORMAT.get(), LibC.errno(), msg);
6163
jnuThrowInternalError(env, errmsg);
6264
}
6365

6466
@CFunction(transition = NO_TRANSITION)
65-
private static native int sprintf(CCharPointer str, CCharPointer format, int errno, CCharPointer msg);
67+
private static native int snprintf(CCharPointer str, UnsignedWord size, CCharPointer format, int errno, CCharPointer msg);
6668

6769
@CLibrary(value = "java", requireStatic = true)
6870
@CFunction(value = "JNU_ThrowInternalError", transition = NO_TRANSITION)

0 commit comments

Comments
 (0)