aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/explicit_bzero.c48
-rw-r--r--lib/fpending.c4
-rw-r--r--lib/getdtablesize.c2
-rw-r--r--lib/gnulib.mk.in39
-rw-r--r--lib/nstrftime.c (renamed from lib/strftime.c)0
-rw-r--r--lib/stdio-impl.h2
-rw-r--r--lib/string.in.h17
-rw-r--r--lib/xalloc-oversized.h2
8 files changed, 97 insertions, 17 deletions
diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
new file mode 100644
index 00000000000..262c68f9cd6
--- /dev/null
+++ b/lib/explicit_bzero.c
@@ -0,0 +1,48 @@
1/* Erasure of sensitive data, generic implementation.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 3 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* An assembler implementation of explicit_bzero can be created as an
20 assembler alias of an optimized bzero implementation.
21 Architecture-specific implementations also need to define
22 __explicit_bzero_chk. */
23
24#if !_LIBC
25# include <config.h>
26#endif
27
28#include <string.h>
29
30/* glibc-internal users use __explicit_bzero_chk, and explicit_bzero
31 redirects to that. */
32#undef explicit_bzero
33
34/* Set LEN bytes of S to 0. The compiler will not delete a call to
35 this function, even if S is dead after the call. */
36void
37explicit_bzero (void *s, size_t len)
38{
39#ifdef HAVE_EXPLICIT_MEMSET
40 explicit_memset (s, 0, len);
41#else
42 memset (s, '\0', len);
43# ifdef __GNUC__
44 /* Compiler barrier. */
45 asm volatile ("" ::: "memory");
46# endif
47#endif
48}
diff --git a/lib/fpending.c b/lib/fpending.c
index c9b77866858..02602a1c27f 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -41,7 +41,7 @@ __fpending (FILE *fp)
41 return fp->_ptr - fp->_buffer; 41 return fp->_ptr - fp->_buffer;
42#elif defined __minix /* Minix */ 42#elif defined __minix /* Minix */
43 return fp_->_ptr - fp_->_buf; 43 return fp_->_ptr - fp_->_buf;
44#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel */ 44#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
45 return (fp_->_ptr ? fp_->_ptr - fp_->_base : 0); 45 return (fp_->_ptr ? fp_->_ptr - fp_->_base : 0);
46#elif defined __UCLIBC__ /* uClibc */ 46#elif defined __UCLIBC__ /* uClibc */
47 return (fp->__modeflags & __FLAG_WRITING ? fp->__bufpos - fp->__bufstart : 0); 47 return (fp->__modeflags & __FLAG_WRITING ? fp->__bufpos - fp->__bufstart : 0);
@@ -51,8 +51,6 @@ __fpending (FILE *fp)
51 return fp->__bufp - fp->__buffer; 51 return fp->__bufp - fp->__buffer;
52#elif defined EPLAN9 /* Plan9 */ 52#elif defined EPLAN9 /* Plan9 */
53 return fp->wp - fp->buf; 53 return fp->wp - fp->buf;
54#elif defined __VMS /* VMS */
55 return (*fp)->_ptr - (*fp)->_base;
56#else 54#else
57# error "Please port gnulib fpending.c to your platform!" 55# error "Please port gnulib fpending.c to your platform!"
58 return 1; 56 return 1;
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index c356cf4aa97..a0928630fa5 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -1,4 +1,4 @@
1/* getdtablesize() function for platforms that don't have it. 1/* getdtablesize() function: Return maximum possible file descriptor value + 1.
2 Copyright (C) 2008-2017 Free Software Foundation, Inc. 2 Copyright (C) 2008-2017 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index fd0f9e5c780..3e57391372a 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=tzset --avoid=unsetenv --avoid=utime --avoid=utime-h --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 diffseq dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr minmax mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub unlocked-io update-copyright utimens vla warnings 24# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=tzset --avoid=unsetenv --avoid=utime --avoid=utime-h --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 diffseq dtoastr dtotimespec dup2 environ execinfo explicit_bzero faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr minmax mkostemp mktime nstrftime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strtoimax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub unlocked-io update-copyright utimens vla warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -125,6 +125,7 @@ GNULIB_DUP2 = @GNULIB_DUP2@
125GNULIB_DUP3 = @GNULIB_DUP3@ 125GNULIB_DUP3 = @GNULIB_DUP3@
126GNULIB_ENVIRON = @GNULIB_ENVIRON@ 126GNULIB_ENVIRON = @GNULIB_ENVIRON@
127GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ 127GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
128GNULIB_EXPLICIT_BZERO = @GNULIB_EXPLICIT_BZERO@
128GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ 129GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
129GNULIB_FCHDIR = @GNULIB_FCHDIR@ 130GNULIB_FCHDIR = @GNULIB_FCHDIR@
130GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ 131GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
@@ -390,6 +391,7 @@ HAVE_DPRINTF = @HAVE_DPRINTF@
390HAVE_DUP2 = @HAVE_DUP2@ 391HAVE_DUP2 = @HAVE_DUP2@
391HAVE_DUP3 = @HAVE_DUP3@ 392HAVE_DUP3 = @HAVE_DUP3@
392HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ 393HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
394HAVE_EXPLICIT_BZERO = @HAVE_EXPLICIT_BZERO@
393HAVE_FACCESSAT = @HAVE_FACCESSAT@ 395HAVE_FACCESSAT = @HAVE_FACCESSAT@
394HAVE_FCHDIR = @HAVE_FCHDIR@ 396HAVE_FCHDIR = @HAVE_FCHDIR@
395HAVE_FCHMODAT = @HAVE_FCHMODAT@ 397HAVE_FCHMODAT = @HAVE_FCHMODAT@
@@ -1356,6 +1358,17 @@ EXTRA_libgnu_a_SOURCES += execinfo.c
1356endif 1358endif
1357## end gnulib module execinfo 1359## end gnulib module execinfo
1358 1360
1361## begin gnulib module explicit_bzero
1362ifeq (,$(OMIT_GNULIB_MODULE_explicit_bzero))
1363
1364
1365EXTRA_DIST += explicit_bzero.c
1366
1367EXTRA_libgnu_a_SOURCES += explicit_bzero.c
1368
1369endif
1370## end gnulib module explicit_bzero
1371
1359## begin gnulib module faccessat 1372## begin gnulib module faccessat
1360ifeq (,$(OMIT_GNULIB_MODULE_faccessat)) 1373ifeq (,$(OMIT_GNULIB_MODULE_faccessat))
1361 1374
@@ -1798,6 +1811,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
1798endif 1811endif
1799## end gnulib module mktime-internal 1812## end gnulib module mktime-internal
1800 1813
1814## begin gnulib module nstrftime
1815ifeq (,$(OMIT_GNULIB_MODULE_nstrftime))
1816
1817libgnu_a_SOURCES += nstrftime.c
1818
1819EXTRA_DIST += strftime.h
1820
1821endif
1822## end gnulib module nstrftime
1823
1801## begin gnulib module openat-h 1824## begin gnulib module openat-h
1802ifeq (,$(OMIT_GNULIB_MODULE_openat-h)) 1825ifeq (,$(OMIT_GNULIB_MODULE_openat-h))
1803 1826
@@ -2386,16 +2409,6 @@ EXTRA_libgnu_a_SOURCES += stpcpy.c
2386endif 2409endif
2387## end gnulib module stpcpy 2410## end gnulib module stpcpy
2388 2411
2389## begin gnulib module strftime
2390ifeq (,$(OMIT_GNULIB_MODULE_strftime))
2391
2392libgnu_a_SOURCES += strftime.c
2393
2394EXTRA_DIST += strftime.h
2395
2396endif
2397## end gnulib module strftime
2398
2399## begin gnulib module string 2412## begin gnulib module string
2400ifeq (,$(OMIT_GNULIB_MODULE_string)) 2413ifeq (,$(OMIT_GNULIB_MODULE_string))
2401 2414
@@ -2411,6 +2424,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2411 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2424 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2412 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2425 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2413 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ 2426 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
2427 -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GNULIB_EXPLICIT_BZERO)/g' \
2414 -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ 2428 -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
2415 -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ 2429 -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
2416 -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ 2430 -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
@@ -2449,7 +2463,8 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2449 -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ 2463 -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
2450 -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ 2464 -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
2451 < $(srcdir)/string.in.h | \ 2465 < $(srcdir)/string.in.h | \
2452 sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ 2466 sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
2467 -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
2453 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ 2468 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
2454 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ 2469 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
2455 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ 2470 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
diff --git a/lib/strftime.c b/lib/nstrftime.c
index 99bee4ef978..99bee4ef978 100644
--- a/lib/strftime.c
+++ b/lib/nstrftime.c
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 75a945eb724..d5b5943fd7c 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -99,6 +99,8 @@
99 int _file; \ 99 int _file; \
100 unsigned int _flag; \ 100 unsigned int _flag; \
101 } *) fp) 101 } *) fp)
102# elif defined __VMS /* OpenVMS */
103# define fp_ ((struct _iobuf *) fp)
102# else 104# else
103# define fp_ fp 105# define fp_ fp
104# endif 106# endif
diff --git a/lib/string.in.h b/lib/string.in.h
index 9a6b311d007..aaff5638d0f 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -74,6 +74,23 @@
74/* The definition of _GL_WARN_ON_USE is copied here. */ 74/* The definition of _GL_WARN_ON_USE is copied here. */
75 75
76 76
77/* Clear a block of memory. The compiler will not delete a call to
78 this function, even if the block is dead after the call. */
79#if @GNULIB_EXPLICIT_BZERO@
80# if ! @HAVE_EXPLICIT_BZERO@
81_GL_FUNCDECL_SYS (explicit_bzero, void,
82 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
83# endif
84_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
85_GL_CXXALIASWARN (explicit_bzero);
86#elif defined GNULIB_POSIXCHECK
87# undef explicit_bzero
88# if HAVE_RAW_DECL_EXPLICIT_BZERO
89_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
90 "use gnulib module explicit_bzero for portability");
91# endif
92#endif
93
77/* Find the index of the least-significant set bit. */ 94/* Find the index of the least-significant set bit. */
78#if @GNULIB_FFSL@ 95#if @GNULIB_FFSL@
79# if !@HAVE_FFSL@ 96# if !@HAVE_FFSL@
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index ff0efc6ba40..2e09bab0be2 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -44,7 +44,7 @@ typedef size_t __xalloc_count_type;
44#if 7 <= __GNUC__ 44#if 7 <= __GNUC__
45# define xalloc_oversized(n, s) \ 45# define xalloc_oversized(n, s) \
46 __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1) 46 __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
47#elif 5 <= __GNUC__ && !__STRICT_ANSI__ 47#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__
48# define xalloc_oversized(n, s) \ 48# define xalloc_oversized(n, s) \
49 (__builtin_constant_p (n) && __builtin_constant_p (s) \ 49 (__builtin_constant_p (n) && __builtin_constant_p (s) \
50 ? __xalloc_oversized (n, s) \ 50 ? __xalloc_oversized (n, s) \