8282978: Wrong parameter passed to GetStringXXXChars in various places

Reviewed-by: alanb, dfuchs
This commit is contained in:
Zhengyu Gu 2022-03-11 13:25:09 +00:00
parent 95ca94436d
commit 0fd09d383b
9 changed files with 22 additions and 22 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -100,7 +100,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
JNU_ThrowNullPointerException(env, "host argument is null"); JNU_ThrowNullPointerException(env, "host argument is null");
return NULL; return NULL;
} }
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); hostname = JNU_GetStringPlatformChars(env, host, NULL);
CHECK_NULL_RETURN(hostname, NULL); CHECK_NULL_RETURN(hostname, NULL);
// try once, with our static buffer // try once, with our static buffer

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -220,7 +220,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
JNU_ThrowNullPointerException(env, "host argument is null"); JNU_ThrowNullPointerException(env, "host argument is null");
return NULL; return NULL;
} }
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); hostname = JNU_GetStringPlatformChars(env, host, NULL);
CHECK_NULL_RETURN(hostname, NULL); CHECK_NULL_RETURN(hostname, NULL);
// try once, with our static buffer // try once, with our static buffer

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -76,7 +76,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
JNU_ThrowNullPointerException(env, "host argument is null"); JNU_ThrowNullPointerException(env, "host argument is null");
return NULL; return NULL;
} }
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); hostname = JNU_GetStringPlatformChars(env, host, NULL);
CHECK_NULL_RETURN(hostname, NULL); CHECK_NULL_RETURN(hostname, NULL);
// try once, with our static buffer // try once, with our static buffer

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -71,7 +71,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
JNU_ThrowNullPointerException(env, "host argument is null"); JNU_ThrowNullPointerException(env, "host argument is null");
return NULL; return NULL;
} }
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); hostname = JNU_GetStringPlatformChars(env, host, NULL);
CHECK_NULL_RETURN(hostname, NULL); CHECK_NULL_RETURN(hostname, NULL);
// try once, with our static buffer // try once, with our static buffer

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -825,7 +825,7 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_SetProperty
*/ */
if (!JNU_IsNull(env, jstr)) { if (!JNU_IsNull(env, jstr)) {
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
cname = (char *) (*env)->GetStringUTFChars(env, jstr, JNI_FALSE); cname = (char *) (*env)->GetStringUTFChars(env, jstr, NULL);
#else #else
cname = (char *) JNU_GetStringPlatformChars(env, jstr, NULL); cname = (char *) JNU_GetStringPlatformChars(env, jstr, NULL);
#endif #endif

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -105,7 +105,7 @@ AwtButton* AwtButton::Create(jobject self, jobject parent)
if (label == NULL) { if (label == NULL) {
labelStr = L""; labelStr = L"";
} else { } else {
labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE); labelStr = JNU_GetStringPlatformChars(env, label, NULL);
} }
style = 0; style = 0;
@ -311,7 +311,7 @@ void AwtButton::_SetLabel(void *param)
if (label == NULL) { if (label == NULL) {
labelStr = TEXT(""); labelStr = TEXT("");
} else { } else {
labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE); labelStr = JNU_GetStringPlatformChars(env, label, NULL);
} }
if (labelStr == NULL) { if (labelStr == NULL) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -106,7 +106,7 @@ AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent)
label = (jstring)env->GetObjectField(target, AwtCheckbox::labelID); label = (jstring)env->GetObjectField(target, AwtCheckbox::labelID);
if (label != NULL) { if (label != NULL) {
labelStr = JNU_GetStringPlatformChars(env, label, 0); labelStr = JNU_GetStringPlatformChars(env, label, NULL);
} }
if (labelStr != 0) { if (labelStr != 0) {
jint x = env->GetIntField(target, AwtComponent::xID); jint x = env->GetIntField(target, AwtComponent::xID);
@ -375,7 +375,7 @@ void AwtCheckbox::_SetLabel(void *param)
} }
else else
{ {
labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE); labelStr = JNU_GetStringPlatformChars(env, label, NULL);
} }
if (labelStr == NULL) if (labelStr == NULL)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -75,9 +75,9 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WDesktopPeer_init
JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
(JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j) (JNIEnv *env, jclass cls, jstring fileOrUri_j, jstring verb_j)
{ {
LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, JNI_FALSE); LPCWSTR fileOrUri_c = JNU_GetStringPlatformChars(env, fileOrUri_j, NULL);
CHECK_NULL_RETURN(fileOrUri_c, NULL); CHECK_NULL_RETURN(fileOrUri_c, NULL);
LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE); LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, NULL);
if (verb_c == NULL) { if (verb_c == NULL) {
JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c); JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
return NULL; return NULL;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -183,7 +183,7 @@ Java_sun_awt_Win32FontManager_registerFontWithPlatform(JNIEnv *env,
jclass cl, jclass cl,
jstring fontName) jstring fontName)
{ {
LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, JNI_FALSE); LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, NULL);
if (file) { if (file) {
::AddFontResourceEx(file, FR_PRIVATE, NULL); ::AddFontResourceEx(file, FR_PRIVATE, NULL);
JNU_ReleaseStringPlatformChars(env, fontName, file); JNU_ReleaseStringPlatformChars(env, fontName, file);
@ -203,7 +203,7 @@ Java_sun_awt_Win32FontManager_deRegisterFontWithPlatform(JNIEnv *env,
jclass cl, jclass cl,
jstring fontName) jstring fontName)
{ {
LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, JNI_FALSE); LPTSTR file = (LPTSTR)JNU_GetStringPlatformChars(env, fontName, NULL);
if (file) { if (file) {
::RemoveFontResourceEx(file, FR_PRIVATE, NULL); ::RemoveFontResourceEx(file, FR_PRIVATE, NULL);
JNU_ReleaseStringPlatformChars(env, fontName, file); JNU_ReleaseStringPlatformChars(env, fontName, file);