Address various review comments.

This commit is contained in:
Sadie Powell 2021-10-05 23:35:58 +01:00
parent 9487bda9a0
commit 92ae54d415
2 changed files with 9 additions and 7 deletions

View File

@ -1829,6 +1829,8 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
stsvalue = atoi (stsvaluestr);
if (stsvalue > 0)
sts_update_expiry(serv->hostname, stsvalue, serv->stsprofile);
else
g_debug ("Malformed STS profile duration: %s", stsvaluestr);
}
} else
{
@ -1840,7 +1842,7 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
{
/* We are connecting on plain text and have found a valid STS profile. */
serv->stsprofile = sts_new ();
strcpy (serv->stsprofile->host, serv->hostname);
g_strlcpy (serv->stsprofile->host, serv->hostname, sizeof (serv->stsprofile->host));
serv->stsprofile->port = stsvalue;
/* Reconfigure with the new port and security settings. */
@ -1859,6 +1861,8 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
prefs.hex_net_reconnect_delay = stsvalue;
break;
}
else
g_debug ("Malformed STS profile port: %s", stsvaluestr);
}
}

View File

@ -67,6 +67,7 @@ sts_load (void)
if (sscanf (buf, "%s %u %ld", profile->host, &profile->port, &profile->expiry) != 3)
{
/* Malformed profile; drop it. */
g_debug ("Malformed STS profile: %s", buf);
g_free (profile);
continue;
}
@ -80,10 +81,7 @@ sts_new (void)
{
struct sts_profile *profile;
profile = malloc (sizeof (struct sts_profile));
profile->host[0] = 0;
profile->port = 0;
profile->expiry = 0;
profile = g_new0 (struct sts_profile, 1);
return profile;
}
@ -94,7 +92,7 @@ sts_parse_cap (const char* cap)
char *value;
GHashTable *table;
table = g_hash_table_new (g_str_hash, g_str_equal);
table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
entries = g_strsplit (cap, ",", 0);
for (currentry = entries; *currentry; ++currentry)
{
@ -103,7 +101,7 @@ sts_parse_cap (const char* cap)
g_hash_table_insert (table, g_strndup (*currentry, value - *currentry), g_strdup (value + 1));
}
g_free (entries);
g_strfreev (entries);
return table;
}