The Samba-Bugzilla – Attachment 12377 Details for
Bug 12157
Coverity and related fixes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fixes for 4.5
v4-5-BZ12157.patch (text/plain), 29.27 KB, created by
Martin Schwenke
on 2016-08-18 05:44:45 UTC
(
hide
)
Description:
Fixes for 4.5
Filename:
MIME Type:
Creator:
Martin Schwenke
Created:
2016-08-18 05:44:45 UTC
Size:
29.27 KB
patch
obsolete
>From f54b4d2671ae0385c8c43a8fe1342138d6b660e0 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 16:42:13 +1000 >Subject: [PATCH 01/17] ctdb-daemon: Fix CID 1272855 Operands don't affect > result > >Failures are already logged at alert/error level above, so just log >the summary at notice level. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit b92c78a043d20d5d94f5dbb0fed750b820b2f248) >--- > ctdb/server/ctdb_ltdb_server.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c >index 6b391b0..8feaff1 100644 >--- a/ctdb/server/ctdb_ltdb_server.c >+++ b/ctdb/server/ctdb_ltdb_server.c >@@ -630,7 +630,7 @@ int ctdb_recheck_persistent_health(struct ctdb_context *ctdb) > ctdb_db->db_path, > ctdb_db->unhealthy_reason)); > } >- DEBUG((fail!=0)?DEBUG_ALERT:DEBUG_NOTICE, >+ DEBUG(DEBUG_NOTICE, > ("ctdb_recheck_persistent_health: OK[%d] FAIL[%d]\n", > ok, fail)); > >-- >2.8.1 > > >From 6ac9fb528cf1f181ed78df6a0879e9905821e841 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 16:46:51 +1000 >Subject: [PATCH 02/17] ctdb-daemon: Fix CID 1125575 Operands don't affect > result > >This is related to an error, so repeatedly log at error level instead >of trying to avoid repetition. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 1be2cd9dd2fc5093121c12aabf25116a840581f8) >--- > ctdb/server/ctdb_monitor.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c >index 87a38c7..00f6524 100644 >--- a/ctdb/server/ctdb_monitor.c >+++ b/ctdb/server/ctdb_monitor.c >@@ -354,7 +354,7 @@ static void ctdb_wait_until_recovered(struct tevent_context *ev, > if (ret != 0) { > ctdb->db_persistent_check_errors++; > if (ctdb->db_persistent_check_errors < ctdb->max_persistent_check_errors) { >- DEBUG(ctdb->db_persistent_check_errors==1?DEBUG_ERR:DEBUG_WARNING, >+ DEBUG(DEBUG_ERR, > (__location__ "ctdb_recheck_persistent_health() " > "failed (%llu of %llu times) - retry later\n", > (unsigned long long)ctdb->db_persistent_check_errors, >-- >2.8.1 > > >From 87840188fe419ff71979216533df1160389301db Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 16:53:54 +1000 >Subject: [PATCH 03/17] ctdb-daemon: Fix CID 1125574 Operands don't affect > result > >Interfaces going up or down are always interesting, so log these at >error level. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 518683abfec163a6186c8502c2f9abae6dccb487) >--- > ctdb/server/ctdb_takeover.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c >index 6d182de..638d18c 100644 >--- a/ctdb/server/ctdb_takeover.c >+++ b/ctdb/server/ctdb_takeover.c >@@ -2364,7 +2364,7 @@ int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb, > return 0; > } > >- DEBUG(iface->link_up?DEBUG_ERR:DEBUG_NOTICE, >+ DEBUG(DEBUG_ERR, > ("iface[%s] has changed it's link status %s => %s\n", > iface->name, > iface->link_up?"up":"down", >-- >2.8.1 > > >From 0ac8bbfe77c91fffd446024dd4aef8aad2fe8d54 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:02:22 +1000 >Subject: [PATCH 04/17] ctdb-tests: Update porting test to be more flexible > about line numbers > >This way the test doesn't need to be changed every time the code is >moved around. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 198ca8839175e93988ee52e033195238064aaba5) >--- > ctdb/tests/cunit/porting_tests_001.sh | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > >diff --git a/ctdb/tests/cunit/porting_tests_001.sh b/ctdb/tests/cunit/porting_tests_001.sh >index 2b03007..98a8af2 100755 >--- a/ctdb/tests/cunit/porting_tests_001.sh >+++ b/ctdb/tests/cunit/porting_tests_001.sh >@@ -11,11 +11,16 @@ remove_socket () > > test_cleanup remove_socket > >+result_filter () >+{ >+ sed -e 's|^\(\.\./common/system_linux\.c\):[0-9][0-9]*|\1:LINE|' >+} >+ > uid=$(id -u) > if [ "$uid" -eq 0 ] ; then >- ok "../common/system_linux.c:607 interface 'fake' not found" >+ ok "../common/system_linux.c:LINE interface 'fake' not found" > else >- ok "../common/system_linux.c:601 failed to open raw socket" >+ ok "../common/system_linux.c:LINE failed to open raw socket" > fi > > unit_test porting_tests --socket=${socket} >-- >2.8.1 > > >From 19b936530784fbfd7f95a47875c0356d2783e314 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Thu, 11 Aug 2016 11:15:58 +1000 >Subject: [PATCH 05/17] ctdb-common: Fix CID 1362729 Unchecked return value > from library > >Drop setting socket non-blocking and close-on-exec. The socket is >closed soon after. Only a single packet is sent, making it almost >impossible for it to block. Also, note that sockets aren't setup this >way for IPv6. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 6d1099a522de129cee8cdf9183ab3aaabe0592db) >--- > ctdb/common/system_aix.c | 3 --- > ctdb/common/system_freebsd.c | 3 --- > ctdb/common/system_gnu.c | 3 --- > ctdb/common/system_kfreebsd.c | 3 --- > ctdb/common/system_linux.c | 3 --- > 5 files changed, 15 deletions(-) > >diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c >index 48cd781..10798a7 100644 >--- a/ctdb/common/system_aix.c >+++ b/ctdb/common/system_aix.c >@@ -143,9 +143,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- set_blocking(s, false); >- set_close_on_exec(s); >- > memset(&ip4pkt, 0, sizeof(ip4pkt)); > ip4pkt.ip.ip_v = 4; > ip4pkt.ip.ip_hl = sizeof(ip4pkt.ip)/4; >diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c >index a03b97a..ca1300a 100644 >--- a/ctdb/common/system_freebsd.c >+++ b/ctdb/common/system_freebsd.c >@@ -180,9 +180,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- set_blocking(s, false); >- set_close_on_exec(s); >- > ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, > (const struct sockaddr *)&dest->ip, > sizeof(dest->ip)); >diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c >index 09c4ffe..0eed47e 100644 >--- a/ctdb/common/system_gnu.c >+++ b/ctdb/common/system_gnu.c >@@ -178,9 +178,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- set_blocking(s, false); >- set_close_on_exec(s); >- > ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip)); > close(s); > if (ret != sizeof(ip4pkt)) { >diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c >index 56f7c1c..87624d6 100644 >--- a/ctdb/common/system_kfreebsd.c >+++ b/ctdb/common/system_kfreebsd.c >@@ -178,9 +178,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- set_blocking(s, false); >- set_close_on_exec(s); >- > ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip)); > close(s); > if (ret != sizeof(ip4pkt)) { >diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c >index b66ce67..bf022e3 100644 >--- a/ctdb/common/system_linux.c >+++ b/ctdb/common/system_linux.c >@@ -386,9 +386,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- set_blocking(s, false); >- set_close_on_exec(s); >- > ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, > (const struct sockaddr *)&dest->ip, > sizeof(dest->ip)); >-- >2.8.1 > > >From 153448276dd272c182c7602526b002bc6a06411a Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:04:45 +1000 >Subject: [PATCH 06/17] ctdb-common: Fix CID 1362728 Unchecked return value > from library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 4bc934f13234ece7fae0d533c23fd879e55b8ad2) >--- > ctdb/common/system_linux.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > >diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c >index bf022e3..a036011 100644 >--- a/ctdb/common/system_linux.c >+++ b/ctdb/common/system_linux.c >@@ -455,7 +455,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > */ > int ctdb_sys_open_capture_socket(const char *iface, void **private_data) > { >- int s; >+ int s, ret; > > /* Open a socket to capture all traffic */ > s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); >@@ -466,7 +466,16 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data) > > DEBUG(DEBUG_DEBUG, (__location__ " Created RAW SOCKET FD:%d for tcp tickle\n", s)); > >- set_blocking(s, false); >+ ret = set_blocking(s, false); >+ if (ret != 0) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ " failed to set socket non-blocking (%s)\n", >+ strerror(errno))); >+ close(s); >+ return -1; >+ } >+ > set_close_on_exec(s); > > return s; >-- >2.8.1 > > >From 65dea5842e8b17fdc33c15c654a3007ffff542b5 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:12:21 +1000 >Subject: [PATCH 07/17] ctdb-tcp: Fix CID 1362727 Unchecked return value from > library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit ce451c7cc670dad3066ee11c69245d841662844e) >--- > ctdb/tcp/tcp_connect.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > >diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c >index bd11c80..2aad8c2 100644 >--- a/ctdb/tcp/tcp_connect.c >+++ b/ctdb/tcp/tcp_connect.c >@@ -139,6 +139,7 @@ void ctdb_tcp_node_connect(struct tevent_context *ev, struct tevent_timer *te, > int sockin_size; > int sockout_size; > ctdb_sock_addr sock_out; >+ int ret; > > ctdb_tcp_stop_connection(node); > >@@ -149,7 +150,18 @@ void ctdb_tcp_node_connect(struct tevent_context *ev, struct tevent_timer *te, > DEBUG(DEBUG_ERR, (__location__ " Failed to create socket\n")); > return; > } >- set_blocking(tnode->fd, false); >+ >+ ret = set_blocking(tnode->fd, false); >+ if (ret != 0) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ " failed to set socket non-blocking (%s)\n", >+ strerror(errno))); >+ close(tnode->fd); >+ tnode->fd = -1; >+ return; >+ } >+ > set_close_on_exec(tnode->fd); > > DEBUG(DEBUG_DEBUG, (__location__ " Created TCP SOCKET FD:%d\n", tnode->fd)); >-- >2.8.1 > > >From 0e5d5f829d2bc88f927c9fc2e595a52b279155a1 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Mon, 15 Aug 2016 09:43:46 +1000 >Subject: [PATCH 08/17] ctdb-tcp: Set file descriptor to -1 after close. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 0e737348227252d2c0d1708be40753775a9b17ad) >--- > ctdb/tcp/tcp_connect.c | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c >index 2aad8c2..91da9e4 100644 >--- a/ctdb/tcp/tcp_connect.c >+++ b/ctdb/tcp/tcp_connect.c >@@ -194,6 +194,7 @@ void ctdb_tcp_node_connect(struct tevent_context *ev, struct tevent_timer *te, > DEBUG(DEBUG_ERR, (__location__ " unknown family %u\n", > sock_in.sa.sa_family)); > close(tnode->fd); >+ tnode->fd = -1; > return; > } > >@@ -201,6 +202,7 @@ void ctdb_tcp_node_connect(struct tevent_context *ev, struct tevent_timer *te, > DEBUG(DEBUG_ERR, (__location__ " Failed to bind socket %s(%d)\n", > strerror(errno), errno)); > close(tnode->fd); >+ tnode->fd = -1; > return; > } > >-- >2.8.1 > > >From ccf74752c1b89dfc6b55820c30079a84672b381e Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:16:34 +1000 >Subject: [PATCH 09/17] ctdb-daemon: Fix CID 1362726 Unchecked return value > from library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 0de52420b8735a50e8681655a49c59d3dab8a61f) >--- > ctdb/server/ctdb_daemon.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > >diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c >index 267d899..6c8129c 100644 >--- a/ctdb/server/ctdb_daemon.c >+++ b/ctdb/server/ctdb_daemon.c >@@ -984,6 +984,7 @@ static void ctdb_accept_client(struct tevent_context *ev, > static int ux_socket_bind(struct ctdb_context *ctdb) > { > struct sockaddr_un addr; >+ int ret; > > ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0); > if (ctdb->daemon.sd == -1) { >@@ -1007,7 +1008,15 @@ static int ux_socket_bind(struct ctdb_context *ctdb) > unlink(ctdb->daemon.name); > > set_close_on_exec(ctdb->daemon.sd); >- set_blocking(ctdb->daemon.sd, false); >+ >+ ret = set_blocking(ctdb->daemon.sd, false); >+ if (ret != 0) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ " failed to set socket non-blocking (%s)\n", >+ strerror(errno))); >+ goto failed; >+ } > > if (bind(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { > DEBUG(DEBUG_CRIT,("Unable to bind on ctdb socket '%s'\n", ctdb->daemon.name)); >-- >2.8.1 > > >From 56821eb26b6c4e1093cc170c6634b91cf11666b1 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:18:55 +1000 >Subject: [PATCH 10/17] ctdb-client: Fix CID 1362725 Unchecked return value > from library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 94018302fd75c079369fff9492c1e09408e848af) >--- > ctdb/client/ctdb_client.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > >diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c >index bad38b6..c67eb2c 100644 >--- a/ctdb/client/ctdb_client.c >+++ b/ctdb/client/ctdb_client.c >@@ -276,6 +276,7 @@ done: > int ctdb_socket_connect(struct ctdb_context *ctdb) > { > struct sockaddr_un addr; >+ int ret; > > memset(&addr, 0, sizeof(addr)); > addr.sun_family = AF_UNIX; >@@ -294,7 +295,17 @@ int ctdb_socket_connect(struct ctdb_context *ctdb) > return -1; > } > >- set_blocking(ctdb->daemon.sd, false); >+ ret = set_blocking(ctdb->daemon.sd, false); >+ if (ret != 0) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ " failed to set socket non-blocking (%s)\n", >+ strerror(errno))); >+ close(ctdb->daemon.sd); >+ ctdb->daemon.sd = -1; >+ return -1; >+ } >+ > set_close_on_exec(ctdb->daemon.sd); > > ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd, >-- >2.8.1 > > >From 7a0630544a6cf7b1ff9b8ceeb56647b7cf283b6f Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Mon, 15 Aug 2016 14:50:09 +1000 >Subject: [PATCH 11/17] ctdb-client: Print error message before next syscall to > avoid losing errno > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 1710b14a3cfac8f6e768c51f7a510b4ed6aac5c7) >--- > ctdb/client/ctdb_client.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > >diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c >index c67eb2c..1661d2a 100644 >--- a/ctdb/client/ctdb_client.c >+++ b/ctdb/client/ctdb_client.c >@@ -289,9 +289,12 @@ int ctdb_socket_connect(struct ctdb_context *ctdb) > } > > if (connect(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ "Failed to connect client socket to daemon (%s)\n", >+ strerror(errno))); > close(ctdb->daemon.sd); > ctdb->daemon.sd = -1; >- DEBUG(DEBUG_ERR,(__location__ " Failed to connect client socket to daemon. Errno:%s(%d)\n", strerror(errno), errno)); > return -1; > } > >-- >2.8.1 > > >From 0135629c70947f2f6a84a989d3d098b1416004c7 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:31:52 +1000 >Subject: [PATCH 12/17] ctdb-tcp: Fix CID 1362724 Unchecked return value from > library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit bacf57c0658a220c9da6d2dfdf8dd42b9a491556) >--- > ctdb/tcp/tcp_connect.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > >diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c >index 91da9e4..82f2e74 100644 >--- a/ctdb/tcp/tcp_connect.c >+++ b/ctdb/tcp/tcp_connect.c >@@ -243,6 +243,7 @@ static void ctdb_listen_event(struct tevent_context *ev, struct tevent_fd *fde, > int fd, nodeid; > struct ctdb_incoming *in; > int one = 1; >+ int ret; > > memset(&addr, 0, sizeof(addr)); > len = sizeof(addr); >@@ -261,7 +262,17 @@ static void ctdb_listen_event(struct tevent_context *ev, struct tevent_fd *fde, > in->fd = fd; > in->ctdb = ctdb; > >- set_blocking(in->fd, false); >+ ret = set_blocking(in->fd, false); >+ if (ret != 0) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ " failed to set socket non-blocking (%s)\n", >+ strerror(errno))); >+ close(in->fd); >+ in->fd = -1; >+ return; >+ } >+ > set_close_on_exec(in->fd); > > DEBUG(DEBUG_DEBUG, (__location__ " Created SOCKET FD:%d to incoming ctdb connection\n", fd)); >-- >2.8.1 > > >From f67f77652c2b5b563b5a574e9d02eee05e261e59 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:35:22 +1000 >Subject: [PATCH 13/17] ctdb-daemon: Fix CID 1362723 Unchecked return value > from library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 1de8948cb5f4d904dd0d5520c3f13034ed522cb2) >--- > ctdb/server/ctdb_daemon.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > >diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c >index 6c8129c..47e49df 100644 >--- a/ctdb/server/ctdb_daemon.c >+++ b/ctdb/server/ctdb_daemon.c >@@ -930,6 +930,7 @@ static void ctdb_accept_client(struct tevent_context *ev, > struct ctdb_client *client; > struct ctdb_client_pid_list *client_pid; > pid_t peer_pid = 0; >+ int ret; > > memset(&addr, 0, sizeof(addr)); > len = sizeof(addr); >@@ -938,7 +939,16 @@ static void ctdb_accept_client(struct tevent_context *ev, > return; > } > >- set_blocking(fd, false); >+ ret = set_blocking(fd, false); >+ if (ret != 0) { >+ DEBUG(DEBUG_ERR, >+ (__location__ >+ " failed to set socket non-blocking (%s)\n", >+ strerror(errno))); >+ close(fd); >+ return; >+ } >+ > set_close_on_exec(fd); > > DEBUG(DEBUG_DEBUG,(__location__ " Created SOCKET FD:%d to connected child\n", fd)); >-- >2.8.1 > > >From 6ea86cd2b6d888a59e0824f62255ce71bc7df036 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Wed, 10 Aug 2016 17:45:35 +1000 >Subject: [PATCH 14/17] ctdb-logging: Fix CID 1272823 Unchecked return value > from library > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 254d5545f45f97afc737f00542dff985cd76a08e) >--- > ctdb/server/ctdb_logging_syslog.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > >diff --git a/ctdb/server/ctdb_logging_syslog.c b/ctdb/server/ctdb_logging_syslog.c >index 54643e2..6d84587 100644 >--- a/ctdb/server/ctdb_logging_syslog.c >+++ b/ctdb/server/ctdb_logging_syslog.c >@@ -216,7 +216,13 @@ static int ctdb_log_setup_syslog_un(TALLOC_CTX *mem_ctx, > talloc_free(state); > return save_errno; > } >- set_blocking(state->fd, false); >+ >+ ret = set_blocking(state->fd, false); >+ if (ret != 0) { >+ int save_errno = errno; >+ talloc_free(state); >+ return save_errno; >+ } > > state->hostname = NULL; /* Make this explicit */ > state->format = format_rfc3164; >-- >2.8.1 > > >From ef5b90601dc2c2389877ff901d271644e3e85f77 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Sat, 13 Aug 2016 10:29:15 +1000 >Subject: [PATCH 15/17] ctdb-tools: Fix CID 1125618 String not null terminated > (STRING_NULL) > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit af502fade13652009e3cf523672ab5e320520042) >--- > ctdb/tools/ctdb.c | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c >index efa0f02..d98a80e 100644 >--- a/ctdb/tools/ctdb.c >+++ b/ctdb/tools/ctdb.c >@@ -4235,6 +4235,7 @@ static int control_restoredb(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, > argv[0]); > return ret; > } >+ db_hdr.name[sizeof(db_hdr.name)-1] = '\0'; > > if (db_hdr.version != DB_VERSION) { > fprintf(stderr, >-- >2.8.1 > > >From 3667da4316a9feef4175cf8c56fcdb0ec52d98d3 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Sat, 13 Aug 2016 10:29:24 +1000 >Subject: [PATCH 16/17] ctdb-tools: Consistently use db_name > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >CID 1364703: Resource leak (RESOURCE_LEAK) > >However, this would already be fixed by the fix for CID 1125618, so >this is probably just a minor bug fix. > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 24001891dd3d990bf1096cbdd83df4d7bc823f8d) >--- > ctdb/tools/ctdb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c >index d98a80e..ab9d1bc 100644 >--- a/ctdb/tools/ctdb.c >+++ b/ctdb/tools/ctdb.c >@@ -4256,7 +4256,8 @@ static int control_restoredb(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, > ret = ctdb_attach(ctdb->ev, ctdb->client, TIMEOUT(), db_name, > db_hdr.flags, &db); > if (ret != 0) { >- fprintf(stderr, "Failed to attach to DB %s\n", db_hdr.name); >+ fprintf(stderr, "Failed to attach to DB %s\n", db_name); >+ close(fd); > return ret; > } > >-- >2.8.1 > > >From bd59f96861bbcea2aaf6af66823e33b06a729211 Mon Sep 17 00:00:00 2001 >From: Martin Schwenke <martin@meltin.net> >Date: Mon, 15 Aug 2016 15:22:54 +1000 >Subject: [PATCH 17/17] ctdb-common: Save errno before closing file to keep > debug accurate > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157 > >In the AIX case, also add the close of the file. > >Signed-off-by: Martin Schwenke <martin@meltin.net> >Reviewed-by: Amitay Isaacs <amitay@gmail.com> >(cherry picked from commit 225575e7e7d154ac24fef71e503e0cccd69f7463) >--- > ctdb/common/system_aix.c | 10 +++++++--- > ctdb/common/system_freebsd.c | 9 +++++++-- > ctdb/common/system_gnu.c | 15 +++++++++++---- > ctdb/common/system_kfreebsd.c | 15 +++++++++++---- > ctdb/common/system_linux.c | 9 +++++++-- > 5 files changed, 43 insertions(+), 15 deletions(-) > >diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c >index 10798a7..e44d1d6 100644 >--- a/ctdb/common/system_aix.c >+++ b/ctdb/common/system_aix.c >@@ -118,7 +118,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > struct ip ip; > struct tcphdr tcp; > } ip4pkt; >- >+ int saved_errno; > > /* for now, we only handle AF_INET addresses */ > if (src->ip.sin_family != AF_INET || dest->ip.sin_family != AF_INET) { >@@ -165,9 +165,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > ip4pkt.tcp.th_win = htons(1234); > ip4pkt.tcp.th_sum = tcp_checksum((uint16_t *)&ip4pkt.tcp, sizeof(ip4pkt.tcp), &ip4pkt.ip); > >- ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, (struct sockaddr *)dest, sizeof(*dest)); >+ ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, >+ (struct sockaddr *)dest, sizeof(*dest)); >+ saved_errno = errno; >+ close(s); > if (ret != sizeof(ip4pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > >diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c >index ca1300a..e72fbbd 100644 >--- a/ctdb/common/system_freebsd.c >+++ b/ctdb/common/system_freebsd.c >@@ -137,6 +137,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > struct ip6_hdr ip6; > struct tcphdr tcp; > } ip6pkt; >+ int saved_errno; > > switch (src->ip.sin_family) { > case AF_INET: >@@ -183,9 +184,11 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, > (const struct sockaddr *)&dest->ip, > sizeof(dest->ip)); >+ saved_errno = errno; > close(s); > if (ret != sizeof(ip4pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >@@ -228,11 +231,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, > (const struct sockaddr *)&dest->ip6, > sizeof(dest->ip6)); >+ saved_errno = errno; > tmpdest->ip6.sin6_port = tmpport; > close(s); > > if (ret != sizeof(ip6pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c >index 0eed47e..603345d 100644 >--- a/ctdb/common/system_gnu.c >+++ b/ctdb/common/system_gnu.c >@@ -136,6 +136,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > struct ip6_hdr ip6; > struct tcphdr tcp; > } ip6pkt; >+ int saved_errno; > > switch (src->ip.sin_family) { > case AF_INET: >@@ -178,10 +179,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip)); >+ ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, >+ &dest->ip, sizeof(dest->ip)); >+ saved_errno = errno; > close(s); > if (ret != sizeof(ip4pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >@@ -220,12 +224,15 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > tmpport = tmpdest->ip6.sin6_port; > > tmpdest->ip6.sin6_port = 0; >- ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, &dest->ip6, sizeof(dest->ip6)); >+ ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, >+ &dest->ip6, sizeof(dest->ip6)); >+ saved_errno = errno; > tmpdest->ip6.sin6_port = tmpport; > close(s); > > if (ret != sizeof(ip6pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c >index 87624d6..7e33990 100644 >--- a/ctdb/common/system_kfreebsd.c >+++ b/ctdb/common/system_kfreebsd.c >@@ -136,6 +136,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > struct ip6_hdr ip6; > struct tcphdr tcp; > } ip6pkt; >+ int saved_errno; > > switch (src->ip.sin_family) { > case AF_INET: >@@ -178,10 +179,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > return -1; > } > >- ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip)); >+ ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, >+ &dest->ip, sizeof(dest->ip)); >+ saved_errno = errno; > close(s); > if (ret != sizeof(ip4pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >@@ -220,12 +224,15 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > tmpport = tmpdest->ip6.sin6_port; > > tmpdest->ip6.sin6_port = 0; >- ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, &dest->ip6, sizeof(dest->ip6)); >+ ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, >+ &dest->ip6, sizeof(dest->ip6)); >+ saved_errno = errno; > tmpdest->ip6.sin6_port = tmpport; > close(s); > > if (ret != sizeof(ip6pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c >index a036011..3647de9 100644 >--- a/ctdb/common/system_linux.c >+++ b/ctdb/common/system_linux.c >@@ -344,6 +344,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > struct ip6_hdr ip6; > struct tcphdr tcp; > } ip6pkt; >+ int saved_errno; > > switch (src->ip.sin_family) { > case AF_INET: >@@ -389,9 +390,11 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, > (const struct sockaddr *)&dest->ip, > sizeof(dest->ip)); >+ saved_errno = errno; > close(s); > if (ret != sizeof(ip4pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >@@ -433,11 +436,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, > ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, > (const struct sockaddr *)&dest->ip6, > sizeof(dest->ip6)); >+ saved_errno = errno; > tmpdest->ip6.sin6_port = tmpport; > close(s); > > if (ret != sizeof(ip6pkt)) { >- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno))); >+ DEBUG(DEBUG_ERR, >+ ("Failed sendto (%s)\n", strerror(saved_errno))); > return -1; > } > break; >-- >2.8.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
amitay
:
review+
Actions:
View
Attachments on
bug 12157
: 12377