summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2c4059f)
raw | patch | inline | side by side (parent: 2c4059f)
author | Florian Forster <octo@huhu.verplant.org> | |
Sat, 4 Sep 2010 20:30:44 +0000 (22:30 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sat, 4 Sep 2010 20:30:44 +0000 (22:30 +0200) |
src/nginx.c | patch | blob | history |
diff --git a/src/nginx.c b/src/nginx.c
index 697684277a153911fdc43474cdc74bdab5b62d1e..36d3d8d2bed85f9de5867f9f381f0102e85f51c0 100644 (file)
--- a/src/nginx.c
+++ b/src/nginx.c
static CURL *curl = NULL;
-#define ABUFFER_SIZE 16384
-static char nginx_buffer[ABUFFER_SIZE];
-static int nginx_buffer_len = 0;
-static char nginx_curl_error[CURL_ERROR_SIZE];
+static char nginx_buffer[16384];
+static size_t nginx_buffer_len = 0;
+static char nginx_curl_error[CURL_ERROR_SIZE];
static const char *config_keys[] =
{
{
size_t len = size * nmemb;
- if ((nginx_buffer_len + len) >= ABUFFER_SIZE)
+ /* Check if the data fits into the memory. If not, truncate it. */
+ if ((nginx_buffer_len + len) >= sizeof (nginx_buffer))
{
- len = (ABUFFER_SIZE - 1) - nginx_buffer_len;
+ assert (sizeof (nginx_buffer) > nginx_buffer_len);
+ len = (sizeof (nginx_buffer) - 1) - nginx_buffer_len;
}
if (len <= 0)
return (len);
- memcpy (nginx_buffer + nginx_buffer_len, (char *) buf, len);
+ memcpy (&nginx_buffer[nginx_buffer_len], buf, len);
nginx_buffer_len += len;
- nginx_buffer[nginx_buffer_len] = '\0';
+ nginx_buffer[nginx_buffer_len] = 0;
return (len);
}