diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-08-07 07:38:10 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-08-07 07:38:10 +0000 |
commit | 07be6ed3522a165e25ef8b6c563e986d74a3bb42 (patch) | |
tree | f0ef850a206da140fc7ea92db4d9e7706ff74c63 /src | |
parent | b4c86736249bb057b04ea9ee8808a12c62b41463 (diff) | |
download | libmicrohttpd-07be6ed3522a165e25ef8b6c563e986d74a3bb42.tar.gz libmicrohttpd-07be6ed3522a165e25ef8b6c563e986d74a3bb42.zip |
connection.c: try_ready_chunked_body(): microoptimization, additional error checking
Diffstat (limited to 'src')
-rw-r--r-- | src/microhttpd/connection.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 472b4448..87c4c4d7 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -406,7 +406,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
406 | struct MHD_Response *response; | 406 | struct MHD_Response *response; |
407 | size_t size; | 407 | size_t size; |
408 | char cbuf[10]; /* 10: max strlen of "%x\r\n" */ | 408 | char cbuf[10]; /* 10: max strlen of "%x\r\n" */ |
409 | size_t cblen; | 409 | int cblen; |
410 | 410 | ||
411 | response = connection->response; | 411 | response = connection->response; |
412 | if (0 == connection->write_buffer_size) | 412 | if (0 == connection->write_buffer_size) |
@@ -479,11 +479,11 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
479 | } | 479 | } |
480 | if (ret > 0xFFFFFF) | 480 | if (ret > 0xFFFFFF) |
481 | ret = 0xFFFFFF; | 481 | ret = 0xFFFFFF; |
482 | MHD_snprintf_ (cbuf, | 482 | cblen = MHD_snprintf_(cbuf, |
483 | sizeof (cbuf), | 483 | sizeof (cbuf), |
484 | "%X\r\n", (unsigned int) ret); | 484 | "%X\r\n", (unsigned int) ret); |
485 | cblen = strlen (cbuf); | 485 | EXTRA_CHECK(cblen > 0); |
486 | EXTRA_CHECK (cblen <= sizeof (cbuf)); | 486 | EXTRA_CHECK(cblen < sizeof(cbuf)); |
487 | memcpy (&connection->write_buffer[sizeof (cbuf) - cblen], cbuf, cblen); | 487 | memcpy (&connection->write_buffer[sizeof (cbuf) - cblen], cbuf, cblen); |
488 | memcpy (&connection->write_buffer[sizeof (cbuf) + ret], "\r\n", 2); | 488 | memcpy (&connection->write_buffer[sizeof (cbuf) + ret], "\r\n", 2); |
489 | connection->response_write_position += ret; | 489 | connection->response_write_position += ret; |