From 843706190212a4491b2849e07485d5db4f0fe4cf Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 13 Jul 2010 12:11:52 +0000 Subject: [PATCH] Don't allow to create devices with '/' in names git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1815 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 9aec11c7b..487582c2e 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -996,6 +996,20 @@ out: return res; } +static int scst_check_device_name(const char *dev_name) +{ + int res = 0; + + if (strchr(dev_name, '/') != NULL) { + PRINT_ERROR("Dev name %s contains illegal character '/'", + dev_name); + res = -EINVAL; + } + + TRACE_EXIT_RES(res); + return res; +} + /** * scst_register_virtual_device() - register a virtual device. * @dev_handler: the device's device handler @@ -1026,6 +1040,10 @@ int scst_register_virtual_device(struct scst_dev_type *dev_handler, goto out; } + res = scst_check_device_name(dev_name); + if (res != 0) + goto out; + res = scst_dev_handler_check(dev_handler); if (res != 0) goto out;