VirtualBox

Changeset 93647 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 8, 2022 9:05:38 AM (3 years ago)
Author:
vboxsync
Message:

FE: bugref:9955: Added conversion from console codepage to UTF-8 in Windows during reading the password from console.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/Common/PasswordInput.cpp

    r93115 r93647  
    2323
    2424#include <iprt/ctype.h>
     25#include <iprt/err.h>
    2526#include <iprt/message.h>
    2627#include <iprt/stream.h>
     
    129130                vrc = RTStrmGetLine(g_pStdIn, &aszPwdInput[0], sizeof(aszPwdInput));
    130131                if (RT_SUCCESS(vrc))
     132                {
     133#ifdef RT_OS_WINDOWS
     134                    /*
     135                     * Returned string encoded in console code page (e.g. Win-125X or CP-XXX).
     136                     * Convert it to Utf-8
     137                     */
     138                    char *pszPassword = NULL;
     139                    vrc = RTStrConsoleCPToUtf8(&pszPassword, aszPwdInput);
     140                    if (RT_SUCCESS(vrc) && pszPassword)
     141                    {
     142                        *pPassword = pszPassword;
     143                        RTMemFree(pszPassword);
     144                    }
     145                    else
     146                        rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE,
     147                                                "Failed to convert password from windows console codepage to Utf-8 (%Rrc)",
     148                                                vrc);
     149#else
    131150                    *pPassword = aszPwdInput;
     151#endif
     152                }
    132153                else
    133154                    rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed read password from command line (%Rrc)", vrc);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette