Compare commits

...
22 Commits
Author SHA1 Message Date
Unbit 0d4172a271 prepare for 2.0 2013-12-30 09:44:59 +01:00
Unbit e842a181aa fixed #478 2013-12-30 06:44:54 +01:00
Unbit 1ba0935579 fixed lua prepare_headers 2013-12-28 18:39:30 +01:00
unbit 920d1e5cfe Merge pull request #497 from xrmx/coverity2812
More coverity fixes
2013-12-28 09:28:31 -08:00
Riccardo Magliocchetti 473b4f1e57 plugins/lua: check return value of uwsgi_response_prepare_headers
Reported by Coverity as CID #1100802
2013-12-28 16:11:59 +01:00
Riccardo Magliocchetti b5c19bc1f8 plugins/php: check return value of uwsgi_response_prepare_headers
Reported by Coverity as CID #1100794
2013-12-28 16:06:58 +01:00
Riccardo Magliocchetti 79222adfe7 plugins/sslrouter: check return value of uwsgi_cr_set_hooks
Reported by Coverity as CID #971229
2013-12-28 15:56:46 +01:00
Riccardo Magliocchetti 8b90efc567 plugins/http: check return value of uwsgi_cr_set_hooks
Reported by Coverity as CID #970970
2013-12-28 15:54:59 +01:00
Riccardo Magliocchetti 4667eedc2b core/static: check return value of uwsgi_response_prepare_headers
Reported by Coverity as CID #970965
2013-12-28 15:49:04 +01:00
Riccardo Magliocchetti 752252c9e4 core/emperor: check return value of uwsgi_stats_str
Reported by Coverity as CID #970959
2013-12-28 15:45:05 +01:00
Unbit 6d91b7317d try to address a strange crash 2013-12-28 07:10:23 +01:00
unbit cddd1148fd Merge pull request #496 from xrmx/coverity2712
More Coverity fixes
2013-12-27 18:02:23 -08:00
Riccardo Magliocchetti c2096e8373 plugins/python: check return value of bind to unix
Reported by Coverity as CID #995784
2013-12-27 19:25:00 +01:00
Riccardo Magliocchetti 4f57ef33af Revert "yaml: fix memory leak"
This reverts commit ba3ac9ad09.

