Enforce max LUNs limitation

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2490 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2010-10-29 18:34:48 +00:00
parent 34d4e3e693
commit e9a57cd875
3 changed files with 17 additions and 0 deletions

View File

@@ -46,6 +46,9 @@
/* Max size of external names, like initiator name */
#define SCST_MAX_EXTERNAL_NAME 256
/* Max LUN. 2 bits are used for addressing method. */
#define SCST_MAX_LUN ((1 << (16-2)) - 1)
/*
* Size of sense sufficient to carry standard sense data.
* Warning! It's allocated on stack!

View File

@@ -2007,7 +2007,14 @@ static ssize_t scst_proc_groups_devices_write(struct file *file,
e++;
while (isspace(*e) && *e != '\0')
e++;
virt_lun = simple_strtoul(e, &e, 0);
if (virt_lun > SCST_MAX_LUN) {
PRINT_ERROR("Too big LUN %d (max %d)", virt_lun,
SCST_MAX_LUN);
res = -EINVAL;
goto out_free_up;
}
while (isspace(*e) && *e != '\0')
e++;

View File

@@ -2720,7 +2720,14 @@ static int __scst_process_luns_mgmt_store(char *buffer,
e++;
while (isspace(*e) && *e != '\0')
e++;
virt_lun = simple_strtoul(e, &e, 0);
if (virt_lun > SCST_MAX_LUN) {
PRINT_ERROR("Too big LUN %d (max %d)", virt_lun,
SCST_MAX_LUN);
res = -EINVAL;
goto out_unlock;
}
while (isspace(*e) && *e != '\0')
e++;