gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] branch master updated (fc629fac -> c4d1c422


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (fc629fac -> c4d1c422)
Date: Sat, 18 May 2019 12:45:41 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from fc629fac configure: fixed MS Lib utility detection after 
6ef94cf448e11a51c4b24d7347351047c39e3afe
     new e53b8ab4 mhd_limits.h: fixed typo
     new f5b87355 http_compression example: fix compiler warning
     new 84905a4d http_chunked_compression example: clarify and improve 
readability
     new c4d1c422 http_chunked_compression: fixed for non-64bit systems

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/examples/http_chunked_compression.c | 36 ++++++++++++++++++++++++++-------
 src/examples/http_compression.c         |  1 +
 src/microhttpd/mhd_limits.h             |  2 +-
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/examples/http_chunked_compression.c 
b/src/examples/http_chunked_compression.c
index 7ccd535e..9c3f629f 100644
--- a/src/examples/http_chunked_compression.c
+++ b/src/examples/http_chunked_compression.c
@@ -25,6 +25,22 @@
 #include "platform.h"
 #include <zlib.h>
 #include <microhttpd.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif /* HAVE_LIMITS_H */
+#include <stddef.h>
+
+#ifndef SSIZE_MAX
+#ifdef __SSIZE_MAX__
+#define SSIZE_MAX __SSIZE_MAX__
+#elif defined(PTRDIFF_MAX)
+#define SSIZE_MAX PTRDIFF_MAX
+#elif defined(INTPTR_MAX)
+#define SSIZE_MAX INTPTR_MAX
+#else
+#define SSIZE_MAX ((ssize_t)(((size_t)-1)>>1))
+#endif
+#endif /* ! SSIZE_MAX */
 
 #define CHUNK 16384
 
@@ -88,30 +104,36 @@ read_cb (void *cls, uint64_t pos, char *mem, size_t size)
   struct Holder *holder = cls;
   void *src;
   void *buf;
+  ssize_t ret;
+  size_t offset;
+  if (pos > SSIZE_MAX)
+    return MHD_CONTENT_READER_END_WITH_ERROR;
+  offset = (size_t) pos;
   src = malloc (size);
   if (NULL == src)
     return MHD_CONTENT_READER_END_WITH_ERROR;
-  size = fread (src, 1, size, holder->file);
-  if ((ssize_t) size < 0)
+  ret = fread (src, 1, size, holder->file);
+  if (ret < 0)
     {
-      size = MHD_CONTENT_READER_END_WITH_ERROR;
+      ret = MHD_CONTENT_READER_END_WITH_ERROR;
       goto done;
     }
   if (0 == size)
     {
-      size = MHD_CONTENT_READER_END_OF_STREAM;
+      ret = MHD_CONTENT_READER_END_OF_STREAM;
       goto done;
     }
-  if (MHD_YES != compress_buf (&holder->stream, src, size, &pos, &buf, &size, 
holder->buf))
-    size = MHD_CONTENT_READER_END_WITH_ERROR;
+  if (MHD_YES != compress_buf (&holder->stream, src, ret, &offset, &buf, 
&size, holder->buf))
+    ret = MHD_CONTENT_READER_END_WITH_ERROR;
   else
     {
       memcpy (mem, buf, size);
+      ret = size;
     }
   free (buf); /* Buf may be set even on error return. */
 done:
   free (src);
-  return size;
+  return ret;
 }
 
 static void
diff --git a/src/examples/http_compression.c b/src/examples/http_compression.c
index a88be54e..1324fa4d 100644
--- a/src/examples/http_compression.c
+++ b/src/examples/http_compression.c
@@ -101,6 +101,7 @@ ahc_echo (void *cls,
   int comp;
   size_t body_len;
   char *body_str;
+  (void) cls;               /* Unused. Silent compiler warning. */
   (void) url;               /* Unused. Silent compiler warning. */
   (void) version;           /* Unused. Silent compiler warning. */
   (void) upload_data;       /* Unused. Silent compiler warning. */
diff --git a/src/microhttpd/mhd_limits.h b/src/microhttpd/mhd_limits.h
index 1b0f5d7d..40ae2e26 100644
--- a/src/microhttpd/mhd_limits.h
+++ b/src/microhttpd/mhd_limits.h
@@ -108,7 +108,7 @@
 #elif defined(INTPTR_MAX)
 #define SSIZE_MAX INTPTR_MAX
 #else
-#define SSIZE_MAN MHD_SIGNED_TYPE_MAX_(ssize_t)
+#define SSIZE_MAX MHD_SIGNED_TYPE_MAX_(ssize_t)
 #endif
 #endif /* ! SSIZE_MAX */
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]