Skip to content

Commit

Permalink
macOS: Stop using sprintf in java.desktop
Browse files Browse the repository at this point in the history
This commit backports the changes for macOS from Java 21, replacing
sprintf() by snprintf().

Signed-off-by: KONNO Kazuhiro <konno@jp.ibm.com>
  • Loading branch information
knn-k committed Jul 4, 2023
1 parent 806d293 commit 7939317
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ===========================================================================
* (C) Copyright IBM Corp. 2023 All Rights Reserved.
* ===========================================================================
*/

#import "java_awt_geom_PathIterator.h"
#import "sun_font_CStrike.h"
Expand Down Expand Up @@ -102,7 +107,7 @@ + (AWTStrike *) awtStrikeForFont:(AWTFont *)awtFont
#define AWT_FONT_CLEANUP_FINISH \
if (_fontThrowJavaException == YES) { \
char s[512]; \
sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__); \
snprintf(s, sizeof(s), "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__); \
JNU_ThrowByName(env, "java/lang/RuntimeException", s); \
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ===========================================================================
* (C) Copyright IBM Corp. 2023 All Rights Reserved.
* ===========================================================================
*/

//#define USE_ERROR
//#define USE_TRACE
Expand Down Expand Up @@ -635,7 +640,7 @@ void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
if (channelName == NULL) {
return;
}
sprintf(channelName, "Ch %d", ch);
snprintf(channelName, 16, "Ch %d", ch);
}

void* jControls[2];
Expand Down

0 comments on commit 7939317

Please sign in to comment.