1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-17 12:41:05 +03:00
Commit Graph

2404 Commits

Author SHA1 Message Date
Bruno Haible
63e26828e0 truncate-tests: New module.
* tests/test-truncate.c: New file.
* modules/truncate-tests: New file.
2017-05-13 02:55:24 +02:00
Bruno Haible
f4d71054e7 truncate: New module.
* lib/unistd.in.h (truncate): New declaration.
* lib/truncate.c: New file.
* m4/truncate.m4: New file.
* m4/unistd_h.m4 (gl_UNISTD_H): Test whether 'truncate' is declared.
(gl_UNISTD_H_DEFAULTS): Initialize GNULIB_TRUNCATE, HAVE_TRUNCATE,
REPLACE_TRUNCATE.
* modules/unistd (Makefile.am): Substitute GNULIB_TRUNCATE,
HAVE_TRUNCATE, REPLACE_TRUNCATE.
* modules/truncate: New file.
* tests/test-unistd-c++.cc (truncate): Test signature.
* doc/posix-functions/truncate.texi: Mention the new module.
2017-05-13 02:54:37 +02:00
Bruno Haible
03c3f38b55 Implement a way to opt out from MSVC support.
This is useful for Emacs.

* modules/msvc-nothrow (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/accept4.c: Include <io.h> as an alternative to msvc-nothrow.h.
* lib/error.c: Likewise.
* lib/fcntl.c: Likewise.
* lib/flock.c: Likewise.
* lib/fstat.c: Likewise.
* lib/fsync.c: Likewise.
* lib/ioctl.c: Likewise.
* lib/isapipe.c: Likewise.
* lib/lseek.c: Likewise.
* lib/nonblocking.c: Likewise.
* lib/poll.c: Likewise.
* lib/select.c: Likewise.
* lib/sockets.h: Likewise.
* lib/sockets.c: Likewise.
* lib/stdio-read.c: Likewise.
* lib/stdio-write.c: Likewise.
* lib/utimens.c: Likewise.
* lib/w32sock.h: Likewise.
* lib/w32spawn.h: Likewise.
* tests/test-cloexec.c: Likewise.
* tests/test-dup-safer.c: Likewise.
* tests/test-dup2.c: Likewise.
* tests/test-dup3.c: Likewise.
* tests/test-fcntl.c: Likewise.
* tests/test-pipe.c: Likewise.
* tests/test-pipe2.c: Likewise.
* lib/ftruncate.c: Likewise.
(chsize_nothrow): Renamed from chsize.
* lib/msvc-nothrow.c: Don't include msvc-inval.h if
HAVE_MSVC_INVALID_PARAMETER_HANDLER is not defined.
* lib/close.c: Likewise.
* lib/dup.c: Likewise.
* lib/fclose.c: Likewise.
* lib/raise.c: Likewise.
* tests/test-fgetc.c: Likewise.
* tests/test-fputc.c: Likewise.
* tests/test-fread.c: Likewise.
* tests/test-fwrite.c: Likewise.
* lib/getdtablesize.c: Likewise.
(_setmaxstdio_nothrow): Renamed from _setmaxstdio.
* lib/isatty.c: Don't include msvc-inval.h if
HAVE_MSVC_INVALID_PARAMETER_HANDLER is not defined.
Include <io.h> as an alternative to msvc-nothrow.h.
* lib/read.c: Likewise.
* lib/write.c: Likewise.
* lib/dup2.c: Likewise.
(dup2_nothrow): New function.
(ms_windows_dup2): Use it.
* m4/close.m4 (gl_FUNC_CLOSE): Invoke gl_MSVC_INVAL and test
HAVE_MSVC_INVALID_PARAMETER_HANDLER only if gl_MSVC_INVAL is defined.
* m4/dup.m4 (gl_FUNC_DUP): Likewise.
* m4/fdopen.m4 (gl_FUNC_FDOPEN): Likewise.
* m4/raise.m4 (gl_FUNC_RAISE): Likewise.
* m4/read.m4 (gl_FUNC_READ): Likewise.
* m4/write.m4 (gl_FUNC_WRITE): Likewise.
* doc/windows-without-msvc.texi: New file.
* doc/gnulib.texi (Native Windows Support without MSVC Support): New
section.
2017-05-10 22:18:34 +02:00
Paul Eggert
d9c44b2b3b intprops: don’t depend on ‘verify’
Problem reported by Ævar Arnfjörð Bjarmason in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00054.html
* lib/intprops.h: Do not include verify.h, and move compile-time
checks from here ...
* tests/test-intprops.c (main): ... to here, if they’re not here
already.  Check widths of other standard integer types.
* modules/intprops (Depends-on): Remove ‘verify’.
2017-05-08 10:38:24 -07:00
Bruno Haible
7a10cf55ff wctype-h-c++-tests: Update.
* tests/test-wctype-h-c++.cc: Reorder to match lib/wchar.in.h.
2017-05-06 00:22:47 +02:00
Bruno Haible
2c3911f5e9 wchar-c++-tests: Update.
* tests/test-wchar-c++.cc (wcsftime): Declare, missing since 2017-04-30.
2017-05-06 00:22:46 +02:00
Bruno Haible
308880d809 utime-h-c++-tests: New module.
* tests/test-utime-h-c++.cc: New file.
(utime): Declare, missing since 2017-04-30.
* modules/utime-h-c++-tests: New file.
2017-05-06 00:22:46 +02:00
Bruno Haible
22760ce69f unistd-c++-tests: Update.
* tests/test-unistd-c++.cc (isatty): Declare, missing since 2012-01-03.
(read): Declare, missing since 2011-04-15.
(sethostname): Declare, missing since 2011-12-03.
2017-05-06 00:22:46 +02:00
Bruno Haible
8f4aa68441 time-c++-tests: Update.
* tests/test-time-c++.cc (tzset): Declare, missing since 2017-05-01.
(localtime, gmtime): Declare, missing since 2017-04-30.
(ctime): Declare, missing since 2017-04-30.
(strftime): Declare, missing since 2017-04-30.
(tzalloc, tzfree, localtime_rz, mktime_z): Declare, missing since
2015-07-24.
2017-05-06 00:22:45 +02:00
Bruno Haible
f614b66a4c sys_resource-c++-tests: New module.
* tests/test-sys_resource-c++.cc: New file.
(getrusage): Declare, missing since 2012-04-13.
* modules/sys_resource-c++-tests: New file.
2017-05-06 00:22:45 +02:00
Bruno Haible
e31d3f5cea strings-c++-tests: New module.
* tests/test-strings-c++.cc: New file.
(ffs): Declare, missing since 2011-07-12.
* modules/strings-c++-tests: New file.
2017-05-06 00:22:45 +02:00
Bruno Haible
ec17d7520f string-c++-tests: Update.
* tests/test-string-c++.cc (ffsl): Declare, missing since 2011-07-15.
(ffsll): Declare, missing since 2011-07-15.
2017-05-06 00:22:44 +02:00
Bruno Haible
b8af9e178a stdlib-c++-tests: Update.
* tests/test-stdlib-c++.cc (posix_openpt): Declare, missing since
2011-10-18.
(ptsname_r): Declare, missing since 2011-11-07.
(qsort_r): Declare, missing since 2014-08-29.
(random, srandom, initstate, setstate): Declare, missing since
2012-01-14.
(secure_getenv): Declare, missing since 2013-02-05.
2017-05-06 00:22:44 +02:00
Bruno Haible
dc3abe2b78 stdio-c++-tests: Update.
* tests/test-stdio-c++.cc (pclose): Declare, missing since 2011-09-18.
2017-05-06 00:22:44 +02:00
Bruno Haible
532cc565b1 signal-h-c++-tests: Update.
* tests/test-signal-h-c++.cc (raise): Remove redundant declaration.
2017-05-06 00:22:43 +02:00
Bruno Haible
b42edb720e math-c++-tests: Update.
* tests/test-math-c++.cc (fmaf): Declare, missing since 2011-10-17.
(fma): Declare, missing since 2011-10-17.
(fmal): Declare, missing since 2011-10-17.
2017-05-06 00:22:38 +02:00
Bruno Haible
b2ed664da2 locale-c++-tests: Update.
* tests/test-locale-c++.cc (localeconv): Declare, missing since
2012-03-25.
2017-05-06 00:22:37 +02:00
Bruno Haible
f33c48694d inttypes-c++-tests: New module.
* tests/test-inttypes-c++.cc: New file.
(strtoimax): Declare, missing since 2012-01-05.
(strtoumax): Declare, missing since 2012-01-05.
* modules/inttypes-c++-tests: New file.
2017-05-06 00:22:37 +02:00
Bruno Haible
89b335be47 dirent-c++-tests: Update.
* tests/test-dirent-c++.cc (readdir): Declare, missing since 2011-09-13.
(rewinddir): Declare, missing since 2011-09-13.
(dirfd): Declare, missing since 2010-03-08.
2017-05-06 00:22:32 +02:00
Bruno Haible
dc2bc50851 utime-tests: New module.
* tests/test-utime.c: New file, based on tests/test-utimens.h.
* tests/test-utimens-common.h: Include <sys/stat.h>.
* modules/utime-tests: New file.
2017-04-30 19:26:36 +02:00
Bruno Haible
8dac05d25a utime-h: New module.
* m4/utime_h.m4: New file.
* lib/utime.in.h: New file.
* modules/utime-h: New file.
* doc/posix-headers/utime.texi: Mention the new module.

* tests/test-utime-h.c: New file.
* modules/utime-h-tests: New file.
2017-04-30 10:21:22 +02:00
Bruno Haible
62f2dba6c1 noreturn: New module.
* lib/noreturn.h: New file.
* modules/noreturn: New file.
* tests/test-noreturn.c: New file.
* modules/noreturn-tests: New file.
* tests/test-noreturn-c++.cc: New file.
* modules/noreturn-c++-tests: New file.
2017-04-29 00:20:16 +02:00
Pádraig Brady
efb84214ac nap.h: Fix compilation on non windows platforms
* tests/nap.h: Move misplaced endif.
2017-04-26 21:47:22 -07:00
Pádraig Brady
94e0157150 time_rz: fix heap buffer overflow vulnerability
This issue has been assigned CVE-2017-7476 and was
detected with American Fuzzy Lop 2.41b run on the
coreutils date(1) program with ASAN enabled.

  ERROR: AddressSanitizer: heap-buffer-overflow on address 0x...
  WRITE of size 8 at 0x60d00000cff8 thread T0
  #1 0x443020 in extend_abbrs lib/time_rz.c:88
  #2 0x443356 in save_abbr lib/time_rz.c:155
  #3 0x44393f in localtime_rz lib/time_rz.c:290
  #4 0x41e4fe in parse_datetime2 lib/parse-datetime.y:1798

A minimized reproducer is the following 120 byte TZ value,
which goes beyond the value of ABBR_SIZE_MIN (119) on x86_64.
Extend the aa...b portion to overwrite more of the heap.

  date -d $(printf 'TZ="aaa%020daaaaaab%089d"')

localtime_rz and mktime_z were affected since commit 4bc76593.
parse_datetime was affected since commit 4e6e16b3f.

* lib/time_rz.c (save_abbr): Rearrange the calculation determining
whether there is enough buffer space available.  The rearrangement
ensures we're only dealing with positive numbers, thus avoiding
the problematic promotion of signed to unsigned causing an invalid
comparison when zone_copy is more than ABBR_SIZE_MIN bytes beyond
the start of the buffer.
* tests/test-parse-datetime.c (main): Add a test case written by
Paul Eggert, which overwrites enough of the heap so that
standard glibc will fail with "free(): invalid pointer"
without the patch applied.
Reported and analyzed at https://bugzilla.redhat.com/1444774
2017-04-26 20:32:12 -07:00
Bruno Haible
be36311df5 nap.h: Port to native Windows.
* tests/nap.h (nap_get_stat): Renamed from get_stat. Remove argument fd;
use nap_fd instead. On native Windows, close and reopen nap_fd.
(nap_works): Don't compare the ctimes, because on native Windows, these
are the creation times.
(nap): Update.
2017-04-25 00:02:53 +02:00
Bruno Haible
5f72078b9b nap.h: Fix logic.
* tests/nap.h (nap): Avoid signed integer overflow in loop.
2017-04-25 00:02:34 +02:00
Bruno Haible
430c2ba513 stat-time: Update comments.
* lib/stat-time.h: Fix reference regarding st_ctime on Windows.
* tests/test-utimens-common.h: Add reference regarding st_ctime on
Windows.
2017-04-23 13:18:16 +02:00
Bruno Haible
e27c63878b vasnprintf tests: Avoid warnings.
* tests/test-vasnprintf-posix3.c (test_function, my_asnprintf,
test_vasnprintf, test_asnprintf): Don't define if there's nothing to
test.
2017-04-22 14:51:37 +02:00
Bruno Haible
d44db1a87a sys_file tests: Avoid warning.
* tests/test-sys_file.c (main): Add a default clause to the switch
statement.
2017-04-22 14:43:23 +02:00
Bruno Haible
bc800241b3 quotearg tests: Avoid warnings.
* tests/test-quotearg.c: Don't include test-quotearg.h if ENABLE_NLS is
false.
2017-04-22 14:24:36 +02:00
Bruno Haible
00ab093875 mbrtowc tests: Fix test failures on MSVC 14.
* tests/test-mbrtowc-w32.c (test_one_locale): Accept MSVC's conversion
behaviour for invalid input.
2017-04-21 16:55:49 +02:00
Bruno Haible
a7bd2403d2 verify tests: Fix spurious failure with parallel make.
* gnulib-tool (func_emit_tests_Makefile_am): Emit initialization of
EXTRA_PROGRAMS.
* tests/test-verify.sh: Build test-verify-try.o, not test-verify.o.
* tests/test-verify-try.c: New file.
* modules/verify-tests (Files): Add it.
(EXTRA_PROGRAMS): Add test-verify-try.
(MOSTLYCLEANFILES): Update accordingly.
Reported by Adam James Stewart <ajstewart@anl.gov>.
2017-04-20 21:29:01 +02:00
Paul Eggert
92869ecaba stdalign: tweak version# and test for HP-UX IA64
Problems reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00078.html
* lib/stdalign.in.h (_Alignas):
* m4/stdalign.m4 (gl_STDALIGN_H):
Use octal, not decimal, for __HP_cc version.  Perhaps HP formerly
used octal (as that is how they document it), but it is decimal in
practice now and the ancient implementations no longer matter.
* tests/test-stdalign.c (main) [__HP_cc && __ia64]: Skip test.
2017-03-19 09:34:46 -07:00
Bruno Haible
69fabe9444 Fix test failures on DragonFlyBSD.
* tests/test-localeconv.c (main): Treat DragonFlyBSD like FreeBSD.
* tests/test-select.h (test_bad_fd): Likewise.
* tests/test-get-rusage-data.c (main): Treat DragonFlyBSD like OpenBSD.
2017-03-15 20:32:45 +01:00
Bruno Haible
8250f4c6d0 test-calloc-gnu: Reenable test also for GCC 7.
* tests/test-calloc-gnu.c (eight): New function.
(main): Don't skip test; use eight() instead.
2017-03-05 02:22:19 +01:00
Jim Meyering
26034f242a test-calloc-gnu: port to GCC7
* tests/test-calloc-gnu.c (main) [__GNUC__ >= 7]: Skip a test
that attempts to calloc more than SIZE_MAX bytes, because GCC7
and newer would detect that at compilation time.
2017-03-04 14:51:50 -08:00
Bruno Haible
bc1d4143ae tests: Avoid compiler warning about uses of null_ptr.
* tests/null-ptr.h: New file.
* tests/test-canonicalize.c: Include null-ptr.h.
(null_ptr): Remove function.
* tests/test-canonicalize-lgpl.c: Likewise.
* tests/test-memmem.c: Likewise.
* tests/test-ptsname_r.c: Likewise.
* modules/canonicalize-tests (Files): Add tests/null-ptr.h.
* modules/canonicalize-lgpl-tests: Likewise.
* modules/memmem-tests: Likewise.
* modules/ptsname_r-tests: Likewise.
Reported by Jim Meyering.
2017-03-04 11:25:20 +01:00
Bruno Haible
4c50d77c87 lock tests: Fix test failure on Mac OS X (regression from 2017-01-05).
Reported by Assaf Gordon <assafgordon@gmail.com> via
Pádraig Brady <P@draigBrady.com>.
* tests/test-lock.c: On Mac OS X, use named semaphores, not unnamed
semaphores.
(USE_NAMED_SEMAPHORE, USE_UNNAMED_SEMAPHORE): New macros.
(atomic_int_semaphore): New macro.
2017-03-03 12:13:48 +01:00
Bruno Haible
c1035211b3 perror tests: Tweak for z/OS.
Reported by Daniel Richard G. <skunk@iskunk.org>.
* tests/test-perror.sh: Don't fail z/OS style perror output.
2017-03-01 00:57:33 +01:00
Bruno Haible
6361efe6e2 lock tests: Fix build failure on z/OS.
Reported by Daniel Richard G. <skunk@iskunk.org>.
* modules/lock-tests (configure.ac): Test for <semaphore.h>.
* tests/test-lock.c (USE_SEMAPHORE): Don't set if <semaphore.h> does not
exist.
2017-02-20 22:34:24 +01:00
Paul Eggert
820fa6ad06 xbinary-io: rename from xsetmode
This patch is taken from suggestions by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00060.html
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00061.html
* lib/binary-io.c (__gl_setmode_check): Set errno to EINVAL,
not ENOTTY, when it is an inappropriate device.
* lib/binary-io.h (SET_BINARY): Resurrect.
* lib/xbinary-io.c: Rename from lib/xsetmode.c.
(xset_binary_mode_error): Rename from xsetmode_error.
* lib/xbinary-io.h: Rename from lib/xsetmode.h.
(xset_binary_mode): Rename from xsetmode.
All uses changed.
* modules/xbinary-io: Rename from modules/xsetmode.
Update file names.
* tests/test-binary-io.sh (tmpfiles): Remove no-longer-used file name.
* NEWS: Update to match revised behavior.
2017-02-16 00:19:20 -08:00
Paul Eggert
87c456bf6f tests: Adjust to recent SET_BINARY change
* tests/test-binary-io.c (main):
* tests/test-binary-io.sh: Remove test for SET_BINARY.
* tests/test-closein.c, tests/test-fflush2.c, tests/test-ftell.c:
* tests/test-ftello.c, tests/test-nonblocking-pipe-child.c:
* tests/test-yesno.c: Use set_binary_mode, not SET_BINARY.
2017-02-15 15:33:36 -08:00
Bruno Haible
d66ababa0f times test: Avoid gcc warnings on Linux/x32.
* tests/test-times.c (main): Really cast printf arguments from clock_t
to 'long int'.
2017-02-12 13:05:25 +01:00
Paul Eggert
6e3459356d stddef-tests: port to SIZE_MAX <= INT_MAX
* tests/test-stddef.c: Include <limits.h>, for INT_MAX.
Do not assume that INT_MAX < SIZE_MAX.
2017-02-08 16:42:05 -08:00
Paul Eggert
16f6a8d8d8 Port to PGI 16.10 x86-64
This patch fixes one real bug in gl_anylinked_list2.h, along with
some minor glitches that are not bugs.  It does not silence PGI’s
thousands of bogus warnings when compiling test-intprops.c.
Fortunately, the warnings do not cause a failure.
* lib/c-ctype.h (_C_CTYPE_LOWER_A_THRU_F_N, _C_CTYPE_LOWER_N):
Rename parameter to avoid PGI warning about ‘#define f(n) 'n'’.
My goodness, PGI goes back a long ways - this predates C89!
* lib/gl_anylinked_list2.h (ASYNCSAFE): Fix bug caught by PGI.
For example, ASYNCSAFE (const void *) should expand to
‘const void *volatile’, not to ‘volatile const void *’.
* lib/spawn.in.h (POSIX_SPAWN_USEVFORK): Don't define if already defined.
* lib/verify.h (verify) [!__GNUC__]:
Use shorter albeit meaningless string to bypass silly compiler limits.
* tests/infinity.h (Infinityf, Infinityd, Infinityl) [__PGI]:
* tests/nan.h (NaNf, NaNd, NaNl):
Use static functions to avoid misguided compiler diagnostics.
Is there some reason we don’t use static functions on all platforms?
2017-01-30 18:21:35 -08:00
Paul Eggert
0e68c6a37e strftime: %z is -00 if unknown
* lib/strftime.c (DO_TZ_OFFSET): Omit arg 'negative'; it's now
the caller's responsibility to set 'negative_number'.  All uses changed.
(__strftime_internal): Put '-' before a zero UTC offset if the time
zone abbreviation starts with "-", which is the recently-introduced
tzdb convention for an unknown UTC offset that is arbitrarily set to 0.
* tests/test-strftime.c: Test for this.
2017-01-14 11:36:52 -08:00
Paul Eggert
e89646ad6f maint: time stamp -> timestamp
Use the spelling "timestamp", as that is what POSIX uses.
2017-01-09 11:58:08 -08:00
Paul Eggert
6a15cedb3f localename-tests: port to NetBSD 7
Problem reported by Nelson H. F. Beebe.
* tests/test-localename.c:
Test newlocale and uselocale only if both exist.
2017-01-06 14:14:57 -08:00
Bruno Haible
b20e8afb0b lock tests: Prefer semaphore over mutex.
* tests/test-lock.c (USE_SEMAPHORE): New constant.
(struct atomic_int, init_atomic_int, get_atomic_int_value,
set_atomic_int_value) [USE_SEMAPHORE]: Define using a POSIX semaphore.
Suggested by Torvald Riegel <triegel@redhat.com>.
2017-01-05 23:53:01 +01:00
Bruno Haible
be95b17ae9 lock: Provide guarantee to avoid writer starvation for rwlocks.
The rationale is: 1) Read-preferring read-write locks are prone to
writer starvation if the number of reader threads multiplied by the
percentage of time they have the lock held is too high. 2) Write-
preferring read-write locks are the only reliable way to avoid this.
3) There have been reports of 'test-lock' hanging on glibc systems
http://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00009.html,
and glibc indeed implements read-preferring rwlocks by default, see
http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html
and https://sourceware.org/bugzilla/show_bug.cgi?id=13701 .

* m4/pthread_rwlock_rdlock.m4: New file.
* m4/lock.m4 (gl_LOCK): Invoke gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER.
* lib/glthread/lock.h [USE_POSIX_THREADS]: Test
HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER. Use a different implementation
of rwlock initialization on glibc systems without
HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER. Use a different implementation
of rwlocks altogether on non-glibc systems without
HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER.
[USE_PTH_THREADS]: Use a different implementation of rwlocks altogether.
* lib/glthread/lock.c [USE_POSIX_THREADS]
(glthread_rwlock_init_for_glibc): New function.
[USE_POSIX_THREADS] (glthread_rwlock_rdlock_multithreaded): Update
comment.
[USE_PTH_THREADS]: New implementation of rwlocks.
[USE_WINDOWS_THREADS] (glthread_rwlock_rdlock_func): Prefer writers over
readers.
* modules/lock (Files): Add m4/pthread_rwlock_rdlock.m4.
(Depends-on): Add 'extensions'.
* tests/test-rwlock1.c: New file.
* lock-tests (Files): Add it.
(Depends-on): Add usleep.
(Makefile.am): Add test-rwlock1 to the tests.
2017-01-05 12:51:36 +01:00