Skip to content

Commit

Permalink
8328703: Illegal accesses in Java_jdk_internal_org_jline_terminal_imp…
Browse files Browse the repository at this point in the history
…l_jna_linux_CLibraryImpl_ioctl0

Reviewed-by: asotona, shade
  • Loading branch information
lahodaj committed Apr 25, 2024
1 parent ef745a6 commit 87e864b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/jdk.internal.le/linux/native/lible/CLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
16 changes: 8 additions & 8 deletions src/jdk.internal.le/macosx/native/lible/CLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit 87e864b

Please sign in to comment.