Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From c5034fe42df8923bcefc10e163151997d70b6241 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 16 Apr 2018 14:56:47 -0700 |
| 4 | Subject: [PATCH] Fix format-truncation errors |
| 5 | |
| 6 | Fixes errors with gcc8 eg. |
| 7 | error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 254 [-Werror=format-truncation=] |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | |
| 11 | --- |
| 12 | src/base/daemon.c | 4 ++-- |
| 13 | src/mds/mds_c_db.c | 8 ++++---- |
| 14 | src/mds/mds_core.h | 4 ++-- |
| 15 | src/mds/mds_dt2c.h | 2 +- |
| 16 | 4 files changed, 9 insertions(+), 9 deletions(-) |
| 17 | |
| 18 | diff --git a/src/base/daemon.c b/src/base/daemon.c |
| 19 | index 361dd8d..4001b73 100644 |
| 20 | --- a/src/base/daemon.c |
| 21 | +++ b/src/base/daemon.c |
| 22 | @@ -95,11 +95,11 @@ static int __create_pidfile(const char *pidfile) |
| 23 | { |
| 24 | FILE *file = NULL; |
| 25 | int fd, rc = 0; |
| 26 | - char pidfiletmp[NAME_MAX] = {0}; |
| 27 | + char pidfiletmp[NAME_MAX+12] = {0}; |
| 28 | pid_t pid; |
| 29 | |
| 30 | pid = getpid(); |
| 31 | - snprintf(pidfiletmp, NAME_MAX, "%s.%u.tmp", pidfile, pid); |
| 32 | + snprintf(pidfiletmp, NAME_MAX+12, "%s.%u.tmp", pidfile, pid); |
| 33 | |
| 34 | /* open the file and associate a stream with it */ |
| 35 | if (((fd = open(pidfiletmp, O_RDWR | O_CREAT, 0644)) == -1) || |
| 36 | diff --git a/src/mds/mds_c_db.c b/src/mds/mds_c_db.c |
| 37 | index e6b95cd..3d4a222 100644 |
| 38 | --- a/src/mds/mds_c_db.c |
| 39 | +++ b/src/mds/mds_c_db.c |
| 40 | @@ -124,10 +124,10 @@ void get_adest_details(MDS_DEST adest, char *adest_details) |
| 41 | } |
| 42 | |
| 43 | if (remote == true) |
| 44 | - snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN, |
| 45 | + snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN+24, |
| 46 | "<rem_nodeid[0x%" PRIx32 "]:%s>", ncs_node_id, process_name); |
| 47 | else |
| 48 | - snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN, |
| 49 | + snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN+24, |
| 50 | "<nodeid[0x%" PRIx32 "]:%s>", ncs_node_id, process_name); |
| 51 | |
| 52 | m_MDS_LOG_DBG("MDS:DB: adest_details: %s ", adest_details); |
| 53 | @@ -207,10 +207,10 @@ void get_subtn_adest_details(MDS_PWE_HDL pwe_hdl, MDS_SVC_ID svc_id, |
| 54 | } |
| 55 | |
| 56 | if (remote == true) |
| 57 | - snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN, |
| 58 | + snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN+24, |
| 59 | "<rem_node[0x%" PRIx32 "]:%s>", ncs_node_id, process_name); |
| 60 | else |
| 61 | - snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN, |
| 62 | + snprintf(adest_details, MDS_MAX_PROCESS_NAME_LEN+24, |
| 63 | "<node[0x%" PRIx32 "]:%s>", ncs_node_id, process_name); |
| 64 | done: |
| 65 | m_MDS_LOG_DBG("MDS:DB: adest_details: %s ", adest_details); |
| 66 | diff --git a/src/mds/mds_core.h b/src/mds/mds_core.h |
| 67 | index 37696d4..7f5225d 100644 |
| 68 | --- a/src/mds/mds_core.h |
| 69 | +++ b/src/mds/mds_core.h |
| 70 | @@ -163,7 +163,7 @@ typedef struct mds_subscription_results_info { |
| 71 | uint32_t msg_snd_cnt; /* Message send count to this destination */ |
| 72 | uint32_t msg_rcv_cnt; /* Message rcv count from this destination */ |
| 73 | char sub_adest_details |
| 74 | - [MDS_MAX_PROCESS_NAME_LEN]; /* <node[slotno]:processname[pid]> */ |
| 75 | + [MDS_MAX_PROCESS_NAME_LEN+24]; /* <node[slotno]:processname[pid]> */ |
| 76 | |
| 77 | } MDS_SUBSCRIPTION_RESULTS_INFO; |
| 78 | |
| 79 | @@ -194,7 +194,7 @@ typedef struct mds_subscription_info { |
| 80 | count is grater than ZERO bcast (multi-unicast) */ |
| 81 | uint32_t prev_ver_sub_count; |
| 82 | char sub_adest_details |
| 83 | - [MDS_MAX_PROCESS_NAME_LEN]; /* <node[slotno]:processname[pid]> */ |
| 84 | + [MDS_MAX_PROCESS_NAME_LEN+24]; /* <node[slotno]:processname[pid]> */ |
| 85 | |
| 86 | } MDS_SUBSCRIPTION_INFO; |
| 87 | |
| 88 | diff --git a/src/mds/mds_dt2c.h b/src/mds/mds_dt2c.h |
| 89 | index 012999c..006b722 100644 |
| 90 | --- a/src/mds/mds_dt2c.h |
| 91 | +++ b/src/mds/mds_dt2c.h |
| 92 | @@ -143,7 +143,7 @@ typedef struct mdtm_send_req { |
| 93 | */ |
| 94 | MDS_DEST adest; /* MDTM to do local/remote routing, destination adest */ |
| 95 | char sub_adest_details |
| 96 | - [MDS_MAX_PROCESS_NAME_LEN]; /* <node[nodeid]:processname[pid]> */ |
| 97 | + [MDS_MAX_PROCESS_NAME_LEN+24]; /* <node[nodeid]:processname[pid]> */ |
| 98 | MDS_SEND_PRIORITY_TYPE pri; |
| 99 | MDS_CLIENT_MSG_FORMAT_VER |
| 100 | msg_fmt_ver; /* message format version specification */ |