diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-02-20 13:23:36 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-02-20 13:23:36 +0000 |
commit | 88e8767791d85aa0d01715f04b7e0f311f54759e (patch) | |
tree | 224ad93bf3c8201cca3317061dd358449bc1eded /distbuild/jm.py | |
parent | 74f60a7ed286dd88e24539d46b9a86147a8e78b5 (diff) | |
parent | 4807c91632e7c9bce2d369c813b428a28ce805b7 (diff) | |
download | morph-88e8767791d85aa0d01715f04b7e0f311f54759e.tar.gz |
Merge remote-tracking branch 'lauren/baserock/lauren/distbuild-invalid-input-crash'
Reviewed-By: Richard Maw <richard.maw@codethink.co.uk>
Reviewed-By: Sam Thursfield <sam.thursfield@codethink.co.uk>
Diffstat (limited to 'distbuild/jm.py')
-rw-r--r-- | distbuild/jm.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/distbuild/jm.py b/distbuild/jm.py index 615100e4..85510924 100644 --- a/distbuild/jm.py +++ b/distbuild/jm.py @@ -1,6 +1,6 @@ # mainloop/jm.py -- state machine for JSON communication between nodes # -# Copyright (C) 2012, 2014 Codethink Limited +# Copyright (C) 2012, 2014 - 2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -109,8 +109,13 @@ class JsonMachine(StateMachine): line = line.rstrip() if self.debug_json: logging.debug('JsonMachine: line: %s' % repr(line)) - msg = yaml.load(json.loads(line)) - self.mainloop.queue_event(self, JsonNewMessage(msg)) + msg = None + try: + msg = yaml.safe_load(json.loads(line)) + except Exception: + logging.error('Invalid input: %s' % line) + if msg: + self.mainloop.queue_event(self, JsonNewMessage(msg)) def _send_eof(self, event_source, event): self.mainloop.queue_event(self, JsonEof()) |