[core,arm] fix optional string redirectedUsername

json-c does return NULL from WINPR_JSON_GetObjectItemCaseSensitive if
the value is NULL, so do a check with WINPR_JSON_HasObjectItem first.
This commit is contained in:
Armin Novak
2025-09-23 12:32:42 +02:00
parent 6cfdf9e43e
commit eebd570d1b

View File

@@ -899,12 +899,17 @@ static BOOL arm_fill_gateway_parameters(rdpArm* arm, const char* message, size_t
}
}
WINPR_JSON* userNameNode = WINPR_JSON_GetObjectItemCaseSensitive(json, "redirectedUserName");
if (userNameNode)
{
const char* userName = WINPR_JSON_GetStringValue(userNameNode);
if (!freerdp_settings_set_string(settings, FreeRDP_Username, userName))
goto fail;
const char key[] = "redirectedUsername";
if (WINPR_JSON_HasObjectItem(json, key))
{
const char* userName = NULL;
WINPR_JSON* userNameNode = WINPR_JSON_GetObjectItemCaseSensitive(json, key);
if (userNameNode)
userName = WINPR_JSON_GetStringValue(userNameNode);
if (!freerdp_settings_set_string(settings, FreeRDP_Username, userName))
goto fail;
}
}
WINPR_JSON* azureMeta =