Since it looks like add_export_option does not copy the string we
shouldn't free it.
2013-12-27 19:16:59 +01:00
Riccardo Magliocchetti aa34beade1 core/legion: fix memory leak
Reported by coverity as CID #971022.
2013-12-27 19:09:49 +01:00
Riccardo Magliocchetti 1149e60125 core/subscription: fix memory leak
Reported by Coverity as CID #971040.
2013-12-27 19:06:12 +01:00
Riccardo Magliocchetti 7def85636e linux_ns: fix memory leak
Reported by Coverity as CID #971052.
2013-12-27 18:53:49 +01:00
Riccardo Magliocchetti d44692b268 plugins/xslt: fix compilation
After 594880fb46
2013-12-27 18:50:46 +01:00
Riccardo Magliocchetti 46322b84b4 plugins/python: fix memory leak
Reported by Coverity as CID #971056
2013-12-27 18:45:44 +01:00
Riccardo Magliocchetti 5785c61a13 core/legion: fix memory leak
Reported by Coverity as CID #1010086
2013-12-27 18:24:02 +01:00
Riccardo Magliocchetti 594880fb46 plugins/xslt: fix memory leak on error path
Reported by Coverity as CID #1125165
2013-12-27 18:17:49 +01:00
Unbit 4373306f78 added --declare-option2 2013-12-27 10:45:41 +01:00
17 changed files with 49 additions and 23 deletions
+2 -1
View File
@@ -1746,7 +1746,8 @@ void emperor_send_stats(int fd) {
goto end0;
struct uwsgi_emperor_scanner *ues = emperor_scanners;
while (ues) {
uwsgi_stats_str(us, ues->arg);
if (uwsgi_stats_str(us, ues->arg))
goto end0;
ues = ues->next;
if (ues) {
if (uwsgi_stats_comma(us))
+4 -1
View File
@@ -737,6 +737,7 @@ void uwsgi_legion_add(struct uwsgi_legion *ul) {
int uwsgi_legion_announce(struct uwsgi_legion *ul) {
struct uwsgi_buffer *ub = uwsgi_buffer_new(4096);
unsigned char *encrypted = NULL;
if (uwsgi_buffer_append_keyval(ub, "legion", 6, ul->legion, ul->legion_len))
goto err;
@@ -769,7 +770,7 @@ int uwsgi_legion_announce(struct uwsgi_legion *ul) {
goto err;
}
unsigned char *encrypted = uwsgi_malloc(ub->pos + 4 + EVP_MAX_BLOCK_LENGTH);
encrypted = uwsgi_malloc(ub->pos + 4 + EVP_MAX_BLOCK_LENGTH);
if (EVP_EncryptInit_ex(ul->encrypt_ctx, NULL, NULL, NULL, NULL) <= 0) {
uwsgi_error("[uwsgi-legion] EVP_EncryptInit_ex()");
goto err;
@@ -808,6 +809,7 @@ int uwsgi_legion_announce(struct uwsgi_legion *ul) {
return 0;
err:
uwsgi_buffer_destroy(ub);
free(encrypted);
return -1;
}
@@ -824,6 +826,7 @@ void uwsgi_opt_legion_mcast(char *opt, char *value, void *foobar) {
exit(1);
}
uwsgi_legion_register_node(ul, uwsgi_str(ul->addr));
free(legion);
}
void uwsgi_opt_legion_node(char *opt, char *value, void *foobar) {
+3
View File
@@ -972,6 +972,9 @@ struct uwsgi_stats *uwsgi_master_generate_stats() {
if (uwsgi_stats_keylong_comma(us, "queue", (unsigned long long) uwsgi_sock->queue))
goto end;
if (uwsgi_stats_keylong_comma(us, "max_queue", (unsigned long long) uwsgi_sock->max_queue))
goto end;
if (uwsgi_stats_keylong_comma(us, "shared", (unsigned long long) uwsgi_sock->shared))
goto end;
+2 -1
View File
@@ -450,7 +450,8 @@ int uwsgi_real_file_serve(struct wsgi_request *wsgi_req, char *real_filename, si
if (wsgi_req->if_modified_since_len) {
time_t ims = parse_http_date(wsgi_req->if_modified_since, wsgi_req->if_modified_since_len);
if (st->st_mtime <= ims) {
uwsgi_response_prepare_headers(wsgi_req, "304 Not Modified", 16);
if (uwsgi_response_prepare_headers(wsgi_req, "304 Not Modified", 16))
return -1;
return uwsgi_response_write_headers_do(wsgi_req);
}
}
+1 -2
View File
@@ -855,9 +855,8 @@ void uwsgi_subscribe(char *subscription, uint8_t cmd) {
}
keysize++;
}
free(lines);
}
free(lines);
}
else {
modifier1 = strchr(subscription_key + 1, ',');
+1
View File
@@ -99,6 +99,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"set-ph", required_argument, 0, "set a placeholder", uwsgi_opt_set_placeholder, (void *) 1, UWSGI_OPT_IMMEDIATE},
{"get", required_argument, 0, "print the specified option value and exit", uwsgi_opt_add_string_list, &uwsgi.get_list, UWSGI_OPT_NO_INITIAL},
{"declare-option", required_argument, 0, "declare a new uWSGI custom option", uwsgi_opt_add_custom_option, NULL, UWSGI_OPT_IMMEDIATE},
{"declare-option2", required_argument, 0, "declare a new uWSGI custom option (non-immediate)", uwsgi_opt_add_custom_option, NULL, 0},
{"for", required_argument, 0, "(opt logic) for cycle", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for, UWSGI_OPT_IMMEDIATE},
{"for-glob", required_argument, 0, "(opt logic) for cycle (expand glob)", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for_glob, UWSGI_OPT_IMMEDIATE},
+3 -5
View File
@@ -226,7 +226,7 @@ void uwsgi_yaml_config(char *file, char *magic_table[]) {
current_depth = depth;
// end the parsing cycle
if (in_uwsgi_section)
goto exit;
return;
}
else if (depth > current_depth && !in_uwsgi_section) {
goto next;
@@ -240,7 +240,7 @@ void uwsgi_yaml_config(char *file, char *magic_table[]) {
// skip list and {} defined dict
if (key[0] == '-' || key[0] == '[' || key[0] == '{') {
if (in_uwsgi_section)
goto exit;
return;
goto next;
}
@@ -260,7 +260,7 @@ void uwsgi_yaml_config(char *file, char *magic_table[]) {
val = strstr(key, ":\t");
}
if (!val)
goto exit;
return;
// get the right key
val[0] = 0;
// yeah overengeneering....
@@ -282,8 +282,6 @@ next:
if (colon) colon[0] = ':';
exit:
free(yaml);
}
#endif
+4 -1
View File
@@ -61,6 +61,7 @@ void linux_namespace_start(void *argv) {
for (;;) {
char stack[PTHREAD_STACK_MIN];
int waitpid_status;
char *pid_str = NULL;
uwsgi_log("*** jailing uWSGI in %s ***\n", uwsgi.ns);
int clone_flags = SIGCHLD | CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNS;
if (uwsgi.ns_net) {
@@ -77,10 +78,12 @@ void linux_namespace_start(void *argv) {
exit(1);
}
#endif
pid_str = uwsgi_num2str((int) pid);
// run the post-jail scripts
if (setenv("UWSGI_JAIL_PID", uwsgi_num2str((int) pid), 1)) {
if (setenv("UWSGI_JAIL_PID", pid_str, 1)) {
uwsgi_error("setenv()");
}
free(pid_str);
uwsgi_hooks_run(uwsgi.hook_post_jail, "post-jail", 1);
struct uwsgi_string_list *usl = uwsgi.exec_post_jail;
while(usl) {
+5 -1
View File
@@ -618,6 +618,9 @@ ssize_t http_parse(struct corerouter_peer *main_peer) {
// is it http body ?
if (hr->rnrn == 4) {
// something bad happened in keepalive mode...
if (!main_peer->session->peers) return -1;
if (hr->content_length == 0 && !hr->raw_body) {
// ignore data...
main_peer->in->pos = 0;
@@ -871,7 +874,8 @@ int http_alloc_session(struct uwsgi_corerouter *ucr, struct uwsgi_gateway_socket
break;
#endif
default:
uwsgi_cr_set_hooks(cs->main_peer, cs->main_peer->last_hook_read, NULL);
if (uwsgi_cr_set_hooks(cs->main_peer, cs->main_peer->last_hook_read, NULL))
return -1;
cs->close = hr_session_close;
break;
}
+2 -1
View File
@@ -798,7 +798,8 @@ static int uwsgi_lua_request(struct wsgi_request *wsgi_req) {
// send status
if (lua_type(L, -3) == LUA_TSTRING || lua_type(L, -3) == LUA_TNUMBER) {
http = lua_tolstring(L, -3, &slen);
uwsgi_response_prepare_headers(wsgi_req, (char *) http, slen);
if (uwsgi_response_prepare_headers(wsgi_req, (char *) http, slen))
goto clear2;
}
else {
uwsgi_log("[uwsgi-lua] invalid response status !!!\n");
+4 -2
View File
@@ -92,11 +92,13 @@ static int sapi_uwsgi_send_headers(sapi_headers_struct *sapi_headers)
int hrc = SG(sapi_headers).http_response_code;
if (!hrc) hrc = 200;
uwsgi_num2str2n(hrc, status, 4);
uwsgi_response_prepare_headers(wsgi_req, status, 3);
if (uwsgi_response_prepare_headers(wsgi_req, status, 3))
return SAPI_HEADER_SEND_FAILED;
}
else {
char *sl = SG(sapi_headers).http_status_line;
uwsgi_response_prepare_headers(wsgi_req, sl + 9 , strlen(sl + 9));
if (uwsgi_response_prepare_headers(wsgi_req, sl + 9 , strlen(sl + 9)))
return SAPI_HEADER_SEND_FAILED;
}
h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
+3 -1
View File
@@ -1795,7 +1795,8 @@ static void uwsgi_python_harakiri(int wid) {
if (up.tracebacker) {
char buf[8192];
char *address = uwsgi_concat2(up.tracebacker, uwsgi_num2str(wid));
char *wid_str = uwsgi_num2str(wid);
char *address = uwsgi_concat2(up.tracebacker, wid_str);
int fd = uwsgi_connect(address, -1, 0);
if (fd < 1)
@@ -1814,6 +1815,7 @@ static void uwsgi_python_harakiri(int wid) {
cleanup:
close(fd);
exit:
free(wid_str);
free(address);
}
+6
View File
@@ -60,6 +60,12 @@ void *uwsgi_python_tracebacker_thread(void *foobar) {
int current_defer_accept = uwsgi.no_defer_accept;
uwsgi.no_defer_accept = 1;
int fd = bind_to_unix(sock_path, uwsgi.listen_queue, uwsgi.chmod_socket, uwsgi.abstract_socket);
if (fd < 0) {
uwsgi.no_defer_accept = current_defer_accept;
free(str_wid);
free(sock_path);
return NULL;
}
uwsgi.no_defer_accept = current_defer_accept;
PyObject *traceback_module = PyImport_ImportModule("traceback");
+2 -1
View File
@@ -362,7 +362,8 @@ static int sslrouter_alloc_session(struct uwsgi_corerouter *ucr, struct uwsgi_ga
SSL_set_fd(sr->ssl, cs->main_peer->fd);
SSL_set_accept_state(sr->ssl);
uwsgi_cr_set_hooks(cs->main_peer, sr_read, NULL);
if (uwsgi_cr_set_hooks(cs->main_peer, sr_read, NULL))
return -1;
return 0;
}
+5 -4
View File
@@ -134,6 +134,7 @@ static int uwsgi_request_xslt(struct wsgi_request *wsgi_req) {
size_t stylesheet_len = 0;
char *params = NULL;
xmlDoc *doc = NULL;
if (uwsgi_parse_vars(wsgi_req)) {
return -1;
@@ -271,16 +272,16 @@ static int uwsgi_request_xslt(struct wsgi_request *wsgi_req) {
return UWSGI_OK;
apply:
if (wsgi_req->query_string_len > 0) {
params = uwsgi_concat2n(wsgi_req->query_string, wsgi_req->query_string_len, "", 0);
}
// we have both the file and the stylesheet, let's run the engine
xmlDoc *doc = xmlParseFile(xmlfile);
doc = xmlParseFile(xmlfile);
free(xmlfile);
if (!doc) {
uwsgi_500(wsgi_req);
return UWSGI_OK;
}
if (wsgi_req->query_string_len > 0) {
params = uwsgi_concat2n(wsgi_req->query_string, wsgi_req->query_string_len, "", 0);
}
output = uwsgi_xslt_apply(doc, stylesheet, params, &output_rlen);
xmlFreeDoc(doc);
if (params) free(params);
+1 -1
View File
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
s.name = 'uwsgi'
s.license = 'GPL-2'
s.version = `python -c "import uwsgiconfig as uc; print uc.uwsgi_version"`.sub(/-dev-.*/,'')
s.date = '2013-12-11'
s.date = '2013-12-30'
s.summary = "uWSGI"
s.description = "The uWSGI server for Ruby/Rack"
s.authors = ["Unbit"]
+1 -1
View File
@@ -1,6 +1,6 @@
# uWSGI build system
uwsgi_version = '2.0-rc1'
uwsgi_version = '2.0'
import os
import re