pwrite: Check offset is not negative.
authorRichard W.M. Jones <rjones@redhat.com>
Sun, 26 Sep 2010 16:59:50 +0000 (17:59 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Sun, 26 Sep 2010 21:21:36 +0000 (22:21 +0100)
daemon/file.c

index 476f445..0849456 100644 (file)
@@ -469,6 +469,11 @@ do_pwrite (const char *path, const char *content, size_t size, int64_t offset)
   int fd;
   ssize_t r;
 
+  if (offset < 0) {
+    reply_with_error ("offset is negative");
+    return -1;
+  }
+
   CHROOT_IN;
   fd = open (path, O_WRONLY);
   CHROOT_OUT;