From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout.scc.kit.edu (scc-mailout.scc.kit.edu [129.13.185.202]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id pAJEV1p9005017 for ; Sat, 19 Nov 2011 09:31:02 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1RRlwa-0006WU-Rp; Sat, 19 Nov 2011 15:31:00 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1RRlwa-00028g-Q2 for tech@mdocml.bsd.lv; Sat, 19 Nov 2011 15:31:00 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1RRlwa-0004Wz-P2 for tech@mdocml.bsd.lv; Sat, 19 Nov 2011 15:31:00 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1RRlwa-0002ZX-Nw for tech@mdocml.bsd.lv; Sat, 19 Nov 2011 15:31:00 +0100 Date: Sat, 19 Nov 2011 15:31:00 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: mdocml: Don't crash if the date can't be extracted. Message-ID: <20111119143100.GD28954@iris.usta.de> References: <201111181704.pAIH46us008066@krisdoz.my.domain> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201111181704.pAIH46us008066@krisdoz.my.domain> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Joerg, i don't understand this. If there is no title, check_root (in man_validate.c) provides defaults. If there is a title, but no date, post_TH (in man_validate.c) sets the date to the empty string, and the same holds for the section. Can you provide examples triggering these NULL pointer accesses? Have a look at http://www.openbsd.org/cgi-bin/cvsweb/src/regress/usr.bin/mandoc/man/TH/ These tests all work for me without your patch. Thanks, Ingo joerg@mdocml.bsd.lv wrote on Fri, Nov 18, 2011 at 12:04:06PM -0500: > Log Message: > ----------- > Don't crash if the date can't be extracted. Don't depend on snprintf > handling NULL strings. > > Modified Files: > -------------- > mdocml: > man_term.c > > Revision Data > ------------- > Index: man_term.c > =================================================================== > RCS file: /home/joerg/cvsroot/mdocml/man_term.c,v > retrieving revision 1.123 > retrieving revision 1.124 > diff -Lman_term.c -Lman_term.c -u -p -r1.123 -r1.124 > --- man_term.c > +++ man_term.c > @@ -969,8 +969,9 @@ print_man_foot(struct termp *p, const vo > term_vspace(p); > term_vspace(p); > term_vspace(p); > - snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); > - datelen = term_strlen(p, meta->date); > + snprintf(title, BUFSIZ, "%s(%s)", meta->title ? meta->title : "", > + meta->msec ? meta->msec : ""); > + datelen = term_strlen(p, meta->date ? meta->date : ""); > > p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; > p->offset = 0; > @@ -986,7 +987,7 @@ print_man_foot(struct termp *p, const vo > if (p->offset + datelen >= p->rmargin) > p->rmargin = p->offset + datelen; > > - term_word(p, meta->date); > + term_word(p, meta->date ? meta->date : ""); > term_flushln(p); > > p->flags &= ~TERMP_NOBREAK; > @@ -1023,7 +1024,8 @@ print_man_head(struct termp *p, const vo > strlcpy(buf, m->vol, BUFSIZ); > buflen = term_strlen(p, buf); > > - snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); > + snprintf(title, BUFSIZ, "%s(%s)", m->title ? m->title : "", > + m->msec ? m->msec : ""); > titlen = term_strlen(p, title); > > p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv