diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-06-29 17:31:04 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-06-29 17:32:35 -0700 |
commit | 35e9dcab5141bf9cae67abe740933fe627ecc371 (patch) | |
tree | 2813d1f6340df34a97695874e5546e4b2454d555 /lib/sha256.c | |
parent | 2e2811865f0adb6658a87d3581a2dc3a9022f451 (diff) | |
download | emacs-35e9dcab5141bf9cae67abe740933fe627ecc371.tar.gz |
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/sha256.c')
-rw-r--r-- | lib/sha256.c | 18 |
1 files changed, 10 insertions, 8 deletions
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 |