Adhemerval Zanella b65b205fbc 
	
	
	libio: Fix fmemopen append mode failure (BZ# 20012) ... 
			The fmemopen implementation does not account the file position correctly in
append mode. The following example shows the failure:
===
int main ()
{
  char buf[10] = "test";
  FILE *fp = fmemopen (buf, 10, "a+");
  fseek (fp, 0, SEEK_SET);
  int gr;
  if ((gr = getc (fp)) != 't' ||
      (gr = getc (fp)) != 'e' ||
      (gr = getc (fp)) != 's' ||
      (gr = getc (fp)) != 't' ||
      (gr = getc (fp)) != EOF)
    {
      printf ("%s: getc failed returned %i\n", __FUNCTION__, gr);
      return 1;
    }
  return 0;
}
===
This is due both how read and write operation update the buffer position,
taking in consideration buffer lenght instead of maximum position defined
by the open mode.  This patch fixes it and also fixes fseek not returning
EINVAL for invalid whence modes.
Tested on x86_64 and i686.
	[BZ #20012 ]
	* libio/fmemopen.c (fmemopen_read): Use buffer maximum position, not
	length to calculate the buffer to read.
	(fmemopen_write): Set the buffer position based on bytes written.
	(fmemopen_seek): Return EINVAL for invalid whence modes. 
		
	 
		2016-04-29 19:25:17 -03:00 
	 
	
	
	
		 
	
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
	
		
			
			
			
			
			
			2013-06-05 20:44:03 +00:00 
		 
	
		
	
		
	
		
	
		
	
		
	
		
	
		
			
			
			
			
			
			2014-12-10 00:41:19 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2014-12-15 10:09:33 +01:00 
		 
	
		
			
			
			
			
			
			2014-12-15 10:09:33 +01:00 
		 
	
		
			
			
			
			
			
			2014-12-15 10:09:33 +01:00 
		 
	
		
	
		
	
		
			
			
			
			
			
			2012-05-24 21:30:43 -06:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-04-26 17:40:25 -03:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-04-14 12:21:53 +02:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2013-10-12 14:47:50 +02:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
	
		
	
		
			
			
			
			
			
			2014-12-11 13:47:44 -08:00 
		 
	
		
	
		
			
			
			
			
			
			2014-12-11 13:47:44 -08:00 
		 
	
		
	
		
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
	
		
	
		
			
			
			
			
			
			2014-12-10 00:41:19 +00:00 
		 
	
		
			
			
			
			
			
			2015-09-03 20:24:54 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2015-09-03 20:24:54 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2015-08-06 02:59:04 -04:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2013-06-07 22:24:35 +00:00 
		 
	
		
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
	
		
			
			
			
			
			
			2015-08-06 02:59:04 -04:00 
		 
	
		
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-04-29 19:25:17 -03:00 
		 
	
		
			
			
			
			
			
			2016-04-26 17:40:25 -03:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-01-07 04:03:21 -05:00 
		 
	
		
			
			
			
			
			
			2015-08-06 02:59:04 -04:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
	
		
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
			
			
			
			
			
			2016-03-31 12:14:33 -05:00 
		 
	
		
			
			
			
			
			
			2014-12-15 11:29:09 -06:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
			
			
			
			
			
			2016-01-07 04:03:21 -05:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2016-04-25 14:10:26 +02:00 
		 
	
		
			
			
			
			
			
			2014-11-05 15:24:08 +05:30 
		 
	
		
			
			
			
			
			
			2014-12-11 13:47:44 -08:00 
		 
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
	
		
			
			
			
			
			
			2014-02-28 11:07:43 -08:00 
		 
	
		
			
			
			
			
			
			2016-04-25 14:10:26 +02:00 
		 
	
		
			
			
			
			
			
			2016-01-21 09:11:17 -05:00 
		 
	
		
	
		
	
		
			
			
			
			
			
			2016-01-04 16:05:18 +00:00 
		 
	
		
			
			
			
			
			
			2015-10-16 20:21:49 +00:00