From fafd88852877051d1ff11674082fb0a74c571970 Mon Sep 17 00:00:00 2001 From: Tim Cava Date: Mon, 26 Aug 2013 08:04:21 +0000 Subject: [PATCH] Cleanup rename_file() a little bit. Use strlcpy, rather than strmcpy. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@368 13b04d17-f746-0410-82c6-800466cd88b0 --- source/misc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/misc.c b/source/misc.c index f2a8603..16ae9e8 100644 --- a/source/misc.c +++ b/source/misc.c @@ -1276,14 +1276,11 @@ FILE *f; #endif } -int rename_file (char *old_file, char **new_file) +int rename_file(char *old_file, char **new_file) { - char *tmp = NULL; - char buffer[BIG_BUFFER_SIZE+4]; - char *c = NULL; FILE *fp; - - + char *c, *tmp = NULL; + char buffer[BIG_BUFFER_SIZE]; c = alloca(10); sprintf(c, "%03i.", getrandom(0, 999)); @@ -1293,7 +1290,7 @@ int rename_file (char *old_file, char **new_file) malloc_sprintf(&tmp, "%s", c); malloc_strcat(&tmp, *new_file); - strmcpy(buffer, *new_file, BIG_BUFFER_SIZE); + strlcpy(buffer, *new_file, sizeof buffer); while ((fp = fopen(tmp, "r")) != NULL) { fclose(fp);