aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2018-06-29 17:31:04 -0700
committerPaul Eggert2018-06-29 17:32:35 -0700
commit35e9dcab5141bf9cae67abe740933fe627ecc371 (patch)
tree2813d1f6340df34a97695874e5546e4b2454d555 /lib
parent2e2811865f0adb6658a87d3581a2dc3a9022f451 (diff)
downloademacs-35e9dcab5141bf9cae67abe740933fe627ecc371.tar.gz
emacs-35e9dcab5141bf9cae67abe740933fe627ecc371.zip
Update from Gnulib
This incorporates: 2018-06-29 regex: glibc does not use intprops.h 2018-06-28 regex: port to recently proposed glibc regex merge 2018-06-25 Continue to use spaces for indentation, not tabs 2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default 2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function 2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi 2018-06-24 maint: clarify comments about sticky EOF 2018-06-24 af_alg: avoid hangs when reading from streams 2018-06-17 crypto: use byteswap 2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi 2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin * build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex: * lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c: * lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c: * lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: * lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4: * m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4: Copy from Gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.c2
-rw-r--r--lib/acl-internal.h6
-rw-r--r--lib/get-permissions.c88
-rw-r--r--lib/getloadavg.c10
-rw-r--r--lib/gettimeofday.c2
-rw-r--r--lib/md5.c18
-rw-r--r--lib/pselect.c4
-rw-r--r--lib/set-permissions.c254
-rw-r--r--lib/sha1.c18
-rw-r--r--lib/sha256.c18
-rw-r--r--lib/sha512.c25
-rw-r--r--lib/time.in.h2
12 files changed, 225 insertions, 222 deletions
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
index 383c5ddb6f6..c62adb0d9d5 100644
--- a/lib/acl-internal.c
+++ b/lib/acl-internal.c
@@ -355,7 +355,7 @@ acl_nontrivial (int count, struct acl_entry *entries)
355 struct acl_entry *ace = &entries[i]; 355 struct acl_entry *ace = &entries[i];
356 356
357 if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP) 357 if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP)
358 return 1; 358 return 1;
359 } 359 }
360 return 0; 360 return 0;
361} 361}
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 6c65e65e5e7..0669d83c469 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -293,10 +293,6 @@ struct permission_context {
293 293
294int get_permissions (const char *, int, mode_t, struct permission_context *); 294int get_permissions (const char *, int, mode_t, struct permission_context *);
295int set_permissions (struct permission_context *, const char *, int); 295int set_permissions (struct permission_context *, const char *, int);
296void free_permission_context (struct permission_context *) 296void free_permission_context (struct permission_context *);
297#if ! (defined USE_ACL && (HAVE_ACL_GET_FILE || defined GETACL))
298 _GL_ATTRIBUTE_CONST
299#endif
300 ;
301 297
302_GL_INLINE_HEADER_END 298_GL_INLINE_HEADER_END
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
index bb1af5dbdfc..83ba2639a17 100644
--- a/lib/get-permissions.c
+++ b/lib/get-permissions.c
@@ -31,7 +31,7 @@
31 31
32int 32int
33get_permissions (const char *name, int desc, mode_t mode, 33get_permissions (const char *name, int desc, mode_t mode,
34 struct permission_context *ctx) 34 struct permission_context *ctx)
35{ 35{
36 memset (ctx, 0, sizeof *ctx); 36 memset (ctx, 0, sizeof *ctx);
37 ctx->mode = mode; 37 ctx->mode = mode;
@@ -57,7 +57,7 @@ get_permissions (const char *name, int desc, mode_t mode,
57 { 57 {
58 ctx->default_acl = acl_get_file (name, ACL_TYPE_DEFAULT); 58 ctx->default_acl = acl_get_file (name, ACL_TYPE_DEFAULT);
59 if (ctx->default_acl == NULL) 59 if (ctx->default_acl == NULL)
60 return -1; 60 return -1;
61 } 61 }
62 62
63# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */ 63# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */
@@ -115,16 +115,16 @@ get_permissions (const char *name, int desc, mode_t mode,
115 int ret; 115 int ret;
116 116
117 if (desc != -1) 117 if (desc != -1)
118 ret = facl (desc, ACE_GETACLCNT, 0, NULL); 118 ret = facl (desc, ACE_GETACLCNT, 0, NULL);
119 else 119 else
120 ret = acl (name, ACE_GETACLCNT, 0, NULL); 120 ret = acl (name, ACE_GETACLCNT, 0, NULL);
121 if (ret < 0) 121 if (ret < 0)
122 { 122 {
123 if (errno == ENOSYS || errno == EINVAL) 123 if (errno == ENOSYS || errno == EINVAL)
124 ret = 0; 124 ret = 0;
125 else 125 else
126 return -1; 126 return -1;
127 } 127 }
128 ctx->ace_count = ret; 128 ctx->ace_count = ret;
129 129
130 if (ctx->ace_count == 0) 130 if (ctx->ace_count == 0)
@@ -138,15 +138,15 @@ get_permissions (const char *name, int desc, mode_t mode,
138 } 138 }
139 139
140 if (desc != -1) 140 if (desc != -1)
141 ret = facl (desc, ACE_GETACL, ctx->ace_count, ctx->ace_entries); 141 ret = facl (desc, ACE_GETACL, ctx->ace_count, ctx->ace_entries);
142 else 142 else
143 ret = acl (name, ACE_GETACL, ctx->ace_count, ctx->ace_entries); 143 ret = acl (name, ACE_GETACL, ctx->ace_count, ctx->ace_entries);
144 if (ret < 0) 144 if (ret < 0)
145 { 145 {
146 if (errno == ENOSYS || errno == EINVAL) 146 if (errno == ENOSYS || errno == EINVAL)
147 { 147 {
148 free (ctx->ace_entries); 148 free (ctx->ace_entries);
149 ctx->ace_entries = NULL; 149 ctx->ace_entries = NULL;
150 ctx->ace_count = 0; 150 ctx->ace_count = 0;
151 break; 151 break;
152 } 152 }
@@ -154,10 +154,10 @@ get_permissions (const char *name, int desc, mode_t mode,
154 return -1; 154 return -1;
155 } 155 }
156 if (ret <= ctx->ace_count) 156 if (ret <= ctx->ace_count)
157 { 157 {
158 ctx->ace_count = ret; 158 ctx->ace_count = ret;
159 break; 159 break;
160 } 160 }
161 /* Huh? The number of ACL entries has increased since the last call. 161 /* Huh? The number of ACL entries has increased since the last call.
162 Repeat. */ 162 Repeat. */
163 free (ctx->ace_entries); 163 free (ctx->ace_entries);
@@ -170,20 +170,20 @@ get_permissions (const char *name, int desc, mode_t mode,
170 int ret; 170 int ret;
171 171
172 if (desc != -1) 172 if (desc != -1)
173 ret = facl (desc, GETACLCNT, 0, NULL); 173 ret = facl (desc, GETACLCNT, 0, NULL);
174 else 174 else
175 ret = acl (name, GETACLCNT, 0, NULL); 175 ret = acl (name, GETACLCNT, 0, NULL);
176 if (ret < 0) 176 if (ret < 0)
177 { 177 {
178 if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP) 178 if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
179 ret = 0; 179 ret = 0;
180 else 180 else
181 return -1; 181 return -1;
182 } 182 }
183 ctx->count = ret; 183 ctx->count = ret;
184 184
185 if (ctx->count == 0) 185 if (ctx->count == 0)
186 break; 186 break;
187 187
188 ctx->entries = (aclent_t *) malloc (ctx->count * sizeof (aclent_t)); 188 ctx->entries = (aclent_t *) malloc (ctx->count * sizeof (aclent_t));
189 if (ctx->entries == NULL) 189 if (ctx->entries == NULL)
@@ -193,26 +193,26 @@ get_permissions (const char *name, int desc, mode_t mode,
193 } 193 }
194 194
195 if (desc != -1) 195 if (desc != -1)
196 ret = facl (desc, GETACL, ctx->count, ctx->entries); 196 ret = facl (desc, GETACL, ctx->count, ctx->entries);
197 else 197 else
198 ret = acl (name, GETACL, ctx->count, ctx->entries); 198 ret = acl (name, GETACL, ctx->count, ctx->entries);
199 if (ret < 0) 199 if (ret < 0)
200 { 200 {
201 if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP) 201 if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
202 { 202 {
203 free (ctx->entries); 203 free (ctx->entries);
204 ctx->entries = NULL; 204 ctx->entries = NULL;
205 ctx->count = 0; 205 ctx->count = 0;
206 break; 206 break;
207 } 207 }
208 else 208 else
209 return -1; 209 return -1;
210 } 210 }
211 if (ret <= ctx->count) 211 if (ret <= ctx->count)
212 { 212 {
213 ctx->count = ret; 213 ctx->count = ret;
214 break; 214 break;
215 } 215 }
216 /* Huh? The number of ACL entries has increased since the last call. 216 /* Huh? The number of ACL entries has increased since the last call.
217 Repeat. */ 217 Repeat. */
218 free (ctx->entries); 218 free (ctx->entries);
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 702338fb9e9..435d10a6b10 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -68,7 +68,7 @@
68 UMAX 68 UMAX
69 UMAX4_3 69 UMAX4_3
70 VMS 70 VMS
71 WINDOWS32 No-op for Windows95/NT. 71 _WIN32 Native Windows (possibly also defined on Cygwin)
72 __linux__ Linux: assumes /proc file system mounted. 72 __linux__ Linux: assumes /proc file system mounted.
73 Support from Michael K. Johnson. 73 Support from Michael K. Johnson.
74 __CYGWIN__ Cygwin emulates linux /proc/loadavg. 74 __CYGWIN__ Cygwin emulates linux /proc/loadavg.
@@ -97,6 +97,10 @@
97 97
98# include "intprops.h" 98# include "intprops.h"
99 99
100# if defined _WIN32 && ! defined __CYGWIN__
101# define WINDOWS32
102# endif
103
100# if !defined (BSD) && defined (ultrix) 104# if !defined (BSD) && defined (ultrix)
101/* Ultrix behaves like BSD on Vaxen. */ 105/* Ultrix behaves like BSD on Vaxen. */
102# define BSD 106# define BSD
@@ -324,7 +328,9 @@
324# define LDAV_SYMBOL "avenrun" 328# define LDAV_SYMBOL "avenrun"
325# endif 329# endif
326 330
327# include <unistd.h> 331# ifdef HAVE_UNISTD_H
332# include <unistd.h>
333# endif
328 334
329/* LOAD_AVE_TYPE should only get defined if we're going to use the 335/* LOAD_AVE_TYPE should only get defined if we're going to use the
330 nlist method. */ 336 nlist method. */
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index d598b2f7f56..fd44f45ca3c 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -45,7 +45,7 @@ initialize (void)
45 if (kernel32 != NULL) 45 if (kernel32 != NULL)
46 { 46 {
47 GetSystemTimePreciseAsFileTimeFunc = 47 GetSystemTimePreciseAsFileTimeFunc =
48 (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime"); 48 (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
49 } 49 }
50 initialized = TRUE; 50 initialized = TRUE;
51} 51}
diff --git a/lib/md5.c b/lib/md5.c
index 577aab46d7a..554d421c7bf 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -52,9 +52,9 @@
52# define md5_buffer __md5_buffer 52# define md5_buffer __md5_buffer
53#endif 53#endif
54 54
55#include <byteswap.h>
55#ifdef WORDS_BIGENDIAN 56#ifdef WORDS_BIGENDIAN
56# define SWAP(n) \ 57# define SWAP(n) bswap_32 (n)
57 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
58#else 58#else
59# define SWAP(n) (n) 59# define SWAP(n) (n)
60#endif 60#endif
@@ -170,6 +170,14 @@ md5_stream (FILE *stream, void *resblock)
170 /* Read block. Take care for partial reads. */ 170 /* Read block. Take care for partial reads. */
171 while (1) 171 while (1)
172 { 172 {
173 /* Either process a partial fread() from this loop,
174 or the fread() in afalg_stream may have gotten EOF.
175 We need to avoid a subsequent fread() as EOF may
176 not be sticky. For details of such systems, see:
177 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
178 if (feof (stream))
179 goto process_partial_block;
180
173 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); 181 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
174 182
175 sum += n; 183 sum += n;
@@ -189,12 +197,6 @@ md5_stream (FILE *stream, void *resblock)
189 } 197 }
190 goto process_partial_block; 198 goto process_partial_block;
191 } 199 }
192
193 /* We've read at least one byte, so ignore errors. But always
194 check for EOF, since feof may be true even though N > 0.
195 Otherwise, we could end up calling fread after EOF. */
196 if (feof (stream))
197 goto process_partial_block;
198 } 200 }
199 201
200 /* Process buffer with BLOCKSIZE bytes. Note that 202 /* Process buffer with BLOCKSIZE bytes. Note that
diff --git a/lib/pselect.c b/lib/pselect.c
index 40758251ef3..33b2719561f 100644
--- a/lib/pselect.c
+++ b/lib/pselect.c
@@ -83,9 +83,9 @@ pselect (int nfds, fd_set *restrict rfds,
83 83
84int 84int
85rpl_pselect (int nfds, fd_set *restrict rfds, 85rpl_pselect (int nfds, fd_set *restrict rfds,
86 fd_set *restrict wfds, fd_set *restrict xfds, 86 fd_set *restrict wfds, fd_set *restrict xfds,
87 struct timespec const *restrict timeout, 87 struct timespec const *restrict timeout,
88 sigset_t const *restrict sigmask) 88 sigset_t const *restrict sigmask)
89{ 89{
90 int i; 90 int i;
91 91
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index 4b7371c9b4b..d42335aa502 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -229,14 +229,14 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
229 if (ret < 0 && errno != EINVAL && errno != ENOTSUP) 229 if (ret < 0 && errno != EINVAL && errno != ENOTSUP)
230 { 230 {
231 if (errno == ENOSYS) 231 if (errno == ENOSYS)
232 { 232 {
233 *must_chmod = true; 233 *must_chmod = true;
234 return 0; 234 return 0;
235 } 235 }
236 return -1; 236 return -1;
237 } 237 }
238 if (ret == 0) 238 if (ret == 0)
239 return 0; 239 return 0;
240 } 240 }
241# endif 241# endif
242 242
@@ -256,18 +256,18 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
256 256
257 if (desc != -1) 257 if (desc != -1)
258 ret = facl (desc, SETACL, 258 ret = facl (desc, SETACL,
259 sizeof (entries) / sizeof (aclent_t), entries); 259 sizeof (entries) / sizeof (aclent_t), entries);
260 else 260 else
261 ret = acl (name, SETACL, 261 ret = acl (name, SETACL,
262 sizeof (entries) / sizeof (aclent_t), entries); 262 sizeof (entries) / sizeof (aclent_t), entries);
263 if (ret < 0) 263 if (ret < 0)
264 { 264 {
265 if (errno == ENOSYS || errno == EOPNOTSUPP) 265 if (errno == ENOSYS || errno == EOPNOTSUPP)
266 { 266 {
267 *must_chmod = true; 267 *must_chmod = true;
268 return 0; 268 return 0;
269 } 269 }
270 return -1; 270 return -1;
271 } 271 }
272 return 0; 272 return 0;
273 } 273 }
@@ -483,7 +483,7 @@ context_acl_from_mode (struct permission_context *ctx)
483 483
484static int 484static int
485set_acls (struct permission_context *ctx, const char *name, int desc, 485set_acls (struct permission_context *ctx, const char *name, int desc,
486 int from_mode, bool *must_chmod, bool *acls_set) 486 int from_mode, bool *must_chmod, bool *acls_set)
487{ 487{
488 int ret = 0; 488 int ret = 0;
489 489
@@ -503,43 +503,43 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
503 if (! ctx->acls_not_supported) 503 if (! ctx->acls_not_supported)
504 { 504 {
505 if (ret == 0 && from_mode) 505 if (ret == 0 && from_mode)
506 { 506 {
507 if (ctx->acl) 507 if (ctx->acl)
508 acl_free (ctx->acl); 508 acl_free (ctx->acl);
509 ctx->acl = acl_from_mode (ctx->mode); 509 ctx->acl = acl_from_mode (ctx->mode);
510 if (ctx->acl == NULL) 510 if (ctx->acl == NULL)
511 ret = -1; 511 ret = -1;
512 } 512 }
513 513
514 if (ret == 0 && ctx->acl) 514 if (ret == 0 && ctx->acl)
515 { 515 {
516 if (HAVE_ACL_SET_FD && desc != -1) 516 if (HAVE_ACL_SET_FD && desc != -1)
517 ret = acl_set_fd (desc, ctx->acl); 517 ret = acl_set_fd (desc, ctx->acl);
518 else 518 else
519 ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl); 519 ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl);
520 if (ret != 0) 520 if (ret != 0)
521 { 521 {
522 if (! acl_errno_valid (errno)) 522 if (! acl_errno_valid (errno))
523 { 523 {
524 ctx->acls_not_supported = true; 524 ctx->acls_not_supported = true;
525 if (from_mode || acl_access_nontrivial (ctx->acl) == 0) 525 if (from_mode || acl_access_nontrivial (ctx->acl) == 0)
526 ret = 0; 526 ret = 0;
527 } 527 }
528 } 528 }
529 else 529 else
530 { 530 {
531 *acls_set = true; 531 *acls_set = true;
532 if (S_ISDIR(ctx->mode)) 532 if (S_ISDIR(ctx->mode))
533 { 533 {
534 if (! from_mode && ctx->default_acl && 534 if (! from_mode && ctx->default_acl &&
535 acl_default_nontrivial (ctx->default_acl)) 535 acl_default_nontrivial (ctx->default_acl))
536 ret = acl_set_file (name, ACL_TYPE_DEFAULT, 536 ret = acl_set_file (name, ACL_TYPE_DEFAULT,
537 ctx->default_acl); 537 ctx->default_acl);
538 else 538 else
539 ret = acl_delete_def_file (name); 539 ret = acl_delete_def_file (name);
540 } 540 }
541 } 541 }
542 } 542 }
543 } 543 }
544 544
545# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */ 545# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */
@@ -573,38 +573,38 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
573 573
574 /* Remove ACLs if the file has ACLs. */ 574 /* Remove ACLs if the file has ACLs. */
575 if (HAVE_ACL_GET_FD && desc != -1) 575 if (HAVE_ACL_GET_FD && desc != -1)
576 acl = acl_get_fd (desc); 576 acl = acl_get_fd (desc);
577 else 577 else
578 acl = acl_get_file (name, ACL_TYPE_EXTENDED); 578 acl = acl_get_file (name, ACL_TYPE_EXTENDED);
579 if (acl) 579 if (acl)
580 { 580 {
581 acl_free (acl); 581 acl_free (acl);
582 582
583 acl = acl_init (0); 583 acl = acl_init (0);
584 if (acl) 584 if (acl)
585 { 585 {
586 if (HAVE_ACL_SET_FD && desc != -1) 586 if (HAVE_ACL_SET_FD && desc != -1)
587 ret = acl_set_fd (desc, acl); 587 ret = acl_set_fd (desc, acl);
588 else 588 else
589 ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl); 589 ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
590 acl_free (acl); 590 acl_free (acl);
591 } 591 }
592 else 592 else
593 ret = -1; 593 ret = -1;
594 } 594 }
595 } 595 }
596 else 596 else
597 { 597 {
598 if (HAVE_ACL_SET_FD && desc != -1) 598 if (HAVE_ACL_SET_FD && desc != -1)
599 ret = acl_set_fd (desc, ctx->acl); 599 ret = acl_set_fd (desc, ctx->acl);
600 else 600 else
601 ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl); 601 ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl);
602 if (ret != 0) 602 if (ret != 0)
603 { 603 {
604 if (! acl_errno_valid (errno) 604 if (! acl_errno_valid (errno)
605 && ! acl_extended_nontrivial (ctx->acl)) 605 && ! acl_extended_nontrivial (ctx->acl))
606 ret = 0; 606 ret = 0;
607 } 607 }
608 } 608 }
609 *acls_set = true; 609 *acls_set = true;
610 610
@@ -626,34 +626,34 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
626 if (ret == 0 && ctx->count) 626 if (ret == 0 && ctx->count)
627 { 627 {
628 if (desc != -1) 628 if (desc != -1)
629 ret = facl (desc, SETACL, ctx->count, ctx->entries); 629 ret = facl (desc, SETACL, ctx->count, ctx->entries);
630 else 630 else
631 ret = acl (name, SETACL, ctx->count, ctx->entries); 631 ret = acl (name, SETACL, ctx->count, ctx->entries);
632 if (ret < 0) 632 if (ret < 0)
633 { 633 {
634 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) 634 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
635 && acl_nontrivial (ctx->count, ctx->entries) == 0) 635 && acl_nontrivial (ctx->count, ctx->entries) == 0)
636 ret = 0; 636 ret = 0;
637 } 637 }
638 else 638 else
639 *acls_set = true; 639 *acls_set = true;
640 } 640 }
641 641
642# ifdef ACE_GETACL 642# ifdef ACE_GETACL
643 if (ret == 0 && ctx->ace_count) 643 if (ret == 0 && ctx->ace_count)
644 { 644 {
645 if (desc != -1) 645 if (desc != -1)
646 ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries); 646 ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
647 else 647 else
648 ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries); 648 ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
649 if (ret < 0) 649 if (ret < 0)
650 { 650 {
651 if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP) 651 if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP)
652 && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0) 652 && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0)
653 ret = 0; 653 ret = 0;
654 } 654 }
655 else 655 else
656 *acls_set = true; 656 *acls_set = true;
657 } 657 }
658# endif 658# endif
659 659
@@ -665,17 +665,17 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
665 if (ret == 0 && ctx->count > 0) 665 if (ret == 0 && ctx->count > 0)
666 { 666 {
667 if (desc != -1) 667 if (desc != -1)
668 ret = fsetacl (desc, ctx->count, ctx->entries); 668 ret = fsetacl (desc, ctx->count, ctx->entries);
669 else 669 else
670 ret = setacl (name, ctx->count, ctx->entries); 670 ret = setacl (name, ctx->count, ctx->entries);
671 if (ret < 0) 671 if (ret < 0)
672 { 672 {
673 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) 673 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
674 && (from_mode || !acl_nontrivial (ctx->count, ctx->entries))) 674 && (from_mode || !acl_nontrivial (ctx->count, ctx->entries)))
675 ret = 0; 675 ret = 0;
676 } 676 }
677 else 677 else
678 *acls_set = true; 678 *acls_set = true;
679 } 679 }
680 680
681# if HAVE_ACLV_H 681# if HAVE_ACLV_H
@@ -686,13 +686,13 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
686 { 686 {
687 ret = acl ((char *) name, ACL_SET, ctx->aclv_count, ctx->aclv_entries); 687 ret = acl ((char *) name, ACL_SET, ctx->aclv_count, ctx->aclv_entries);
688 if (ret < 0) 688 if (ret < 0)
689 { 689 {
690 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) 690 if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
691 && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries))) 691 && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries)))
692 ret = 0; 692 ret = 0;
693 } 693 }
694 else 694 else
695 *acls_set = true; 695 *acls_set = true;
696 } 696 }
697# endif 697# endif
698 698
@@ -711,16 +711,16 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
711 if (ret == 0 && ctx->have_u) 711 if (ret == 0 && ctx->have_u)
712 { 712 {
713 if (desc != -1) 713 if (desc != -1)
714 ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len); 714 ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len);
715 else 715 else
716 ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len); 716 ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len);
717 if (ret < 0) 717 if (ret < 0)
718 { 718 {
719 if (errno == ENOSYS && from_mode) 719 if (errno == ENOSYS && from_mode)
720 ret = 0; 720 ret = 0;
721 } 721 }
722 else 722 else
723 *acls_set = true; 723 *acls_set = true;
724 } 724 }
725 725
726# elif HAVE_ACLSORT /* NonStop Kernel */ 726# elif HAVE_ACLSORT /* NonStop Kernel */
@@ -732,12 +732,12 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
732 { 732 {
733 ret = acl ((char *) name, ACL_SET, ctx->count, ctx->entries); 733 ret = acl ((char *) name, ACL_SET, ctx->count, ctx->entries);
734 if (ret != 0) 734 if (ret != 0)
735 { 735 {
736 if (!acl_nontrivial (ctx->count, ctx->entries)) 736 if (!acl_nontrivial (ctx->count, ctx->entries))
737 ret = 0; 737 ret = 0;
738 } 738 }
739 else 739 else
740 *acls_set = true; 740 *acls_set = true;
741 } 741 }
742 742
743# else /* No ACLs */ 743# else /* No ACLs */
@@ -805,7 +805,7 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
805 { 805 {
806 ret = chmod_or_fchmod (name, desc, ctx->mode); 806 ret = chmod_or_fchmod (name, desc, ctx->mode);
807 if (ret != 0) 807 if (ret != 0)
808 return -1; 808 return -1;
809 } 809 }
810 810
811#if USE_ACL 811#if USE_ACL
@@ -815,18 +815,18 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
815 int saved_errno = ret ? errno : 0; 815 int saved_errno = ret ? errno : 0;
816 816
817 /* If we can't set an acl which we expect to be able to set, try setting 817 /* If we can't set an acl which we expect to be able to set, try setting
818 the permissions to ctx->mode. Due to possible inherited permissions, 818 the permissions to ctx->mode. Due to possible inherited permissions,
819 we cannot simply chmod. */ 819 we cannot simply chmod. */
820 820
821 ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set); 821 ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set);
822 if (! acls_set) 822 if (! acls_set)
823 must_chmod = true; 823 must_chmod = true;
824 824
825 if (saved_errno) 825 if (saved_errno)
826 { 826 {
827 errno = saved_errno; 827 errno = saved_errno;
828 ret = -1; 828 ret = -1;
829 } 829 }
830 } 830 }
831#endif 831#endif
832 832
@@ -837,10 +837,10 @@ set_permissions (struct permission_context *ctx, const char *name, int desc)
837 ret = chmod_or_fchmod (name, desc, ctx->mode); 837 ret = chmod_or_fchmod (name, desc, ctx->mode);
838 838
839 if (saved_errno) 839 if (saved_errno)
840 { 840 {
841 errno = saved_errno; 841 errno = saved_errno;
842 ret = -1; 842 ret = -1;
843 } 843 }
844 } 844 }
845 845
846 return ret; 846 return ret;
diff --git a/lib/sha1.c b/lib/sha1.c
index 8306d887da5..cd79dfa8770 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -37,11 +37,11 @@
37# include "unlocked-io.h" 37# include "unlocked-io.h"
38#endif 38#endif
39 39
40#include <byteswap.h>
40#ifdef WORDS_BIGENDIAN 41#ifdef WORDS_BIGENDIAN
41# define SWAP(n) (n) 42# define SWAP(n) (n)
42#else 43#else
43# define SWAP(n) \ 44# define SWAP(n) bswap_32 (n)
44 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
45#endif 45#endif
46 46
47#define BLOCKSIZE 32768 47#define BLOCKSIZE 32768
@@ -158,6 +158,14 @@ sha1_stream (FILE *stream, void *resblock)
158 /* Read block. Take care for partial reads. */ 158 /* Read block. Take care for partial reads. */
159 while (1) 159 while (1)
160 { 160 {
161 /* Either process a partial fread() from this loop,
162 or the fread() in afalg_stream may have gotten EOF.
163 We need to avoid a subsequent fread() as EOF may
164 not be sticky. For details of such systems, see:
165 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
166 if (feof (stream))
167 goto process_partial_block;
168
161 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); 169 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
162 170
163 sum += n; 171 sum += n;
@@ -177,12 +185,6 @@ sha1_stream (FILE *stream, void *resblock)
177 } 185 }
178 goto process_partial_block; 186 goto process_partial_block;
179 } 187 }
180
181 /* We've read at least one byte, so ignore errors. But always
182 check for EOF, since feof may be true even though N > 0.
183 Otherwise, we could end up calling fread after EOF. */
184 if (feof (stream))
185 goto process_partial_block;
186 } 188 }
187 189
188 /* Process buffer with BLOCKSIZE bytes. Note that 190 /* Process buffer with BLOCKSIZE bytes. Note that
diff --git a/lib/sha256.c b/lib/sha256.c
index a036befcafd..c518517077c 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -36,11 +36,11 @@
36# include "unlocked-io.h" 36# include "unlocked-io.h"
37#endif 37#endif
38 38
39#include <byteswap.h>
39#ifdef WORDS_BIGENDIAN 40#ifdef WORDS_BIGENDIAN
40# define SWAP(n) (n) 41# define SWAP(n) (n)
41#else 42#else
42# define SWAP(n) \ 43# define SWAP(n) bswap_32 (n)
43 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
44#endif 44#endif
45 45
46#define BLOCKSIZE 32768 46#define BLOCKSIZE 32768
@@ -208,6 +208,14 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
208 /* Read block. Take care for partial reads. */ 208 /* Read block. Take care for partial reads. */
209 while (1) 209 while (1)
210 { 210 {
211 /* Either process a partial fread() from this loop,
212 or the fread() in afalg_stream may have gotten EOF.
213 We need to avoid a subsequent fread() as EOF may
214 not be sticky. For details of such systems, see:
215 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
216 if (feof (stream))
217 goto process_partial_block;
218
211 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); 219 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
212 220
213 sum += n; 221 sum += n;
@@ -227,12 +235,6 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
227 } 235 }
228 goto process_partial_block; 236 goto process_partial_block;
229 } 237 }
230
231 /* We've read at least one byte, so ignore errors. But always
232 check for EOF, since feof may be true even though N > 0.
233 Otherwise, we could end up calling fread after EOF. */
234 if (feof (stream))
235 goto process_partial_block;
236 } 238 }
237 239
238 /* Process buffer with BLOCKSIZE bytes. Note that 240 /* Process buffer with BLOCKSIZE bytes. Note that
diff --git a/lib/sha512.c b/lib/sha512.c
index e175e705f52..e854951eb31 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -36,18 +36,11 @@
36# include "unlocked-io.h" 36# include "unlocked-io.h"
37#endif 37#endif
38 38
39#include <byteswap.h>
39#ifdef WORDS_BIGENDIAN 40#ifdef WORDS_BIGENDIAN
40# define SWAP(n) (n) 41# define SWAP(n) (n)
41#else 42#else
42# define SWAP(n) \ 43# define SWAP(n) bswap_64 (n)
43 u64or (u64or (u64or (u64shl (n, 56), \
44 u64shl (u64and (n, u64lo (0x0000ff00)), 40)), \
45 u64or (u64shl (u64and (n, u64lo (0x00ff0000)), 24), \
46 u64shl (u64and (n, u64lo (0xff000000)), 8))), \
47 u64or (u64or (u64and (u64shr (n, 8), u64lo (0xff000000)), \
48 u64and (u64shr (n, 24), u64lo (0x00ff0000))), \
49 u64or (u64and (u64shr (n, 40), u64lo (0x0000ff00)), \
50 u64shr (n, 56))))
51#endif 44#endif
52 45
53#define BLOCKSIZE 32768 46#define BLOCKSIZE 32768
@@ -216,6 +209,14 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
216 /* Read block. Take care for partial reads. */ 209 /* Read block. Take care for partial reads. */
217 while (1) 210 while (1)
218 { 211 {
212 /* Either process a partial fread() from this loop,
213 or the fread() in afalg_stream may have gotten EOF.
214 We need to avoid a subsequent fread() as EOF may
215 not be sticky. For details of such systems, see:
216 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
217 if (feof (stream))
218 goto process_partial_block;
219
219 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); 220 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
220 221
221 sum += n; 222 sum += n;
@@ -235,12 +236,6 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
235 } 236 }
236 goto process_partial_block; 237 goto process_partial_block;
237 } 238 }
238
239 /* We've read at least one byte, so ignore errors. But always
240 check for EOF, since feof may be true even though N > 0.
241 Otherwise, we could end up calling fread after EOF. */
242 if (feof (stream))
243 goto process_partial_block;
244 } 239 }
245 240
246 /* Process buffer with BLOCKSIZE bytes. Note that 241 /* Process buffer with BLOCKSIZE bytes. Note that
diff --git a/lib/time.in.h b/lib/time.in.h
index a2dca89340c..cda16c69d2c 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -212,7 +212,7 @@ _GL_CXXALIASWARN (gmtime_r);
212# define localtime rpl_localtime 212# define localtime rpl_localtime
213# endif 213# endif
214_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) 214_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
215 _GL_ARG_NONNULL ((1))); 215 _GL_ARG_NONNULL ((1)));
216_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); 216_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
217# else 217# else
218_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); 218_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));