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