From cc64f006bae2e1c1378f5d14063a116e6ef4aaaf Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 16 Feb 2015 14:11:41 +0000 Subject: Clamp width and indent settings to sensible values. Ignore errors for now. Patch from tedu@. --- term_ascii.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/term_ascii.c b/term_ascii.c index df191103..4ce4b686 100644 --- a/term_ascii.c +++ b/term_ascii.c @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.42 2014/12/31 16:52:40 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.43 2015/02/16 14:11:41 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -63,6 +63,8 @@ ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts) const char *toks[5]; char *v; struct termp *p; + const char *errstr; + int num; p = mandoc_calloc(1, sizeof(struct termp)); @@ -109,10 +111,14 @@ ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts) while (outopts && *outopts) switch (getsubopt(&outopts, UNCONST(toks), &v)) { case 0: - p->defindent = (size_t)atoi(v); + num = strtonum(v, 0, 1000, &errstr); + if (!errstr) + p->defindent = num; break; case 1: - p->defrmargin = (size_t)atoi(v); + num = strtonum(v, 0, 1000, &errstr); + if (!errstr) + p->defrmargin = num; break; case 2: /* -- cgit v1.2.3-56-ge451