From eebd570d1bc574c1689f307f042bf401ff07cb80 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 23 Sep 2025 12:32:42 +0200 Subject: [PATCH] [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. --- libfreerdp/core/gateway/arm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libfreerdp/core/gateway/arm.c b/libfreerdp/core/gateway/arm.c index 86b04376d..03347495d 100644 --- a/libfreerdp/core/gateway/arm.c +++ b/libfreerdp/core/gateway/arm.c @@ -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 =