Merge pull request #2786 from mfleisz/fix_makecert

winpr/tools: Fixed x509_get_default_name failing with long computer names
This commit is contained in:
MartinHaimberger 2015-07-15 14:10:44 +02:00
commit b0eccc9392
1 changed files with 13 additions and 8 deletions

View File

@ -306,19 +306,24 @@ char* x509_name_parse(char* name, char* txt, int* length)
char* x509_get_default_name()
{
CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD nSize = MAX_COMPUTERNAME_LENGTH;
CHAR* computerName;
DWORD nSize = 0;
char* ret;
if (!GetComputerNameExA(ComputerNameNetBIOS, computerName, &nSize))
if (GetComputerNameExA(ComputerNamePhysicalNetBIOS, NULL, &nSize) ||
GetLastError() != ERROR_MORE_DATA)
return NULL;
ret = _strdup(computerName);
if (!ret)
computerName = (CHAR*)calloc(nSize, 1);
if (!computerName)
return NULL;
return ret;
if (!GetComputerNameExA(ComputerNamePhysicalNetBIOS, computerName, &nSize))
{
free(computerName);
return NULL;
}
return computerName;
}
int command_line_pre_filter(MAKECERT_CONTEXT* context, int index, int argc, LPCSTR* argv)