You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Karl Fogel <kf...@newton.ch.collab.net> on 2002/11/04 18:37:45 UTC

Re: svn commit: rev 3643 - trunk/subversion/include trunk/subversion/libsvn_repos

kfogel@tigris.org writes:
> Log:
> Resolve issue #966: empty input caused 'svnadmin load' to segfault.
> 
> * subversion/include/svn_error_codes.h 
>   (SVN_ERR_BAD_INPUT): New error code.
> 
> * subversion/libsvn_repos/load.c 
>   (svn_repos_parse_dumpstream): Check that the first call to
>   svn_stream_readline got some data.

I also tried to write a regression test for this, but got stumped on
the question of how to portably feed empty input to 'svnadmin load' on
stdin, in Python.  (Is creating empty file even a necessary part of
this?)  Anyone know an answer off the top of their head?  I could
probably kluge something together, after poking around on python.org,
but I have a feeling there's a standard technique for this situation.

Here's my patch-in-progress; see where it says "???".

* subversion/tests/clients/cmdline/svnadmin_tests.py
  (load_empty_file): New test, incomplete.


Index: svnadmin_tests.py
===================================================================
--- svnadmin_tests.py	(revision 3643)
+++ svnadmin_tests.py	(working copy)
@@ -332,6 +332,27 @@
                "* Dumped revision 1.\n",
                "* Dumped revision 2.\n"], errput)
 
+#----------------------------------------------------------------------
+
+def load_empty_file(sbox):
+  "test 'svnadmin load' on an empty file"
+
+  repos = os.path.join(svntest.main.temp_dir, sbox.name)
+  empty_file = os.path.join(svntest.main.temp_dir,
+                            sbox.name + ".empty-dumpfile")
+
+  svntest.main.create_repos(repos)
+  fp = open(empty_file, 'w')
+  fp.close()
+
+  output, errput = svntest.main.run_svnadmin("load", repos, "### ???")
+  for line in errput:
+    if re.match(".*empty or incomplete input data*", line):
+      return 0
+
+  # Else never matched the expected error string, so return failure.
+  return 1
+
 
 ########################################################################
 # Run the tests
@@ -345,7 +366,8 @@
               remove_txn,
               list_revs,
               dump_copied_dir,
-              dump_move_dir_modify_child
+              dump_move_dir_modify_child,
+              load_empty_file,
              ]
 
 if __name__ == '__main__':

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 3643 - trunk/subversion/include trunk/subversion/libsvn_repos

Posted by Branko Čibej <br...@xbc.nu>.
Greg Stein wrote:

>I'm not sure about the proces invocation stuff in the test suite. One of the
>things that I've wanted to get to, but just haven't. You'll need to poke
>around for it.
>  
>
Whatever we have is in svntest.main._run_command(). However, it has a
big drawback: we don't get the exit status from the child. Using the
Popen class would help here, but that's only available on Unix. Damn!

In the past, I cheated past this limitation the usual way -- using
dup&spawn instead of popen. It sucks, but it works...

-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 3643 - trunk/subversion/include trunk/subversion/libsvn_repos

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Greg Stein <gs...@lyra.org> writes:
> Yup. When you start the subprocess (via a popen varient), you get back a
> pipe that is connected to the child process' stdin. Just close the end in
> the parent. The child process sees that as EOF.
> 
> I'm not sure about the proces invocation stuff in the test suite. One of the
> things that I've wanted to get to, but just haven't. You'll need to poke
> around for it.

Thanks, that helps.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: rev 3643 - trunk/subversion/include trunk/subversion/libsvn_repos

Posted by Greg Stein <gs...@lyra.org>.
On Mon, Nov 04, 2002 at 12:37:45PM -0600, Karl Fogel wrote:
> kfogel@tigris.org writes:
> > Log:
> > Resolve issue #966: empty input caused 'svnadmin load' to segfault.
> > 
> > * subversion/include/svn_error_codes.h 
> >   (SVN_ERR_BAD_INPUT): New error code.
> > 
> > * subversion/libsvn_repos/load.c 
> >   (svn_repos_parse_dumpstream): Check that the first call to
> >   svn_stream_readline got some data.
> 
> I also tried to write a regression test for this, but got stumped on
> the question of how to portably feed empty input to 'svnadmin load' on
> stdin, in Python.  (Is creating empty file even a necessary part of
> this?)  Anyone know an answer off the top of their head?  I could

Yup. When you start the subprocess (via a popen varient), you get back a
pipe that is connected to the child process' stdin. Just close the end in
the parent. The child process sees that as EOF.

I'm not sure about the proces invocation stuff in the test suite. One of the
things that I've wanted to get to, but just haven't. You'll need to poke
around for it.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org