[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 1/4] pread: Check count and offset parameters are not negative.



The first two patches add pread-device.

(pwrite-device, which I added a few days ago, is also required for this).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
>From e65f5213637e71f6f88763ce177fd23c65e1033d Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones redhat com>
Date: Mon, 27 Sep 2010 10:51:38 +0100
Subject: [PATCH 1/4] pread: Check count and offset parameters are not negative.

---
 daemon/file.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/daemon/file.c b/daemon/file.c
index 9403100..5bc5f41 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -415,6 +415,16 @@ do_pread (const char *path, int count, int64_t offset, size_t *size_r)
   ssize_t r;
   char *buf;
 
+  if (count < 0) {
+    reply_with_error ("count is negative");
+    return NULL;
+  }
+
+  if (offset < 0) {
+    reply_with_error ("offset is negative");
+    return NULL;
+  }
+
   /* The actual limit on messages is smaller than this.  This check
    * just limits the amount of memory we'll try and allocate in the
    * function.  If the message is larger than the real limit, that
-- 
1.7.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]