Fixed #3778: Printer driver name conversion.
authorArmin Novak <armin.novak@thincast.com>
Fri, 17 Feb 2017 10:40:52 +0000 (11:40 +0100)
committerArmin Novak <armin.novak@thincast.com>
Fri, 17 Feb 2017 10:40:52 +0000 (11:40 +0100)
channels/printer/client/printer_win.c

index dc36642..552cb38 100644 (file)
@@ -186,8 +186,8 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
        rdpWinPrinter* win_printer;
        wchar_t wname[256];
        DWORD needed;
+       int status;
        PRINTER_INFO_2 *prninfo=NULL;
-       size_t charsConverted;
 
        win_printer = (rdpWinPrinter*) calloc(1, sizeof(rdpWinPrinter));
        if (!win_printer)
@@ -220,10 +220,10 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver,
        GetPrinter(win_printer->hPrinter, 2, (LPBYTE) prninfo, needed, &needed);
 
        if (drivername)
-               win_printer->printer.driver = _wcsdup(drivername);
+               status = ConvertFromUnicode(CP_UTF8, 0, drivername, -1, &win_printer->printer.driver, 0, NULL, NULL);
        else
-               win_printer->printer.driver = _wcsdup(prninfo->pDriverName);
-       if (!win_printer->printer.driver)
+               status = ConvertFromUnicode(CP_UTF8, 0, prninfo->pDriverName, -1, &win_printer->printer.driver, 0, NULL, NULL);
+       if (!win_printer->printer.driver || (status <= 0))
        {
                GlobalFree(prninfo);
                free(win_printer->printer.name);