pwrite: Check offset is not negative.
[libguestfs.git] / 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;