mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-20 12:11:26 +00:00
scst_vdisk: Make expl_alua sysfs attribute input validation more strict
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6640 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -255,6 +255,32 @@ static inline void hex2bin(u8 *dst, const char *src, size_t count)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
|
||||
static inline int __must_check kstrtoull(const char *s, unsigned int base,
|
||||
unsigned long long *res)
|
||||
{
|
||||
return strict_strtoull(s, base, res);
|
||||
}
|
||||
|
||||
static inline int __must_check kstrtoll(const char *s, unsigned int base,
|
||||
long long *res)
|
||||
{
|
||||
return strict_strtoll(s, base, res);
|
||||
}
|
||||
|
||||
static inline int __must_check kstrtoul(const char *s, unsigned int base,
|
||||
unsigned long *res)
|
||||
{
|
||||
return strict_strtoul(s, base, res);
|
||||
}
|
||||
|
||||
static inline int __must_check kstrtol(const char *s, unsigned int base,
|
||||
long *res)
|
||||
{
|
||||
return strict_strtol(s, base, res);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* <linux/list.h> */
|
||||
|
||||
#ifndef __list_for_each
|
||||
|
||||
@@ -8823,7 +8823,7 @@ static ssize_t vdisk_sysfs_expl_alua_store(struct kobject *kobj,
|
||||
struct scst_device *dev;
|
||||
struct scst_vdisk_dev *virt_dev;
|
||||
char ch[16];
|
||||
bool expl_alua;
|
||||
unsigned long expl_alua;
|
||||
int res;
|
||||
|
||||
TRACE_ENTRY();
|
||||
@@ -8831,14 +8831,17 @@ static ssize_t vdisk_sysfs_expl_alua_store(struct kobject *kobj,
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
sprintf(ch, "%.*s", min_t(int, sizeof(ch) - 1, count), buf);
|
||||
expl_alua = !!simple_strtoul(ch, NULL, 0);
|
||||
res = kstrtoul(ch, NULL, &expl_alua);
|
||||
if (res < 0)
|
||||
goto out;
|
||||
|
||||
spin_lock(&virt_dev->flags_lock);
|
||||
virt_dev->expl_alua = expl_alua;
|
||||
virt_dev->expl_alua = !!expl_alua;
|
||||
spin_unlock(&virt_dev->flags_lock);
|
||||
|
||||
res = count;
|
||||
|
||||
out:
|
||||
TRACE_EXIT_RES(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user