aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-01 16:00:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-01 16:00:58 +0000
commitebe40a4ec213f98f25c04877cf2d50a32681248c (patch)
tree04288c073002a9993033f968fbb64a930255a6b8
parentca6f84339d4e4202a4cf23994fb07b21eefbbe5b (diff)
downloadmandoc-ebe40a4ec213f98f25c04877cf2d50a32681248c.tar.gz
mandoc-ebe40a4ec213f98f25c04877cf2d50a32681248c.tar.zst
mandoc-ebe40a4ec213f98f25c04877cf2d50a32681248c.zip
Fix an off-by-one string read access that could happen if an empty
string argument preceded a string argument beginning with "--". Found by Leah Neukirchen <leah at vuxu dot org> with -Wpointer-compare.
-rw-r--r--mdoc_validate.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index f4381800..b36d3c0a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.359 2018/08/01 13:46:15 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.360 2018/08/01 16:00:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -437,14 +437,13 @@ check_text_em(struct roff_man *mdoc, int ln, int pos, char *p)
isalpha((unsigned char)cp[-3]) :
np != NULL &&
np->type == ROFFT_TEXT &&
- np->string != '\0' &&
+ *np->string != '\0' &&
isalpha((unsigned char)np->string[
strlen(np->string) - 1])) ||
(cp[1] != '\0' && cp[2] != '\0' ?
isalpha((unsigned char)cp[2]) :
nn != NULL &&
nn->type == ROFFT_TEXT &&
- nn->string != '\0' &&
isalpha((unsigned char)*nn->string))) {
mandoc_msg(MANDOCERR_DASHDASH, mdoc->parse,
ln, pos + (int)(cp - p) - 1, NULL);