* NetBSD PR bin/48438: mandoc(1) fails to handle nested double quote correctly.
@ 2013-12-10 9:26 Thomas Klausner
2013-12-10 15:09 ` Anthony J. Bentley
2013-12-16 0:23 ` Ingo Schwarze
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Klausner @ 2013-12-10 9:26 UTC (permalink / raw)
To: discuss
FYI: A bug report filed against the mandoc in NetBSD.
Thomas
----- Forwarded message from tsugutomo.enami@jp.sony.com -----
Date: Tue, 10 Dec 2013 08:45:00 +0000 (UTC)
From: tsugutomo.enami@jp.sony.com
To: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: bin/48438: mandoc(1) fails to handle nested double quote correctly.
>Number: 48438
>Category: bin
>Synopsis: mandoc(1) fails to handle nested double quote correctly.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Dec 10 08:45:00 +0000 2013
>Originator: enami tsugutomo
>Release: NetBSD 6.1_STABLE
>Organization:
>Environment:
System: NetBSD sigtrap.sm.sony.co.jp 6.1_STABLE NetBSD 6.1_STABLE (GENERIC) #44: Mon Oct 21 17:13:31 JST 2013 enami@sigtrap.sm.sony.co.jp:/home/enami/src/netbsd-6/obj.amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
mandoc(1) fails to handle nested double quote correctly.
>How-To-Repeat:
% cd /usr/src
% for c in 'nroff -mandoc' mandoc; do $c usr.bin/jot/jot.1; done | grep grep
grep `jot -s "" -b . 80`
grep `jot -s """" -b . 80`
%
The former is correct output by nroff -mandoc and the latter is incorrect
output by mandoc command.
>Fix:
Skip double qoute inside double quote like mandoc_getarg() does.
Index: dist/mdoc_argv.c
===================================================================
RCS file: /cvsroot/src/external/bsd/mdocml/dist/mdoc_argv.c,v
retrieving revision 1.4
diff -u -r1.4 mdoc_argv.c
--- dist/mdoc_argv.c 3 Apr 2013 14:50:26 -0000 1.4
+++ dist/mdoc_argv.c 10 Dec 2013 08:39:42 -0000
@@ -550,6 +550,7 @@
*/
if (MDOC_PHRASELIT & m->flags || '\"' == buf[*pos]) {
+ int pairs = 0;
if ( ! (MDOC_PHRASELIT & m->flags))
*v = &buf[++(*pos)];
@@ -557,11 +558,14 @@
m->flags |= MDOC_PHRASELIT;
for ( ; buf[*pos]; (*pos)++) {
+ if (pairs)
+ buf[*pos - pairs] = buf[*pos];
if ('\"' != buf[*pos])
continue;
if ('\"' != buf[*pos + 1])
break;
(*pos)++;
+ pairs++;
}
if ('\0' == buf[*pos]) {
@@ -572,7 +576,7 @@
}
m->flags &= ~MDOC_PHRASELIT;
- buf[(*pos)++] = '\0';
+ buf[(*pos)++ - pairs] = '\0';
if ('\0' == buf[*pos])
return(ARGS_QWORD);
----- End forwarded message -----
--
To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: NetBSD PR bin/48438: mandoc(1) fails to handle nested double quote correctly.
2013-12-10 9:26 NetBSD PR bin/48438: mandoc(1) fails to handle nested double quote correctly Thomas Klausner
@ 2013-12-10 15:09 ` Anthony J. Bentley
2013-12-16 0:23 ` Ingo Schwarze
1 sibling, 0 replies; 3+ messages in thread
From: Anthony J. Bentley @ 2013-12-10 15:09 UTC (permalink / raw)
To: discuss
On Tue, Dec 10, 2013 at 2:26 AM, Thomas Klausner <wiz@netbsd.org> wrote:
> ----- Forwarded message from tsugutomo.enami@jp.sony.com -----
> % cd /usr/src
> % for c in 'nroff -mandoc' mandoc; do $c usr.bin/jot/jot.1; done | grep grep
> grep `jot -s "" -b . 80`
> grep `jot -s """" -b . 80`
This doesn't happen on OpenBSD's jot.1, but that's because the man
page is slightly different, not because the bug is fixed:
-.Dl "grep \`jot \-s """" \-b . 80\`"
+.Dl $ grep `jot \-s \&"\&" \-b . 80`
--
Anthony J. Bentley
--
To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: NetBSD PR bin/48438: mandoc(1) fails to handle nested double quote correctly.
2013-12-10 9:26 NetBSD PR bin/48438: mandoc(1) fails to handle nested double quote correctly Thomas Klausner
2013-12-10 15:09 ` Anthony J. Bentley
@ 2013-12-16 0:23 ` Ingo Schwarze
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Schwarze @ 2013-12-16 0:23 UTC (permalink / raw)
To: discuss; +Cc: Thomas Klausner
Hi Thomas,
Thomas Klausner wrote on Tue, Dec 10, 2013 at 10:26:43AM +0100:
> FYI: A bug report filed against the mandoc in NetBSD.
> Thomas
I just fixed this in OpenBSD and bsd.lv, with minimal tweaking to make
sure the quoted literal is always NUL-terminated.
Many thanks to Enami-san for the excellent patch elegantly solving
a long-standing problem and to wiz@ for forwarding it here!
Yours,
Ingo
> ----- Forwarded message from tsugutomo.enami@jp.sony.com -----
>
> Date: Tue, 10 Dec 2013 08:45:00 +0000 (UTC)
> From: tsugutomo.enami@jp.sony.com
> To: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> Cc:
> Subject: bin/48438: mandoc(1) fails to handle nested double quote correctly.
>
> >Number: 48438
> >Category: bin
> >Synopsis: mandoc(1) fails to handle nested double quote correctly.
> >Confidential: no
> >Severity: non-critical
> >Priority: medium
> >Responsible: bin-bug-people
> >State: open
> >Class: sw-bug
> >Submitter-Id: net
> >Arrival-Date: Tue Dec 10 08:45:00 +0000 2013
> >Originator: enami tsugutomo
> >Release: NetBSD 6.1_STABLE
> >Organization:
> >Environment:
> System: NetBSD sigtrap.sm.sony.co.jp 6.1_STABLE NetBSD 6.1_STABLE (GENERIC) #44: Mon Oct 21 17:13:31 JST 2013 enami@sigtrap.sm.sony.co.jp:/home/enami/src/netbsd-6/obj.amd64/sys/arch/amd64/compile/GENERIC amd64
> Architecture: x86_64
> Machine: amd64
> >Description:
> mandoc(1) fails to handle nested double quote correctly.
>
> >How-To-Repeat:
>
> % cd /usr/src
> % for c in 'nroff -mandoc' mandoc; do $c usr.bin/jot/jot.1; done | grep grep
> grep `jot -s "" -b . 80`
> grep `jot -s """" -b . 80`
> %
>
> The former is correct output by nroff -mandoc and the latter is incorrect
> output by mandoc command.
>
> >Fix:
>
> Skip double qoute inside double quote like mandoc_getarg() does.
>
> Index: dist/mdoc_argv.c
> ===================================================================
> RCS file: /cvsroot/src/external/bsd/mdocml/dist/mdoc_argv.c,v
> retrieving revision 1.4
> diff -u -r1.4 mdoc_argv.c
> --- dist/mdoc_argv.c 3 Apr 2013 14:50:26 -0000 1.4
> +++ dist/mdoc_argv.c 10 Dec 2013 08:39:42 -0000
> @@ -550,6 +550,7 @@
> */
>
> if (MDOC_PHRASELIT & m->flags || '\"' == buf[*pos]) {
> + int pairs = 0;
> if ( ! (MDOC_PHRASELIT & m->flags))
> *v = &buf[++(*pos)];
>
> @@ -557,11 +558,14 @@
> m->flags |= MDOC_PHRASELIT;
>
> for ( ; buf[*pos]; (*pos)++) {
> + if (pairs)
> + buf[*pos - pairs] = buf[*pos];
> if ('\"' != buf[*pos])
> continue;
> if ('\"' != buf[*pos + 1])
> break;
> (*pos)++;
> + pairs++;
> }
>
> if ('\0' == buf[*pos]) {
> @@ -572,7 +576,7 @@
> }
>
> m->flags &= ~MDOC_PHRASELIT;
> - buf[(*pos)++] = '\0';
> + buf[(*pos)++ - pairs] = '\0';
>
> if ('\0' == buf[*pos])
> return(ARGS_QWORD);
--
To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-16 0:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 9:26 NetBSD PR bin/48438: mandoc(1) fails to handle nested double quote correctly Thomas Klausner
2013-12-10 15:09 ` Anthony J. Bentley
2013-12-16 0:23 ` Ingo Schwarze
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).