[PATCH 3 of 3] changegroup: don't accept odd chunk headers

Mads Kiilerich mads at kiilerich.com
Tue Feb 22 07:47:46 CST 2011


On 02/22/2011 02:29 PM, Jim Hague wrote:
> Hi,
>
> (Apologies if I'm the 1000th email on this)
>
> This patch breaks pulling and pushing for me, at least from a same-filesystem
> repo.
>
> jim at eccles:~/src/test-downstream$ hg push
> pushing to /home/jim/src/test
> searching for changes
> adding changesets
> transaction abort!
> rollback completed
> ** unknown exception encountered, please report by visiting
> **  http://mercurial.selenic.com/wiki/BugTracker
> ** Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5]
> ** Mercurial Distributed SCM (version 1.7.5+116-9f2c407caf34)
> ** Extensions loaded: bugzilla, fetch, mq, rebase, transplant
> Traceback (most recent call last):
>    File "/home/jim/src/hg-main/hg", line 38, in<module>
>      mercurial.dispatch.run()
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 16, in run
>      sys.exit(dispatch(sys.argv[1:]))
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 36, in dispatch
>      return _runcatch(u, args)
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 58, in _runcatch
>      return _dispatch(ui, args)
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 601, in _dispatch
>      cmdpats, cmdoptions)
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 406, in runcommand
>      ret = _runcommand(ui, options, cmd, d)
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 655, in _runcommand
>      return checkargs()
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 609, in checkargs
>      return cmdfunc()
>    File "/home/jim/src/hg-main/mercurial/dispatch.py", line 598, in<lambda>
>      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
>    File "/home/jim/src/hg-main/mercurial/util.py", line 433, in check
>      return func(*args, **kwargs)
>    File "/home/jim/src/hg-main/mercurial/extensions.py", line 133, in wrap
>      util.checksignature(origfn), *args, **kwargs)
>    File "/home/jim/src/hg-main/mercurial/util.py", line 433, in check
>      return func(*args, **kwargs)
>    File "/home/jim/src/hg-main/hgext/mq.py", line 3038, in mqcommand
>      return orig(ui, repo, *args, **kwargs)
>    File "/home/jim/src/hg-main/mercurial/util.py", line 433, in check
>      return func(*args, **kwargs)
>    File "/home/jim/src/hg-main/mercurial/commands.py", line 3011, in push
>      newbranch=opts.get('new_branch'))
>    File "/home/jim/src/hg-main/mercurial/localrepo.py", line 1418, in push
>      lock=lock)
>    File "/home/jim/src/hg-main/mercurial/localrepo.py", line 1812, in
> addchangegroup
>      if (cl.addgroup(source, csmap, trp) is None
>    File "/home/jim/src/hg-main/mercurial/revlog.py", line 1122, in addgroup
>      chunkdata = bundle.parsechunk()
>    File "/home/jim/src/hg-main/mercurial/changegroup.py", line 170, in
> parsechunk
>      l = self.chunklength()
>    File "/home/jim/src/hg-main/mercurial/changegroup.py", line 154, in
> chunklength
>      d = readexactly(stream, 4)
> NameError: global name 'stream' is not defined
>
> Fixing what I guess is a typo cures it.
>
> diff -r 9f2c407caf34 mercurial/changegroup.py
> --- a/mercurial/changegroup.py  Tue Feb 22 03:10:37 2011 +0100
> +++ b/mercurial/changegroup.py  Tue Feb 22 13:27:19 2011 +0000
> @@ -151,7 +151,7 @@
>           return self._stream.close()
>
>       def chunklength(self):
> -        d = readexactly(stream, 4)
> +        d = readexactly(self._stream, 4)
>           l = struct.unpack(">l", d)[0]
>           if l<= 4:
>               if l:

Right, thanks, sorry. I must have missed a qref before bombing :-(

Matt, please unqueue the 3rd patch - or fold it with this fix.

/Mads


More information about the Mercurial-devel mailing list