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

Re: svn commit: rev 891 - trunk/subversion/mod_dav_svn trunk/subversion/libsvn_ra_dav

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2002-01-16 15:48:10 CET

On 15 Jan 2002, Karl Fogel wrote:
> > + /* ### the svndiff stream parser does not obey svn_stream semantics
> > + ### in its write handler. it does not output the number of bytes
> > + ### consumed by the handler. specifically, it may decrement the
> > + ### number by 4 for the header, then never touch it again. that
> > + ### makes it appear like an incomplete write.
> > + ### disable this check for now. the svndiff parser actually does
> > + ### consume all bytes, all the time.
> > + */
>
> Zounds. Glad you noticed that; I think Greg Hudson could fix it
> fastest.

Well, according to the specification, "a short write should never occur
without an associated error," so the check is unnecessary verbiage. But,
yes, svndiff's write handler is misbehaving. Here is an untested fix
(no, I won't check it in; no, I don't like the name "lenval" very much
either, but I can't think of a better one right now; yes, this is a diff
against the old CVS repository, but I don't think the code has changed
since then):

Index: svndiff.c
===================================================================
RCS file:
/usr/local/tigris/data/helm/cvs/repository/subversion/subversion/libsvn_delta/svndiff.c,v
retrieving revision 1.29
diff -u -r1.29 svndiff.c
--- svndiff.c 2001/08/27 17:26:21 1.29
+++ svndiff.c 2002/01/16 13:44:32
@@ -358,29 +358,30 @@
   struct decode_baton *db = (struct decode_baton *) baton;
   const unsigned char *p, *end;
   apr_off_t val, sview_offset;
- apr_size_t sview_len, tview_len, inslen, newlen, remaining, npos;
+ apr_size_t lenval, sview_len, tview_len, inslen, newlen, remaining, npos;
   svn_txdelta_window_t *window;
   svn_error_t *err;
   svn_txdelta_op_t *op;
   int ninst;

   /* Chew up four bytes at the beginning for the header. */
+ lenval = *len;
   if (db->header_bytes < 4)
     {
       int nheader = 4 - db->header_bytes;
- if (nheader > *len)
- nheader = *len;
+ if (nheader > lenval)
+ nheader = lenval;
       if (memcmp (buffer, "SVN\0" + db->header_bytes, nheader) != 0)
         return svn_error_create (SVN_ERR_SVNDIFF_INVALID_HEADER,
                                  0, NULL, db->pool,
                                  "svndiff has invalid header");
- *len -= nheader;
+ lenval -= nheader;
       buffer += nheader;
       db->header_bytes += nheader;
     }

   /* Concatenate the old with the new. */
- svn_stringbuf_appendbytes (db->buffer, buffer, *len);
+ svn_stringbuf_appendbytes (db->buffer, buffer, lenval);

   /* Read the header, if we have enough bytes for that. */
   p = (const unsigned char *) db->buffer->data;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:56 2006

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.