summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-06-29 21:20:31 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-06-29 21:20:31 +0000
commit28fb10f422f4625c8f96902291781134ce7480f6 (patch)
tree11ddea8daeef82d4ccf8ceebfba6339ac000d85a
parent4d3ce3168697232f8d3fae53c2c45bd3aae0f64f (diff)
downloadmandoc-28fb10f422f4625c8f96902291781134ce7480f6.tar.gz
Bugfix in roff_setstrn():
Do not call strcmp() on an array of char that might not be NUL-terminated.
-rw-r--r--roff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/roff.c b/roff.c
index e29df8fd..48eaf047 100644
--- a/roff.c
+++ b/roff.c
@@ -2068,7 +2068,8 @@ roff_setstrn(struct roffkv **r, const char *name, size_t namesz,
/* Search for an existing string with the same name. */
n = *r;
- while (n && strcmp(name, n->key.p))
+ while (n && (namesz != n->key.sz ||
+ strncmp(n->key.p, name, namesz)))
n = n->next;
if (NULL == n) {