From 75e953789d8239113c17601a64815b62de77a34de64a9821904324e436627d5c Mon Sep 17 00:00:00 2001 From: Bin Liu Date: Thu, 19 Apr 2018 09:12:27 +0000 Subject: [PATCH] Accepting request 598458 from home:BinLiu:branches:network:ha-clustering:Factory - corosync-2.4.4 is available now(bsc#1089836) man:fix in corosync-qdevice.8 quorumtool: remove duplicated help message cfg: nodeid should be unsigned int coroparse: Use readdir instead of readdir_r wd: fix snprintf warnings Fix compile errors in qdevice on FreeBSD qdevice: mv free(str) after port validation Fix various typos Fix typo: recomended -> recommended man: support SOURCE_DATE_EPOCH configure: add --with-initconfigdir option Use static case blocks to determine distro flavor Use RuntimeDirectory instead of tmpfiles.d coroparse: Do not convert empty uid, gid to 0 sam: Fix snprintf compiler warnings quorumtool: Use full buffer size in snprintf man: Add note about qdevice parallel cmds start sync: Remove unneeded determine sync code sync: Call sync_init of all services at once corosync.conf: publicize nodelist.node.name totemudp[u]: Drop truncated packets on receive logging: Make blackbox configurable logging: Close before and open blackbox after fork init: Quote subshell result properly blackbox: Quote subshell result properly qdevice: quote certutils scripts properly sam_test_agent: Remove unused assignment qdevice: Fix NULL pointer dereference quorumtool: Don't set our_flags without v_handle OBS-URL: https://build.opensuse.org/request/show/598458 OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/corosync?expand=0&rev=143 --- 0002-fix-ifdown-udp.patch | 70 +- 0004-mark-corosync-as-a-static-service.patch | 22 +- 0005-do-not-convert-empty-uid-gid-to-0.patch | 27 +- ...-Fix-compile-warnings-with-GCC-7.2.1.patch | 137 +-- ...> 0007-add-config-for-corosync-qnetd.patch | 0 ...ll-sync_init-of-all-services-at-once.patch | 349 ------ ... 0008-bsc#1083561-upgrade-from-1-x-y.patch | 0 0008-wd-fix-snprintf-warnings.patch | 60 -- ...atch => 0009-bsc#1088619-add-version.patch | 2 +- ...ce-mv-free-str-after-port-validation.patch | 22 - ...-net-instance.c-optarg-should-be-str.patch | 25 + ...sue-with-partial-big-packet-assembly.patch | 159 --- ...-u-Drop-truncated-packets-on-receive.patch | 91 -- 0013-logging-Make-blackbox-configurable.patch | 201 ---- ...-before-and-open-blackbox-after-fork.patch | 61 -- 0015-coverity-fixes.patch | 999 ------------------ ...sync-Integer-overflow-in-totemcrypto.patch | 26 - corosync-2.4.3.tar.gz | 3 - corosync-2.4.4.tar.gz | 3 + corosync.changes | 78 ++ corosync.spec | 30 +- 21 files changed, 190 insertions(+), 2175 deletions(-) rename 0009-add-config-for-corosync-qnetd.patch => 0007-add-config-for-corosync-qnetd.patch (100%) delete mode 100644 0007-sync-Call-sync_init-of-all-services-at-once.patch rename 0016-bsc#1083561-upgrade-from-1-x-y.patch => 0008-bsc#1083561-upgrade-from-1-x-y.patch (100%) delete mode 100644 0008-wd-fix-snprintf-warnings.patch rename 0017-bsc#1088619-add-version.patch => 0009-bsc#1088619-add-version.patch (95%) delete mode 100644 0010-qdevice-mv-free-str-after-port-validation.patch create mode 100644 0010-qdevice-net-instance.c-optarg-should-be-str.patch delete mode 100644 0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch delete mode 100644 0012-totemudp-u-Drop-truncated-packets-on-receive.patch delete mode 100644 0013-logging-Make-blackbox-configurable.patch delete mode 100644 0014-logging-Close-before-and-open-blackbox-after-fork.patch delete mode 100644 0015-coverity-fixes.patch delete mode 100644 0018-bsc#1089346-corosync-Integer-overflow-in-totemcrypto.patch delete mode 100644 corosync-2.4.3.tar.gz create mode 100644 corosync-2.4.4.tar.gz diff --git a/0002-fix-ifdown-udp.patch b/0002-fix-ifdown-udp.patch index 6136092..3a126e7 100644 --- a/0002-fix-ifdown-udp.patch +++ b/0002-fix-ifdown-udp.patch @@ -1,8 +1,17 @@ +From ec2dfbec877fee166b31493e2dba41a850380608 Mon Sep 17 00:00:00 2001 +From: Bin Liu +Date: Tue, 17 Apr 2018 18:04:52 +0800 +Subject: [PATCH] totemudp: Add local loop support for unicast msgs + +--- + exec/totemudp.c | 218 ++++++++++++++++++++++++++++++++------------------------ + 1 file changed, 126 insertions(+), 92 deletions(-) + diff --git a/exec/totemudp.c b/exec/totemudp.c -index 31d05704..47830e4b 100644 +index 4b644ae..ea18897 100644 --- a/exec/totemudp.c +++ b/exec/totemudp.c -@@ -207,8 +207,6 @@ static int totemudp_build_sockets ( +@@ -205,8 +205,6 @@ static int totemudp_build_sockets ( struct totemudp_socket *sockets, struct totem_ip_address *bound_to); @@ -11,15 +20,15 @@ index 31d05704..47830e4b 100644 static void totemudp_instance_initialize (struct totemudp_instance *instance) { memset (instance, 0, sizeof (struct totemudp_instance)); -@@ -269,6 +267,7 @@ static inline void ucast_sendmsg ( +@@ -267,6 +265,7 @@ static inline void ucast_sendmsg ( struct sockaddr_storage sockaddr; struct iovec iovec; int addrlen; + int send_sock; - /* - * Encrypt and digest the message -@@ -313,11 +312,19 @@ static inline void ucast_sendmsg ( + if (msg_len + crypto_get_current_sec_header_size(instance->crypto_inst) > sizeof(buf_out)) { + log_printf(LOGSYS_LEVEL_CRIT, "UDP message for ucast is too big. Ignoring message"); +@@ -317,11 +316,19 @@ static inline void ucast_sendmsg ( #endif @@ -30,7 +39,7 @@ index 31d05704..47830e4b 100644 + msg_ucast.msg_name = NULL; + msg_ucast.msg_namelen = 0; + } -+ ++ /* * Transmit unicast message * An error here is recovered by totemsrp @@ -40,7 +49,7 @@ index 31d05704..47830e4b 100644 MSG_NOSIGNAL); if (res < 0) { LOGSYS_PERROR (errno, instance->totemudp_log_level_debug, -@@ -380,18 +387,20 @@ static inline void mcast_sendmsg ( +@@ -390,18 +397,20 @@ static inline void mcast_sendmsg ( msg_mcast.msg_accrightslen = 0; #endif @@ -73,7 +82,7 @@ index 31d05704..47830e4b 100644 } /* -@@ -556,7 +565,6 @@ static void timer_function_netif_check_timeout ( +@@ -580,7 +589,6 @@ static void timer_function_netif_check_timeout ( struct totemudp_instance *instance = (struct totemudp_instance *)data; int interface_up; int interface_num; @@ -81,7 +90,7 @@ index 31d05704..47830e4b 100644 /* * Build sockets for every interface -@@ -593,28 +601,31 @@ static void timer_function_netif_check_timeout ( +@@ -617,28 +625,31 @@ static void timer_function_netif_check_timeout ( qb_loop_poll_del (instance->totemudp_poll_handle, instance->totemudp_sockets.mcast_recv); close (instance->totemudp_sockets.mcast_recv); @@ -120,7 +129,7 @@ index 31d05704..47830e4b 100644 /* * Add a timer to retry building interfaces and request memb_gather_enter -@@ -630,34 +641,29 @@ static void timer_function_netif_check_timeout ( +@@ -654,34 +665,29 @@ static void timer_function_netif_check_timeout ( * Interface is up */ instance->netif_bind_state = BIND_STATE_REGULAR; @@ -168,7 +177,7 @@ index 31d05704..47830e4b 100644 totemip_copy (&instance->my_id, &instance->totem_interface->boundto); -@@ -708,6 +714,66 @@ static void totemudp_traffic_control_set(struct totemudp_instance *instance, int +@@ -732,6 +738,66 @@ static void totemudp_traffic_control_set(struct totemudp_instance *instance, int #endif } @@ -235,21 +244,18 @@ index 31d05704..47830e4b 100644 static int totemudp_build_sockets_ip ( struct totemudp_instance *instance, struct totem_ip_address *mcast_address, -@@ -730,7 +796,8 @@ static int totemudp_build_sockets_ip ( +@@ -755,7 +821,6 @@ static int totemudp_build_sockets_ip ( int res; int flag; uint8_t sflag; - int i; -+ -+ /* * Create multicast recv socket -@@ -760,24 +827,6 @@ static int totemudp_build_sockets_ip ( - return (-1); +@@ -786,27 +851,6 @@ static int totemudp_build_sockets_ip ( } -- /* + /* - * Create local multicast loop socket - */ - if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sockets->local_mcast_loop) == -1) { @@ -267,10 +273,14 @@ index 31d05704..47830e4b 100644 - return (-1); - } - } - - - -@@ -875,18 +924,6 @@ static int totemudp_build_sockets_ip ( +- +- +- +- /* + * Setup mcast send socket + */ + sockets->mcast_send = socket (bindnet_address->family, SOCK_DGRAM, 0); +@@ -930,18 +974,6 @@ static int totemudp_build_sockets_ip ( "Unable to set SO_SNDBUF size on UDP mcast socket"); return (-1); } @@ -289,7 +299,7 @@ index 31d05704..47830e4b 100644 res = getsockopt (sockets->mcast_recv, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, &optlen); if (res == 0) { -@@ -900,17 +937,6 @@ static int totemudp_build_sockets_ip ( +@@ -955,19 +987,6 @@ static int totemudp_build_sockets_ip ( "Transmit multicast socket send buffer size (%d bytes).", sendbuf_size); } @@ -304,10 +314,12 @@ index 31d05704..47830e4b 100644 - log_printf (instance->totemudp_log_level_debug, - "Local transmit multicast loop socket send buffer size (%d bytes).", sendbuf_size); - } - - +- +- /* -@@ -1178,8 +1204,19 @@ int totemudp_initialize ( + * Join group membership on socket + */ +@@ -1256,8 +1275,19 @@ int totemudp_initialize ( instance->totemudp_target_set_completed = target_set_completed; @@ -329,7 +341,7 @@ index 31d05704..47830e4b 100644 /* * RRP layer isn't ready to receive message because it hasn't -@@ -1242,10 +1279,14 @@ int totemudp_recv_flush (void *udp_context) +@@ -1320,10 +1350,14 @@ int totemudp_recv_flush (void *udp_context) for (i = 0; i < 2; i++) { sock = -1; if (i == 0) { @@ -337,7 +349,7 @@ index 31d05704..47830e4b 100644 + if (instance->netif_bind_state == BIND_STATE_REGULAR) { + sock = instance->totemudp_sockets.mcast_recv; + } else { -+ continue ; ++ continue; + } } if (i == 1) { @@ -347,5 +359,5 @@ index 31d05704..47830e4b 100644 assert(sock != -1); -- -2.12.3 +2.13.6 diff --git a/0004-mark-corosync-as-a-static-service.patch b/0004-mark-corosync-as-a-static-service.patch index 842fc9e..ecf8a49 100644 --- a/0004-mark-corosync-as-a-static-service.patch +++ b/0004-mark-corosync-as-a-static-service.patch @@ -1,8 +1,22 @@ ---- corosync-2.4.2.orig/init/corosync.service.in 2017-08-29 15:47:18.131052520 +0800 -+++ corosync-2.4.2/init/corosync.service.in 2017-08-29 15:46:24.949842298 +0800 -@@ -23,4 +23,4 @@ - #ExecStartPre=/sbin/modprobe softdog soft_margin=60 +From f1c6610de162a1bcf4bedab28398ab3f0ac6bb9d Mon Sep 17 00:00:00 2001 +From: Bin Liu +Date: Tue, 17 Apr 2018 17:00:28 +0800 +Subject: [PATCH] mark corosync as a static service + +--- + init/corosync.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/init/corosync.service.in b/init/corosync.service.in +index 7733a98..e6c1805 100644 +--- a/init/corosync.service.in ++++ b/init/corosync.service.in +@@ -23,4 +23,4 @@ Type=forking + #ExecStartPre=/sbin/modprobe softdog [Install] -WantedBy=multi-user.target +#WantedBy=multi-user.target +-- +2.13.6 + diff --git a/0005-do-not-convert-empty-uid-gid-to-0.patch b/0005-do-not-convert-empty-uid-gid-to-0.patch index d2abd88..fba501f 100644 --- a/0005-do-not-convert-empty-uid-gid-to-0.patch +++ b/0005-do-not-convert-empty-uid-gid-to-0.patch @@ -1,5 +1,14 @@ +From 31d931be66ef9ebf0aeb8e1dffa33e3280bfe732 Mon Sep 17 00:00:00 2001 +From: Bin Liu +Date: Tue, 17 Apr 2018 17:06:20 +0800 +Subject: [PATCH] do not convert empty uid gid to 0 + +--- + exec/coroparse.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + diff --git a/exec/coroparse.c b/exec/coroparse.c -index 374ed7dd..ac654a11 100644 +index 96bb83a..da82d54 100644 --- a/exec/coroparse.c +++ b/exec/coroparse.c @@ -139,6 +139,12 @@ static int uid_determine (const char *req_user) @@ -7,26 +16,26 @@ index 374ed7dd..ac654a11 100644 char *ep; + if(*req_user == '\0') { -+ sprintf (error_string_response, -+ "The user can not be empty, please read the documentation."); -+ return (-1); ++ sprintf (error_string_response, ++ "The user can not be empty, please read the documentation."); ++ return (-1); + } + id = strtol(req_user, &ep, 10); - if (*ep == '\0' && id >= 0 && id <= UINT_MAX) { + if (*req_user != '\0' && *ep == '\0' && id >= 0 && id <= UINT_MAX) { return (id); @@ -193,6 +199,12 @@ static int gid_determine (const char *req_group) long int id; char *ep; + if(*req_group == '\0') { -+ sprintf (error_string_response, -+ "The group can not be empty, please read the documentation."); -+ return (-1); ++ sprintf (error_string_response, ++ "The group can not be empty, please read the documentation."); ++ return (-1); + } + id = strtol(req_group, &ep, 10); - if (*ep == '\0' && id >= 0 && id <= UINT_MAX) { + if (*req_group != '\0' && *ep == '\0' && id >= 0 && id <= UINT_MAX) { return (id); -- 2.13.6 diff --git a/0006-Fix-compile-warnings-with-GCC-7.2.1.patch b/0006-Fix-compile-warnings-with-GCC-7.2.1.patch index 1465147..08a9254 100644 --- a/0006-Fix-compile-warnings-with-GCC-7.2.1.patch +++ b/0006-Fix-compile-warnings-with-GCC-7.2.1.patch @@ -1,7 +1,4 @@ -1. sam: Fix snprintf compiler warnings -2. cpg_test_agent: Fix snprintf compiler warnings -3. quorumtool: Use full buffer size in snprintf -4. readdir_r is deprecated in glibc 2.24 in favor of readdir +//cpg_test_agent: Fix snprintf compiler warnings --- cts/agents/cpg_test_agent.c | 8 ++++---- exec/coroparse.c | 18 +++--------------- @@ -35,138 +32,6 @@ index 0837c69c..2224141c 100644 list_add_tail (&log_pt->list, &config_chg_log_head); qb_log (LOG_INFO, "cpg event %s", log_pt->log); } -diff --git a/exec/coroparse.c b/exec/coroparse.c -index 2777a632..96bb83a5 100644 ---- a/exec/coroparse.c -+++ b/exec/coroparse.c -@@ -1241,11 +1241,8 @@ static int read_uidgid_files_into_icmap( - const char *dirname; - DIR *dp; - struct dirent *dirent; -- struct dirent *entry; - char filename[PATH_MAX + FILENAME_MAX + 1]; - int res = 0; -- size_t len; -- int return_code; - struct stat stat_buf; - enum main_cp_cb_data_state state = MAIN_CP_CB_DATA_STATE_NORMAL; - char key_name[ICMAP_KEYNAME_MAXLEN]; -@@ -1256,17 +1253,9 @@ static int read_uidgid_files_into_icmap( - if (dp == NULL) - return 0; - -- len = offsetof(struct dirent, d_name) + FILENAME_MAX + 1; -- -- entry = malloc(len); -- if (entry == NULL) { -- res = 0; -- goto error_exit; -- } -- -- for (return_code = readdir_r(dp, entry, &dirent); -- dirent != NULL && return_code == 0; -- return_code = readdir_r(dp, entry, &dirent)) { -+ for (dirent = readdir(dp); -+ dirent != NULL; -+ dirent = readdir(dp)) { - - snprintf(filename, sizeof (filename), "%s/%s", dirname, dirent->d_name); - res = stat (filename, &stat_buf); -@@ -1288,7 +1277,6 @@ static int read_uidgid_files_into_icmap( - } - - error_exit: -- free (entry); - closedir(dp); - - return res; -diff --git a/lib/sam.c b/lib/sam.c -index 33aa3944..527b99cb 100644 ---- a/lib/sam.c -+++ b/lib/sam.c -@@ -145,6 +145,7 @@ static cs_error_t sam_cmap_update_key (enum sam_cmap_key_t key, const char *valu - cs_error_t err; - const char *svalue; - uint64_t hc_period, last_hc; -+ - const char *ssvalue[] = { [SAM_RECOVERY_POLICY_QUIT] = "quit", [SAM_RECOVERY_POLICY_RESTART] = "restart" }; - char key_name[CMAP_KEYNAME_MAXLEN]; - -@@ -152,8 +153,13 @@ static cs_error_t sam_cmap_update_key (enum sam_cmap_key_t key, const char *valu - case SAM_CMAP_KEY_RECOVERY: - svalue = ssvalue[SAM_RP_MASK (sam_internal_data.recovery_policy)]; - -- snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -- "recovery"); -+ if (snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -+ "recovery") >= CMAP_KEYNAME_MAXLEN) { -+ -+ err = CS_ERR_NAME_TOO_LONG; -+ goto exit_error; -+ } -+ - if ((err = cmap_set_string(sam_internal_data.cmap_handle, key_name, svalue)) != CS_OK) { - goto exit_error; - } -@@ -161,8 +167,13 @@ static cs_error_t sam_cmap_update_key (enum sam_cmap_key_t key, const char *valu - case SAM_CMAP_KEY_HC_PERIOD: - hc_period = sam_internal_data.time_interval; - -- snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -- "poll_period"); -+ if (snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -+ "poll_period") >= CMAP_KEYNAME_MAXLEN) { -+ -+ err = CS_ERR_NAME_TOO_LONG; -+ goto exit_error; -+ } -+ - if ((err = cmap_set_uint64(sam_internal_data.cmap_handle, key_name, hc_period)) != CS_OK) { - goto exit_error; - } -@@ -170,16 +181,25 @@ static cs_error_t sam_cmap_update_key (enum sam_cmap_key_t key, const char *valu - case SAM_CMAP_KEY_LAST_HC: - last_hc = cs_timestamp_get(); - -- snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -- "last_updated"); -+ if (snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -+ "last_updated") >= CMAP_KEYNAME_MAXLEN) { -+ -+ err = CS_ERR_NAME_TOO_LONG; -+ goto exit_error; -+ } - if ((err = cmap_set_uint64(sam_internal_data.cmap_handle, key_name, last_hc)) != CS_OK) { - goto exit_error; - } - break; - case SAM_CMAP_KEY_STATE: - svalue = value; -- snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -- "state"); -+ if (snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path, -+ "state") >= CMAP_KEYNAME_MAXLEN) { -+ -+ err = CS_ERR_NAME_TOO_LONG; -+ goto exit_error; -+ } -+ - if ((err = cmap_set_string(sam_internal_data.cmap_handle, key_name, svalue)) != CS_OK) { - goto exit_error; - } -diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c -index 52c141ce..19696659 100644 ---- a/tools/corosync-quorumtool.c -+++ b/tools/corosync-quorumtool.c -@@ -519,7 +519,7 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name - if (info[i].flags & VOTEQUORUM_INFO_QDEVICE_REGISTERED) { - char buf[10]; - -- snprintf(buf, sizeof(buf) - 1, -+ snprintf(buf, sizeof(buf), - "%s,%s,%s", - info[i].flags & VOTEQUORUM_INFO_QDEVICE_ALIVE?"A":"NA", - info[i].flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE?"V":"NV", -- 2.13.6 diff --git a/0009-add-config-for-corosync-qnetd.patch b/0007-add-config-for-corosync-qnetd.patch similarity index 100% rename from 0009-add-config-for-corosync-qnetd.patch rename to 0007-add-config-for-corosync-qnetd.patch diff --git a/0007-sync-Call-sync_init-of-all-services-at-once.patch b/0007-sync-Call-sync_init-of-all-services-at-once.patch deleted file mode 100644 index 52a20e8..0000000 --- a/0007-sync-Call-sync_init-of-all-services-at-once.patch +++ /dev/null @@ -1,349 +0,0 @@ -This patch solves situation which can happen very rearly: -- Node B is running -- Node A is started and tries to create singleton membership. It also - initialize service S which tries to send message during initialization -- Just before node A finished move to operational state, it gets - Node B multicast message so moves to gather state -- Node A and B creates membership and moves to operational state and - sync is started -- Node A and B receives message sent by node A during initialization of - service S -- Node A exits before sync of service is finished - -In this situation, node B may never execute sync_init for -service S. So node B service S is not aware of existence of node A but -it received message from it. - -Similar situation can theoretically also happen during merge. - -Solution is to change flow of sync, so now it looks like: - -- Build service_list -- Call sync_init for all local services -- Send service_list -- Receive service_list from all members and send barier -- For all services: - - Receive barier - - Call sync_activate if this is not first service - - Call sync_process for next service or finish sync if previous - this service is the last one - - Send barier - ---- - exec/sync.c | 174 +++++++++++++++--------------------------------------------- - 1 file changed, 44 insertions(+), 130 deletions(-) - -diff --git a/exec/sync.c b/exec/sync.c -index 283634a8..1efa3577 100644 ---- a/exec/sync.c -+++ b/exec/sync.c -@@ -62,10 +62,8 @@ LOGSYS_DECLARE_SUBSYS ("SYNC"); - - #define MESSAGE_REQ_SYNC_BARRIER 0 - #define MESSAGE_REQ_SYNC_SERVICE_BUILD 1 --#define MESSAGE_REQ_SYNC_MEMB_DETERMINE 2 - - enum sync_process_state { -- INIT, - PROCESS, - ACTIVATE - }; -@@ -96,11 +94,6 @@ struct processor_entry { - int received; - }; - --struct req_exec_memb_determine_message { -- struct qb_ipc_request_header header __attribute__((aligned(8))); -- struct memb_ring_id ring_id __attribute__((aligned(8))); --}; -- - struct req_exec_service_build_message { - struct qb_ipc_request_header header __attribute__((aligned(8))); - struct memb_ring_id ring_id __attribute__((aligned(8))); -@@ -117,14 +110,6 @@ static enum sync_state my_state = SYNC_BARRIER; - - static struct memb_ring_id my_ring_id; - --static struct memb_ring_id my_memb_determine_ring_id; -- --static int my_memb_determine = 0; -- --static unsigned int my_memb_determine_list[PROCESSOR_COUNT_MAX]; -- --static unsigned int my_memb_determine_list_entries = 0; -- - static int my_processing_idx = 0; - - static hdb_handle_t my_schedwrk_handle; -@@ -157,6 +142,8 @@ static int schedwrk_processor (const void *context); - - static void sync_process_enter (void); - -+static void sync_process_call_init (void); -+ - static struct totempg_group sync_group = { - .group = "sync", - .group_len = 4 -@@ -234,7 +221,6 @@ static void sync_barrier_handler (unsigned int nodeid, const void *msg) - - my_processing_idx += 1; - if (my_service_list_entries == my_processing_idx) { -- my_memb_determine_list_entries = 0; - sync_synchronization_completed (); - } else { - sync_process_enter (); -@@ -242,15 +228,6 @@ static void sync_barrier_handler (unsigned int nodeid, const void *msg) - } - } - --static void dummy_sync_init ( -- const unsigned int *trans_list, -- size_t trans_list_entries, -- const unsigned int *member_list, -- size_t member_list_entries, -- const struct memb_ring_id *ring_id) --{ --} -- - static void dummy_sync_abort (void) - { - } -@@ -272,31 +249,6 @@ static int service_entry_compare (const void *a, const void *b) - return (service_entry_a->service_id > service_entry_b->service_id); - } - --static void sync_memb_determine (unsigned int nodeid, const void *msg) --{ -- const struct req_exec_memb_determine_message *req_exec_memb_determine_message = msg; -- int found = 0; -- int i; -- -- if (memcmp (&req_exec_memb_determine_message->ring_id, -- &my_memb_determine_ring_id, sizeof (struct memb_ring_id)) != 0) { -- -- log_printf (LOGSYS_LEVEL_DEBUG, "memb determine for old ring - discarding"); -- return; -- } -- -- my_memb_determine = 1; -- for (i = 0; i < my_memb_determine_list_entries; i++) { -- if (my_memb_determine_list[i] == nodeid) { -- found = 1; -- } -- } -- if (found == 0) { -- my_memb_determine_list[my_memb_determine_list_entries] = nodeid; -- my_memb_determine_list_entries += 1; -- } --} -- - static void sync_service_build_handler (unsigned int nodeid, const void *msg) - { - const struct req_exec_service_build_message *req_exec_service_build_message = msg; -@@ -321,15 +273,14 @@ static void sync_service_build_handler (unsigned int nodeid, const void *msg) - } - } - if (found == 0) { -- my_service_list[my_service_list_entries].state = -- INIT; -+ my_service_list[my_service_list_entries].state = PROCESS; - my_service_list[my_service_list_entries].service_id = - req_exec_service_build_message->service_list[i]; - sprintf (my_service_list[my_service_list_entries].name, - "Unknown External Service (id = %d)\n", - req_exec_service_build_message->service_list[i]); - my_service_list[my_service_list_entries].sync_init = -- dummy_sync_init; -+ NULL; - my_service_list[my_service_list_entries].sync_abort = - dummy_sync_abort; - my_service_list[my_service_list_entries].sync_process = -@@ -356,6 +307,7 @@ static void sync_service_build_handler (unsigned int nodeid, const void *msg) - } - } - if (barrier_reached) { -+ log_printf (LOGSYS_LEVEL_DEBUG, "enter sync process"); - sync_process_enter (); - } - } -@@ -375,31 +327,9 @@ static void sync_deliver_fn ( - case MESSAGE_REQ_SYNC_SERVICE_BUILD: - sync_service_build_handler (nodeid, msg); - break; -- case MESSAGE_REQ_SYNC_MEMB_DETERMINE: -- sync_memb_determine (nodeid, msg); -- break; - } - } - --static void memb_determine_message_transmit (void) --{ -- struct iovec iovec; -- struct req_exec_memb_determine_message req_exec_memb_determine_message; -- -- req_exec_memb_determine_message.header.size = sizeof (struct req_exec_memb_determine_message); -- req_exec_memb_determine_message.header.id = MESSAGE_REQ_SYNC_MEMB_DETERMINE; -- -- memcpy (&req_exec_memb_determine_message.ring_id, -- &my_memb_determine_ring_id, -- sizeof (struct memb_ring_id)); -- -- iovec.iov_base = (char *)&req_exec_memb_determine_message; -- iovec.iov_len = sizeof (req_exec_memb_determine_message); -- -- (void)totempg_groups_mcast_joined (sync_group_handle, -- &iovec, 1, TOTEMPG_AGREED); --} -- - static void barrier_message_transmit (void) - { - struct iovec iovec; -@@ -441,6 +371,38 @@ static void sync_barrier_enter (void) - barrier_message_transmit (); - } - -+static void sync_process_call_init (void) -+{ -+ unsigned int old_trans_list[PROCESSOR_COUNT_MAX]; -+ size_t old_trans_list_entries = 0; -+ int o, m; -+ int i; -+ -+ memcpy (old_trans_list, my_trans_list, my_trans_list_entries * -+ sizeof (unsigned int)); -+ old_trans_list_entries = my_trans_list_entries; -+ -+ my_trans_list_entries = 0; -+ for (o = 0; o < old_trans_list_entries; o++) { -+ for (m = 0; m < my_member_list_entries; m++) { -+ if (old_trans_list[o] == my_member_list[m]) { -+ my_trans_list[my_trans_list_entries] = my_member_list[m]; -+ my_trans_list_entries++; -+ break; -+ } -+ } -+ } -+ -+ for (i = 0; i < my_service_list_entries; i++) { -+ if (my_sync_callbacks_retrieve(my_service_list[i].service_id, NULL) != -1) { -+ my_service_list[i].sync_init (my_trans_list, -+ my_trans_list_entries, my_member_list, -+ my_member_list_entries, -+ &my_ring_id); -+ } -+ } -+} -+ - static void sync_process_enter (void) - { - int i; -@@ -452,13 +414,13 @@ static void sync_process_enter (void) - */ - if (my_service_list_entries == 0) { - my_state = SYNC_SERVICELIST_BUILD; -- my_memb_determine_list_entries = 0; - sync_synchronization_completed (); - return; - } - for (i = 0; i < my_processor_list_entries; i++) { - my_processor_list[i].received = 0; - } -+ - schedwrk_create (&my_schedwrk_handle, - schedwrk_processor, - NULL); -@@ -498,7 +460,7 @@ static void sync_servicelist_build_enter ( - if (sync_callbacks.sync_init == NULL) { - continue; - } -- my_service_list[my_service_list_entries].state = INIT; -+ my_service_list[my_service_list_entries].state = PROCESS; - my_service_list[my_service_list_entries].service_id = i; - strcpy (my_service_list[my_service_list_entries].name, - sync_callbacks.name); -@@ -516,42 +478,16 @@ static void sync_servicelist_build_enter ( - service_build.service_list_entries = my_service_list_entries; - - service_build_message_transmit (&service_build); -+ -+ log_printf (LOGSYS_LEVEL_DEBUG, "call init for locally known services"); -+ sync_process_call_init (); - } - - static int schedwrk_processor (const void *context) - { - int res = 0; - -- if (my_service_list[my_processing_idx].state == INIT) { -- unsigned int old_trans_list[PROCESSOR_COUNT_MAX]; -- size_t old_trans_list_entries = 0; -- int o, m; -- my_service_list[my_processing_idx].state = PROCESS; -- -- memcpy (old_trans_list, my_trans_list, my_trans_list_entries * -- sizeof (unsigned int)); -- old_trans_list_entries = my_trans_list_entries; -- -- my_trans_list_entries = 0; -- for (o = 0; o < old_trans_list_entries; o++) { -- for (m = 0; m < my_member_list_entries; m++) { -- if (old_trans_list[o] == my_member_list[m]) { -- my_trans_list[my_trans_list_entries] = my_member_list[m]; -- my_trans_list_entries++; -- break; -- } -- } -- } -- -- if (my_sync_callbacks_retrieve(my_service_list[my_processing_idx].service_id, NULL) != -1) { -- my_service_list[my_processing_idx].sync_init (my_trans_list, -- my_trans_list_entries, my_member_list, -- my_member_list_entries, -- &my_ring_id); -- } -- } - if (my_service_list[my_processing_idx].state == PROCESS) { -- my_service_list[my_processing_idx].state = PROCESS; - if (my_sync_callbacks_retrieve(my_service_list[my_processing_idx].service_id, NULL) != -1) { - res = my_service_list[my_processing_idx].sync_process (); - } else { -@@ -574,14 +510,8 @@ void sync_start ( - ENTER(); - memcpy (&my_ring_id, ring_id, sizeof (struct memb_ring_id)); - -- if (my_memb_determine) { -- my_memb_determine = 0; -- sync_servicelist_build_enter (my_memb_determine_list, -- my_memb_determine_list_entries, ring_id); -- } else { -- sync_servicelist_build_enter (member_list, member_list_entries, -- ring_id); -- } -+ sync_servicelist_build_enter (member_list, member_list_entries, -+ ring_id); - } - - void sync_save_transitional ( -@@ -610,19 +540,3 @@ void sync_abort (void) - */ - memset (&my_ring_id, 0, sizeof (struct memb_ring_id)); - } -- --void sync_memb_list_determine (const struct memb_ring_id *ring_id) --{ -- ENTER(); -- memcpy (&my_memb_determine_ring_id, ring_id, -- sizeof (struct memb_ring_id)); -- -- memb_determine_message_transmit (); --} -- --void sync_memb_list_abort (void) --{ -- ENTER(); -- my_memb_determine_list_entries = 0; -- memset (&my_memb_determine_ring_id, 0, sizeof (struct memb_ring_id)); --} --- -2.13.6 - diff --git a/0016-bsc#1083561-upgrade-from-1-x-y.patch b/0008-bsc#1083561-upgrade-from-1-x-y.patch similarity index 100% rename from 0016-bsc#1083561-upgrade-from-1-x-y.patch rename to 0008-bsc#1083561-upgrade-from-1-x-y.patch diff --git a/0008-wd-fix-snprintf-warnings.patch b/0008-wd-fix-snprintf-warnings.patch deleted file mode 100644 index f060e20..0000000 --- a/0008-wd-fix-snprintf-warnings.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff --git a/exec/wd.c b/exec/wd.c -index 8d0734c9..042d2046 100644 ---- a/exec/wd.c -+++ b/exec/wd.c -@@ -221,15 +221,15 @@ static int32_t wd_resource_state_is_ok (struct resource *ref) - uint64_t allowed_period; - char key_name[ICMAP_KEYNAME_MAXLEN]; - -- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "last_updated"); -- if (icmap_get_uint64(key_name, &last_updated) != CS_OK) { -+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "last_updated") >= ICMAP_KEYNAME_MAXLEN) || -+ (icmap_get_uint64(key_name, &last_updated) != CS_OK)) { - /* key does not exist. - */ - return CS_FALSE; - } - -- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state"); -- if (icmap_get_string(key_name, &state) != CS_OK || strcmp(state, "disabled") == 0) { -+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state") >= ICMAP_KEYNAME_MAXLEN) || -+ (icmap_get_string(key_name, &state) != CS_OK || strcmp(state, "disabled") == 0)) { - /* key does not exist. - */ - if (state != NULL) -@@ -279,8 +279,8 @@ static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data) - - next_timeout = ref->check_timeout; - -- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "poll_period"); -- if (icmap_get_uint64(ref->res_path, &tmp_value) == CS_OK) { -+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "poll_period") >= ICMAP_KEYNAME_MAXLEN) || -+ (icmap_get_uint64(ref->res_path, &tmp_value) == CS_OK)) { - if (tmp_value >= WD_MIN_TIMEOUT_MS && tmp_value <= WD_MAX_TIMEOUT_MS) { - log_printf (LOGSYS_LEVEL_DEBUG, - "poll_period changing from:%"PRIu64" to %"PRIu64".", -@@ -299,8 +299,8 @@ static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data) - } - } - -- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "recovery"); -- if (icmap_get_string(key_name, &ref->recovery) != CS_OK) { -+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "recovery") >= ICMAP_KEYNAME_MAXLEN) || -+ (icmap_get_string(key_name, &ref->recovery) != CS_OK)) { - /* key does not exist. - */ - log_printf (LOGSYS_LEVEL_WARNING, -@@ -308,8 +308,8 @@ static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data) - cs_fsm_state_set(&ref->fsm, WD_S_STOPPED, ref, wd_fsm_cb); - return; - } -- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state"); -- if (icmap_get_string(key_name, &state) != CS_OK) { -+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state") >= ICMAP_KEYNAME_MAXLEN) || -+ (icmap_get_string(key_name, &state) != CS_OK)) { - /* key does not exist. - */ - log_printf (LOGSYS_LEVEL_WARNING, --- -2.13.6 - diff --git a/0017-bsc#1088619-add-version.patch b/0009-bsc#1088619-add-version.patch similarity index 95% rename from 0017-bsc#1088619-add-version.patch rename to 0009-bsc#1088619-add-version.patch index 8d6543f..7737f99 100644 --- a/0017-bsc#1088619-add-version.patch +++ b/0009-bsc#1088619-add-version.patch @@ -1,4 +1,4 @@ --- /dev/null 2018-04-10 08:30:37.121221591 +0800 +++ corosync-2.4.3/.tarball-version 2018-04-10 18:30:37.907779088 +0800 @@ -0,0 +1 @@ -+2.4.3 ++2.4.4 diff --git a/0010-qdevice-mv-free-str-after-port-validation.patch b/0010-qdevice-mv-free-str-after-port-validation.patch deleted file mode 100644 index bb399b8..0000000 --- a/0010-qdevice-mv-free-str-after-port-validation.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/qdevices/qdevice-net-instance.c b/qdevices/qdevice-net-instance.c -index 7adcaa3f..e4b7b04d 100644 ---- a/qdevices/qdevice-net-instance.c -+++ b/qdevices/qdevice-net-instance.c -@@ -274,12 +274,12 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - if (cmap_get_string(cmap_handle, "quorum.device.net.port", &str) == CS_OK) { - host_port = strtol(str, &ep, 10); - -- free(str); -- - if (host_port <= 0 || host_port > ((uint16_t)~0) || *ep != '\0') { - qdevice_log(LOG_ERR, "quorum.device.net.port must be in range 0-65535"); -+ free(str); - goto error_free_host_addr; - } -+ free(str); - } else { - host_port = QNETD_DEFAULT_HOST_PORT; - } --- -2.13.6 - diff --git a/0010-qdevice-net-instance.c-optarg-should-be-str.patch b/0010-qdevice-net-instance.c-optarg-should-be-str.patch new file mode 100644 index 0000000..a983667 --- /dev/null +++ b/0010-qdevice-net-instance.c-optarg-should-be-str.patch @@ -0,0 +1,25 @@ +From fab3ef5e63e1ad61d03b1230e8f900bf1279cc81 Mon Sep 17 00:00:00 2001 +From: Bin Liu +Date: Thu, 19 Apr 2018 16:52:27 +0800 +Subject: [PATCH] qdevice-net-instance.c: optarg should be str + +--- + qdevices/qdevice-net-instance.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/qdevices/qdevice-net-instance.c b/qdevices/qdevice-net-instance.c +index 87cf3ee0..a3231cd5 100644 +--- a/qdevices/qdevice-net-instance.c ++++ b/qdevices/qdevice-net-instance.c +@@ -273,7 +273,7 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) + host_addr = str; + + if (cmap_get_string(cmap_handle, "quorum.device.net.port", &str) == CS_OK) { +- if (utils_strtonum(optarg, 1, UINT16_MAX, &lli) == -1) { ++ if (utils_strtonum(str, 1, UINT16_MAX, &lli) == -1) { + qdevice_log(LOG_ERR, "quorum.device.net.port must be in range 1-%u", UINT16_MAX); + free(str); + goto error_free_host_addr; +-- +2.13.6 + diff --git a/0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch b/0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch deleted file mode 100644 index b71bc9c..0000000 --- a/0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch +++ /dev/null @@ -1,159 +0,0 @@ -diff --git a/lib/cpg.c b/lib/cpg.c -index c831390b..a0e662f0 100644 ---- a/lib/cpg.c -+++ b/lib/cpg.c -@@ -80,6 +80,15 @@ - */ - #define CPG_MEMORY_MAP_UMASK 077 - -+struct cpg_assembly_data -+{ -+ struct list_head list; -+ uint32_t nodeid; -+ uint32_t pid; -+ char *assembly_buf; -+ uint32_t assembly_buf_ptr; -+}; -+ - struct cpg_inst { - qb_ipcc_connection_t *c; - int finalize; -@@ -89,14 +98,8 @@ struct cpg_inst { - cpg_model_v1_data_t model_v1_data; - }; - struct list_head iteration_list_head; -- uint32_t max_msg_size; -- char *assembly_buf; -- uint32_t assembly_buf_ptr; -- int assembling; /* Flag that says we have started assembling a message. -- * It's here to catch the situation where a node joins -- * the cluster/group in the middle of a CPG message send -- * so we don't pass on a partial message to the client. -- */ -+ uint32_t max_msg_size; -+ struct list_head assembly_list_head; - }; - static void cpg_inst_free (void *inst); - -@@ -231,6 +234,8 @@ cs_error_t cpg_model_initialize ( - - list_init(&cpg_inst->iteration_list_head); - -+ list_init(&cpg_inst->assembly_list_head); -+ - hdb_handle_put (&cpg_handle_t_db, *handle); - - return (CS_OK); -@@ -382,6 +387,8 @@ cs_error_t cpg_dispatch ( - struct cpg_address left_list[CPG_MEMBERS_MAX]; - struct cpg_address joined_list[CPG_MEMBERS_MAX]; - struct cpg_name group_name; -+ struct cpg_assembly_data *assembly_data; -+ struct list_head *iter, *tmp_iter; - mar_cpg_address_t *left_list_start; - mar_cpg_address_t *joined_list_start; - unsigned int i; -@@ -471,32 +478,63 @@ cs_error_t cpg_dispatch ( - &group_name, - &res_cpg_partial_deliver_callback->group_name); - -+ /* -+ * Search for assembly data for current messages (nodeid, pid) pair in list of assemblies -+ */ -+ assembly_data = NULL; -+ for (iter = cpg_inst->assembly_list_head.next; iter != &cpg_inst->assembly_list_head; iter = iter->next) { -+ struct cpg_assembly_data *current_assembly_data = list_entry (iter, struct cpg_assembly_data, list); -+ if (current_assembly_data->nodeid == res_cpg_partial_deliver_callback->nodeid && current_assembly_data->pid == res_cpg_partial_deliver_callback->pid) { -+ assembly_data = current_assembly_data; -+ break; -+ } -+ } -+ - if (res_cpg_partial_deliver_callback->type == LIBCPG_PARTIAL_FIRST) { -+ - /* -- * Allocate a buffer to contain a full message. -+ * As this is LIBCPG_PARTIAL_FIRST packet, check that there is no ongoing assembly - */ -- cpg_inst->assembly_buf = malloc(res_cpg_partial_deliver_callback->msglen); -- if (!cpg_inst->assembly_buf) { -+ if (assembly_data) { -+ error = CS_ERR_MESSAGE_ERROR; -+ goto error_put; -+ } -+ -+ assembly_data = malloc(sizeof(struct cpg_assembly_data)); -+ if (!assembly_data) { - error = CS_ERR_NO_MEMORY; - goto error_put; - } -- cpg_inst->assembling = 1; -- cpg_inst->assembly_buf_ptr = 0; -+ -+ assembly_data->nodeid = res_cpg_partial_deliver_callback->nodeid; -+ assembly_data->pid = res_cpg_partial_deliver_callback->pid; -+ assembly_data->assembly_buf = malloc(res_cpg_partial_deliver_callback->msglen); -+ if (!assembly_data->assembly_buf) { -+ free(assembly_data); -+ error = CS_ERR_NO_MEMORY; -+ goto error_put; -+ } -+ assembly_data->assembly_buf_ptr = 0; -+ list_init (&assembly_data->list); -+ -+ list_add (&assembly_data->list, &cpg_inst->assembly_list_head); - } -- if (cpg_inst->assembling) { -- memcpy(cpg_inst->assembly_buf + cpg_inst->assembly_buf_ptr, -- res_cpg_partial_deliver_callback->message, res_cpg_partial_deliver_callback->fraglen); -- cpg_inst->assembly_buf_ptr += res_cpg_partial_deliver_callback->fraglen; -+ if (assembly_data) { -+ memcpy(assembly_data->assembly_buf + assembly_data->assembly_buf_ptr, -+ res_cpg_partial_deliver_callback->message, res_cpg_partial_deliver_callback->fraglen); -+ assembly_data->assembly_buf_ptr += res_cpg_partial_deliver_callback->fraglen; - - if (res_cpg_partial_deliver_callback->type == LIBCPG_PARTIAL_LAST) { - cpg_inst_copy.model_v1_data.cpg_deliver_fn (handle, - &group_name, - res_cpg_partial_deliver_callback->nodeid, - res_cpg_partial_deliver_callback->pid, -- cpg_inst->assembly_buf, -+ assembly_data->assembly_buf, - res_cpg_partial_deliver_callback->msglen); -- free(cpg_inst->assembly_buf); -- cpg_inst->assembling = 0; -+ -+ list_del (&assembly_data->list); -+ free(assembly_data->assembly_buf); -+ free(assembly_data); - } - } - break; -@@ -538,6 +576,24 @@ cs_error_t cpg_dispatch ( - joined_list, - res_cpg_confchg_callback->joined_list_entries); - -+ /* -+ * If member left while his partial packet was being assembled, assembly data must be removed from list -+ */ -+ for (i = 0; i < res_cpg_confchg_callback->left_list_entries; i++) { -+ for (iter = cpg_inst->assembly_list_head.next; iter != &cpg_inst->assembly_list_head;iter = tmp_iter) { -+ struct cpg_assembly_data *current_assembly_data = list_entry (iter, struct cpg_assembly_data, list); -+ -+ tmp_iter = iter->next; -+ -+ if (current_assembly_data->nodeid != left_list[i].nodeid || current_assembly_data->pid != left_list[i].pid) -+ continue; -+ -+ list_del (¤t_assembly_data->list); -+ free(current_assembly_data->assembly_buf); -+ free(current_assembly_data); -+ } -+ } -+ - break; - case MESSAGE_RES_CPG_TOTEM_CONFCHG_CALLBACK: - if (cpg_inst_copy.model_v1_data.cpg_totem_confchg_fn == NULL) { --- -2.13.6 - diff --git a/0012-totemudp-u-Drop-truncated-packets-on-receive.patch b/0012-totemudp-u-Drop-truncated-packets-on-receive.patch deleted file mode 100644 index 3eaf058..0000000 --- a/0012-totemudp-u-Drop-truncated-packets-on-receive.patch +++ /dev/null @@ -1,91 +0,0 @@ -diff --git a/exec/totemudp.c b/exec/totemudp.c -index 2f36b5d9..40e99f93 100644 ---- a/exec/totemudp.c -+++ b/exec/totemudp.c -@@ -452,6 +452,7 @@ static int net_deliver_fn ( - struct sockaddr_storage system_from; - int bytes_received; - int res = 0; -+ int truncated_packet; - - if (instance->flushing == 1) { - iovec = &instance->totemudp_iov_recv_flush; -@@ -489,6 +490,31 @@ static int net_deliver_fn ( - instance->stats_recv += bytes_received; - } - -+ truncated_packet = 0; -+ -+#ifdef HAVE_MSGHDR_FLAGS -+ if (msg_recv.msg_flags & MSG_TRUNC) { -+ truncated_packet = 1; -+ } -+#else -+ /* -+ * We don't have MSGHDR_FLAGS, but we can (hopefully) safely make assumption that -+ * if bytes_received == FRAME_SIZE_MAX then packet is truncated -+ */ -+ if (bytes_received == FRAME_SIZE_MAX) { -+ truncated_packet = 1; -+ } -+#endif -+ -+ if (truncated_packet) { -+ log_printf(instance->totemudp_log_level_error, -+ "Received too big message. This may be because something bad is happening" -+ "on the network (attack?), or you tried join more nodes than corosync is" -+ "compiled with (%u) or bug in the code (bad estimation of " -+ "the FRAME_SIZE_MAX). Dropping packet.", PROCESSOR_COUNT_MAX); -+ return (0); -+ } -+ - /* - * Authenticate and if authenticated, decrypt datagram - */ -diff --git a/exec/totemudpu.c b/exec/totemudpu.c -index 9e076423..569e67a0 100644 ---- a/exec/totemudpu.c -+++ b/exec/totemudpu.c -@@ -446,6 +446,7 @@ static int net_deliver_fn ( - struct sockaddr_storage system_from; - int bytes_received; - int res = 0; -+ int truncated_packet; - - iovec = &instance->totemudpu_iov_recv; - -@@ -479,6 +480,31 @@ static int net_deliver_fn ( - instance->stats_recv += bytes_received; - } - -+ truncated_packet = 0; -+ -+#ifdef HAVE_MSGHDR_FLAGS -+ if (msg_recv.msg_flags & MSG_TRUNC) { -+ truncated_packet = 1; -+ } -+#else -+ /* -+ * We don't have MSGHDR_FLAGS, but we can (hopefully) safely make assumption that -+ * if bytes_received == FRAME_SIZE_MAX then packet is truncated -+ */ -+ if (bytes_received == FRAME_SIZE_MAX) { -+ truncated_packet = 1; -+ } -+#endif -+ -+ if (truncated_packet) { -+ log_printf(instance->totemudpu_log_level_error, -+ "Received too big message. This may be because something bad is happening" -+ "on the network (attack?), or you tried join more nodes than corosync is" -+ "compiled with (%u) or bug in the code (bad estimation of " -+ "the FRAME_SIZE_MAX). Dropping packet.", PROCESSOR_COUNT_MAX); -+ return (0); -+ } -+ - /* - * Authenticate and if authenticated, decrypt datagram - */ --- -2.13.6 - diff --git a/0013-logging-Make-blackbox-configurable.patch b/0013-logging-Make-blackbox-configurable.patch deleted file mode 100644 index 2f9ee10..0000000 --- a/0013-logging-Make-blackbox-configurable.patch +++ /dev/null @@ -1,201 +0,0 @@ -diff --git a/exec/logconfig.c b/exec/logconfig.c -index 6d0bed6a..ccbffae6 100644 ---- a/exec/logconfig.c -+++ b/exec/logconfig.c -@@ -127,7 +127,7 @@ static int insert_into_buffer( - } - - /* -- * format set is the only global specific option that -+ * format set is global specific option that - * doesn't apply at system/subsystem level. - */ - static int corosync_main_config_format_set ( -@@ -228,6 +228,40 @@ parse_error: - return (-1); - } - -+/* -+ * blackbox is another global specific option that -+ * doesn't apply at system/subsystem level. -+ */ -+static int corosync_main_config_blackbox_set ( -+ const char **error_string) -+{ -+ const char *error_reason; -+ char *value = NULL; -+ -+ if (map_get_string("logging.blackbox", &value) == CS_OK) { -+ if (strcmp (value, "on") == 0) { -+ (void)logsys_blackbox_set(QB_TRUE); -+ } else if (strcmp (value, "off") == 0) { -+ (void)logsys_blackbox_set(QB_FALSE); -+ } else { -+ error_reason = "unknown value for blackbox"; -+ free(value); -+ goto parse_error; -+ } -+ -+ free(value); -+ } else { -+ (void)logsys_blackbox_set(QB_TRUE); -+ } -+ -+ return (0); -+ -+parse_error: -+ *error_string = error_reason; -+ -+ return (-1); -+} -+ - static int corosync_main_config_log_destination_set ( - const char *path, - const char *key, -@@ -522,6 +556,10 @@ static int corosync_main_config_read_logging ( - goto parse_error; - } - -+ if (corosync_main_config_blackbox_set(&error_reason) < 0) { -+ goto parse_error; -+ } -+ - if (corosync_main_config_set ("logging", NULL, &error_reason) < 0) { - goto parse_error; - } -diff --git a/exec/logsys.c b/exec/logsys.c -index 6b4995dd..a38cc5e8 100644 ---- a/exec/logsys.c -+++ b/exec/logsys.c -@@ -119,6 +119,8 @@ static char *format_buffer=NULL; - - static int logsys_thread_started = 0; - -+static int logsys_blackbox_enabled = 1; -+ - static int _logsys_config_subsys_get_unlocked (const char *subsys) - { - unsigned int i; -@@ -309,7 +311,6 @@ int _logsys_system_setup( - int i; - int32_t fidx; - char tempsubsys[LOGSYS_MAX_SUBSYS_NAMELEN]; -- int blackbox_enable_res; - - if ((mainsystem == NULL) || - (strlen(mainsystem) >= LOGSYS_MAX_SUBSYS_NAMELEN)) { -@@ -371,7 +372,12 @@ int _logsys_system_setup( - QB_LOG_FILTER_FILE, "*", LOG_TRACE); - qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_SIZE, IPC_LOGSYS_SIZE); - qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_THREADED, QB_FALSE); -- blackbox_enable_res = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_TRUE); -+ -+ /* -+ * Blackbox is disabled at the init and enabled later based -+ * on config (logging.blackbox) value. -+ */ -+ qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE); - - if (logsys_format_set(NULL) == -1) { - return -1; -@@ -397,14 +403,6 @@ int _logsys_system_setup( - } - } - -- if (blackbox_enable_res < 0) { -- LOGSYS_PERROR (-blackbox_enable_res, LOGSYS_LEVEL_WARNING, -- "Unable to initialize log flight recorder. "\ -- "The most common cause of this error is " \ -- "not enough space on /dev/shm. Corosync will continue work, " \ -- "but blackbox will not be available"); -- } -- - pthread_mutex_unlock (&logsys_config_mutex); - - return (0); -@@ -767,10 +765,26 @@ static void _logsys_config_apply_per_subsys(int32_t s) - logsys_loggers[s].dirty = QB_FALSE; - } - -+static void _logsys_config_apply_blackbox(void) { -+ int blackbox_enable_res; -+ -+ blackbox_enable_res = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, logsys_blackbox_enabled); -+ -+ if (blackbox_enable_res < 0) { -+ LOGSYS_PERROR (-blackbox_enable_res, LOGSYS_LEVEL_WARNING, -+ "Unable to initialize log flight recorder. "\ -+ "The most common cause of this error is " \ -+ "not enough space on /dev/shm. Corosync will continue work, " \ -+ "but blackbox will not be available"); -+ } -+} -+ - void logsys_config_apply(void) - { - int32_t s; - -+ _logsys_config_apply_blackbox(); -+ - for (s = 0; s <= LOGSYS_MAX_SUBSYS_COUNT; s++) { - if (strcmp(logsys_loggers[s].subsys, "") == 0) { - continue; -@@ -838,3 +852,13 @@ int logsys_thread_start (void) - - return (0); - } -+ -+void logsys_blackbox_set(int enable) -+{ -+ -+ pthread_mutex_lock (&logsys_config_mutex); -+ -+ logsys_blackbox_enabled = enable; -+ -+ pthread_mutex_unlock (&logsys_config_mutex); -+} -diff --git a/exec/main.c b/exec/main.c -index 7fe24e2e..cd587dc8 100644 ---- a/exec/main.c -+++ b/exec/main.c -@@ -220,6 +220,7 @@ static void corosync_blackbox_write_to_file (void) - - if ((res = qb_log_blackbox_write_to_file(fname)) < 0) { - LOGSYS_PERROR(-res, LOGSYS_LEVEL_ERROR, "Can't store blackbox file"); -+ return ; - } - snprintf(fdata_fname, sizeof(fdata_fname), "%s/fdata", get_run_dir()); - unlink(fdata_fname); -diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h -index 0b2fbff8..ec38d2cb 100644 ---- a/include/corosync/logsys.h -+++ b/include/corosync/logsys.h -@@ -256,6 +256,8 @@ extern int _logsys_subsys_create (const char *subsys, const char *filename); - */ - extern int logsys_thread_start (void); - -+extern void logsys_blackbox_set(int enable); -+ - /** - * @brief logsys_subsys_id - */ -diff --git a/man/corosync.conf.5 b/man/corosync.conf.5 -index 06390281..68103d0e 100644 ---- a/man/corosync.conf.5 -+++ b/man/corosync.conf.5 -@@ -539,6 +539,12 @@ This specifies that the code function name should be printed. - - The default is off. - -+.TP -+blackbox -+This specifies that blackbox functionality should be enabled. -+ -+The defualt is on. -+ - .PP - The following options are valid both for top level logging directive - and they can be overridden in logger_subsys entries. --- -2.13.6 - diff --git a/0014-logging-Close-before-and-open-blackbox-after-fork.patch b/0014-logging-Close-before-and-open-blackbox-after-fork.patch deleted file mode 100644 index c8af6cd..0000000 --- a/0014-logging-Close-before-and-open-blackbox-after-fork.patch +++ /dev/null @@ -1,61 +0,0 @@ -diff --git a/exec/logsys.c b/exec/logsys.c -index a38cc5e8..8c9c222c 100644 ---- a/exec/logsys.c -+++ b/exec/logsys.c -@@ -862,3 +862,19 @@ void logsys_blackbox_set(int enable) - - pthread_mutex_unlock (&logsys_config_mutex); - } -+ -+/* -+ * To set correct pid to qb blackbox filename after tty dettach (fork) we have to -+ * close (this function) and (if needed) reopen blackbox (logsys_blackbox_postfork function). -+ */ -+void logsys_blackbox_prefork(void) -+{ -+ -+ (void)qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE); -+} -+ -+void logsys_blackbox_postfork(void) -+{ -+ -+ _logsys_config_apply_blackbox(); -+} -diff --git a/exec/main.c b/exec/main.c -index cd587dc8..426e56d0 100644 ---- a/exec/main.c -+++ b/exec/main.c -@@ -1460,7 +1460,13 @@ int main (int argc, char **argv, char **envp) - * Now we are fully initialized. - */ - if (background) { -+ logsys_blackbox_prefork(); -+ - corosync_tty_detach (); -+ -+ logsys_blackbox_postfork(); -+ -+ log_printf (LOGSYS_LEVEL_DEBUG, "Corosync TTY detached"); - } - - /* -diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h -index ec38d2cb..a4aad69b 100644 ---- a/include/corosync/logsys.h -+++ b/include/corosync/logsys.h -@@ -258,6 +258,11 @@ extern int logsys_thread_start (void); - - extern void logsys_blackbox_set(int enable); - -+extern void logsys_blackbox_prefork(void); -+ -+extern void logsys_blackbox_postfork(void); -+ -+ - /** - * @brief logsys_subsys_id - */ --- -2.13.6 - diff --git a/0015-coverity-fixes.patch b/0015-coverity-fixes.patch deleted file mode 100644 index 6f7274f..0000000 --- a/0015-coverity-fixes.patch +++ /dev/null @@ -1,999 +0,0 @@ -diff --git a/init/corosync-notifyd.in b/init/corosync-notifyd.in -index 0f34e791..d3575795 100755 ---- a/init/corosync-notifyd.in -+++ b/init/corosync-notifyd.in -@@ -99,7 +99,7 @@ stop() - ! status $prog > /dev/null 2>&1 && return - - echo -n "Signaling $desc ($prog) to terminate: " -- kill -TERM $(pidof $prog) > /dev/null 2>&1 -+ kill -TERM "$(pidof $prog)" > /dev/null 2>&1 - success - echo - -diff --git a/init/corosync-qdevice.in b/init/corosync-qdevice.in -index 8e4bb291..1cd32709 100755 ---- a/init/corosync-qdevice.in -+++ b/init/corosync-qdevice.in -@@ -113,7 +113,7 @@ stop() - ! status $prog > /dev/null 2>&1 && return - - echo -n "Signaling $desc ($prog) to terminate: " -- kill -TERM $(pidof $prog) > /dev/null 2>&1 -+ kill -TERM "$(pidof $prog)" > /dev/null 2>&1 - success - echo - -diff --git a/init/corosync-qnetd.in b/init/corosync-qnetd.in -index 681ea085..c06dbb97 100755 ---- a/init/corosync-qnetd.in -+++ b/init/corosync-qnetd.in -@@ -120,7 +120,7 @@ stop() - ! status $prog > /dev/null 2>&1 && return - - echo -n "Signaling $desc ($prog) to terminate: " -- kill -TERM $(pidof $prog) > /dev/null 2>&1 -+ kill -TERM "$(pidof $prog)" > /dev/null 2>&1 - success - echo - -diff --git a/init/corosync.in b/init/corosync.in -index 0868f116..fc3ce58c 100755 ---- a/init/corosync.in -+++ b/init/corosync.in -@@ -128,7 +128,7 @@ stop() - ! status $prog > /dev/null 2>&1 && return - - echo -n "Signaling $desc ($prog) to terminate: " -- kill -TERM $(pidof $prog) > /dev/null 2>&1 -+ kill -TERM "$(pidof $prog)" > /dev/null 2>&1 - success - echo - -diff --git a/tools/corosync-blackbox.sh b/tools/corosync-blackbox.sh -index fb5ce96f..1ca831f3 100644 ---- a/tools/corosync-blackbox.sh -+++ b/tools/corosync-blackbox.sh -@@ -29,6 +29,6 @@ - # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - # THE POSSIBILITY OF SUCH DAMAGE. - --corosync-cmapctl -s runtime.blackbox.dump_state str $(date +%s) --corosync-cmapctl -s runtime.blackbox.dump_flight_data str $(date +%s) -+corosync-cmapctl -s runtime.blackbox.dump_state str "$(date +%s)" -+corosync-cmapctl -s runtime.blackbox.dump_flight_data str "$(date +%s)" - qb-blackbox "@LOCALSTATEDIR@/lib/corosync/fdata" - - -diff --git a/qdevices/corosync-qdevice-net-certutil.sh b/qdevices/corosync-qdevice-net-certutil.sh -index 10b47c8a..b3286295 100644 ---- a/qdevices/corosync-qdevice-net-certutil.sh -+++ b/qdevices/corosync-qdevice-net-certutil.sh -@@ -37,19 +37,13 @@ - BASE_DIR="@COROSYSCONFDIR@/qdevice/net" - DB_DIR_QNETD="@COROSYSCONFDIR@/qnetd/nssdb" - DB_DIR_NODE="$BASE_DIR/nssdb" --# Validity of certificate (months) --CRT_VALIDITY=1200 - CA_NICKNAME="QNet CA" --SERVER_NICKNAME="QNetd Cert" - CLUSTER_NICKNAME="Cluster Cert" --CA_SUBJECT="CN=QNet CA" --SERVER_SUBJECT="CN=Qnetd Server" - PWD_FILE_BASE="pwdfile.txt" - NOISE_FILE_BASE="noise.txt" - SERIAL_NO_FILE_BASE="serial.txt" - CA_EXPORT_FILE="$DB_DIR_QNETD/qnetd-cacert.crt" - CRQ_FILE_BASE="qdevice-net-node.crq" --CRT_FILE_BASE="" # Generated from cluster name - P12_FILE_BASE="qdevice-net-node.p12" - QNETD_CERTUTIL_CMD="corosync-qnetd-certutil" - -@@ -309,7 +303,6 @@ PWD_FILE="$DB_DIR/$PWD_FILE_BASE" - NOISE_FILE="$DB_DIR/$NOISE_FILE_BASE" - SERIAL_NO_FILE="$DB_DIR/$SERIAL_NO_FILE_BASE" - CRQ_FILE="$DB_DIR/$CRQ_FILE_BASE" --CRT_FILE="$DB_DIR/cluster-$CLUSTER_NAME.crt" - P12_FILE="$DB_DIR/$P12_FILE_BASE" - - case "$OPERATION" in -diff --git a/qdevices/corosync-qnetd-certutil.sh b/qdevices/corosync-qnetd-certutil.sh -index 726f482f..fa1d229d 100644 ---- a/qdevices/corosync-qnetd-certutil.sh -+++ b/qdevices/corosync-qnetd-certutil.sh -@@ -40,14 +40,12 @@ DB_DIR="$CONFIG_DIR/nssdb" - CRT_VALIDITY=1200 - CA_NICKNAME="QNet CA" - SERVER_NICKNAME="QNetd Cert" --CLUSTER_NICKNAME="Cluster Cert" - CA_SUBJECT="CN=QNet CA" - SERVER_SUBJECT="CN=Qnetd Server" - PWD_FILE="$DB_DIR/pwdfile.txt" - NOISE_FILE="$DB_DIR/noise.txt" - SERIAL_NO_FILE="$DB_DIR/serial.txt" - CA_EXPORT_FILE="$DB_DIR/qnetd-cacert.crt" --CRT_FILE_BASE="" # Generated from cluster name - - usage() { - echo "$0: [-i|-s] [-c certificate] [-n cluster_name]" -@@ -62,7 +60,7 @@ usage() { - - chown_ref_cfgdir() { - if [ "$UID" == "0" ];then -- chown --reference="$CONFIG_DIR" "$@" 2>/dev/null || chown `stat -f "%u:%g" "$CONFIG_DIR"` "$@" 2>/dev/null || return $? -+ chown --reference="$CONFIG_DIR" "$@" 2>/dev/null || chown "$(stat -f "%u:%g" "$CONFIG_DIR")" "$@" 2>/dev/null || return $? - fi - } - -@@ -123,14 +121,14 @@ init_qnetd_ca() { - echo "Creating new CA" - # Create self-signed certificate (CA). Asks 3 questions (is this CA, lifetime and critical extension - echo -e "y\n0\ny\n" | certutil -S -n "$CA_NICKNAME" -s "$CA_SUBJECT" -x \ -- -t "CT,," -m `get_serial_no` -v $CRT_VALIDITY -d "$DB_DIR" \ -+ -t "CT,," -m "$(get_serial_no)" -v $CRT_VALIDITY -d "$DB_DIR" \ - -z "$NOISE_FILE" -f "$PWD_FILE" -2 - # Export CA certificate in ascii - certutil -L -d "$DB_DIR" -n "$CA_NICKNAME" > "$CA_EXPORT_FILE" - certutil -L -d "$DB_DIR" -n "$CA_NICKNAME" -a >> "$CA_EXPORT_FILE" - chown_ref_cfgdir "$CA_EXPORT_FILE" - -- certutil -S -n "$SERVER_NICKNAME" -s "$SERVER_SUBJECT" -c "$CA_NICKNAME" -t "u,u,u" -m `get_serial_no` \ -+ certutil -S -n "$SERVER_NICKNAME" -s "$SERVER_SUBJECT" -c "$CA_NICKNAME" -t "u,u,u" -m "$(get_serial_no)" \ - -v $CRT_VALIDITY -d "$DB_DIR" -z "$NOISE_FILE" -f "$PWD_FILE" - - echo "QNetd CA certificate is exported as $CA_EXPORT_FILE" -@@ -145,7 +143,7 @@ sign_cluster_cert() { - fi - - echo "Signing cluster certificate" -- certutil -C -v "$CRT_VALIDITY" -m `get_serial_no` -i "$CERTIFICATE_FILE" -o "$CRT_FILE" -c "$CA_NICKNAME" -d "$DB_DIR" -+ certutil -C -v "$CRT_VALIDITY" -m "$(get_serial_no)" -i "$CERTIFICATE_FILE" -o "$CRT_FILE" -c "$CA_NICKNAME" -d "$DB_DIR" - chown_ref_cfgdir "$CRT_FILE" - - echo "Certificate stored in $CRT_FILE" - -diff --git a/cts/agents/sam_test_agent.c b/cts/agents/sam_test_agent.c -index c395db28..39d406c3 100644 ---- a/cts/agents/sam_test_agent.c -+++ b/cts/agents/sam_test_agent.c -@@ -1220,7 +1220,6 @@ static void do_command (int sock, char* func, char*args[], int num_args) - } else if (strcmp ("sam_stop", func) == 0) { - err = sam_stop (); - if (err != CS_OK) { -- err = -1; - qb_log (LOG_ERR,"RPC:%s sam_stop failed!", func); - snprintf (response, 100, "%s", FAIL_STR); - } - -diff --git a/qdevices/process-list.c b/qdevices/process-list.c -index ad2d598b..e5c20db4 100644 ---- a/qdevices/process-list.c -+++ b/qdevices/process-list.c -@@ -161,6 +161,7 @@ process_list_parse_command(const char *command, size_t *no_params) - if (res_argv[zi] == NULL) { - process_list_free_argv(*no_params, res_argv); - res_argv = NULL; -+ goto exit_res; - } - zi++; - } - -diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c -index b37e67f7..2ea006b5 100644 ---- a/tools/corosync-quorumtool.c -+++ b/tools/corosync-quorumtool.c -@@ -532,7 +532,9 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name - printf("%s", g_view_list[i].name); - if (g_view_list[i].node_id == our_nodeid) { - printf(" (local)"); -- our_flags = info[i].flags; -+ if (v_handle) { -+ our_flags = info[i].flags; -+ } - } - printf("\n"); - } - -diff --git a/qdevices/corosync-qdevice-net-certutil.sh b/qdevices/corosync-qdevice-net-certutil.sh -index b3286295..22bc899a 100644 ---- a/qdevices/corosync-qdevice-net-certutil.sh -+++ b/qdevices/corosync-qdevice-net-certutil.sh -@@ -369,7 +369,7 @@ case "$OPERATION" in - - master_node="$1" - shift 1 -- other_nodes="$@" -+ other_nodes="$*" - - if [ "$CLUSTER_NAME" == "" ];then - echo "You have to specify cluster name" >&2 - -diff --git a/qdevices/qnetd-ipc.c b/qdevices/qnetd-ipc.c -index 0d40275e..e5228373 100644 ---- a/qdevices/qnetd-ipc.c -+++ b/qdevices/qnetd-ipc.c -@@ -174,7 +174,8 @@ void - qnetd_ipc_client_disconnect(struct qnetd_instance *instance, struct unix_socket_client *client) - { - -- if (PR_DestroySocketPollFd( -+ if ((struct qnetd_ipc_user_data *)(client)->user_data != NULL && -+ PR_DestroySocketPollFd( - ((struct qnetd_ipc_user_data *)(client)->user_data)->nspr_poll_fd) != PR_SUCCESS) { - qnetd_log_nss(LOG_WARNING, "Unable to destroy client IPC poll socket fd"); - } - -diff --git a/qdevices/Makefile.am b/qdevices/Makefile.am -index 0ab73464..28388a93 100644 ---- a/qdevices/Makefile.am -+++ b/qdevices/Makefile.am -@@ -156,9 +156,9 @@ corosync-qdevice-net-certutil: corosync-qdevice-net-certutil.sh - $< > $@ - - TESTS = qnetd-cluster-list.test dynar.test dynar-simple-lex.test \ -- dynar-getopt-lex.test process-list.test -+ dynar-getopt-lex.test process-list.test utils.test - check_PROGRAMS = qnetd-cluster-list.test dynar.test dynar-simple-lex.test \ -- dynar-getopt-lex.test process-list.test -+ dynar-getopt-lex.test process-list.test utils.test - - qnetd_cluster_list_test_SOURCES = qnetd-cluster-list.c test-qnetd-cluster-list.c \ - qnetd-cluster.c qnetd-cluster.h \ -@@ -172,5 +172,6 @@ dynar_simple_lex_test_SOURCES = test-dynar-simple-lex.c dynar.c dynar-str.c dyna - dynar_getopt_lex_test_SOURCES = test-dynar-getopt-lex.c dynar.c dynar-str.c dynar-getopt-lex.c - process_list_test_SOURCES = test-process-list.c dynar.c dynar-str.c dynar-simple-lex.c \ - process-list.c -+utils_test_SOURCES = test-utils.c utils.c - - endif -diff --git a/qdevices/test-utils.c b/qdevices/test-utils.c -new file mode 100644 -index 00000000..00d5b464 ---- /dev/null -+++ b/qdevices/test-utils.c -@@ -0,0 +1,81 @@ -+/* -+ * Copyright (c) 2015-2018 Red Hat, Inc. -+ * -+ * All rights reserved. -+ * -+ * Author: Jan Friesse (jfriesse@redhat.com) -+ * -+ * This software licensed under BSD license, the text of which follows: -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions are met: -+ * -+ * - Redistributions of source code must retain the above copyright notice, -+ * this list of conditions and the following disclaimer. -+ * - Redistributions in binary form must reproduce the above copyright notice, -+ * this list of conditions and the following disclaimer in the documentation -+ * and/or other materials provided with the distribution. -+ * - Neither the name of the Red Hat, Inc. nor the names of its -+ * contributors may be used to endorse or promote products derived from this -+ * software without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -+ * THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+#include -+#include -+#include -+#include -+ -+#include "utils.h" -+ -+int -+main(void) -+{ -+ long long int ll; -+ long long int lli; -+ char buf[32]; -+ -+ assert(utils_strtonum("0", 0, 100, &ll) == 0); -+ assert(ll == 0); -+ -+ assert(utils_strtonum("100", 0, 100, &ll) == 0); -+ assert(ll == 100); -+ -+ assert(utils_strtonum("101", 0, 100, &ll) != 0); -+ assert(utils_strtonum("0", 1, 100, &ll) != 0); -+ -+ errno = ERANGE; -+ assert(utils_strtonum("10", 0, 100, &ll) == 0); -+ assert(ll == 10); -+ -+ assert(utils_strtonum("-1", -1, 0, &ll) == 0); -+ assert(ll == -1); -+ -+ assert(utils_strtonum("-10", -20, -10, &ll) == 0); -+ assert(ll == -10); -+ -+ assert(utils_strtonum("0", 1, 0, &ll) == -1); -+ -+ for (lli = -100; lli <= 100; lli++) { -+ assert(snprintf(buf, sizeof(buf), "%lld", lli) > 0); -+ -+ assert(utils_strtonum(buf, -100, 100, &ll) == 0); -+ assert(ll == lli); -+ } -+ -+ assert(utils_strtonum("test", -1000, 1000, &ll) == -1); -+ assert(utils_strtonum("12a", -1000, 1000, &ll) == -1); -+ -+ return (0); -+} -diff --git a/qdevices/utils.c b/qdevices/utils.c -index 9574c96a..aba921c3 100644 ---- a/qdevices/utils.c -+++ b/qdevices/utils.c -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2015-2016 Red Hat, Inc. -+ * Copyright (c) 2015-2018 Red Hat, Inc. - * - * All rights reserved. - * -@@ -206,3 +206,33 @@ utils_fd_set_non_blocking(int fd) - - return (0); - } -+ -+/* -+ * Safer wrapper of strtoll. Return 0 on success, otherwise -1. -+ */ -+int -+utils_strtonum(const char *str, long long int min_val, long long int max_val, -+ long long int *res) -+{ -+ long long int tmp_ll; -+ char *ep; -+ -+ if (min_val > max_val) { -+ return (-1); -+ } -+ -+ errno = 0; -+ -+ tmp_ll = strtoll(str, &ep, 10); -+ if (ep == str || *ep != '\0' || errno != 0) { -+ return (-1); -+ } -+ -+ if (tmp_ll < min_val || tmp_ll > max_val) { -+ return (-1); -+ } -+ -+ *res = tmp_ll; -+ -+ return (0); -+} -diff --git a/qdevices/utils.h b/qdevices/utils.h -index fe9b5b47..0d96df43 100644 ---- a/qdevices/utils.h -+++ b/qdevices/utils.h -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2015-2016 Red Hat, Inc. -+ * Copyright (c) 2015-2018 Red Hat, Inc. - * - * All rights reserved. - * -@@ -62,6 +62,9 @@ extern void utils_tty_detach(void); - - extern int utils_fd_set_non_blocking(int fd); - -+extern int utils_strtonum(const char *str, long long int min_val, -+ long long int max_val, long long int *res); -+ - #ifdef __cplusplus - } - #endif - -diff --git a/qdevices/qdevice-advanced-settings.c b/qdevices/qdevice-advanced-settings.c -index e3d7a9a9..41df6ca5 100644 ---- a/qdevices/qdevice-advanced-settings.c -+++ b/qdevices/qdevice-advanced-settings.c -@@ -33,8 +33,10 @@ - */ - - #include --#include -+ - #include -+#include -+#include - - #include "dynar.h" - #include "dynar-getopt-lex.h" -@@ -126,7 +128,6 @@ qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings, - const char *option, const char *value) - { - long long int tmpll; -- char *ep; - - if (strcasecmp(option, "lock_file") == 0) { - free(settings->lock_file); -@@ -141,15 +142,13 @@ qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings, - return (-1); - } - } else if (strcasecmp(option, "local_socket_backlog") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_LOCAL_SOCKET_BACKLOG || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_LOCAL_SOCKET_BACKLOG, INT_MAX, &tmpll) == -1) { - return (-2); - } - - settings->local_socket_backlog = (int)tmpll; - } else if (strcasecmp(option, "max_cs_try_again") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_MAX_CS_TRY_AGAIN || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_MAX_CS_TRY_AGAIN, INT_MAX, &tmpll) == -1) { - return (-2); - } - -@@ -161,71 +160,70 @@ qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings, - return (-1); - } - } else if (strcasecmp(option, "ipc_max_clients") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_IPC_MAX_CLIENTS || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_IPC_MAX_CLIENTS, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - - settings->ipc_max_clients = (size_t)tmpll; - } else if (strcasecmp(option, "ipc_max_receive_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->ipc_max_receive_size = (size_t)tmpll; - } else if (strcasecmp(option, "ipc_max_send_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->ipc_max_send_size = (size_t)tmpll; - } else if (strcasecmp(option, "heuristics_ipc_max_send_buffers") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_IPC_MAX_SEND_BUFFERS || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_IPC_MAX_SEND_BUFFERS, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_ipc_max_send_buffers = (size_t)tmpll; - } else if (strcasecmp(option, "heuristics_ipc_max_send_receive_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_IPC_MAX_SEND_RECEIVE_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_IPC_MAX_SEND_RECEIVE_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_ipc_max_send_receive_size = (size_t)tmpll; - } else if (strcasecmp(option, "heuristics_min_timeout") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_TIMEOUT || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_TIMEOUT, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_min_timeout = (uint32_t)tmpll; - } else if (strcasecmp(option, "heuristics_max_timeout") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_TIMEOUT || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_TIMEOUT, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_max_timeout = (uint32_t)tmpll; - } else if (strcasecmp(option, "heuristics_min_interval") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_INTERVAL, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_min_interval = (uint32_t)tmpll; - } else if (strcasecmp(option, "heuristics_max_interval") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_INTERVAL, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_max_interval = (uint32_t)tmpll; - } else if (strcasecmp(option, "heuristics_max_execs") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_MAX_EXECS || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_MAX_EXECS, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - -@@ -237,15 +235,15 @@ qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings, - - settings->heuristics_use_execvp = (uint8_t)tmpll; - } else if (strcasecmp(option, "heuristics_max_processes") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_MAX_PROCESSES || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_MAX_PROCESSES, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->heuristics_max_processes = (size_t)tmpll; - } else if (strcasecmp(option, "heuristics_kill_list_interval") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_MIN_HEURISTICS_KILL_LIST_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_MIN_HEURISTICS_KILL_LIST_INTERVAL, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - -@@ -257,36 +255,36 @@ qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings, - return (-1); - } - } else if (strcasecmp(option, "net_initial_msg_receive_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_initial_msg_receive_size = (size_t)tmpll; - } else if (strcasecmp(option, "net_initial_msg_send_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_initial_msg_send_size = (size_t)tmpll; - } else if (strcasecmp(option, "net_min_msg_send_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_min_msg_send_size = (size_t)tmpll; - } else if (strcasecmp(option, "net_max_msg_receive_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_max_msg_receive_size = (size_t)tmpll; - } else if (strcasecmp(option, "net_max_send_buffers") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_MAX_SEND_BUFFERS || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_MAX_SEND_BUFFERS, LLONG_MAX, -+ &tmpll) == -1) { - return (-2); - } - -@@ -304,29 +302,29 @@ qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings, - return (-1); - } - } else if (strcasecmp(option, "net_heartbeat_interval_min") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_HEARTBEAT_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_HEARTBEAT_INTERVAL, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_heartbeat_interval_min = (uint32_t)tmpll; - } else if (strcasecmp(option, "net_heartbeat_interval_max") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_HEARTBEAT_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_HEARTBEAT_INTERVAL, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_heartbeat_interval_max = (uint32_t)tmpll; - } else if (strcasecmp(option, "net_min_connect_timeout") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_CONNECT_TIMEOUT || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_CONNECT_TIMEOUT, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - - settings->net_min_connect_timeout = (uint32_t)tmpll; - } else if (strcasecmp(option, "net_max_connect_timeout") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QDEVICE_NET_MIN_CONNECT_TIMEOUT || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QDEVICE_NET_MIN_CONNECT_TIMEOUT, UINT32_MAX, -+ &tmpll) == -1) { - return (-2); - } - -diff --git a/qdevices/qdevice-instance.c b/qdevices/qdevice-instance.c -index 52593281..dd49b585 100644 ---- a/qdevices/qdevice-instance.c -+++ b/qdevices/qdevice-instance.c -@@ -67,8 +67,7 @@ int - qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instance) - { - char *str; -- long int li; -- char *ep; -+ long long int lli; - int i; - int res; - cs_error_t cs_err; -@@ -87,9 +86,8 @@ qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instanc - instance->heuristics_instance.timeout = instance->heartbeat_interval / 2; - if (cmap_get_string(instance->cmap_handle, - "quorum.device.heuristics.timeout", &str) == CS_OK) { -- li = strtol(str, &ep, 10); -- if (li < instance->advanced_settings->heuristics_min_timeout || -- li > instance->advanced_settings->heuristics_max_timeout || *ep != '\0') { -+ if (utils_strtonum(str, instance->advanced_settings->heuristics_min_timeout, -+ instance->advanced_settings->heuristics_max_timeout, &lli) == -1) { - qdevice_log(LOG_ERR, "heuristics.timeout must be valid number in " - "range <%"PRIu32",%"PRIu32">", - instance->advanced_settings->heuristics_min_timeout, -@@ -98,7 +96,7 @@ qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instanc - free(str); - return (-1); - } else { -- instance->heuristics_instance.timeout = li; -+ instance->heuristics_instance.timeout = lli; - } - - free(str); -@@ -107,9 +105,8 @@ qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instanc - instance->heuristics_instance.sync_timeout = instance->sync_heartbeat_interval / 2; - if (cmap_get_string(instance->cmap_handle, - "quorum.device.heuristics.sync_timeout", &str) == CS_OK) { -- li = strtol(str, &ep, 10); -- if (li < instance->advanced_settings->heuristics_min_timeout || -- li > instance->advanced_settings->heuristics_max_timeout || *ep != '\0') { -+ if (utils_strtonum(str, instance->advanced_settings->heuristics_min_timeout, -+ instance->advanced_settings->heuristics_max_timeout, &lli) == -1) { - qdevice_log(LOG_ERR, "heuristics.sync_timeout must be valid number in " - "range <%"PRIu32",%"PRIu32">", - instance->advanced_settings->heuristics_min_timeout, -@@ -118,7 +115,7 @@ qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instanc - free(str); - return (-1); - } else { -- instance->heuristics_instance.sync_timeout = li; -+ instance->heuristics_instance.sync_timeout = lli; - } - - free(str); -@@ -127,9 +124,8 @@ qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instanc - instance->heuristics_instance.interval = instance->heartbeat_interval * 3; - if (cmap_get_string(instance->cmap_handle, - "quorum.device.heuristics.interval", &str) == CS_OK) { -- li = strtol(str, &ep, 10); -- if (li < instance->advanced_settings->heuristics_min_interval || -- li > instance->advanced_settings->heuristics_max_interval || *ep != '\0') { -+ if (utils_strtonum(str, instance->advanced_settings->heuristics_min_interval, -+ instance->advanced_settings->heuristics_max_interval, &lli) == -1) { - qdevice_log(LOG_ERR, "heuristics.interval must be valid number in " - "range <%"PRIu32",%"PRIu32">", - instance->advanced_settings->heuristics_min_interval, -@@ -138,7 +134,7 @@ qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance *instanc - free(str); - return (-1); - } else { -- instance->heuristics_instance.interval = li; -+ instance->heuristics_instance.interval = lli; - } - - free(str); -diff --git a/qdevices/qdevice-net-instance.c b/qdevices/qdevice-net-instance.c -index e4b7b04d..87cf3ee0 100644 ---- a/qdevices/qdevice-net-instance.c -+++ b/qdevices/qdevice-net-instance.c -@@ -32,6 +32,8 @@ - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -+#include -+ - #include "qdevice-config.h" - #include "qdevice-log.h" - #include "qdevice-net-instance.h" -@@ -214,7 +216,7 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - cmap_handle_t cmap_handle; - enum tlv_tls_supported tls_supported; - int i; -- long int li; -+ long long int lli; - enum tlv_decision_algorithm_type decision_algorithm; - struct tlv_tie_breaker tie_breaker; - uint32_t heartbeat_interval; -@@ -222,7 +224,6 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - uint32_t cast_vote_timer_interval; - char *host_addr; - int host_port; -- char *ep; - char *cluster_name; - uint32_t connect_timeout; - struct qdevice_net_instance *net_instance; -@@ -272,14 +273,14 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - host_addr = str; - - if (cmap_get_string(cmap_handle, "quorum.device.net.port", &str) == CS_OK) { -- host_port = strtol(str, &ep, 10); -- -- if (host_port <= 0 || host_port > ((uint16_t)~0) || *ep != '\0') { -- qdevice_log(LOG_ERR, "quorum.device.net.port must be in range 0-65535"); -+ if (utils_strtonum(optarg, 1, UINT16_MAX, &lli) == -1) { -+ qdevice_log(LOG_ERR, "quorum.device.net.port must be in range 1-%u", UINT16_MAX); - free(str); - goto error_free_host_addr; - } - free(str); -+ -+ host_port = lli; - } else { - host_port = QNETD_DEFAULT_HOST_PORT; - } -@@ -353,15 +354,14 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - } else if (strcmp(str, "highest") == 0) { - tie_breaker.mode = TLV_TIE_BREAKER_MODE_HIGHEST; - } else { -- li = strtol(str, &ep, 10); -- if (li <= 0 || li > ((uint32_t)~0) || *ep != '\0') { -+ if (utils_strtonum(str, 1, UINT32_MAX, &lli) == -1) { - qdevice_log(LOG_ERR, "tie_breaker must be lowest|highest|valid_node_id"); - free(str); - goto error_free_cluster_name; - } - - tie_breaker.mode = TLV_TIE_BREAKER_MODE_NODE_ID; -- tie_breaker.node_id = li; -+ tie_breaker.node_id = lli; - } - - free(str); -@@ -373,9 +373,8 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - if (cmap_get_string(cmap_handle, "quorum.device.net.connect_timeout", &str) != CS_OK) { - connect_timeout = heartbeat_interval; - } else { -- li = strtol(str, &ep, 10); -- if (li < instance->advanced_settings->net_min_connect_timeout || -- li > instance->advanced_settings->net_max_connect_timeout || *ep != '\0') { -+ if (utils_strtonum(str, instance->advanced_settings->net_min_connect_timeout, -+ instance->advanced_settings->net_max_connect_timeout, &lli) == -1) { - qdevice_log(LOG_ERR, "connect_timeout must be valid number in " - "range <%"PRIu32",%"PRIu32">", - instance->advanced_settings->net_min_connect_timeout, -@@ -384,7 +383,7 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - goto error_free_cluster_name; - } - -- connect_timeout = li; -+ connect_timeout = (uint32_t)lli; - - free(str); - } -@@ -392,14 +391,14 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance) - if (cmap_get_string(cmap_handle, "quorum.device.net.force_ip_version", &str) != CS_OK) { - force_ip_version = 0; - } else { -- li = strtol(str, &ep, 10); -- if ((li != 0 && li != 4 && li != 6) || *ep != '\0') { -+ if ((utils_strtonum(str, 0, 6, &lli) == -1) || -+ (lli != 0 && lli != 4 && lli != 6)) { - qdevice_log(LOG_ERR, "force_ip_version must be one of 0|4|6"); - free(str); - goto error_free_cluster_name; - } - -- force_ip_version = li; -+ force_ip_version = lli; - - free(str); - } - -diff --git a/qdevices/corosync-qnetd.c b/qdevices/corosync-qnetd.c -index c6b8b0dc..9af94b7b 100644 ---- a/qdevices/corosync-qnetd.c -+++ b/qdevices/corosync-qnetd.c -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -426,7 +427,6 @@ cli_parse(int argc, char * const argv[], char **host_addr, uint16_t *host_port, - struct qnetd_advanced_settings *advanced_settings) - { - int ch; -- char *ep; - long long int tmpll; - - *host_addr = NULL; -@@ -469,19 +469,18 @@ cli_parse(int argc, char * const argv[], char **host_addr, uint16_t *host_port, - } - break; - case 'm': -- errno = 0; -- -- tmpll = strtoll(optarg, &ep, 10); -- if (tmpll < 0 || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(optarg, 0, LLONG_MAX, &tmpll) == -1) { - errx(1, "max clients value %s is invalid", optarg); - } -+ - *max_clients = (size_t)tmpll; - break; - case 'p': -- *host_port = strtol(optarg, &ep, 10); -- if (*host_port <= 0 || *host_port > ((uint16_t)~0) || *ep != '\0') { -- errx(1, "host port must be in range 0-65535"); -+ if (utils_strtonum(optarg, 1, UINT16_MAX, &tmpll) == -1) { -+ errx(1, "host port must be in range 1-%u", UINT16_MAX); - } -+ -+ *host_port = tmpll; - break; - case 'S': - cli_parse_long_opt(advanced_settings, optarg); -diff --git a/qdevices/qnetd-advanced-settings.c b/qdevices/qnetd-advanced-settings.c -index f1eff374..04519f0a 100644 ---- a/qdevices/qnetd-advanced-settings.c -+++ b/qdevices/qnetd-advanced-settings.c -@@ -33,8 +33,10 @@ - */ - - #include --#include -+ - #include -+#include -+#include - - #include "dynar.h" - #include "dynar-getopt-lex.h" -@@ -96,32 +98,27 @@ qnetd_advanced_settings_set(struct qnetd_advanced_settings *settings, - const char *option, const char *value) - { - long long int tmpll; -- char *ep; - - if (strcasecmp(option, "listen_backlog") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_LISTEN_BACKLOG || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_LISTEN_BACKLOG, INT_MAX, &tmpll) == -1) { - return (-2); - } - - settings->listen_backlog = (int)tmpll; - } else if (strcasecmp(option, "max_client_send_buffers") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_CLIENT_SEND_BUFFERS || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_CLIENT_SEND_BUFFERS, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - - settings->max_client_send_buffers = (size_t)tmpll; - } else if (strcasecmp(option, "max_client_send_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_CLIENT_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_CLIENT_RECEIVE_SEND_SIZE, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - - settings->max_client_send_size = (size_t)tmpll; - } else if (strcasecmp(option, "max_client_receive_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_CLIENT_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_CLIENT_RECEIVE_SEND_SIZE, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - -@@ -139,15 +136,13 @@ qnetd_advanced_settings_set(struct qnetd_advanced_settings *settings, - return (-1); - } - } else if (strcasecmp(option, "heartbeat_interval_min") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_HEARTBEAT_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_HEARTBEAT_INTERVAL, UINT32_MAX, &tmpll) == -1) { - return (-2); - } - - settings->heartbeat_interval_min = (uint32_t)tmpll; - } else if (strcasecmp(option, "heartbeat_interval_max") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_HEARTBEAT_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_HEARTBEAT_INTERVAL, UINT32_MAX, &tmpll) == -1) { - return (-2); - } - -@@ -159,8 +154,7 @@ qnetd_advanced_settings_set(struct qnetd_advanced_settings *settings, - - settings->dpd_enabled = (uint8_t)tmpll; - } else if (strcasecmp(option, "dpd_interval") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_DPD_INTERVAL || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_DPD_INTERVAL, UINT32_MAX, &tmpll) == -1) { - return (-2); - } - -@@ -178,29 +172,25 @@ qnetd_advanced_settings_set(struct qnetd_advanced_settings *settings, - return (-1); - } - } else if (strcasecmp(option, "local_socket_backlog") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_LOCAL_SOCKET_BACKLOG || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_LOCAL_SOCKET_BACKLOG, INT_MAX, &tmpll) == -1) { - return (-2); - } - - settings->local_socket_backlog = (int)tmpll; - } else if (strcasecmp(option, "ipc_max_clients") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_IPC_MAX_CLIENTS || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_IPC_MAX_CLIENTS, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - - settings->ipc_max_clients = (size_t)tmpll; - } else if (strcasecmp(option, "ipc_max_receive_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_IPC_RECEIVE_SEND_SIZE, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - - settings->ipc_max_receive_size = (size_t)tmpll; - } else if (strcasecmp(option, "ipc_max_send_size") == 0) { -- tmpll = strtoll(value, &ep, 10); -- if (tmpll < QNETD_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') { -+ if (utils_strtonum(value, QNETD_MIN_IPC_RECEIVE_SEND_SIZE, LLONG_MAX, &tmpll) == -1) { - return (-2); - } - -diff --git a/exec/main.c b/exec/main.c -index 426e56d0..5523432b 100644 ---- a/exec/main.c -+++ b/exec/main.c -@@ -1258,6 +1258,8 @@ int main (int argc, char **argv, char **envp) - } else if (strcmp(optarg, "min") == 0) { - prio = INT_MAX; - } else { -+ errno = 0; -+ - tmpli = strtol(optarg, &ep, 10); - if (errno != 0 || *ep != '\0' || tmpli > INT_MAX || tmpli < INT_MIN) { - fprintf(stderr, "Priority value %s is invalid", optarg); - diff --git a/0018-bsc#1089346-corosync-Integer-overflow-in-totemcrypto.patch b/0018-bsc#1089346-corosync-Integer-overflow-in-totemcrypto.patch deleted file mode 100644 index 062725e..0000000 --- a/0018-bsc#1089346-corosync-Integer-overflow-in-totemcrypto.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- corosync-2.4.3.orig/exec/totemcrypto.c 2017-10-20 20:40:19.000000000 +0800 -+++ corosync-2.4.3/exec/totemcrypto.c 2018-04-13 13:01:02.864922963 +0800 -@@ -736,6 +736,11 @@ - unsigned char tmp_hash[hash_len[instance->crypto_hash_type]]; - int datalen = *buf_len - hash_len[instance->crypto_hash_type]; - -+ if (*buf_len <= hash_len[instance->crypto_hash_type]) { -+ log_printf(instance->log_level_security, "Received message is too short... ignoring"); -+ return -1; -+ } -+ - if (calculate_nss_hash(instance, buf, datalen, tmp_hash) < 0) { - return -1; - } -@@ -845,6 +850,11 @@ - { - struct crypto_config_header *cch = (struct crypto_config_header *)buf; - -+ if (*buf_len <= sizeof(struct crypto_config_header)) { -+ log_printf(instance->log_level_security, "Received message is too short... ignoring"); -+ return (-1); -+ } -+ - if (cch->crypto_cipher_type != CRYPTO_CIPHER_TYPE_2_3) { - log_printf(instance->log_level_security, - "Incoming packet has different crypto type. Rejecting"); diff --git a/corosync-2.4.3.tar.gz b/corosync-2.4.3.tar.gz deleted file mode 100644 index 531d0fe..0000000 --- a/corosync-2.4.3.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2752c8707f95e510fd0a4de47b55f0055cd3e16be8f5bfcef0ef8d2e85b84b82 -size 578510 diff --git a/corosync-2.4.4.tar.gz b/corosync-2.4.4.tar.gz new file mode 100644 index 0000000..5fb6742 --- /dev/null +++ b/corosync-2.4.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa1d27be34b23e31b7780748aa5baf01b2b5340c33e57f4f955496a047161161 +size 581496 diff --git a/corosync.changes b/corosync.changes index 0c7cbf4..f137c13 100644 --- a/corosync.changes +++ b/corosync.changes @@ -1,3 +1,81 @@ +------------------------------------------------------------------- +Tue Apr 17 10:19:52 UTC 2018 - bliu@suse.com + +- corosync-2.4.4 is available now(bsc#1089836) + man:fix in corosync-qdevice.8 + quorumtool: remove duplicated help message + cfg: nodeid should be unsigned int + coroparse: Use readdir instead of readdir_r + wd: fix snprintf warnings + Fix compile errors in qdevice on FreeBSD + qdevice: mv free(str) after port validation + Fix various typos + Fix typo: recomended -> recommended + man: support SOURCE_DATE_EPOCH + configure: add --with-initconfigdir option + Use static case blocks to determine distro flavor + Use RuntimeDirectory instead of tmpfiles.d + coroparse: Do not convert empty uid, gid to 0 + sam: Fix snprintf compiler warnings + quorumtool: Use full buffer size in snprintf + man: Add note about qdevice parallel cmds start + sync: Remove unneeded determine sync code + sync: Call sync_init of all services at once + corosync.conf: publicize nodelist.node.name + totemudp[u]: Drop truncated packets on receive + logging: Make blackbox configurable + logging: Close before and open blackbox after fork + init: Quote subshell result properly + blackbox: Quote subshell result properly + qdevice: quote certutils scripts properly + sam_test_agent: Remove unused assignment + qdevice: Fix NULL pointer dereference + quorumtool: Don't set our_flags without v_handle + qdevice: Nodelist is set into string not array + qdevice: Check if user_data can be dereferenced + qdevice: Add safer wrapper of strtoll + qdevice: Replace strtol by strtonum + qnetd: Replace strtol by strtonum + main: Set errno before calling of strtol + totemcrypto: Implement bad crypto header guess + cpg: Use list_del instead of qb_list_del + totemcrypto: Check length of the packet + totemsrp: Implement sanity checks of received msgs + totemsrp: Check join and leave msg length + totemudp: Check lenght of message to sent + qdevice msgio: Fix reading of msg longer than i32 + logsys: Avoid redundant callsite section checking + man: corosync-qdevice: fix formatting vs. punctuation + man: corosync-qdevice: some more stylistics + man: fix cpg_mcast_joined.3.in + libcpg: Fix issue with partial big packet assembly + totempg: Fix fragmentation segfault + totempg: use iovec[i].iov_len instead of copy_len + totempg: Fix corrupted messages + cpg: Handle fragmented message sending interrupt + corosync.aug: Add missing options + systemd: Delete unnecessary soft_margin + + Added: + corosync-2.4.4.tar.gz + 0010-qdevice-net-instance.c-optarg-should-be-str.patch + Deleted: + 0007-sync-Call-sync_init-of-all-services-at-once.patch + 0008-wd-fix-snprintf-warnings.patch + 0009-add-config-for-corosync-qnetd.patch + 0010-qdevice-mv-free-str-after-port-validation.patch + 0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch + 0012-totemudp-u-Drop-truncated-packets-on-receive.patch + 0013-logging-Make-blackbox-configurable.patch + 0014-logging-Close-before-and-open-blackbox-after-fork.patch + 0015-coverity-fixes.patch + 0018-bsc#1089346-corosync-Integer-overflow-in-totemcrypto.patch + corosync-2.4.3.tar.gz + Renamed: + 0009-add-config-for-corosync-qnetd.patch -> 0007-add-config-for-corosync-qnetd.patch + 0016-bsc#1083561-upgrade-from-1-x-y.patch -> 0008-bsc#1083561-upgrade-from-1-x-y.patch + 0017-bsc#1088619-add-version.patch -> 0009-bsc#1088619-add-version.patch + ------------------------------------------------------------------- Fri Apr 13 05:17:10 UTC 2018 - bliu@suse.com diff --git a/corosync.spec b/corosync.spec index 49f0fb2..d72b596 100644 --- a/corosync.spec +++ b/corosync.spec @@ -50,7 +50,7 @@ Name: corosync Summary: The Corosync Cluster Engine and Application Programming Interfaces License: BSD-3-Clause Group: Productivity/Clustering/HA -Version: 2.4.3 +Version: 2.4.4 Release: 0 Url: http://corosync.github.io/corosync/ Source0: %{name}-%{version}.tar.gz @@ -68,18 +68,10 @@ Patch10: 0003-fix-tmpfiles-create.patch Patch11: 0004-mark-corosync-as-a-static-service.patch Patch12: 0005-do-not-convert-empty-uid-gid-to-0.patch Patch13: 0006-Fix-compile-warnings-with-GCC-7.2.1.patch -Patch14: 0007-sync-Call-sync_init-of-all-services-at-once.patch -Patch15: 0008-wd-fix-snprintf-warnings.patch -Patch16: 0009-add-config-for-corosync-qnetd.patch -Patch17: 0010-qdevice-mv-free-str-after-port-validation.patch -Patch18: 0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch -Patch19: 0012-totemudp-u-Drop-truncated-packets-on-receive.patch -Patch20: 0013-logging-Make-blackbox-configurable.patch -Patch21: 0014-logging-Close-before-and-open-blackbox-after-fork.patch -Patch22: 0015-coverity-fixes.patch -Patch23: 0016-bsc#1083561-upgrade-from-1-x-y.patch -Patch24: 0017-bsc#1088619-add-version.patch -Patch25: 0018-bsc#1089346-corosync-Integer-overflow-in-totemcrypto.patch +Patch14: 0007-add-config-for-corosync-qnetd.patch +Patch15: 0008-bsc#1083561-upgrade-from-1-x-y.patch +Patch16: 0009-bsc#1088619-add-version.patch +Patch17: 0010-qdevice-net-instance.c-optarg-should-be-str.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build # openais is indeed gone and should be uninstalled. Yes, we do not @@ -162,14 +154,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build %patch15 -p1 %patch16 -p1 %patch17 -p1 -%patch18 -p1 -%patch19 -p1 -%patch20 -p1 -%patch21 -p1 -%patch22 -p1 -%patch23 -p1 -%patch24 -p1 -%patch25 -p1 %build %if %{with runautogen} @@ -272,8 +256,6 @@ install -m 770 -d %{buildroot}/run/corosync-qnetd %if %{with systemd} sed -i -e 's/^#User=/User=/' \ %{buildroot}%{_unitdir}/corosync-qnetd.service -sed -i -e 's/root/coroqnetd/g' \ - %{buildroot}%{_tmpfilesdir}/corosync-qnetd.conf %else sed -i -e 's/^COROSYNC_QNETD_RUNAS=""$/COROSYNC_QNETD_RUNAS="coroqnetd"/' \ %{buildroot}%{_sysconfdir}/sysconfig/corosync-qnetd @@ -671,7 +653,6 @@ getent passwd coroqnetd >/dev/null || useradd -r -g coroqnetd -u 701 -s /sbin/no exit 0 %post -n corosync-qnetd -%tmpfiles_create /usr/lib/tmpfiles.d/corosync-qnetd.conf %if %{sles_version} > 0 ln -s /run/corosync-qnetd /var/run/ %endif @@ -706,7 +687,6 @@ fi %{_sbindir}/rccorosync-qnetd %dir %{_datadir}/corosync %{_datadir}/corosync/corosync-qnetd -%{_tmpfilesdir}/corosync-qnetd.conf %endif %{_mandir}/man8/corosync-qnetd-tool.8* %{_mandir}/man8/corosync-qnetd-certutil.8*