diff options
author | Andrey Ryabinin <a.ryabinin@samsung.com> | 2015-01-27 14:00:19 +0100 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2015-03-20 15:34:43 +0100 |
commit | 179a5bc4b8cbe68ca675057b960dd805867e41c4 (patch) | |
tree | 600cff80e3c7483509d90ef2a4dad7db529a5ec3 /net/9p | |
parent | 9p: use unsigned integers for nwqid/count (diff) | |
download | linux-179a5bc4b8cbe68ca675057b960dd805867e41c4.tar.xz linux-179a5bc4b8cbe68ca675057b960dd805867e41c4.zip |
net/9p: use memcpy() instead of snprintf() in p9_mount_tag_show()
p9_mount_tag_show() uses '%s' format string to print
non-NULL terminated chan->tag string. This leads
to out of bounds memory read, because format '%s'
implies that string is NULL-terminated.
The length of string is know here, so its simpler and safer
to use memcpy instead of snprintf().
Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/trans_virtio.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 36a1a739ad68..486df019f875 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -504,7 +504,10 @@ static ssize_t p9_mount_tag_show(struct device *dev, vdev = dev_to_virtio(dev); chan = vdev->priv; - return snprintf(buf, chan->tag_len + 1, "%s", chan->tag); + memcpy(buf, chan->tag, chan->tag_len); + buf[chan->tag_len] = 0; + + return chan->tag_len + 1; } static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL); |