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:
commit
b0eccc9392
@ -306,19 +306,24 @@ char* x509_name_parse(char* name, char* txt, int* length)
|
|||||||
|
|
||||||
char* x509_get_default_name()
|
char* x509_get_default_name()
|
||||||
{
|
{
|
||||||
CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
|
CHAR* computerName;
|
||||||
DWORD nSize = MAX_COMPUTERNAME_LENGTH;
|
DWORD nSize = 0;
|
||||||
|
|
||||||
char* ret;
|
if (GetComputerNameExA(ComputerNamePhysicalNetBIOS, NULL, &nSize) ||
|
||||||
|
GetLastError() != ERROR_MORE_DATA)
|
||||||
if (!GetComputerNameExA(ComputerNameNetBIOS, computerName, &nSize))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret = _strdup(computerName);
|
computerName = (CHAR*)calloc(nSize, 1);
|
||||||
if (!ret)
|
if (!computerName)
|
||||||
return NULL;
|
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)
|
int command_line_pre_filter(MAKECERT_CONTEXT* context, int index, int argc, LPCSTR* argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user