summaryrefslogtreecommitdiff
path: root/xml.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-04-10 20:08:02 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-04-10 20:08:02 +0200
commit4a7f419877607b735b26c56dacd566023c3d7da7 (patch)
tree8e19fb51ce110cbb965d7fc8d06edbbba33c8cd3 /xml.c
parent1226cf84fdae3396499c5e1efc742391e537103a (diff)
xml: stricter check of entity: must end with ';', ...
... zero output buffer if codepoint length is 0
Diffstat (limited to 'xml.c')
-rw-r--r--xml.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/xml.c b/xml.c
index 5c23a6b..178b8ed 100644
--- a/xml.c
+++ b/xml.c
@@ -280,10 +280,9 @@ xml_numericentitytostr(const char *e, char *buf, size_t bufsiz)
else
l = strtoul(e, &end, 10);
/* invalid value or not a well-formed entity */
- if (errno != 0 || (*end != '\0' && *end != ';'))
- return 0;
- if (!(len = xml_codepointtoutf8(l, &cp)))
+ if (errno || *end != ';')
return 0;
+ len = xml_codepointtoutf8(l, &cp);
/* make string */
for (b = 0; b < len; b++)
buf[b] = (cp >> (8 * (len - 1 - b))) & 0xff;