From: Siddhesh Poyarekar Date: Sat, 20 Oct 2012 02:30:58 +0000 (+0530) Subject: Retry read in ld.so if the entire ELF header is not read in X-Git-Tag: upstream/2.30~10133 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88481c163885767a6617823314802aa772271804;p=external%2Fglibc.git Retry read in ld.so if the entire ELF header is not read in [BZ #13601] A read operation could return less than requested data for a number of reasons. --- diff --git a/ChangeLog b/ChangeLog index e5d8bba..eb60959 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-10-20 Siddhesh Poyarekar + + [BZ #13601] + * elf/dl-load.c (open_verify): Retry read if the entire ELF + header is not read in. + 2012-10-19 Joseph Myers * io/Makefile ($(objpfx)ftwtest.out): Depend on ftwtest-sh. Pass diff --git a/NEWS b/NEWS index aa40b75..fd3f6e5 100644 --- a/NEWS +++ b/NEWS @@ -10,13 +10,13 @@ Version 2.17 * The following bugs are resolved with this release: 1349, 3479, 5044, 5298, 5400, 6530, 6778, 6808, 9685, 9914, 10014, 10038, - 10631, 11438, 11607, 12140, 13412, 13542, 13629, 13679, 13696, 13717, - 13741, 13939, 13966, 14042, 14090, 14150, 14151, 14154, 14157, 14166, - 14173, 14195, 14237, 14251, 14252, 14283, 14298, 14303, 14307, 14328, - 14331, 14336, 14337, 14347, 14349, 14376, 14417, 14459, 14476, 14477, - 14505, 14510, 14516, 14518, 14519, 14530, 14532, 14538, 14543, 14544, - 14545, 14557, 14562, 14568, 14576, 14579, 14583, 14587, 14602, 14621, - 14638, 14645, 14648, 14652, 14660, 14661, 14694, 14716. + 10631, 11438, 11607, 12140, 13412, 13542, 13601, 13629, 13679, 13696, + 13717, 13741, 13939, 13966, 14042, 14090, 14150, 14151, 14154, 14157, + 14166, 14173, 14195, 14237, 14251, 14252, 14283, 14298, 14303, 14307, + 14328, 14331, 14336, 14337, 14347, 14349, 14376, 14417, 14459, 14476, + 14477, 14505, 14510, 14516, 14518, 14519, 14530, 14532, 14538, 14543, + 14544, 14545, 14557, 14562, 14568, 14576, 14579, 14583, 14587, 14602, + 14621, 14638, 14645, 14648, 14652, 14660, 14661, 14694, 14716. * Support for STT_GNU_IFUNC symbols added for s390 and s390x. Optimized versions of memcpy, memset, and memcmp added for System z10 and diff --git a/elf/dl-load.c b/elf/dl-load.c index 0bfa74a..4b57879 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1722,10 +1722,20 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader, /* We successfully openened the file. Now verify it is a file we can use. */ __set_errno (0); - fbp->len = __libc_read (fd, fbp->buf, sizeof (fbp->buf)); + fbp->len = 0; + assert (sizeof (fbp->buf) > sizeof (ElfW(Ehdr))); + /* Read in the header. */ + do + { + ssize_t retlen = __libc_read (fd, fbp->buf + fbp->len, + sizeof (fbp->buf) - fbp->len); + if (retlen <= 0) + break; + fbp->len += retlen; + } + while (__builtin_expect (fbp->len < sizeof (ElfW(Ehdr)), 0)); /* This is where the ELF header is loaded. */ - assert (sizeof (fbp->buf) > sizeof (ElfW(Ehdr))); ehdr = (ElfW(Ehdr) *) fbp->buf; /* Now run the tests. */