[MERGE][#246180] Make sure we never read more than 64k at a time from a smart medium.

John Arbash Meinel john at arbash-meinel.com
Tue Jul 22 00:19:50 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Bennetts wrote:
| Hi everyone,
|
| I believe this patch fixes
<https://bugs.launchpad.net/bzr/+bug/246180>, which
| is a regression from 1.5 and thus marked Critical.  I don't run
Windows myself
| though, so testing by Windows (and also OS X) users would be greatly
| appreciated.
|
| The core bug fix is to make sure that bzr doesn't ever try to read
more than 64k
| from a socket (or pipe) when doing smart protocol operations.
|
| The patch achieves this by doing some refactoring: the patch deletes
more lines
| than it adds, even though it adds some comments and expands some
docstrings.  In
| particular there's now a SmartMedium base class used by both the
client- and
| server-side code, and the 64k limit is enforced there.  Previously
multiple
| locations in the code were responsible for this, which is what made the
| recurrence of this bug possible.  There's now also just one place that
| implements the logic to read a line from a medium too.
|
| So, the new code is simpler, clearer, shorter, and less buggy.  Please
review :)
|
| Here's the diffstat for the curious:
|
|  smart/medium.py            |  201
++++++++++++++++++++++++---------------------
|  smart/protocol.py          |   28 ------
|  transport/http/__init__.py |    1
|  3 files changed, 113 insertions(+), 117 deletions(-)
|
| -Andrew.
|
|

BB:tweak

Overall, I like it.

I wonder if putting "64 * 1024" everywhere would be better as
_MAX_READ_BYTES = 64 * 1024

And then just referencing the constant.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiFGZYACgkQJdeBCYSNAAOulACfeAhv0Jkzh1lST4nYBJ3X8eGZ
XisAoMzI+q0FK1D6aAac5xq+a8viigZr
=EWnd
-----END PGP SIGNATURE-----



More information about the bazaar mailing list