diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-05-18 13:44:07 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-05-18 13:44:45 +0300 |
commit | c4d1c422f3fa9303e879dd60134394097cc7c8b0 (patch) | |
tree | 995452980647433e6bad0c0f9980888ab3200fb4 /src | |
parent | 84905a4df0448257e846e97eeed8a4d4f3e275bc (diff) | |
download | libmicrohttpd-c4d1c422f3fa9303e879dd60134394097cc7c8b0.tar.gz libmicrohttpd-c4d1c422f3fa9303e879dd60134394097cc7c8b0.zip |
http_chunked_compression: fixed for non-64bit systems
Diffstat (limited to 'src')
-rw-r--r-- | src/examples/http_chunked_compression.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/examples/http_chunked_compression.c b/src/examples/http_chunked_compression.c index 6c55ef5f..9c3f629f 100644 --- a/src/examples/http_chunked_compression.c +++ b/src/examples/http_chunked_compression.c | |||
@@ -25,6 +25,22 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include <zlib.h> | 26 | #include <zlib.h> |
27 | #include <microhttpd.h> | 27 | #include <microhttpd.h> |
28 | #ifdef HAVE_LIMITS_H | ||
29 | #include <limits.h> | ||
30 | #endif /* HAVE_LIMITS_H */ | ||
31 | #include <stddef.h> | ||
32 | |||
33 | #ifndef SSIZE_MAX | ||
34 | #ifdef __SSIZE_MAX__ | ||
35 | #define SSIZE_MAX __SSIZE_MAX__ | ||
36 | #elif defined(PTRDIFF_MAX) | ||
37 | #define SSIZE_MAX PTRDIFF_MAX | ||
38 | #elif defined(INTPTR_MAX) | ||
39 | #define SSIZE_MAX INTPTR_MAX | ||
40 | #else | ||
41 | #define SSIZE_MAX ((ssize_t)(((size_t)-1)>>1)) | ||
42 | #endif | ||
43 | #endif /* ! SSIZE_MAX */ | ||
28 | 44 | ||
29 | #define CHUNK 16384 | 45 | #define CHUNK 16384 |
30 | 46 | ||
@@ -89,6 +105,10 @@ read_cb (void *cls, uint64_t pos, char *mem, size_t size) | |||
89 | void *src; | 105 | void *src; |
90 | void *buf; | 106 | void *buf; |
91 | ssize_t ret; | 107 | ssize_t ret; |
108 | size_t offset; | ||
109 | if (pos > SSIZE_MAX) | ||
110 | return MHD_CONTENT_READER_END_WITH_ERROR; | ||
111 | offset = (size_t) pos; | ||
92 | src = malloc (size); | 112 | src = malloc (size); |
93 | if (NULL == src) | 113 | if (NULL == src) |
94 | return MHD_CONTENT_READER_END_WITH_ERROR; | 114 | return MHD_CONTENT_READER_END_WITH_ERROR; |
@@ -103,7 +123,7 @@ read_cb (void *cls, uint64_t pos, char *mem, size_t size) | |||
103 | ret = MHD_CONTENT_READER_END_OF_STREAM; | 123 | ret = MHD_CONTENT_READER_END_OF_STREAM; |
104 | goto done; | 124 | goto done; |
105 | } | 125 | } |
106 | if (MHD_YES != compress_buf (&holder->stream, src, ret, &pos, &buf, &size, holder->buf)) | 126 | if (MHD_YES != compress_buf (&holder->stream, src, ret, &offset, &buf, &size, holder->buf)) |
107 | ret = MHD_CONTENT_READER_END_WITH_ERROR; | 127 | ret = MHD_CONTENT_READER_END_WITH_ERROR; |
108 | else | 128 | else |
109 | { | 129 | { |