summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-09-27 10:51:38 +0100
committerRichard W.M. Jones <rjones@redhat.com>2010-09-27 10:51:38 +0100
commite65f5213637e71f6f88763ce177fd23c65e1033d (patch)
tree0e72e60661616d960c7883826a6141aa18f1308e /daemon
parent533aff2879d85a4061b9d31e9b25996ce0af60f5 (diff)
downloadlibguestfs-e65f5213637e71f6f88763ce177fd23c65e1033d.tar.gz
libguestfs-e65f5213637e71f6f88763ce177fd23c65e1033d.tar.xz
libguestfs-e65f5213637e71f6f88763ce177fd23c65e1033d.zip
pread: Check count and offset parameters are not negative.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/file.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/daemon/file.c b/daemon/file.c
index 9403100d..5bc5f412 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