summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tobias.klauser@zhinst.com>2015-05-15 17:55:33 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2015-10-23 10:04:01 +0200
commitfec5a5f526e15dbdea4cfb32ecc855506665c7b5 (patch)
tree1720b465b1b323bae71eac2c64fecfe0eab7d265
parent332211ed906a6d3c7ffb0f3cae1865348aadcd14 (diff)
usb: gadget: android: Use strlcpy instead of sscanf to get string attributes
sscanf() stops at first space it encounters, thus spaces are not represented i.e. in iManufacturer or iProduct. Fix this by using strlcpy for string attributes. [ZI: Backported from upstream android gadget driver] Signed-off-by: Tobias Klauser <tobias.klauser@zhinst.com>
-rw-r--r--drivers/usb/gadget/android.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c
index 9f79c267890e..c055c1fd873c 100644
--- a/drivers/usb/gadget/android.c
+++ b/drivers/usb/gadget/android.c
@@ -987,11 +987,9 @@ static ssize_t \
field ## _store(struct device *dev, struct device_attribute *attr, \
const char *buf, size_t size) \
{ \
- if (size >= sizeof(buffer)) return -EINVAL; \
- if (sscanf(buf, "%s", buffer) == 1) { \
- return size; \
- } \
- return -1; \
+ if (size >= sizeof(buffer)) \
+ return -EINVAL; \
+ return strlcpy(buffer, buf, sizeof(buffer)); \
} \
static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, field ## _show, field ## _store);