[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5577 - libmicrohttpd/src/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5577 - libmicrohttpd/src/daemon |
Date: |
Fri, 31 Aug 2007 14:46:42 -0600 (MDT) |
Author: grothoff
Date: 2007-08-31 14:46:42 -0600 (Fri, 31 Aug 2007)
New Revision: 5577
Modified:
libmicrohttpd/src/daemon/connection.c
libmicrohttpd/src/daemon/internal.h
Log:
fix
Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c 2007-08-31 20:31:52 UTC (rev
5576)
+++ libmicrohttpd/src/daemon/connection.c 2007-08-31 20:46:42 UTC (rev
5577)
@@ -813,11 +813,11 @@
{
buf = MHD_pool_reallocate (connection->pool,
connection->read_buffer,
- connection->read_buffer_size,
+ (connection->read_buffer == NULL) ? 0 :
connection->read_buffer_size + 1,
connection->uploadSize + 1);
if (buf == NULL)
return MHD_NO;
- connection->read_buffer_size = connection->uploadSize + 1;
+ connection->read_buffer_size = connection->uploadSize;
connection->read_buffer = buf;
return MHD_YES;
}
@@ -851,6 +851,9 @@
return MHD_NO;
if (0 == strcasecmp (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, encoding))
{
+ /* add 0-termination, that's why the actual buffer size
+ is always 1 more than what is actually required for the data! */
+ connection->read_buffer[connection->readLoc] = '\0';
ret = parse_arguments (MHD_POSTDATA_KIND,
connection, connection->read_buffer);
/* invalidate read buffer for other uses --
@@ -924,6 +927,10 @@
(connection->uploadSize == -1) && (connection->socket_fd == -1)))
{
connection->bodyReceived = 1;
+ MHD_pool_reallocate(connection->pool,
+ (connection->read_buffer == NULL) ? 0 :
connection->read_buffer_size + 1,
+ connection->read_buffer_size,
+ 0);
connection->readLoc = 0;
connection->read_buffer_size = 0;
connection->read_buffer = NULL;
@@ -959,7 +966,7 @@
connection->read_buffer,
connection->read_buffer_size,
connection->read_buffer_size * 2 +
- MHD_BUF_INC_SIZE);
+ MHD_BUF_INC_SIZE + 1);
if (tmp == NULL)
{
MHD_DLOG (connection->daemon,
Modified: libmicrohttpd/src/daemon/internal.h
===================================================================
--- libmicrohttpd/src/daemon/internal.h 2007-08-31 20:31:52 UTC (rev 5576)
+++ libmicrohttpd/src/daemon/internal.h 2007-08-31 20:46:42 UTC (rev 5577)
@@ -230,7 +230,9 @@
/**
* Buffer for reading requests. Allocated
- * in pool.
+ * in pool. Actually one byte larger than
+ * read_buffer_size (if non-NULL) to allow for
+ * 0-termination.
*/
char *read_buffer;
@@ -253,7 +255,10 @@
pthread_t pid;
/**
- * Size of read_buffer (in bytes).
+ * Size of read_buffer (in bytes). This value indicates
+ * how many bytes we're willing to read into the buffer;
+ * the real buffer is one byte longer to allow for
+ * adding zero-termination (when needed).
*/
size_t read_buffer_size;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5577 - libmicrohttpd/src/daemon,
gnunet <=