Fix a leftover use of the old TR_AAA_SERVER structure
authorJennifer Richards <jennifer@painless-security.com>
Thu, 24 May 2018 18:01:14 +0000 (14:01 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Thu, 24 May 2018 18:01:14 +0000 (14:01 -0400)
common/tr_idp_encoders.c

index 72acd15..4b3d845 100644 (file)
 
 static char *tr_aaa_server_to_str(TALLOC_CTX *mem_ctx, TR_AAA_SERVER *aaa)
 {
-  return talloc_strndup(mem_ctx, aaa->hostname->buf, aaa->hostname->len);
+  char *aaa_hostname = tr_name_strdup( tr_aaa_server_get_hostname(aaa) );
+  char *result = NULL;
+
+  if (aaa_hostname == NULL)
+    return NULL;
+
+  result = talloc_asprintf(mem_ctx,
+                           "%s:%d",
+                           aaa_hostname,
+                           tr_aaa_server_get_port(aaa));
+  free(aaa_hostname);
+  return result;
 }
 
 
@@ -151,14 +162,9 @@ cleanup:
 
 static json_t *tr_aaa_server_to_json(TR_AAA_SERVER *aaa)
 {
-  char *hostname = tr_name_strdup(aaa->hostname);
-  char *s = NULL;
+  char *s = tr_aaa_server_to_str(NULL, aaa);
   json_t *jstr = NULL;
 
-  if (hostname == NULL)
-    return NULL;
-
-  s = talloc_asprintf(NULL, "%s:%d", hostname, TID_PORT);
   if (s) {
     jstr = json_string(s);
     talloc_free(s);