unescape & in PassStub (#8183)

* unescape & in PassStub

windows sometimes creates .msrcincident file with escaped ampersand as `&` in PassStub. Need to unescape or server will deny connection and complain about incorrect password.

* Update assistance.c
This commit is contained in:
garbb
2022-09-08 00:52:36 -07:00
committed by GitHub
parent 078fc50102
commit 6b62ce9200

View File

@@ -742,6 +742,7 @@ int freerdp_assistance_parse_file_buffer(rdpAssistanceFile* file, const char* bu
char* p;
char* q;
char* r;
char* amp;
int status;
size_t length;
@@ -894,6 +895,10 @@ int freerdp_assistance_parse_file_buffer(rdpAssistanceFile* file, const char* bu
if (p)
{
p += sizeof("PassStub=\"") - 1;
// needs to be unescaped (& => &)
amp = strstr(p, "&");
q = strchr(p, '"');
if (!q)
@@ -909,13 +914,31 @@ int freerdp_assistance_parse_file_buffer(rdpAssistanceFile* file, const char* bu
return -1;
}
length = q - p;
if (amp)
{
length = q - p - 4;
}
else
{
length = q - p;
}
file->PassStub = (char*)malloc(length + 1);
if (!file->PassStub)
return -1;
CopyMemory(file->PassStub, p, length);
if (amp)
{
// just skip over "amp;" leaving "&"
CopyMemory(file->PassStub, p, amp - p + 1);
CopyMemory(file->PassStub + (amp - p + 1), amp + 5, q - amp + 5);
}
else
{
CopyMemory(file->PassStub, p, length);
}
file->PassStub[length] = '\0';
}