From 87e864bf21d71daae4e001ec4edbb4ef1f60c36d Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 25 Apr 2024 08:11:56 +0000 Subject: [PATCH] 8328703: Illegal accesses in Java_jdk_internal_org_jline_terminal_impl_jna_linux_CLibraryImpl_ioctl0 Reviewed-by: asotona, shade --- .../linux/native/lible/CLibrary.cpp | 16 ++++++++-------- .../macosx/native/lible/CLibrary.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/jdk.internal.le/linux/native/lible/CLibrary.cpp b/src/jdk.internal.le/linux/native/lible/CLibrary.cpp index 7815fe0cd2e..3215e1f5013 100644 --- a/src/jdk.internal.le/linux/native/lible/CLibrary.cpp +++ b/src/jdk.internal.le/linux/native/lible/CLibrary.cpp @@ -150,20 +150,20 @@ JNIEXPORT void JNICALL Java_jdk_internal_org_jline_terminal_impl_jna_linux_CLibr (JNIEnv *env, jobject, jint fd, jint cmd, jobject data) { winsize ws; - ws.ws_row = env->GetIntField(data, ws_row); - ws.ws_col = env->GetIntField(data, ws_col); - ws.ws_xpixel = env->GetIntField(data, ws_xpixel); - ws.ws_ypixel = env->GetIntField(data, ws_ypixel); + ws.ws_row = env->GetShortField(data, ws_row); + ws.ws_col = env->GetShortField(data, ws_col); + ws.ws_xpixel = env->GetShortField(data, ws_xpixel); + ws.ws_ypixel = env->GetShortField(data, ws_ypixel); if (ioctl(fd, cmd, &ws) != 0) { throw_errno(env); return ; } - env->SetIntField(data, ws_row, ws.ws_row); - env->SetIntField(data, ws_col, ws.ws_col); - env->SetIntField(data, ws_xpixel, ws.ws_xpixel); - env->SetIntField(data, ws_ypixel, ws.ws_ypixel); + env->SetShortField(data, ws_row, ws.ws_row); + env->SetShortField(data, ws_col, ws.ws_col); + env->SetShortField(data, ws_xpixel, ws.ws_xpixel); + env->SetShortField(data, ws_ypixel, ws.ws_ypixel); } /* diff --git a/src/jdk.internal.le/macosx/native/lible/CLibrary.cpp b/src/jdk.internal.le/macosx/native/lible/CLibrary.cpp index 760e090f5e8..3bc481f4afa 100644 --- a/src/jdk.internal.le/macosx/native/lible/CLibrary.cpp +++ b/src/jdk.internal.le/macosx/native/lible/CLibrary.cpp @@ -154,20 +154,20 @@ JNIEXPORT void JNICALL Java_jdk_internal_org_jline_terminal_impl_jna_osx_CLibrar (JNIEnv *env, jobject, jint fd, jlong cmd, jobject data) { winsize ws; - ws.ws_row = env->GetIntField(data, ws_row); - ws.ws_col = env->GetIntField(data, ws_col); - ws.ws_xpixel = env->GetIntField(data, ws_xpixel); - ws.ws_ypixel = env->GetIntField(data, ws_ypixel); + ws.ws_row = env->GetShortField(data, ws_row); + ws.ws_col = env->GetShortField(data, ws_col); + ws.ws_xpixel = env->GetShortField(data, ws_xpixel); + ws.ws_ypixel = env->GetShortField(data, ws_ypixel); if (ioctl(fd, cmd, &ws) != 0) { throw_errno(env); return ; } - env->SetIntField(data, ws_row, ws.ws_row); - env->SetIntField(data, ws_col, ws.ws_col); - env->SetIntField(data, ws_xpixel, ws.ws_xpixel); - env->SetIntField(data, ws_ypixel, ws.ws_ypixel); + env->SetShortField(data, ws_row, ws.ws_row); + env->SetShortField(data, ws_col, ws.ws_col); + env->SetShortField(data, ws_xpixel, ws.ws_xpixel); + env->SetShortField(data, ws_ypixel, ws.ws_ypixel); } /*