source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Fix possible segfaults in `Lk' -T[x]html handler, which made
Date: Mon, 4 Apr 2011 11:45:12 -0400 (EDT)	[thread overview]
Message-ID: <201104041545.p34FjCnH014685@krisdoz.my.domain> (raw)

Log Message:
-----------
Fix possible segfaults in `Lk' -T[x]html handler, which made some
assumptions about its children.  Also remove superfluous reassignment to
local variable.

Modified Files:
--------------
    mdocml:
        Makefile
        mdoc_html.c

Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.157 -r1.158
--- mdoc_html.c
+++ mdoc_html.c
@@ -1603,20 +1603,22 @@ mdoc_sp_pre(MDOC_ARGS)
 static int
 mdoc_lk_pre(MDOC_ARGS)
 {
-	const struct mdoc_node	*nn;
-	struct htmlpair		 tag[2];
+	struct htmlpair	 tag[2];
 
-	nn = n->child;
+	if (NULL == (n = n->child))
+		return(0);
+
+	assert(MDOC_TEXT == n->type);
 
 	PAIR_CLASS_INIT(&tag[0], "link-ext");
-	PAIR_HREF_INIT(&tag[1], nn->string);
-	print_otag(h, TAG_A, 2, tag);
+	PAIR_HREF_INIT(&tag[1], n->string);
 
-	if (NULL == nn || NULL == nn->next) 
-		return(1);
+	print_otag(h, TAG_A, 2, tag);
 
-	for (nn = nn->next; nn; nn = nn->next) 
-		print_text(h, nn->string);
+	for (n = n->next; n; n = n->next) {
+		assert(MDOC_TEXT == n->type);
+		print_text(h, n->string);
+	}
 
 	return(0);
 }
Index: Makefile
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v
retrieving revision 1.327
retrieving revision 1.328
diff -LMakefile -LMakefile -u -p -r1.327 -r1.328
--- Makefile
+++ Makefile
@@ -317,7 +317,7 @@ mandoc: $(MANDOC_OBJS) libmandoc.a
 
 # You'll need -ldb for Linux.
 mandoc-db: $(MANDOCDB_OBJS) libmandoc.a
-	$(CC) -o $@ $(MANDOCDB_OBJS) libmandoc.a
+	$(CC) -o $@ $(MANDOCDB_OBJS) libmandoc.a -ldb
 
 llib-lmandoc.ln: $(MANDOC_LNS)
 	$(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS)
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2011-04-04 15:45 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=201104041545.p34FjCnH014685@krisdoz.my.domain \
    --to=kristaps@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).