From 4777666588f81684af955b81a34980484de38ed4 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 25 Oct 2013 19:26:58 +0200 Subject: [PATCH 1/6] plugins/rrdtools: don't leak filename Reported by coverity as CID #1112121 --- plugins/rrdtool/rrdtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rrdtool/rrdtool.c b/plugins/rrdtool/rrdtool.c index ff39f8b1..a73eda1c 100644 --- a/plugins/rrdtool/rrdtool.c +++ b/plugins/rrdtool/rrdtool.c @@ -104,8 +104,8 @@ static void rrdtool_post_init() { exit(1); } created++; - free(filename); } + free(filename); um = um->next; } uwsgi_rwunlock(uwsgi.metrics_lock); From be2ed4dc4aa81af69730ecfa8790bf6fd474cdcf Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 25 Oct 2013 19:30:08 +0200 Subject: [PATCH 2/6] core/snmp: fix usage of pointer outside of scope Reported by Coverity as CID #1112122 --- core/snmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/snmp.c b/core/snmp.c index b2ed383f..5cc34ff9 100644 --- a/core/snmp.c +++ b/core/snmp.c @@ -305,6 +305,7 @@ static uint8_t snmp_int_to_snmp(uint64_t snmp_val, uint8_t oid_type, uint8_t * b uint8_t tlen; int i, j; uint8_t *ptr = (uint8_t *) & snmp_val; + int32_t val32 = (int32_t) snmp_val; // check for counter, counter64 or gauge @@ -316,7 +317,6 @@ static uint8_t snmp_int_to_snmp(uint64_t snmp_val, uint8_t oid_type, uint8_t * b } else { tlen = 4; - int32_t val32 = (int32_t) snmp_val; ptr = (uint8_t *) &val32; } From 0e695cbd6efb1a45dec7da1759122e92dcd7974d Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 25 Oct 2013 19:35:38 +0200 Subject: [PATCH 3/6] core/fsmon: fix memory leak Reported by Coverity as CID #1100817 --- core/fsmon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/fsmon.c b/core/fsmon.c index 8a306783..f02043e6 100644 --- a/core/fsmon.c +++ b/core/fsmon.c @@ -38,6 +38,7 @@ void uwsgi_fsmon_setup() { char *space = strchr(copy, ' '); if (!space) { uwsgi_log("[uwsgi-fsmon] invalid syntax: \"%s\"\n", usl->value); + free(copy); goto next; } *space = 0; From 082b178ae3455906998f75b6f203aaf1af77fa43 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 25 Oct 2013 19:41:27 +0200 Subject: [PATCH 4/6] core/io: Fix resource leak Reported by Coverity as CID #1100815 --- core/io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/io.c b/core/io.c index 8db4d433..fe720098 100644 --- a/core/io.c +++ b/core/io.c @@ -364,6 +364,7 @@ static char *uwsgi_scheme_data(char *url, size_t *size, int add_zero) { } } } + close(fd); return buffer; } From 0227ff7a9ba0dd650fdba2768186a36af17b3d8f Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 25 Oct 2013 19:45:51 +0200 Subject: [PATCH 5/6] core/utils: fix resource leak Reported by Coverity as CID #1100814 --- core/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/utils.c b/core/utils.c index 2451d368..3c3c59c7 100644 --- a/core/utils.c +++ b/core/utils.c @@ -4228,6 +4228,7 @@ void uwsgi_envdir(char *edir) { free(content); } + closedir(d); } void uwsgi_envdirs(struct uwsgi_string_list *envdirs) { From c1d9c4ef12960a49f5b81537d301b3e20a616f99 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 25 Oct 2013 19:51:11 +0200 Subject: [PATCH 6/6] core/utils: fix resource leak in uwsgi_write_intfile The more error condition you squeeze in one line the more chances to leak :) Reported by Coverity as CID #1100812 --- core/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/utils.c b/core/utils.c index 3c3c59c7..48071ba8 100644 --- a/core/utils.c +++ b/core/utils.c @@ -3419,7 +3419,11 @@ int uwsgi_write_intfile(char *filename, int n) { uwsgi_error_open(filename); exit(1); } - if (fprintf(pidfile, "%d\n", n) <= 0 || ferror(pidfile) || fclose(pidfile)) { + if (fprintf(pidfile, "%d\n", n) <= 0 || ferror(pidfile)) { + fclose(pidfile); + return -1; + } + if (fclose(pidfile)) { return -1; } return 0;