xen/xenbus: fix overflow check in xenbus_file_write()
authorJan Beulich <JBeulich@suse.com>
Wed, 17 Oct 2012 17:14:09 +0000 (13:14 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 30 Oct 2012 13:57:49 +0000 (09:57 -0400)
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
[v1: Rebased on upstream]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/xenbus/xenbus_dev_frontend.c

index 89f7625..ac72702 100644 (file)
@@ -458,7 +458,7 @@ static ssize_t xenbus_file_write(struct file *filp,
                goto out;
 
        /* Can't write a xenbus message larger we can buffer */
-       if ((len + u->len) > sizeof(u->u.buffer)) {
+       if (len > sizeof(u->u.buffer) - u->len) {
                /* On error, dump existing buffer */
                u->len = 0;
                rc = -EINVAL;