summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerenc Wágner <wferi@niif.hu>2015-07-08 14:41:27 +0200
committerHeinz Mauelshagen <heinzm@redhat.com>2015-08-18 17:35:49 +0200
commite3b02994bfc4eb125d6228fcea8c235eb5c44cce (patch)
treeba30240cd12ffe9a2928156746ebc306a2754aec
parent6944ba906f5ddb24797a0657757c949eadb008c9 (diff)
downloadlvm2-e3b02994bfc4eb125d6228fcea8c235eb5c44cce.tar.gz
cmirrord: avoid resync buffer overflow in LOG_SPRINT
Use snprintf() instead of sprintf() to exclude the possibility of overflowing the resync history buffers.
-rw-r--r--daemons/cmirrord/functions.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index f6e09180d..61b3e118f 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -32,12 +32,13 @@
#define LOG_OFFSET 2
#define RESYNC_HISTORY 50
+#define RESYNC_BUFLEN 128
//static char resync_history[RESYNC_HISTORY][128];
//static int idx = 0;
#define LOG_SPRINT(_lc, f, arg...) do { \
lc->idx++; \
lc->idx = lc->idx % RESYNC_HISTORY; \
- sprintf(lc->resync_history[lc->idx], f, ## arg); \
+ snprintf(lc->resync_history[lc->idx], RESYNC_BUFLEN, f, ## arg); \
} while (0)
struct log_header {
@@ -88,7 +89,7 @@ struct log_c {
size_t disk_size; /* size of disk_buffer in bytes */
void *disk_buffer; /* aligned memory for O_DIRECT */
int idx;
- char resync_history[RESYNC_HISTORY][128];
+ char resync_history[RESYNC_HISTORY][RESYNC_BUFLEN];
};
struct mark_entry {