I have taken you comments into consideration and i have improved the patch.
Please review and comment.Thank you!
On 04/10/2013 04:37 PM, Eduardo Silva wrote:
thanks, some patch comments:
-> strlen("CONTENT_TYPE=application/x-www-form-urlencoded")
for a fixed size string put it in a macro and then you can do
sizeof(MACRO_NAME), on that way the pre-processor of the compiler will
put that length statically and it will not need to perform strlen()
over the same string again and again.
avoid to call snprintf() many times, please also check the
mk_api->str_build() call.
regards,
On Wed, Apr 10, 2013 at 7:19 AM, Denis Mone <[email protected]
<mailto:[email protected]>> wrote:
Hi i find out that the solution i had provided about the #172 bug
(the post array not working) has a leak.
I have provided a patch witch fix it.Please review and comment.
Thank you!
_______________________________________________
Monkey mailing list
[email protected]
<mailto:[email protected]>
http://lists.monkey-project.com/listinfo/monkey
--
Eduardo Silva
http://edsiper.linuxchile.cl
http://www.monkey-project.com
>From a86c225e4b97bacf24c4261f86b9d75486678621 Mon Sep 17 00:00:00 2001
From: Denis Mone <[email protected]>
Date: Wed, 10 Apr 2013 16:08:32 +0300
Subject: [PATCH] Follow up on bug #172. There is a problem with the sr data
structure the sr->content_type.data field contains the
content_type value as well as the content_length value.This
in combination with the SHORTLEN value(64) leads wrong
characters being copied to the content_type ENV variable.
---
plugins/cgi/cgi.c | 6 +++++-
plugins/cgi/cgi.h | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/plugins/cgi/cgi.c b/plugins/cgi/cgi.c
index 48afba9..2c84e7e 100644
--- a/plugins/cgi/cgi.c
+++ b/plugins/cgi/cgi.c
@@ -25,6 +25,9 @@
#include "cgi.h"
+#define CONTENT_TYPE_ENV_STR "CONTENT_TYPE=application/x-www-form-urlencoded"
+
+
MONKEY_PLUGIN("cgi", /* shortname */
"CGI handler", /* name */
VERSION, /* version */
@@ -170,7 +173,8 @@ static int do_cgi(const char *const __restrict__ file,
}
if (sr->content_type.len) {
- snprintf(content_type, SHORTLEN, "CONTENT_TYPE=%s", sr->content_type.data);
+ size_t l = sizeof(CONTENT_TYPE_ENV_STR);
+ snprintf(content_type, l, "CONTENT_TYPE=%s", sr->content_type.data);
env[envpos++] = content_type;
}
diff --git a/plugins/cgi/cgi.h b/plugins/cgi/cgi.h
index f9d89c7..1e41b56 100644
--- a/plugins/cgi/cgi.h
+++ b/plugins/cgi/cgi.h
@@ -35,7 +35,7 @@
enum {
PATHLEN = 1024,
- SHORTLEN = 64;
+ SHORTLEN = 64
};
struct cgi_request {
--
1.7.10.4
_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey