From 6c187d167b3547bef7fce4a910d43d18fbac2c6c Mon Sep 17 00:00:00 2001 From: z3APA3A <3APA3A@3proxy.ru> Date: Sat, 28 Nov 2015 22:56:20 +0300 Subject: [PATCH] Memory safety issues on configuration reload memcpy for potentially overlapped regions replaced with memmove --- src/3proxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3proxy.c b/src/3proxy.c index 833c02e..b22d541 100644 --- a/src/3proxy.c +++ b/src/3proxy.c @@ -313,7 +313,7 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha len = 0; if(argm[argc]!=(incbegin+1)) { len = (int)strlen((char *)argm[argc]); - memcpy(buf+*inbuf, argm[argc], len); + memmove(buf+*inbuf, argm[argc], len); } if((res = read(fd, buf+*inbuf+len, STRINGBUF-(1+len))) <= 0) { perror((char *)incbegin+1); @@ -1873,7 +1873,7 @@ int readconfig(FILE * fp){ struct commands * cm; int res = 0; - if( !(buf = myalloc(bufsize)) || ! (argv = myalloc(NPARAMS * sizeof(unsigned char *) + 1)) ) { + if( !(buf = myalloc(bufsize)) || ! (argv = myalloc((NPARAMS + 1) * sizeof(unsigned char *))) ) { fprintf(stderr, "No memory for configuration"); return(10); }