diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/acl-internal.c | 2 | ||||
-rw-r--r-- | lib/acl-internal.h | 6 | ||||
-rw-r--r-- | lib/get-permissions.c | 88 | ||||
-rw-r--r-- | lib/getloadavg.c | 10 | ||||
-rw-r--r-- | lib/gettimeofday.c | 2 | ||||
-rw-r--r-- | lib/md5.c | 18 | ||||
-rw-r--r-- | lib/pselect.c | 4 | ||||
-rw-r--r-- | lib/set-permissions.c | 254 | ||||
-rw-r--r-- | lib/sha1.c | 18 | ||||
-rw-r--r-- | lib/sha256.c | 18 | ||||
-rw-r--r-- | lib/sha512.c | 25 | ||||
-rw-r--r-- | lib/time.in.h | 2 |
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) struct acl_entry *ace = &entries[i]; if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP) - return 1; + return 1; } return 0; } 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 { int get_permissions (const char *, int, mode_t, struct permission_context *); int set_permissions (struct permission_context *, const char *, int); -void free_permission_context (struct permission_context *) -#if ! (defined USE_ACL && (HAVE_ACL_GET_FILE || defined GETACL)) - _GL_ATTRIBUTE_CONST -#endif - ; +void free_permission_context (struct permission_context *); _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 @@ int get_permissions (const char *name, int desc, mode_t mode, - struct permission_context *ctx) + struct permission_context *ctx) { memset (ctx, 0, sizeof *ctx); ctx->mode = mode; @@ -57,7 +57,7 @@ get_permissions (const char *name, int desc, mode_t mode, { ctx->default_acl = acl_get_file (name, ACL_TYPE_DEFAULT); if (ctx->default_acl == NULL) - return -1; + return -1; } # if HAVE_ACL_TYPE_NFS4 /* FreeBSD */ @@ -115,16 +115,16 @@ get_permissions (const char *name, int desc, mode_t mode, int ret; if (desc != -1) - ret = facl (desc, ACE_GETACLCNT, 0, NULL); + ret = facl (desc, ACE_GETACLCNT, 0, NULL); else - ret = acl (name, ACE_GETACLCNT, 0, NULL); + ret = acl (name, ACE_GETACLCNT, 0, NULL); if (ret < 0) - { - if (errno == ENOSYS || errno == EINVAL) - ret = 0; - else - return -1; - } + { + if (errno == ENOSYS || errno == EINVAL) + ret = 0; + else + return -1; + } ctx->ace_count = ret; if (ctx->ace_count == 0) @@ -138,15 +138,15 @@ get_permissions (const char *name, int desc, mode_t mode, } if (desc != -1) - ret = facl (desc, ACE_GETACL, ctx->ace_count, ctx->ace_entries); + ret = facl (desc, ACE_GETACL, ctx->ace_count, ctx->ace_entries); else - ret = acl (name, ACE_GETACL, ctx->ace_count, ctx->ace_entries); + ret = acl (name, ACE_GETACL, ctx->ace_count, ctx->ace_entries); if (ret < 0) { if (errno == ENOSYS || errno == EINVAL) { - free (ctx->ace_entries); - ctx->ace_entries = NULL; + free (ctx->ace_entries); + ctx->ace_entries = NULL; ctx->ace_count = 0; break; } @@ -154,10 +154,10 @@ get_permissions (const char *name, int desc, mode_t mode, return -1; } if (ret <= ctx->ace_count) - { - ctx->ace_count = ret; - break; - } + { + ctx->ace_count = ret; + break; + } /* Huh? The number of ACL entries has increased since the last call. Repeat. */ free (ctx->ace_entries); @@ -170,20 +170,20 @@ get_permissions (const char *name, int desc, mode_t mode, int ret; if (desc != -1) - ret = facl (desc, GETACLCNT, 0, NULL); + ret = facl (desc, GETACLCNT, 0, NULL); else - ret = acl (name, GETACLCNT, 0, NULL); + ret = acl (name, GETACLCNT, 0, NULL); if (ret < 0) - { - if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP) - ret = 0; - else - return -1; - } + { + if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP) + ret = 0; + else + return -1; + } ctx->count = ret; if (ctx->count == 0) - break; + break; ctx->entries = (aclent_t *) malloc (ctx->count * sizeof (aclent_t)); if (ctx->entries == NULL) @@ -193,26 +193,26 @@ get_permissions (const char *name, int desc, mode_t mode, } if (desc != -1) - ret = facl (desc, GETACL, ctx->count, ctx->entries); + ret = facl (desc, GETACL, ctx->count, ctx->entries); else - ret = acl (name, GETACL, ctx->count, ctx->entries); + ret = acl (name, GETACL, ctx->count, ctx->entries); if (ret < 0) - { - if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP) - { - free (ctx->entries); - ctx->entries = NULL; - ctx->count = 0; - break; - } - else - return -1; - } + { + if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP) + { + free (ctx->entries); + ctx->entries = NULL; + ctx->count = 0; + break; + } + else + return -1; + } if (ret <= ctx->count) - { - ctx->count = ret; - break; - } + { + ctx->count = ret; + break; + } /* Huh? The number of ACL entries has increased since the last call. Repeat. */ 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 @@ UMAX UMAX4_3 VMS - WINDOWS32 No-op for Windows95/NT. + _WIN32 Native Windows (possibly also defined on Cygwin) __linux__ Linux: assumes /proc file system mounted. Support from Michael K. Johnson. __CYGWIN__ Cygwin emulates linux /proc/loadavg. @@ -97,6 +97,10 @@ # include "intprops.h" +# if defined _WIN32 && ! defined __CYGWIN__ +# define WINDOWS32 +# endif + # if !defined (BSD) && defined (ultrix) /* Ultrix behaves like BSD on Vaxen. */ # define BSD @@ -324,7 +328,9 @@ # define LDAV_SYMBOL "avenrun" # endif -# include <unistd.h> +# ifdef HAVE_UNISTD_H +# include <unistd.h> +# endif /* LOAD_AVE_TYPE should only get defined if we're going to use the 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) if (kernel32 != NULL) { GetSystemTimePreciseAsFileTimeFunc = - (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime"); + (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime"); } initialized = TRUE; } 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 @@ # define md5_buffer __md5_buffer #endif +#include <byteswap.h> #ifdef WORDS_BIGENDIAN -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) +# define SWAP(n) bswap_32 (n) #else # define SWAP(n) (n) #endif @@ -170,6 +170,14 @@ md5_stream (FILE *stream, void *resblock) /* Read block. Take care for partial reads. */ while (1) { + /* Either process a partial fread() from this loop, + or the fread() in afalg_stream may have gotten EOF. + We need to avoid a subsequent fread() as EOF may + not be sticky. For details of such systems, see: + https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */ + if (feof (stream)) + goto process_partial_block; + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; @@ -189,12 +197,6 @@ md5_stream (FILE *stream, void *resblock) } goto process_partial_block; } - - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; } /* 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, int rpl_pselect (int nfds, fd_set *restrict rfds, - fd_set *restrict wfds, fd_set *restrict xfds, + fd_set *restrict wfds, fd_set *restrict xfds, struct timespec const *restrict timeout, - sigset_t const *restrict sigmask) + sigset_t const *restrict sigmask) { int i; 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) if (ret < 0 && errno != EINVAL && errno != ENOTSUP) { if (errno == ENOSYS) - { - *must_chmod = true; - return 0; - } + { + *must_chmod = true; + return 0; + } return -1; } if (ret == 0) - return 0; + return 0; } # endif @@ -256,18 +256,18 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod) if (desc != -1) ret = facl (desc, SETACL, - sizeof (entries) / sizeof (aclent_t), entries); + sizeof (entries) / sizeof (aclent_t), entries); else ret = acl (name, SETACL, - sizeof (entries) / sizeof (aclent_t), entries); + sizeof (entries) / sizeof (aclent_t), entries); if (ret < 0) { - if (errno == ENOSYS || errno == EOPNOTSUPP) - { - *must_chmod = true; - return 0; - } - return -1; + if (errno == ENOSYS || errno == EOPNOTSUPP) + { + *must_chmod = true; + return 0; + } + return -1; } return 0; } @@ -483,7 +483,7 @@ context_acl_from_mode (struct permission_context *ctx) static int set_acls (struct permission_context *ctx, const char *name, int desc, - int from_mode, bool *must_chmod, bool *acls_set) + int from_mode, bool *must_chmod, bool *acls_set) { int ret = 0; @@ -503,43 +503,43 @@ set_acls (struct permission_context *ctx, const char *name, int desc, if (! ctx->acls_not_supported) { if (ret == 0 && from_mode) - { - if (ctx->acl) - acl_free (ctx->acl); - ctx->acl = acl_from_mode (ctx->mode); - if (ctx->acl == NULL) - ret = -1; - } + { + if (ctx->acl) + acl_free (ctx->acl); + ctx->acl = acl_from_mode (ctx->mode); + if (ctx->acl == NULL) + ret = -1; + } if (ret == 0 && ctx->acl) - { - if (HAVE_ACL_SET_FD && desc != -1) - ret = acl_set_fd (desc, ctx->acl); - else - ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl); - if (ret != 0) - { - if (! acl_errno_valid (errno)) - { - ctx->acls_not_supported = true; - if (from_mode || acl_access_nontrivial (ctx->acl) == 0) - ret = 0; - } - } - else - { - *acls_set = true; - if (S_ISDIR(ctx->mode)) - { - if (! from_mode && ctx->default_acl && - acl_default_nontrivial (ctx->default_acl)) - ret = acl_set_file (name, ACL_TYPE_DEFAULT, - ctx->default_acl); - else - ret = acl_delete_def_file (name); - } - } - } + { + if (HAVE_ACL_SET_FD && desc != -1) + ret = acl_set_fd (desc, ctx->acl); + else + ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl); + if (ret != 0) + { + if (! acl_errno_valid (errno)) + { + ctx->acls_not_supported = true; + if (from_mode || acl_access_nontrivial (ctx->acl) == 0) + ret = 0; + } + } + else + { + *acls_set = true; + if (S_ISDIR(ctx->mode)) + { + if (! from_mode && ctx->default_acl && + acl_default_nontrivial (ctx->default_acl)) + ret = acl_set_file (name, ACL_TYPE_DEFAULT, + ctx->default_acl); + else + ret = acl_delete_def_file (name); + } + } + } } # if HAVE_ACL_TYPE_NFS4 /* FreeBSD */ @@ -573,38 +573,38 @@ set_acls (struct permission_context *ctx, const char *name, int desc, /* Remove ACLs if the file has ACLs. */ if (HAVE_ACL_GET_FD && desc != -1) - acl = acl_get_fd (desc); + acl = acl_get_fd (desc); else - acl = acl_get_file (name, ACL_TYPE_EXTENDED); + acl = acl_get_file (name, ACL_TYPE_EXTENDED); if (acl) - { - acl_free (acl); - - acl = acl_init (0); - if (acl) - { - if (HAVE_ACL_SET_FD && desc != -1) - ret = acl_set_fd (desc, acl); - else - ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl); - acl_free (acl); - } - else - ret = -1; - } + { + acl_free (acl); + + acl = acl_init (0); + if (acl) + { + if (HAVE_ACL_SET_FD && desc != -1) + ret = acl_set_fd (desc, acl); + else + ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl); + acl_free (acl); + } + else + ret = -1; + } } else { if (HAVE_ACL_SET_FD && desc != -1) - ret = acl_set_fd (desc, ctx->acl); + ret = acl_set_fd (desc, ctx->acl); else - ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl); + ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl); if (ret != 0) - { - if (! acl_errno_valid (errno) - && ! acl_extended_nontrivial (ctx->acl)) - ret = 0; - } + { + if (! acl_errno_valid (errno) + && ! acl_extended_nontrivial (ctx->acl)) + ret = 0; + } } *acls_set = true; @@ -626,34 +626,34 @@ set_acls (struct permission_context *ctx, const char *name, int desc, if (ret == 0 && ctx->count) { if (desc != -1) - ret = facl (desc, SETACL, ctx->count, ctx->entries); + ret = facl (desc, SETACL, ctx->count, ctx->entries); else - ret = acl (name, SETACL, ctx->count, ctx->entries); + ret = acl (name, SETACL, ctx->count, ctx->entries); if (ret < 0) - { - if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) - && acl_nontrivial (ctx->count, ctx->entries) == 0) - ret = 0; - } + { + if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) + && acl_nontrivial (ctx->count, ctx->entries) == 0) + ret = 0; + } else - *acls_set = true; + *acls_set = true; } # ifdef ACE_GETACL if (ret == 0 && ctx->ace_count) { if (desc != -1) - ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries); + ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries); else - ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries); + ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries); if (ret < 0) - { - if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP) - && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0) - ret = 0; - } + { + if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP) + && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0) + ret = 0; + } else - *acls_set = true; + *acls_set = true; } # endif @@ -665,17 +665,17 @@ set_acls (struct permission_context *ctx, const char *name, int desc, if (ret == 0 && ctx->count > 0) { if (desc != -1) - ret = fsetacl (desc, ctx->count, ctx->entries); + ret = fsetacl (desc, ctx->count, ctx->entries); else - ret = setacl (name, ctx->count, ctx->entries); + ret = setacl (name, ctx->count, ctx->entries); if (ret < 0) - { - if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) - && (from_mode || !acl_nontrivial (ctx->count, ctx->entries))) - ret = 0; - } + { + if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) + && (from_mode || !acl_nontrivial (ctx->count, ctx->entries))) + ret = 0; + } else - *acls_set = true; + *acls_set = true; } # if HAVE_ACLV_H @@ -686,13 +686,13 @@ set_acls (struct permission_context *ctx, const char *name, int desc, { ret = acl ((char *) name, ACL_SET, ctx->aclv_count, ctx->aclv_entries); if (ret < 0) - { - if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) - && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries))) - ret = 0; - } + { + if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) + && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries))) + ret = 0; + } else - *acls_set = true; + *acls_set = true; } # endif @@ -711,16 +711,16 @@ set_acls (struct permission_context *ctx, const char *name, int desc, if (ret == 0 && ctx->have_u) { if (desc != -1) - ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len); + ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len); else - ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len); + ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len); if (ret < 0) - { - if (errno == ENOSYS && from_mode) - ret = 0; - } + { + if (errno == ENOSYS && from_mode) + ret = 0; + } else - *acls_set = true; + *acls_set = true; } # elif HAVE_ACLSORT /* NonStop Kernel */ @@ -732,12 +732,12 @@ set_acls (struct permission_context *ctx, const char *name, int desc, { ret = acl ((char *) name, ACL_SET, ctx->count, ctx->entries); if (ret != 0) - { - if (!acl_nontrivial (ctx->count, ctx->entries)) - ret = 0; - } + { + if (!acl_nontrivial (ctx->count, ctx->entries)) + ret = 0; + } else - *acls_set = true; + *acls_set = true; } # else /* No ACLs */ @@ -805,7 +805,7 @@ set_permissions (struct permission_context *ctx, const char *name, int desc) { ret = chmod_or_fchmod (name, desc, ctx->mode); if (ret != 0) - return -1; + return -1; } #if USE_ACL @@ -815,18 +815,18 @@ set_permissions (struct permission_context *ctx, const char *name, int desc) int saved_errno = ret ? errno : 0; /* If we can't set an acl which we expect to be able to set, try setting - the permissions to ctx->mode. Due to possible inherited permissions, - we cannot simply chmod. */ + the permissions to ctx->mode. Due to possible inherited permissions, + we cannot simply chmod. */ ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set); if (! acls_set) - must_chmod = true; + must_chmod = true; if (saved_errno) - { - errno = saved_errno; - ret = -1; - } + { + errno = saved_errno; + ret = -1; + } } #endif @@ -837,10 +837,10 @@ set_permissions (struct permission_context *ctx, const char *name, int desc) ret = chmod_or_fchmod (name, desc, ctx->mode); if (saved_errno) - { - errno = saved_errno; - ret = -1; - } + { + errno = saved_errno; + ret = -1; + } } 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 @@ # include "unlocked-io.h" #endif +#include <byteswap.h> #ifdef WORDS_BIGENDIAN # define SWAP(n) (n) #else -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) +# define SWAP(n) bswap_32 (n) #endif #define BLOCKSIZE 32768 @@ -158,6 +158,14 @@ sha1_stream (FILE *stream, void *resblock) /* Read block. Take care for partial reads. */ while (1) { + /* Either process a partial fread() from this loop, + or the fread() in afalg_stream may have gotten EOF. + We need to avoid a subsequent fread() as EOF may + not be sticky. For details of such systems, see: + https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */ + if (feof (stream)) + goto process_partial_block; + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; @@ -177,12 +185,6 @@ sha1_stream (FILE *stream, void *resblock) } goto process_partial_block; } - - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; } /* 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 @@ # include "unlocked-io.h" #endif +#include <byteswap.h> #ifdef WORDS_BIGENDIAN # define SWAP(n) (n) #else -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) +# define SWAP(n) bswap_32 (n) #endif #define BLOCKSIZE 32768 @@ -208,6 +208,14 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock, /* Read block. Take care for partial reads. */ while (1) { + /* Either process a partial fread() from this loop, + or the fread() in afalg_stream may have gotten EOF. + We need to avoid a subsequent fread() as EOF may + not be sticky. For details of such systems, see: + https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */ + if (feof (stream)) + goto process_partial_block; + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; @@ -227,12 +235,6 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock, } goto process_partial_block; } - - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; } /* 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 @@ # include "unlocked-io.h" #endif +#include <byteswap.h> #ifdef WORDS_BIGENDIAN # define SWAP(n) (n) #else -# define SWAP(n) \ - u64or (u64or (u64or (u64shl (n, 56), \ - u64shl (u64and (n, u64lo (0x0000ff00)), 40)), \ - u64or (u64shl (u64and (n, u64lo (0x00ff0000)), 24), \ - u64shl (u64and (n, u64lo (0xff000000)), 8))), \ - u64or (u64or (u64and (u64shr (n, 8), u64lo (0xff000000)), \ - u64and (u64shr (n, 24), u64lo (0x00ff0000))), \ - u64or (u64and (u64shr (n, 40), u64lo (0x0000ff00)), \ - u64shr (n, 56)))) +# define SWAP(n) bswap_64 (n) #endif #define BLOCKSIZE 32768 @@ -216,6 +209,14 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock, /* Read block. Take care for partial reads. */ while (1) { + /* Either process a partial fread() from this loop, + or the fread() in afalg_stream may have gotten EOF. + We need to avoid a subsequent fread() as EOF may + not be sticky. For details of such systems, see: + https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */ + if (feof (stream)) + goto process_partial_block; + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; @@ -235,12 +236,6 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock, } goto process_partial_block; } - - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; } /* 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); # define localtime rpl_localtime # endif _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) - _GL_ARG_NONNULL ((1))); + _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); # else _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); |