Skip to content

Commit d739c65

Browse files
committed
Fix invalid entities in listclient xml
This fixes a bug where listener Referer or User-Agent strings containing a sequence like `&T;` was not escaped properly and therefore made the whole XML document invalid. Injecting new XML nodes (<foo></foo>) was not possible, it seems in the worse case all it could cause was that the XML failed to parse. Fix #2255
1 parent 2355271 commit d739c65

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/admin.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,20 +680,20 @@ static inline xmlNodePtr __add_listener(client_t *client,
680680

681681
tmp = httpp_getvar(client->parser, "user-agent");
682682
if (tmp)
683-
xmlNewChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "UserAgent" : "useragent"), XMLSTR(tmp));
683+
xmlNewTextChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "UserAgent" : "useragent"), XMLSTR(tmp));
684684

685685
tmp = httpp_getvar(client->parser, "referer");
686686
if (tmp)
687-
xmlNewChild(node, NULL, XMLSTR("referer"), XMLSTR(tmp));
687+
xmlNewTextChild(node, NULL, XMLSTR("referer"), XMLSTR(tmp));
688688

689689
snprintf(buf, sizeof(buf), "%lu", (unsigned long)(now - client->con->con_time));
690690
xmlNewChild(node, NULL, XMLSTR(mode == OMODE_LEGACY ? "Connected" : "connected"), XMLSTR(buf));
691691

692692
if (client->username)
693-
xmlNewChild(node, NULL, XMLSTR("username"), XMLSTR(client->username));
693+
xmlNewTextChild(node, NULL, XMLSTR("username"), XMLSTR(client->username));
694694

695695
if (client->role)
696-
xmlNewChild(node, NULL, XMLSTR("role"), XMLSTR(client->role));
696+
xmlNewTextChild(node, NULL, XMLSTR("role"), XMLSTR(client->role));
697697

698698
#ifdef HAVE_OPENSSL
699699
xmlNewChild(node, NULL, XMLSTR("tls"), XMLSTR(client->con->ssl ? "true" : "false"));

0 commit comments

Comments
 (0)