summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNathan Angelacos <nangel@alpinelinux.org>2010-10-18 00:23:51 +0000
committerNathan Angelacos <nangel@alpinelinux.org>2010-10-18 00:23:51 +0000
commit2051d1173da76d6470663c9ab715638d1c7844e2 (patch)
tree3fcead24b45d9ec340d673d5fbce0197e47e0e8b /src
parentbef8f32c5153ec308aebabc0ad7309dadf8baaa5 (diff)
downloadhaserl-2051d1173da76d6470663c9ab715638d1c7844e2.tar.bz2
haserl-2051d1173da76d6470663c9ab715638d1c7844e2.tar.xz
0.9.27 version
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/haserl.c25
-rw-r--r--src/rfc2388.c13
3 files changed, 33 insertions, 13 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5d38878..cf11ae7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -49,10 +49,10 @@ haserl_SOURCES = common.c common.h sliding_buffer.c sliding_buffer.h \
$(BASHSOURCE) $(LUASOURCE) haserl.c haserl.h
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
#--------- Unit Tests ----------------------
diff --git a/src/haserl.c b/src/haserl.c
index 049e7f9..f1965af 100644
--- a/src/haserl.c
+++ b/src/haserl.c
@@ -269,7 +269,7 @@ myputenv (list_t * cur, char *str, char *prefix)
/* if an array, create a new string with this
* value added to the end of the old value(s)
*/
- temp = xmalloc (strlen (cur->buf) + strlen(entry) - len + 1);
+ temp = xmalloc (strlen (cur->buf) + strlen (entry) - len + 1);
memmove (temp, cur->buf, strlen (cur->buf) + 1);
strcat (temp, "\n");
strcat (temp, str + keylen + 3);
@@ -664,7 +664,16 @@ unlink_uploadlist ()
}
-
+void
+cleanup (void)
+{
+ if (global.uploadlist)
+ {
+ unlink_uploadlist ();
+ free_token_list (global.uploadlist);
+ global.uploadlist = NULL;
+ }
+}
/*-------------------------------------------------------------------------
*
@@ -693,6 +702,11 @@ main (int argc, char *argv[])
list_t *env = NULL;
+ if (atexit (cleanup) != 0)
+ {
+ die_with_message (NULL, NULL, "atexit() failed");
+ }
+
assignGlobalStartupValues ();
#ifndef JUST_LUACSHELL
haserl_buffer_init (&script_text);
@@ -898,13 +912,6 @@ main (int argc, char *argv[])
shell_destroy ();
}
-
- if (global.uploadlist)
- {
- unlink_uploadlist ();
- free_token_list (global.uploadlist);
- }
-
#ifndef JUST_LUACSHELL
/* destroy the script */
buffer_destroy (&script_text);
diff --git a/src/rfc2388.c b/src/rfc2388.c
index b9e8daf..ea1615e 100644
--- a/src/rfc2388.c
+++ b/src/rfc2388.c
@@ -160,6 +160,10 @@ mime_var_putenv (list_t * env, mime_var_t * obj)
haserl_buffer_init (&buf);
if (obj->name)
{
+ /* For file uploads, this creates FORM_foo=tempfile_pathspec.
+ That name can be overwritten by a subsequent foo=/etc/passwd,
+ for instance. This code block is depricated for FILE uploads
+ only. (it is still valid for non-form uploads */
buffer_add (&(obj->value), "", 1);
buffer_add (&buf, obj->name, strlen (obj->name));
buffer_add (&buf, "=", 1);
@@ -171,6 +175,15 @@ mime_var_putenv (list_t * env, mime_var_t * obj)
}
if (obj->filename)
{
+ /* This creates HASERL_foo_path=tempfile_pathspec. */
+ buffer_add (&buf, obj->name, strlen (obj->name));
+ buffer_add (&buf, "_path=", 6);
+ buffer_add (&buf, (char *) obj->value.data,
+ strlen ((char *) obj->value.data) + 1);
+ myputenv (env, (char *) buf.data, "HASERL_");
+ buffer_reset (&buf);
+
+ /* this saves the name of the file the client supplied */
buffer_add (&buf, obj->name, strlen (obj->name));
buffer_add (&buf, "_name=", 6);
buffer_add (&buf, obj->filename, strlen (obj->filename) + 1);