winpr-comm: fixed QueryCommDevice() when used with some wide characters

This commit is contained in:
Emmanuel Ledoux 2014-07-04 12:24:41 +02:00 committed by Emmanuel Ledoux
parent 94dfce4f52
commit 37dc55d7c2
2 changed files with 4 additions and 4 deletions

View File

@ -970,7 +970,7 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
for (i=1; i<10; i++)
{
TCHAR genericName[5];
if (_stprintf_s(genericName, 5, "COM%d", i) < 0)
if (_stprintf_s(genericName, 5, _T("COM%d"), i) < 0)
{
return FALSE;
}
@ -983,7 +983,7 @@ static BOOL _IsReservedCommDeviceName(LPCTSTR lpName)
for (i=1; i<10; i++)
{
TCHAR genericName[5];
if (_stprintf_s(genericName, 5, "LPT%d", i) < 0)
if (_stprintf_s(genericName, 5, _T("LPT%d"), i) < 0)
{
return FALSE;
}
@ -1172,7 +1172,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax)
}
_tcscpy(lpTargetPath, storedTargetPath);
_tcscat(lpTargetPath, ""); /* 2nd final '\0' */
lpTargetPath[_tcslen(storedTargetPath) + 1] = '\0'; /* 2nd final '\0' */
return _tcslen(lpTargetPath) + 2;
}

View File

@ -53,7 +53,7 @@ static int test_CommDevice(LPCTSTR lpDeviceName, BOOL expectedResult)
tcslen = QueryCommDevice(lpDeviceName, lpTargetPath, MAX_PATH);
if (expectedResult)
{
if (tcslen <= _tcslen(lpDeviceName)) /* at least 2 more TCHAR are expected */
if (tcslen <= _tcslen(lpTargetPath)) /* at least 2 more TCHAR are expected */
{
_tprintf(_T("QueryCommDevice failure: didn't found the device name: %s\n"), lpDeviceName);
return FALSE;