From c62c3c98bf0912d233d55aaab8501bf56396548b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 17 Dec 2016 12:40:23 +0100 Subject: [PATCH] uORB devices: Guard more against invalid handles fed to publish routine --- src/modules/uORB/uORBDevices.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/uORB/uORBDevices.cpp b/src/modules/uORB/uORBDevices.cpp index ed44d7a9c9..3d2943ee33 100644 --- a/src/modules/uORB/uORBDevices.cpp +++ b/src/modules/uORB/uORBDevices.cpp @@ -424,7 +424,13 @@ uORB::DeviceNode::publish(const orb_metadata *meta, orb_advert_t handle, const v uORB::DeviceNode *devnode = (uORB::DeviceNode *)handle; int ret; - /* this is a bit risky, since we are trusting the handle in order to deref it */ + /* check if the device handle is initialized */ + if ((devnode == nullptr) || (meta == nullptr)) { + errno = EFAULT; + return ERROR; + } + + /* check if the orb meta data matches the publication */ if (devnode->_meta != meta) { errno = EINVAL; return ERROR;