bug-hurd
[Top][All Lists]
Advanced

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

[PATCH] libstore/file.c


From: Neal H Walfield
Subject: [PATCH] libstore/file.c
Date: Wed, 7 Mar 2001 00:20:24 +0100
User-agent: Mutt/1.3.12i

It appears to me that io_read requires a malloced buffer.  According
to store semantics, only a pointer to a pointer to a buffer is passed.
Thus, those programs using libstore and the file class crash violently.
The attached patch fixes this problem, however, I do not know if this
is the correct place for it (where is io_read?  In libc -- I failed to
find it).

Thanks.

diff -Nur hurd-20010115-snapshot/libstore/ChangeLog 
hurd-20010115/libstore/ChangeLog
--- hurd-20010115-snapshot/libstore/ChangeLog   Sun Jan 14 22:59:21 2001
+++ hurd-20010115/libstore/ChangeLog    Wed Mar  7 00:15:48 2001
@@ -1,3 +1,9 @@
+2001-03-07  Neal H Walfield <neal@cs.uml.edu>
+
+       * file.c: Include mach.h
+       (file_read): vm_allocate the buffer.
+       (file_byte_read): Likewise.
+
 2001-01-14  Roland McGrath  <roland@frob.com>
 
        * encode.c (too_big): New static function.
diff -Nur hurd-20010115-snapshot/libstore/file.c hurd-20010115/libstore/file.c
--- hurd-20010115-snapshot/libstore/file.c      Mon Jan  8 23:33:11 2001
+++ hurd-20010115/libstore/file.c       Tue Mar  6 19:04:43 2001
@@ -23,6 +23,7 @@
 #include <fcntl.h>
 #include <hurd.h>
 
+#include <mach.h>
 #include <hurd/io.h>
 
 #include "store.h"
@@ -33,6 +34,11 @@
           size_t *len)
 {
   size_t bsize = store->block_size;
+  error_t err;
+
+  err = vm_allocate (mach_task_self (), buf, amount, 1);
+  if (err)
+    return err;
   return io_read (store->port, (char **)buf, len, addr * bsize, amount);
 }
 
@@ -202,6 +208,11 @@
                store_offset_t addr, size_t index, size_t amount,
                void **buf, size_t *len)
 {
+  error_t err;
+
+  err = vm_allocate (mach_task_self (), buf, amount, 1);
+  if (err)
+    return err;
   return io_read (store->port, (char **)buf, len, addr, amount);
 }
 

Attachment: pgpmJqCU7cLzJ.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]