diff options
author | Joseph Myers <joseph@codesourcery.com> | 2014-11-12 16:22:51 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2014-11-12 16:22:51 +0000 |
commit | 5a6fa4d7ed465c2f7da9d73004c972519dc2100e (patch) | |
tree | cefc8c3b17e8e57731afe93278c12a0d5137bae0 | |
parent | 2581b98ecb1f2b3669a4b88a605f763fa4e85ee6 (diff) | |
download | glibc-5a6fa4d7ed465c2f7da9d73004c972519dc2100e.tar.gz glibc-5a6fa4d7ed465c2f7da9d73004c972519dc2100e.tar.xz glibc-5a6fa4d7ed465c2f7da9d73004c972519dc2100e.zip |
Fix tzfile.c namespace (bug 17583).
tzfile.c is brought in by various ISO C functions, but calls fileno, fread_unlocked and ftello, which are not ISO C functions. This patch adds names __fileno, __fread_unlocked and __ftello for those functions, making tzfile.c use those new names. Note: there are various uses of fileno elsewhere in glibc that I didn't change, although it may turn out that some of those also need to use __fileno. Tested for x86_64 with the glibc testsuite. Changed line numbers in tzfile.c cause changes in assertions, and for some reason this ends up with different instruction choice and register allocation, affecting the size of __tzfile_read and so making comparison of disassembly for libc.so problematic. [BZ #17583] * libio/fileno.c (fileno): Rename to __fileno and define as weak alias of __fileno. Use libc_hidden_weak. (__fileno): Use libc_hidden_def. [weak_alias] (fileno_unlocked): Define as weak alias of __fileno. * libio/ftello.c (ftello): Rename to __ftello and define as weak alias of __ftello. [__OFF_T_MATCHES_OFF64_T] (ftello64): Define as weak alias of __ftello. * libio/iofread.c [weak_alias && !_IO_MTSAFE_IO] (__fread_unlocked): Define as strong alias of _IO_fread. Use libc_hidden_def. (fread_unlocked): Don't use libc_hidden_ver. * libio/iofread_u.c (fread_unlocked): Rename to __fread_unlocked and define as weak alias of __fread_unlocked. Don't use libc_hidden_def. (__fread_unlocked): Use libc_hidden_def. * include/stdio.h (__fileno): Declare. Use libc_hidden_proto. (ftello): Don't use libc_hidden_proto. (__ftello): Declare. Use libc_hidden_proto. (fread_unlocked): Don't use libc_hidden_proto. (__fread_unlocked): Declare. Use libc_hidden_proto. * time/tzfile.c (__tzfile_read): Use __fileno, __fread_unlocked and __ftello instead of fileno, fread_unlocked and ftello.
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | include/stdio.h | 8 | ||||
-rw-r--r-- | libio/fileno.c | 8 | ||||
-rw-r--r-- | libio/ftello.c | 7 | ||||
-rw-r--r-- | libio/iofread.c | 3 | ||||
-rw-r--r-- | libio/iofread_u.c | 5 | ||||
-rw-r--r-- | time/tzfile.c | 39 |
8 files changed, 69 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog index 874d2d9108..ee9f3120df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2014-11-12 Joseph Myers <joseph@codesourcery.com> + + [BZ #17583] + * libio/fileno.c (fileno): Rename to __fileno and define as weak + alias of __fileno. Use libc_hidden_weak. + (__fileno): Use libc_hidden_def. + [weak_alias] (fileno_unlocked): Define as weak alias of __fileno. + * libio/ftello.c (ftello): Rename to __ftello and define as weak + alias of __ftello. + [__OFF_T_MATCHES_OFF64_T] (ftello64): Define as weak alias of + __ftello. + * libio/iofread.c [weak_alias && !_IO_MTSAFE_IO] + (__fread_unlocked): Define as strong alias of _IO_fread. Use + libc_hidden_def. + (fread_unlocked): Don't use libc_hidden_ver. + * libio/iofread_u.c (fread_unlocked): Rename to __fread_unlocked + and define as weak alias of __fread_unlocked. Don't use + libc_hidden_def. + (__fread_unlocked): Use libc_hidden_def. + * include/stdio.h (__fileno): Declare. Use libc_hidden_proto. + (ftello): Don't use libc_hidden_proto. + (__ftello): Declare. Use libc_hidden_proto. + (fread_unlocked): Don't use libc_hidden_proto. + (__fread_unlocked): Declare. Use libc_hidden_proto. + * time/tzfile.c (__tzfile_read): Use __fileno, __fread_unlocked + and __ftello instead of fileno, fread_unlocked and ftello. + 2012-11-12 Siddhesh Poyarekar <siddhesh@redhat.com> * sysdeps/s390/s390-32/bcopy.S (__bcopy): Use GOT instead of diff --git a/NEWS b/NEWS index a1743d7ecf..4727ea24cc 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,7 @@ Version 2.21 6652, 12926, 14132, 14138, 14171, 15215, 15884, 17266, 17344, 17363, 17370, 17371, 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522, - 17555. + 17555, 17583. * New locales: tu_IN, bh_IN. diff --git a/include/stdio.h b/include/stdio.h index 9f2ea31bc9..f6c0a77b3c 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -143,12 +143,16 @@ libc_hidden_proto (perror) libc_hidden_proto (remove) libc_hidden_proto (rewind) libc_hidden_proto (fileno) +extern __typeof (fileno) __fileno; +libc_hidden_proto (__fileno) libc_hidden_proto (fwrite) libc_hidden_proto (fseek) -libc_hidden_proto (ftello) +extern __typeof (ftello) __ftello; +libc_hidden_proto (__ftello) libc_hidden_proto (fflush) libc_hidden_proto (fflush_unlocked) -libc_hidden_proto (fread_unlocked) +extern __typeof (fread_unlocked) __fread_unlocked; +libc_hidden_proto (__fread_unlocked) libc_hidden_proto (fwrite_unlocked) libc_hidden_proto (fgets_unlocked) libc_hidden_proto (fputs_unlocked) diff --git a/libio/fileno.c b/libio/fileno.c index 92b0332c84..411ea0e052 100644 --- a/libio/fileno.c +++ b/libio/fileno.c @@ -28,7 +28,7 @@ #include <stdio.h> int -fileno (fp) +__fileno (fp) _IO_FILE* fp; { CHECK_FILE (fp, EOF); @@ -41,12 +41,14 @@ fileno (fp) return _IO_fileno (fp); } -libc_hidden_def (fileno) +libc_hidden_def (__fileno) +weak_alias (__fileno, fileno) +libc_hidden_weak (fileno) #ifdef weak_alias /* The fileno implementation for libio does not require locking because it only accesses once a single variable and this is already atomic (at least at thread level). Therefore we don't test _IO_MTSAFE_IO here. */ -weak_alias (fileno, fileno_unlocked) +weak_alias (__fileno, fileno_unlocked) #endif diff --git a/libio/ftello.c b/libio/ftello.c index 208ff8cfce..33a2160c18 100644 --- a/libio/ftello.c +++ b/libio/ftello.c @@ -31,7 +31,7 @@ off_t -ftello (fp) +__ftello (fp) _IO_FILE *fp; { _IO_off64_t pos; @@ -61,8 +61,9 @@ ftello (fp) } return pos; } -libc_hidden_def (ftello) +libc_hidden_def (__ftello) +weak_alias (__ftello, ftello) #ifdef __OFF_T_MATCHES_OFF64_T -weak_alias (ftello, ftello64) +weak_alias (__ftello, ftello64) #endif diff --git a/libio/iofread.c b/libio/iofread.c index ca792a20bd..a9d6282d6f 100644 --- a/libio/iofread.c +++ b/libio/iofread.c @@ -49,7 +49,8 @@ libc_hidden_def (_IO_fread) weak_alias (_IO_fread, fread) # ifndef _IO_MTSAFE_IO +strong_alias (_IO_fread, __fread_unlocked) +libc_hidden_def (__fread_unlocked) weak_alias (_IO_fread, fread_unlocked) -libc_hidden_ver (_IO_fread, fread_unlocked) # endif #endif diff --git a/libio/iofread_u.c b/libio/iofread_u.c index 5e462254a9..f0059b4bad 100644 --- a/libio/iofread_u.c +++ b/libio/iofread_u.c @@ -30,7 +30,7 @@ #undef fread_unlocked _IO_size_t -fread_unlocked (buf, size, count, fp) +__fread_unlocked (buf, size, count, fp) void *buf; _IO_size_t size; _IO_size_t count; @@ -44,4 +44,5 @@ fread_unlocked (buf, size, count, fp) bytes_read = _IO_sgetn (fp, (char *) buf, bytes_requested); return bytes_requested == bytes_read ? count : bytes_read / size; } -libc_hidden_def (fread_unlocked) +libc_hidden_def (__fread_unlocked) +weak_alias (__fread_unlocked, fread_unlocked) diff --git a/time/tzfile.c b/time/tzfile.c index 52f0994815..9abfa4729e 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -170,7 +170,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) goto ret_free_transitions; /* Get information about the file we are actually using. */ - if (fstat64 (fileno (f), &st) != 0) + if (fstat64 (__fileno (f), &st) != 0) { fclose (f); goto ret_free_transitions; @@ -188,8 +188,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap) __fsetlocking (f, FSETLOCKING_BYCALLER); read_again: - if (__builtin_expect (fread_unlocked ((void *) &tzhead, sizeof (tzhead), - 1, f) != 1, 0) + if (__builtin_expect (__fread_unlocked ((void *) &tzhead, sizeof (tzhead), + 1, f) != 1, 0) || memcmp (tzhead.tzh_magic, TZ_MAGIC, sizeof (tzhead.tzh_magic)) != 0) goto lose; @@ -248,7 +248,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) tzspec_len = 0; if (sizeof (time_t) == 8 && trans_width == 8) { - off_t rem = st.st_size - ftello (f); + off_t rem = st.st_size - __ftello (f); if (__builtin_expect (rem < 0 || (size_t) rem < (num_transitions * (8 + 1) + num_types * 6 @@ -293,17 +293,18 @@ __tzfile_read (const char *file, size_t extra, char **extrap) if (sizeof (time_t) == 4 || __builtin_expect (trans_width == 8, 1)) { - if (__builtin_expect (fread_unlocked (transitions, trans_width + 1, - num_transitions, f) + if (__builtin_expect (__fread_unlocked (transitions, trans_width + 1, + num_transitions, f) != num_transitions, 0)) goto lose; } else { - if (__builtin_expect (fread_unlocked (transitions, 4, num_transitions, f) + if (__builtin_expect (__fread_unlocked (transitions, 4, + num_transitions, f) != num_transitions, 0) - || __builtin_expect (fread_unlocked (type_idxs, 1, num_transitions, - f) != num_transitions, 0)) + || __builtin_expect (__fread_unlocked (type_idxs, 1, num_transitions, + f) != num_transitions, 0)) goto lose; } @@ -337,7 +338,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap) { unsigned char x[4]; int c; - if (__builtin_expect (fread_unlocked (x, 1, sizeof (x), f) != sizeof (x), + if (__builtin_expect (__fread_unlocked (x, 1, + sizeof (x), f) != sizeof (x), 0)) goto lose; c = getc_unlocked (f); @@ -352,13 +354,13 @@ __tzfile_read (const char *file, size_t extra, char **extrap) types[i].offset = (long int) decode (x); } - if (__glibc_unlikely (fread_unlocked (zone_names, 1, chars, f) != chars)) + if (__glibc_unlikely (__fread_unlocked (zone_names, 1, chars, f) != chars)) goto lose; for (i = 0; i < num_leaps; ++i) { unsigned char x[8]; - if (__builtin_expect (fread_unlocked (x, 1, trans_width, f) + if (__builtin_expect (__fread_unlocked (x, 1, trans_width, f) != trans_width, 0)) goto lose; if (sizeof (time_t) == 4 || trans_width == 4) @@ -366,7 +368,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) else leaps[i].transition = (time_t) decode64 (x); - if (__glibc_unlikely (fread_unlocked (x, 1, 4, f) != 4)) + if (__glibc_unlikely (__fread_unlocked (x, 1, 4, f) != 4)) goto lose; leaps[i].change = (long int) decode (x); } @@ -396,7 +398,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) { /* Skip over the newline first. */ if (getc_unlocked (f) != '\n' - || (fread_unlocked (tzspec, 1, tzspec_len - 1, f) + || (__fread_unlocked (tzspec, 1, tzspec_len - 1, f) != tzspec_len - 1)) tzspec = NULL; else @@ -405,8 +407,8 @@ __tzfile_read (const char *file, size_t extra, char **extrap) else if (sizeof (time_t) == 4 && tzhead.tzh_version[0] != '\0') { /* Get the TZ string. */ - if (__builtin_expect (fread_unlocked ((void *) &tzhead, sizeof (tzhead), - 1, f) != 1, 0) + if (__builtin_expect (__fread_unlocked ((void *) &tzhead, + sizeof (tzhead), 1, f) != 1, 0) || (memcmp (tzhead.tzh_magic, TZ_MAGIC, sizeof (tzhead.tzh_magic)) != 0)) goto lose; @@ -427,14 +429,15 @@ __tzfile_read (const char *file, size_t extra, char **extrap) + num_isgmt2); off_t off; if (fseek (f, to_skip, SEEK_CUR) != 0 - || (off = ftello (f)) < 0 + || (off = __ftello (f)) < 0 || st.st_size < off + 2) goto lose; tzspec_len = st.st_size - off - 1; char *tzstr = alloca (tzspec_len); if (getc_unlocked (f) != '\n' - || (fread_unlocked (tzstr, 1, tzspec_len - 1, f) != tzspec_len - 1)) + || (__fread_unlocked (tzstr, 1, tzspec_len - 1, f) + != tzspec_len - 1)) goto lose; tzstr[tzspec_len - 1] = '\0'; tzspec = __tzstring (tzstr); |