From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-1.sys.kth.se (smtp-1.sys.kth.se [130.237.32.175]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p3UMbdHW026769 for ; Sat, 30 Apr 2011 18:37:40 -0400 (EDT) Received: from mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 2A8D0154134; Sun, 1 May 2011 00:37:34 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-1.sys.kth.se ([130.237.32.175]) by mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) (amavisd-new, port 10024) with LMTP id ezkWahAOrfde; Sun, 1 May 2011 00:37:27 +0200 (CEST) X-KTH-Auth: kristaps [213.103.216.43] X-KTH-mail-from: kristaps@bsd.lv Received: from macky.local (s213-103-216-43.cust.tele2.se [213.103.216.43]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 70E22154133; Sun, 1 May 2011 00:37:27 +0200 (CEST) Message-ID: <4DBC8F27.3040600@bsd.lv> Date: Sun, 01 May 2011 00:37:27 +0200 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 To: tech@mdocml.bsd.lv, Jason McIntyre Subject: [PATCH] \N'nnn' protection. Content-Type: multipart/mixed; boundary="------------020505080202050709020907" This is a multi-part message in MIME format. --------------020505080202050709020907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, Enclosed is a patch to limit possible \N'nnn' escapes. \N transforms the number 'nnn' into its character representation and is marked as "for backwards compatibility" in mandoc_char(7). I can only find manuals using this for the double-quote \N'34', so this seems safe, but maybe one of you knows of crazy \N usage that would inspire me to re-think. However, throwing, e.g., the \b character in there will cause at least -Tps and -Tpdf to puke. Thoughts? Kristaps --------------020505080202050709020907 Content-Type: text/plain; name="patch.chars.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch.chars.txt" Index: chars.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v retrieving revision 1.39 diff -u -r1.39 chars.c --- chars.c 30 Apr 2011 22:24:31 -0000 1.39 +++ chars.c 30 Apr 2011 22:31:11 -0000 @@ -20,6 +20,7 @@ #endif #include +#include #include #include #include @@ -148,12 +149,10 @@ return('\0'); i = atoi(p); - /* - * FIXME: - * This is wrong. Anything could be written here! - * This should be carefully screened for possible characters. - */ - return(i <= 0 || i > 255 ? '\0' : (char)i); + if (isalnum(i) || ispunct(i) || ' ' == (char)i) + return(i); + + return('\0'); } --------------020505080202050709020907-- -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv