From 239583b0ef7e37dca95a3bf9f3c16648e6aa140d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 14 Aug 2008 03:08:21 +0000 Subject: Gracefully handle illegal port paths from client for set_port_value. git-svn-id: http://svn.drobilla.net/lad/ingen@1364 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/events/SetPortValueEvent.cpp | 27 ++++++++++++++++++++------- src/libs/engine/events/SetPortValueEvent.hpp | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/libs') diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index a184bd95..4152bb7b 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -91,10 +91,14 @@ void SetPortValueEvent::pre_process() { if (_queued) { - if (_port == NULL) - _port = _engine.object_store()->find_port(_port_path); + if (_port == NULL) { + if (Path::is_valid(_port_path)) + _port = _engine.object_store()->find_port(_port_path); + else + _error = ILLEGAL_PATH; + } - if (_port == NULL) + if (_port == NULL && _error == NO_ERROR) _error = PORT_NOT_FOUND; } @@ -108,11 +112,16 @@ SetPortValueEvent::execute(ProcessContext& context) Event::execute(context); assert(_time >= context.start() && _time <= context.end()); - if (_port == NULL) - _port = _engine.object_store()->find_port(_port_path); + if (_error == NO_ERROR && _port == NULL) { + if (Path::is_valid(_port_path)) + _port = _engine.object_store()->find_port(_port_path); + else + _error = ILLEGAL_PATH; + } if (_port == NULL) { - _error = PORT_NOT_FOUND; + if (_error == NO_ERROR) + _error = PORT_NOT_FOUND; /*} else if (_port->buffer(0)->capacity() < _data_size) { _error = NO_SPACE;*/ } else { @@ -155,9 +164,13 @@ SetPortValueEvent::post_process() { if (_error == NO_ERROR) { assert(_port != NULL); - _responder->respond_ok(); _engine.broadcaster()->send_control_change(_port_path, *(float*)_data); + + } else if (_error == ILLEGAL_PATH) { + string msg = "Illegal port path \""; + msg.append(_port_path).append("\""); + _responder->respond_error(msg); } else if (_error == PORT_NOT_FOUND) { string msg = "Unable to find port "; diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp index 6f89fc20..5c952a61 100644 --- a/src/libs/engine/events/SetPortValueEvent.hpp +++ b/src/libs/engine/events/SetPortValueEvent.hpp @@ -66,7 +66,7 @@ public: void post_process(); private: - enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE }; + enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, ILLEGAL_PATH }; bool _queued; bool _omni; -- cgit v1.2.1