From 4f917794a7ff995021a1292dbeb3920a398e0bfe Mon Sep 17 00:00:00 2001 From: Eric Windisch Date: Mon, 28 Jan 2013 12:32:34 -0500 Subject: Dict args safe processing. Improve safety of dict args in process() Change-Id: I0eae36ca6566c1b60f0a01ebee57ae8a7530fcb1 --- openstack/common/rpc/impl_zmq.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'openstack/common/rpc/impl_zmq.py') diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py index ee313eb..b759b46 100644 --- a/openstack/common/rpc/impl_zmq.py +++ b/openstack/common/rpc/impl_zmq.py @@ -321,21 +321,22 @@ class ConsumerBase(object): return [result] def process(self, style, target, proxy, ctx, data): + data.setdefault('version', None) + data.setdefault('args', {}) + # Method starting with - are # processed internally. (non-valid method name) - method = data['method'] + method = data.get('method') + if not method: + LOG.error(_("RPC message did not include method.")) + return # Internal method # uses internal context for safety. - if data['method'][0] == '-': - # For reply / process_reply - method = method[1:] - if method == 'reply': - self.private_ctx.reply(ctx, proxy, **data['args']) + if method == '-reply': + self.private_ctx.reply(ctx, proxy, **data['args']) return - data.setdefault('version', None) - data.setdefault('args', {}) proxy.dispatch(ctx, data['version'], data['method'], **data['args']) -- cgit