* texi2mdoc: Protect recursive printindex.
@ 2015-03-13 8:13 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-03-13 8:13 UTC (permalink / raw)
To: source
Log Message:
-----------
Protect recursive printindex.
Modified Files:
--------------
texi2mdoc:
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -Lmain.c -Lmain.c -u -p -r1.69 -r1.70
--- main.c
+++ main.c
@@ -1516,12 +1516,16 @@ indexcmp(const void *p1, const void *p2)
static void
doprintindex(struct texi *p, enum texicmd cmd, size_t *pos)
{
- size_t i, j, start, end, len;
+ static size_t guard = 0;
+ size_t i, j, start, end, len;
#if HAVE_INDEX
- char *cp;
- char buf[PATH_MAX];
+ char *cp;
+ char buf[PATH_MAX];
#endif
+ if (guard++ > 8)
+ texierr(p, "recursive @printindex");
+
while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
advance(p, pos);
start = *pos;
@@ -1529,15 +1533,18 @@ doprintindex(struct texi *p, enum texicm
advance(p, pos);
if ((end = *pos) == BUFSZ(p)) {
texiwarn(p, "unexpected EOF");
+ guard--;
return;
}
advance(p, pos);
if (*pos == BUFSZ(p)) {
texiwarn(p, "unexpected EOF");
+ guard--;
return;
} else if (0 == (len = end - start)) {
texiwarn(p, "zero-length index");
+ guard--;
return;
}
@@ -1552,9 +1559,12 @@ doprintindex(struct texi *p, enum texicm
if (i == p->indexsz) {
texiwarn(p, "cannot find index");
+ guard--;
return;
- } else if (0 == p->indexs[i].indexsz)
+ } else if (0 == p->indexs[i].indexsz) {
+ guard--;
return;
+ }
/* Alphabetically sort our indices. */
qsort(p->indexs[i].index,
@@ -1601,6 +1611,7 @@ doprintindex(struct texi *p, enum texicm
p->seenvs = 0;
teximacro(p, "El");
texivspace(p);
+ guard--;
}
static void
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-13 8:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 8:13 texi2mdoc: Protect recursive printindex kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).