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

Backport-of: 87e864bf21d71daae4e001ec4edbb4ef1f60c36d
  • Loading branch information
shipilev committed May 2, 2024
1 parent 72d3f61 commit d2e1ea4
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

1 comment on commit d2e1ea4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.