summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
Diffstat (limited to 'libio')
-rw-r--r--libio/fmemopen.c10
-rw-r--r--libio/iofopncook.c3
2 files changed, 9 insertions, 4 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index 92df2e4424..99670b5c58 100644
--- a/libio/fmemopen.c
+++ b/libio/fmemopen.c
@@ -69,6 +69,7 @@
  *   so I don't need the stream to add null characters on its own.)
  */
 
+#include <errno.h>
 #include <libio.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -96,7 +97,7 @@ fmemopen_read (void *cookie, char *b, size_t s)
   if (c->pos + s > c->size)
     {
       if (c->pos == c->size)
-	return -1;
+	return 0;
       s = c->size - c->pos;
     }
 
@@ -123,7 +124,10 @@ fmemopen_write (void *cookie, const char *b, size_t s)
   if (c->pos + s + addnullc > c->size)
     {
       if (c->pos + addnullc == c->size)
-	return -1;
+	{
+	  __set_errno (ENOSPC);
+	  return -1;
+	}
       s = c->size - c->pos - addnullc;
     }
 
@@ -142,7 +146,7 @@ fmemopen_write (void *cookie, const char *b, size_t s)
 
 
 int
-fmemopen_seek (void *cookie, _IO_off64_t * p, int w)
+fmemopen_seek (void *cookie, _IO_off64_t *p, int w)
 {
   _IO_off64_t np;
   fmemopen_cookie_t *c;
diff --git a/libio/iofopncook.c b/libio/iofopncook.c
index c016cfb1d5..52e025b4c9 100644
--- a/libio/iofopncook.c
+++ b/libio/iofopncook.c
@@ -76,7 +76,8 @@ _IO_cookie_seek (fp, offset, dir)
 
   return ((cfile->__io_functions.seek == NULL
 	   || (cfile->__io_functions.seek (cfile->__cookie, &offset, dir)
-	       == (_IO_off64_t) -1))
+	       == -1)
+	   || offset == (_IO_off64_t) -1)
 	  ? _IO_pos_BAD : offset);
 }