From ee40d29b914020c6cfb048892453378d17d0f22a Mon Sep 17 00:00:00 2001 From: Alexander Senier Date: Sat, 12 Aug 2017 19:32:06 +0200 Subject: [PATCH] base-linux: Log error message for too long files The filename buffer of a dataspace in base-linux is limited to 40 bytes. When using file names longer than this, the remainder gets dropped silently. Add an error message to aid debugging this case. --- repos/base-linux/src/core/dataspace_component.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/repos/base-linux/src/core/dataspace_component.cc b/repos/base-linux/src/core/dataspace_component.cc index 542e98057..e2f0e3a5a 100644 --- a/repos/base-linux/src/core/dataspace_component.cc +++ b/repos/base-linux/src/core/dataspace_component.cc @@ -35,6 +35,12 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) { Session_label const label = label_from_args(args); Linux_dataspace::Filename fname; + + if (label.last_element().length() > sizeof(fname.buf)) { + Genode::error("file name too long: ", label.last_element()); + throw Service_denied(); + } + strncpy(fname.buf, label.last_element().string(), sizeof(fname.buf)); /* only files inside the current working directory are allowed */