aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
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
commitab189900401da15dee3e20b86bd32d1cdb7e37ac (patch)
tree59a9e4c754e06f9f4a4d84341be3f4312f4b1a00 /roff.c
parent0b6903db7750adfcd88f388a0196037f91e474c6 (diff)
downloadmandoc-ab189900401da15dee3e20b86bd32d1cdb7e37ac.tar.gz
mandoc-ab189900401da15dee3e20b86bd32d1cdb7e37ac.tar.zst
mandoc-ab189900401da15dee3e20b86bd32d1cdb7e37ac.zip
Bugfix in roff_setstrn():
Do not call strcmp() on an array of char that might not be NUL-terminated.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/roff.c b/roff.c
index 46ed2d7c..30e92309 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.210 2014/06/25 00:20:19 schwarze Exp $ */
+/* $Id: roff.c,v 1.211 2014/06/29 21:20:31 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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) {