aboutsummaryrefslogtreecommitdiff
path: root/mathvec
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-04-27 11:51:01 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-06-03 15:07:21 -0300
commit321e1cef26ccbece949b16622ef74c203bd8ecc6 (patch)
tree1923671f7f5e17d8c440044a2a2d065340706234 /mathvec
parentc2fba3b047c2fac50985a47ff96075b5d9078432 (diff)
downloadglibc-321e1cef26ccbece949b16622ef74c203bd8ecc6.zip
glibc-321e1cef26ccbece949b16622ef74c203bd8ecc6.tar.gz
glibc-321e1cef26ccbece949b16622ef74c203bd8ecc6.tar.bz2
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. This is a backport of b65b205fbcabbb02463e31df17f5cabf7556f892. [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.
Diffstat (limited to 'mathvec')
0 files changed, 0 insertions, 0 deletions