summaryrefslogtreecommitdiff
path: root/source3/web/cgi.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-12-03 17:17:05 -0800
committerJeremy Allison <jra@samba.org>2007-12-03 17:17:05 -0800
commit6f46f75dfc2c80b99a6a5fb277bab456a5fd247b (patch)
tree7fb83fb23d7cdb81efb63de88d92ffe5d032a5f1 /source3/web/cgi.c
parenta22487025d20c6683f24fe3c5bb35b555d064523 (diff)
downloadsamba-6f46f75dfc2c80b99a6a5fb277bab456a5fd247b.tar.gz
samba-6f46f75dfc2c80b99a6a5fb277bab456a5fd247b.tar.bz2
samba-6f46f75dfc2c80b99a6a5fb277bab456a5fd247b.zip
Make strhex_to_str clear on string limits. Remove pstring from web/*.c
Jeremy. (This used to be commit f9c8d62389f8cb47837e5360209936176537df13)
Diffstat (limited to 'source3/web/cgi.c')
-rw-r--r--source3/web/cgi.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index 41ac29be5d..07a6fbcf54 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -173,7 +173,7 @@ void cgi_load_variables(void)
variables[num_variables].name = SMB_STRDUP(tok);
variables[num_variables].value = SMB_STRDUP(p+1);
- if (!variables[num_variables].name ||
+ if (!variables[num_variables].name ||
!variables[num_variables].value)
continue;
@@ -186,32 +186,36 @@ void cgi_load_variables(void)
printf("<!== Commandline var %s has value \"%s\" ==>\n",
variables[num_variables].name,
variables[num_variables].value);
-#endif
+#endif
num_variables++;
if (num_variables == MAX_VARIABLES) break;
}
}
#ifdef DEBUG_COMMENTS
- printf("<!== End dump in cgi_load_variables() ==>\n");
+ printf("<!== End dump in cgi_load_variables() ==>\n");
#endif
/* variables from the client are in UTF-8 - convert them
to our internal unix charset before use */
for (i=0;i<num_variables;i++) {
- pstring dest;
-
- convert_string(CH_UTF8, CH_UNIX,
- variables[i].name, -1,
- dest, sizeof(dest), True);
- free(variables[i].name);
- variables[i].name = SMB_STRDUP(dest);
-
- convert_string(CH_UTF8, CH_UNIX,
+ TALLOC_CTX *frame = talloc_stackframe();
+ char *dest;
+
+ dest = NULL;
+ convert_string_allocate(frame, CH_UTF8, CH_UNIX,
+ variables[i].name, -1,
+ &dest, True);
+ SAFE_FREE(variables[i].name);
+ variables[i].name = SMB_STRDUP(dest ? dest : "");
+
+ dest = NULL;
+ convert_string_allocate(frame, CH_UTF8, CH_UNIX,
variables[i].value, -1,
- dest, sizeof(dest), True);
- free(variables[i].value);
- variables[i].value = SMB_STRDUP(dest);
+ &dest, True);
+ SAFE_FREE(variables[i].value);
+ variables[i].value = SMB_STRDUP(dest ? dest : "");
+ TALLOC_FREE(frame);
}
}
@@ -219,7 +223,7 @@ void cgi_load_variables(void)
/***************************************************************************
find a variable passed via CGI
Doesn't quite do what you think in the case of POST text variables, because
- if they exist they might have a value of "" or even " ", depending on the
+ if they exist they might have a value of "" or even " ", depending on the
browser. Also doesn't allow for variables[] containing multiple variables
with the same name and the same or different values.
***************************************************************************/