You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Hideki IWAMOTO <hi...@gaia.eonet.ne.jp> on 2012/12/31 20:07:56 UTC
[PATCH] "svn diff -x -w" gets error or outputs incorrect diff
Hi.
I found a bug in token_compare() defined in
subversion/libsvn_diff/diff_file.c.
When reading token from file, offset of the normalized token
and the length before normalization are used.
This causes reading exceeding the file size or comparison beyond the end-of-line.
The attached patch fix this.
How to reproduce
----------------
$ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp1
$ printf ' @@@\n' | dd of=cmp1 bs=8 seek=16383 conv=notrunc
$ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp2
$ printf ' @@@\n' | dd of=cmp2 bs=8 seek=16383 conv=notrunc
$ hexdump -C cmp1
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
*
0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 40 40 40 0a |........ @@@.|
00020000
$ hexdump -C cmp2
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
*
0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 20 40 40 40 |........ @@@|
00020000 0a |.|
00020001
$ svn di -x -b --old=cmp1 --new=cmp2
$ svn di -x -w --old=cmp1 --new=cmp2
subversion/svn/diff-cmd.c:383: (apr_err=70014)
subversion/libsvn_client/diff.c:2994: (apr_err=70014)
subversion/libsvn_client/diff.c:2086: (apr_err=70014)
subversion/libsvn_client/diff.c:2031: (apr_err=70014)
subversion/libsvn_client/diff.c:1717: (apr_err=70014)
subversion/libsvn_client/diff.c:958: (apr_err=70014)
subversion/libsvn_client/diff.c:853: (apr_err=70014)
subversion/libsvn_diff/diff_file.c:1267: (apr_err=70014)
subversion/libsvn_diff/diff.c:169: (apr_err=70014)
subversion/libsvn_diff/token.c:179: (apr_err=70014)
subversion/libsvn_diff/token.c:105: (apr_err=70014)
subversion/libsvn_diff/diff_file.c:1065: (apr_err=70014)
subversion/libsvn_subr/io.c:3222: (apr_err=70014)
svn: E070014: Can't read file '/tmp/cmp2': End of file found
$ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp3
$ printf ' @@@\naaaaaaa\n' | dd of=cmp3 bs=8 seek=16383 conv=notrunc
$ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp4
$ printf ' @@@\nbbbbbbb\n' | dd of=cmp4 bs=8 seek=16383 conv=notrunc
$ hexdump -C cmp3
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
*
0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 40 40 40 0a |........ @@@.|
00020000 61 61 61 61 61 61 61 0a |aaaaaaa.|
00020008
$ hexdump -C cmp4
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
*
0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 20 40 40 40 |........ @@@|
00020000 0a 62 62 62 62 62 62 62 0a |.bbbbbbb.|
00020009
$ svn di -x -b --old=cmp3 --new=cmp4
Index: cmp4
===================================================================
--- cmp4 (.../cmp3) (working copy)
+++ cmp4 (.../cmp4) (working copy)
@@ -131063,4 +131063,4 @@
@@@
-aaaaaaa
+bbbbbbb
$ svn di -x -w --old=cmp3 --new=cmp4
Index: cmp4
===================================================================
--- cmp4 (.../cmp3) (working copy)
+++ cmp4 (.../cmp4) (working copy)
@@ -131062,5 +131062,5 @@
- @@@
-aaaaaaa
+ @@@
+bbbbbbb
--
Hideki IWAMOTO <hi...@gaia.eonet.ne.jp>
RE: [PATCH] "svn diff -x -w" gets error or outputs incorrect diff
Posted by Gavin Baumanis <ga...@thespidernet.com>.
Hi Hideki,
Thanks very much for the update.
I will remove the thread from my watch list.
> -----Original Message-----
> From: Hideki IWAMOTO [mailto:hideki.iwamoto@gaia.eonet.ne.jp]
> Sent: Thursday, 7 March 2013 17:17
> To: Gavin Baumanis
> Cc: dev@subversion.apache.org
> Subject: Re: [PATCH] "svn diff -x -w" gets error or outputs incorrect diff
>
> Hi.
>
> > With the considerable time that has passed - could I please ask you to
> > check that it still applies cleanly to trunk and resubmit it?
>
> This fix was already committed in r1427278.
>
> http://mail-archives.apache.org/mod_mbox/subversion-
> commits/201301.mbox/%3c20130101020336.5FC7123888CD@eris.apache.o
> rg%3e
>
> On Thu, 7 Mar 2013 09:58:25 -0500
> "Gavin Baumanis" <ga...@thespidernet.com> wrote:
>
> > HI Hideki,
> > Sorry about the delay in getting to your patch submission, I'm not too
> > sure how managed to miss it.
> >
> > With the considerable time that has passed - could I please ask you to
> > check that it still applies cleanly to trunk and resubmit it?
> >
> > Gavin.
> >
>
> --
> Hideki IWAMOTO <hi...@gaia.eonet.ne.jp>
Re: [PATCH] "svn diff -x -w" gets error or outputs incorrect diff
Posted by Hideki IWAMOTO <hi...@gaia.eonet.ne.jp>.
Hi.
> With the considerable time that has passed - could I please ask you to check
> that it still applies cleanly to trunk and resubmit it?
This fix was already committed in r1427278.
http://mail-archives.apache.org/mod_mbox/subversion-commits/201301.mbox/%3c20130101020336.5FC7123888CD@eris.apache.org%3e
On Thu, 7 Mar 2013 09:58:25 -0500
"Gavin Baumanis" <ga...@thespidernet.com> wrote:
> HI Hideki,
> Sorry about the delay in getting to your patch submission, I'm not too sure
> how managed to miss it.
>
> With the considerable time that has passed - could I please ask you to check
> that it still applies cleanly to trunk and resubmit it?
>
> Gavin.
>
--
Hideki IWAMOTO <hi...@gaia.eonet.ne.jp>
RE: [PATCH] "svn diff -x -w" gets error or outputs incorrect diff
Posted by Gavin Baumanis <ga...@thespidernet.com>.
HI Hideki,
Sorry about the delay in getting to your patch submission, I'm not too sure
how managed to miss it.
With the considerable time that has passed - could I please ask you to check
that it still applies cleanly to trunk and resubmit it?
Gavin.
> -----Original Message-----
> From: Hideki IWAMOTO [mailto:hideki.iwamoto@gaia.eonet.ne.jp]
> Sent: Monday, 31 December 2012 14:08
> To: dev@subversion.apache.org
> Subject: [PATCH] "svn diff -x -w" gets error or outputs incorrect diff
>
> Hi.
>
> I found a bug in token_compare() defined in
subversion/libsvn_diff/diff_file.c.
> When reading token from file, offset of the normalized token and the
length
> before normalization are used.
> This causes reading exceeding the file size or comparison beyond the
end-of-
> line.
> The attached patch fix this.
>
> How to reproduce
> ----------------
> $ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp1
> $ printf ' @@@\n' | dd of=cmp1 bs=8 seek=16383 conv=notrunc
> $ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp2
> $ printf ' @@@\n' | dd of=cmp2 bs=8 seek=16383 conv=notrunc
> $ hexdump -C cmp1
> 00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a
|................|
> *
> 0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 40 40 40 0a |........
@@@.|
> 00020000
> $ hexdump -C cmp2
> 00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a
|................|
> *
> 0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 20 40 40 40 |........
@@@|
> 00020000 0a |.|
> 00020001
> $ svn di -x -b --old=cmp1 --new=cmp2
> $ svn di -x -w --old=cmp1 --new=cmp2
> subversion/svn/diff-cmd.c:383: (apr_err=70014)
> subversion/libsvn_client/diff.c:2994: (apr_err=70014)
> subversion/libsvn_client/diff.c:2086: (apr_err=70014)
> subversion/libsvn_client/diff.c:2031: (apr_err=70014)
> subversion/libsvn_client/diff.c:1717: (apr_err=70014)
> subversion/libsvn_client/diff.c:958: (apr_err=70014)
> subversion/libsvn_client/diff.c:853: (apr_err=70014)
> subversion/libsvn_diff/diff_file.c:1267: (apr_err=70014)
> subversion/libsvn_diff/diff.c:169: (apr_err=70014)
> subversion/libsvn_diff/token.c:179: (apr_err=70014)
> subversion/libsvn_diff/token.c:105: (apr_err=70014)
> subversion/libsvn_diff/diff_file.c:1065: (apr_err=70014)
> subversion/libsvn_subr/io.c:3222: (apr_err=70014)
> svn: E070014: Can't read file '/tmp/cmp2': End of file found
>
> $ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp3
> $ printf ' @@@\naaaaaaa\n' | dd of=cmp3 bs=8 seek=16383 conv=notrunc
> $ dd if=/dev/zero bs=1k count=128 | tr '\0' '\n' > cmp4
> $ printf ' @@@\nbbbbbbb\n' | dd of=cmp4 bs=8 seek=16383
> conv=notrunc
> $ hexdump -C cmp3
> 00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a
|................|
> *
> 0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 40 40 40 0a |........
@@@.|
> 00020000 61 61 61 61 61 61 61 0a |aaaaaaa.|
> 00020008
> $ hexdump -C cmp4
> 00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a
|................|
> *
> 0001fff0 0a 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 20 40 40 40 |........
@@@|
> 00020000 0a 62 62 62 62 62 62 62 0a |.bbbbbbb.|
> 00020009
> $ svn di -x -b --old=cmp3 --new=cmp4
> Index: cmp4
> ============================================================
> =======
> --- cmp4 (.../cmp3) (working copy)
> +++ cmp4 (.../cmp4) (working copy)
> @@ -131063,4 +131063,4 @@
>
>
> @@@
> -aaaaaaa
> +bbbbbbb
> $ svn di -x -w --old=cmp3 --new=cmp4
> Index: cmp4
> ============================================================
> =======
> --- cmp4 (.../cmp3) (working copy)
> +++ cmp4 (.../cmp4) (working copy)
> @@ -131062,5 +131062,5 @@
>
>
>
> - @@@
> -aaaaaaa
> + @@@
> +bbbbbbb
>
> --
> Hideki IWAMOTO <hi...@gaia.eonet.ne.jp>