[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7438 - in libmicrohttpd: . src/daemon
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7438 - in libmicrohttpd: . src/daemon |
Date: |
Wed, 16 Jul 2008 18:51:10 -0600 (MDT) |
Author: grothoff
Date: 2008-07-16 18:51:10 -0600 (Wed, 16 Jul 2008)
New Revision: 7438
Modified:
libmicrohttpd/ChangeLog
libmicrohttpd/src/daemon/connection.c
Log:
bugfix in handling very large chunked data
Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog 2008-07-16 03:12:54 UTC (rev 7437)
+++ libmicrohttpd/ChangeLog 2008-07-17 00:51:10 UTC (rev 7438)
@@ -1,3 +1,7 @@
+Wed Jul 16 18:54:03 MDT 2008
+ Fixed bug generating chunked responses with chunk sizes
+ greater than 0xFFFFFF (would cause protocol violations). -CG
+
Mon May 26 13:28:57 MDT 2008
Updated and improved documentation.
Releasing GNU libmicrohttpd 0.3.1. -CG
Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c 2008-07-16 03:12:54 UTC (rev
7437)
+++ libmicrohttpd/src/daemon/connection.c 2008-07-17 00:51:10 UTC (rev
7438)
@@ -323,7 +323,8 @@
char *buf;
struct MHD_Response *response;
unsigned int size;
- char cbuf[9];
+ char cbuf[10]; /* 10: max strlen of "%x\r\n" */
+ int cblen;
response = connection->response;
if (connection->write_buffer_size == 0)
@@ -353,8 +354,8 @@
ret = response->crc (response->crc_cls,
connection->response_write_position,
- &connection->write_buffer[8],
- connection->write_buffer_size - 8 - 2);
+ &connection->write_buffer[sizeof(cbuf)],
+ connection->write_buffer_size - sizeof(cbuf) - 2);
if (ret == -1)
{
/* end of message, signal other side! */
@@ -371,12 +372,13 @@
}
if (ret > 0xFFFFFF)
ret = 0xFFFFFF;
- snprintf (cbuf, 8, "%X\r\n", ret);
- memcpy (&connection->write_buffer[8 - strlen (cbuf)], cbuf, strlen (cbuf));
- memcpy (&connection->write_buffer[8 + ret], "\r\n", 2);
+ cblen = snprintf (cbuf, sizeof(cbuf), "%X\r\n", ret);
+ EXTRA_CHECK(cblen <= sizeof(cbuf));
+ memcpy (&connection->write_buffer[sizeof(cbuf) - cblen], cbuf, cblen);
+ memcpy (&connection->write_buffer[sizeof(cbuf) + ret], "\r\n", 2);
connection->response_write_position += ret;
- connection->write_buffer_send_offset = 8 - strlen (cbuf);
- connection->write_buffer_append_offset = 8 + ret + 2;
+ connection->write_buffer_send_offset = sizeof(cbuf) - cblen;
+ connection->write_buffer_append_offset = sizeof(cbuf) + ret + 2;
return MHD_YES;
}
@@ -1233,7 +1235,7 @@
}
#if DEBUG_SEND_DATA
fprintf (stderr,
- "Sent HEADER response: `%.*s'\n",
+ "Sent response: `%.*s'\n",
ret,
&connection->write_buffer[connection->write_buffer_send_offset]);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7438 - in libmicrohttpd: . src/daemon,
gnunet <=