summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerenc Wágner <wferi@niif.hu>2015-07-08 14:41:26 +0200
committerMarian Csontos <mcsontos@redhat.com>2015-08-18 16:23:38 +0200
commit6ddcaa22bbff9928e8017797fc7ab44b8085e2a5 (patch)
tree77e6b6b62d716803eed0165d70faee693434f33b
parent9887bb774ba8b6ab043e98052b908fa062346b86 (diff)
downloadlvm2-6ddcaa22bbff9928e8017797fc7ab44b8085e2a5.tar.gz
cmirrord: avoid debugging buffer overflow in LOG_SPRINT
Use snprintf() instead of sprintf() to exclude the possibility of overflowing the debugging history buffers.
-rw-r--r--daemons/cmirrord/cluster.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/daemons/cmirrord/cluster.c b/daemons/cmirrord/cluster.c
index 4a4bdabca..2850d9b9b 100644
--- a/daemons/cmirrord/cluster.c
+++ b/daemons/cmirrord/cluster.c
@@ -104,10 +104,11 @@ static SaVersionT version = { 'B', 1, 1 };
#endif
#define DEBUGGING_HISTORY 100
+#define DEBUGGING_BUFLEN 128
#define LOG_SPRINT(cc, f, arg...) do { \
cc->idx++; \
cc->idx = cc->idx % DEBUGGING_HISTORY; \
- sprintf(cc->debugging[cc->idx], f, ## arg); \
+ snprintf(cc->debugging[cc->idx], DEBUGGING_BUFLEN, f, ## arg); \
} while (0)
static int log_resp_rec = 0;
@@ -150,7 +151,7 @@ struct clog_cpg {
uint32_t checkpoint_requesters[MAX_CHECKPOINT_REQUESTERS];
struct checkpoint_data *checkpoint_list;
int idx;
- char debugging[DEBUGGING_HISTORY][128];
+ char debugging[DEBUGGING_HISTORY][DEBUGGING_BUFLEN];
};
static struct dm_list clog_cpg_list;