Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8292866: Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation check M…
…ultiByteToWideChar return value for failures

Reviewed-by: mdoerr, stuefe
  • Loading branch information
MBaesken committed Sep 12, 2022
1 parent 68da02c commit 699c429
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -700,6 +700,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
STRRET strret;
OLECHAR olePath[MAX_PATH]; // wide-char version of path name
LPWSTR wstr;
int ret;

IShellFolder* pParent = (IShellFolder*)parentIShellFolder;
if (pParent == NULL) {
Expand All @@ -719,12 +720,18 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
switch (strret.uType) {
case STRRET_CSTR :
// IShellFolder::ParseDisplayName requires the path name in Unicode.
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strret.cStr, -1, olePath, MAX_PATH);
ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strret.cStr, -1, olePath, MAX_PATH);
if (ret == 0) {
return NULL;
}
wstr = olePath;
break;

case STRRET_OFFSET :
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (CHAR *)pidl + strret.uOffset, -1, olePath, MAX_PATH);
ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (CHAR *)pidl + strret.uOffset, -1, olePath, MAX_PATH);
if (ret == 0) {
return NULL;
}
wstr = olePath;
break;

Expand Down

5 comments on commit 699c429

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 699c429 Sep 28, 2022

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch MBaesken-backport-699c4296 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 699c4296 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 12 Sep 2022 and was reviewed by Martin Doerr and Thomas Stuefe.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-699c4296:MBaesken-backport-699c4296
$ git checkout MBaesken-backport-699c4296
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-699c4296

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 699c429 Nov 4, 2022

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch MBaesken-backport-699c4296 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 699c4296 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 12 Sep 2022 and was reviewed by Martin Doerr and Thomas Stuefe.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev MBaesken-backport-699c4296:MBaesken-backport-699c4296
$ git checkout MBaesken-backport-699c4296
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev MBaesken-backport-699c4296

Please sign in to comment.