[PATCH 2 of 3] chgserver: check type passed to S channel
Jun Wu
quark at fb.com
Fri Jan 6 11:17:57 EST 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1483719145 0
# Fri Jan 06 16:12:25 2017 +0000
# Node ID 703fee4099efac592f6ae1c48bfebf806dfd95bf
# Parent 530b32a20c085fd9819bad3235ffbca5f98095ea
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 703fee4099ef
chgserver: check type passed to S channel
It currently only supports the "system" type. Add an explicit check.
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -313,10 +313,13 @@ class channeledsystem(object):
self.out.flush()
- length = self.in_.read(4)
- length, = struct.unpack('>I', length)
- if length != 4:
- raise error.Abort(_('invalid response'))
- rc, = struct.unpack('>i', self.in_.read(4))
- return rc
+ if type == 'system':
+ length = self.in_.read(4)
+ length, = struct.unpack('>I', length)
+ if length != 4:
+ raise error.Abort(_('invalid response'))
+ rc, = struct.unpack('>i', self.in_.read(4))
+ return rc
+ else:
+ raise error.ProgrammingError('invalid S channel type: %s' % type)
_iochannels = [
More information about the Mercurial-devel
mailing list