From 15358636cf67fb570231ec8521533bd2d3146b65 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 11 May 2023 18:09:43 +0000 Subject: [PATCH] 8307848: update for deprecated sprintf for jdk.attach Reviewed-by: sspitsyn, cjplummer --- .../windows/native/libattach/VirtualMachineImpl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c index f08a7c004b3..3e3118c327f 100644 --- a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c +++ b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,7 +209,7 @@ JNIEXPORT jlong JNICALL Java_sun_tools_attach_VirtualMachineImpl_openProcess } else { char err_mesg[255]; /* include the last error in the default detail message */ - sprintf(err_mesg, "OpenProcess(pid=%d) failed; LastError=0x%x", + snprintf(err_mesg, sizeof(err_mesg), "OpenProcess(pid=%d) failed; LastError=0x%x", (int)pid, (int)GetLastError()); JNU_ThrowIOExceptionWithLastError(env, err_mesg); } @@ -492,7 +492,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue break; default : { char errmsg[128]; - sprintf(errmsg, "Remote thread failed for unknown reason (%d)", exitCode); + snprintf(errmsg, sizeof(errmsg), "Remote thread failed for unknown reason (%d)", exitCode); JNU_ThrowInternalError(env, errmsg); } }