From 83078af5b0b1db4eb185cb256ebb76c117eea110 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Fri, 13 Oct 2006 23:46:32 +0000 Subject: [PATCH] Changed sprintf() calls to snprintf(). --- main.c | 4 ++-- util.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 52ec58e2..46d62509 100644 --- a/main.c +++ b/main.c @@ -1258,8 +1258,8 @@ static RETSIGTYPE rsync_panic_handler(UNUSED(int whatsig)) char cmd_buf[300]; int ret; - sprintf(cmd_buf, get_panic_action(), - getpid(), getpid()); + snprintf(cmd_buf, sizeof cmd_buf, get_panic_action(), + getpid(), getpid()); /* Unless we failed to execute gdb, we allow the process to * continue. I'm not sure if that's right. */ diff --git a/util.c b/util.c index f32d881a..0887e7fc 100644 --- a/util.c +++ b/util.c @@ -359,7 +359,7 @@ int robust_unlink(const char *fname) /* start where the last one left off to reduce chance of clashes */ start = counter; do { - sprintf(&path[pos], "%03d", counter); + snprintf(&path[pos], 4, "%03d", counter); if (++counter >= MAX_RENAMES) counter = 1; } while ((rc = access(path, 0)) == 0 && counter != start); @@ -1115,7 +1115,7 @@ char *human_num(int64 num) units = 'K'; } if (units) { - sprintf(bufs[n], "%.2f%c", dnum, units); + snprintf(bufs[n], sizeof bufs[0], "%.2f%c", dnum, units); return bufs[n]; } } -- 2.34.1