mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-27 07:59:41 +08:00
Use memmove for overlapping region
This commit is contained in:
1 parent
a986ed7a07
commit
8c2ad56665
5 files changed
+32
-10
No files matched your search
+3
-2
@@ -171,12 +171,13 @@ int sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char *
|
||||
if(delim != EOF){
|
||||
unsigned char *d = (unsigned char *)memchr(base + *offp, delim, n);
|
||||
if(d) n = (int)(d - (base + *offp)) + 1;
|
||||
memcpy(buf + i, base + *offp, n);
|
||||
/* caller may use param->srvbuf / param->clibuf as buf */
|
||||
memmove(buf + i, base + *offp, n);
|
||||
i += n; *offp += n;
|
||||
if(d || i >= bufsize) return i;
|
||||
}
|
||||
else {
|
||||
memcpy(buf + i, base + *offp, n);
|
||||
memmove(buf + i, base + *offp, n);
|
||||
i += n; *offp += n;
|
||||
if(i >= bufsize) return i;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user