[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Dump parser forward compatibility problem

From: Erik Huelsmann <e.huelsmann_at_gmx.net>
Date: 2004-12-24 00:23:00 CET

From the docstring for svn_repos_parse_dumpstream2:

 * This parser has built-in knowledge of the dumpfile format, but only
 * in a general sense:
 *
 * * it recognizes revision and node records by looking for either
 * a REVISION_NUMBER or NODE_PATH headers.
 *
 * * it recognizes the CONTENT-LENGTH headers, so it knows if and
 * how to suck up the content body.
 *
 * * it knows how to parse a content body into two parts: props
 * and text, and pass the pieces to the vtable.

I think the interface promise above guarantees forward compatability where
we can add content fields without causing problems with old parsers. If such
a field were present, Content-Length > Text-content-length +
Prop-content-length. We don't read past Text-content-length +
Prop-content-length however, contrary to what the above suggests.

I think the patch below would fix that:

Index: subversion/libsvn_repos/load.c
===================================================================
--- subversion/libsvn_repos/load.c (revision 12503)
+++ subversion/libsvn_repos/load.c (working copy)
@@ -691,7 +691,36 @@
                                        buflen,
                                        found_node ? nodepool : revpool));
         }
-
+
+ /* if we have a content-length header, did we read all of it?
+ in case of an old v1, we *always* read all of it, because
+ text-content-length = content-length - prop-content-length
+ */
+ if (content_length && ! old_v1_with_cl)
+ {
+ svn_filesize_t prop_value = prop_cl ? svn__atoui64 (prop_cl) : 0;
+ svn_filesize_t text_value = text_cl ? svn__atoui64 (text_cl) : 0;
+ svn_filesize_t cl_value =
+ svn__atoui64 (content_length) - prop_value - text_value;
+ apr_size_t rlen, num_to_read;
+
+ /* Regardless of whether or not we have a sink for our data, we
+ need to read it. */
+ while (cl_value > 0)
+ {
+ if (cl_value >= buflen)
+ rlen = buflen;
+ else
+ rlen = (apr_size_t) cl_value;
+
+ num_to_read = rlen;
+ SVN_ERR (svn_stream_read (stream, buffer, &rlen));
+ cl_value -= rlen;
+ if (rlen != num_to_read)
+ return stream_ran_dry ();
+ }
+ }
+
       /* If we just finished processing a node record, we need to
          close the node record and clear the per-node subpool. */
       if (found_node)

Comments?

bye,

Erik.

-- 
Psssst! Mit GMX Handyrechnung senken: http://www.gmx.net/de/go/mail
100 FreeSMS/Monat (GMX TopMail), 50 (GMX ProMail), 10 (GMX FreeMail)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 24 00:24:04 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.