source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: joerg@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Don't crash if the date can't be extracted.
Date: Fri, 18 Nov 2011 12:04:06 -0500 (EST)	[thread overview]
Message-ID: <201111181704.pAIH46us008066@krisdoz.my.domain> (raw)

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 source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2011-11-18 17:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201111181704.pAIH46us008066@krisdoz.my.domain \
    --to=joerg@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).