Skip to content

Commit 021372c

Browse files
committed
8328703: Illegal accesses in Java_jdk_internal_org_jline_terminal_impl_jna_linux_CLibraryImpl_ioctl0
Backport-of: 87e864bf21d71daae4e001ec4edbb4ef1f60c36d
1 parent d459ae9 commit 021372c

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/jdk.internal.le/linux/native/lible/CLibrary.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,20 @@ JNIEXPORT void JNICALL Java_jdk_internal_org_jline_terminal_impl_jna_linux_CLibr
150150
(JNIEnv *env, jobject, jint fd, jint cmd, jobject data) {
151151
winsize ws;
152152

153-
ws.ws_row = env->GetIntField(data, ws_row);
154-
ws.ws_col = env->GetIntField(data, ws_col);
155-
ws.ws_xpixel = env->GetIntField(data, ws_xpixel);
156-
ws.ws_ypixel = env->GetIntField(data, ws_ypixel);
153+
ws.ws_row = env->GetShortField(data, ws_row);
154+
ws.ws_col = env->GetShortField(data, ws_col);
155+
ws.ws_xpixel = env->GetShortField(data, ws_xpixel);
156+
ws.ws_ypixel = env->GetShortField(data, ws_ypixel);
157157

158158
if (ioctl(fd, cmd, &ws) != 0) {
159159
throw_errno(env);
160160
return ;
161161
}
162162

163-
env->SetIntField(data, ws_row, ws.ws_row);
164-
env->SetIntField(data, ws_col, ws.ws_col);
165-
env->SetIntField(data, ws_xpixel, ws.ws_xpixel);
166-
env->SetIntField(data, ws_ypixel, ws.ws_ypixel);
163+
env->SetShortField(data, ws_row, ws.ws_row);
164+
env->SetShortField(data, ws_col, ws.ws_col);
165+
env->SetShortField(data, ws_xpixel, ws.ws_xpixel);
166+
env->SetShortField(data, ws_ypixel, ws.ws_ypixel);
167167
}
168168

169169
/*

src/jdk.internal.le/macosx/native/lible/CLibrary.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,20 @@ JNIEXPORT void JNICALL Java_jdk_internal_org_jline_terminal_impl_jna_osx_CLibrar
154154
(JNIEnv *env, jobject, jint fd, jlong cmd, jobject data) {
155155
winsize ws;
156156

157-
ws.ws_row = env->GetIntField(data, ws_row);
158-
ws.ws_col = env->GetIntField(data, ws_col);
159-
ws.ws_xpixel = env->GetIntField(data, ws_xpixel);
160-
ws.ws_ypixel = env->GetIntField(data, ws_ypixel);
157+
ws.ws_row = env->GetShortField(data, ws_row);
158+
ws.ws_col = env->GetShortField(data, ws_col);
159+
ws.ws_xpixel = env->GetShortField(data, ws_xpixel);
160+
ws.ws_ypixel = env->GetShortField(data, ws_ypixel);
161161

162162
if (ioctl(fd, cmd, &ws) != 0) {
163163
throw_errno(env);
164164
return ;
165165
}
166166

167-
env->SetIntField(data, ws_row, ws.ws_row);
168-
env->SetIntField(data, ws_col, ws.ws_col);
169-
env->SetIntField(data, ws_xpixel, ws.ws_xpixel);
170-
env->SetIntField(data, ws_ypixel, ws.ws_ypixel);
167+
env->SetShortField(data, ws_row, ws.ws_row);
168+
env->SetShortField(data, ws_col, ws.ws_col);
169+
env->SetShortField(data, ws_xpixel, ws.ws_xpixel);
170+
env->SetShortField(data, ws_ypixel, ws.ws_ypixel);
171171
}
172172

173173
/*

0 commit comments

Comments
 (0)