Skip to content

Commit

Permalink
Remove strcats
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann authored Jul 6, 2024
1 parent 2bf13c3 commit 31b360e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,9 +1224,10 @@ int sockgets(char *s, int *len)
/* Might be necessary to prepend stored-up data! */
if (socklist[ret].handler.sock.inbuf != NULL) {
p = socklist[ret].handler.sock.inbuf;
socklist[ret].handler.sock.inbuf = nmalloc(strlen(p) + strlen(xx) + 1);
strcpy(socklist[ret].handler.sock.inbuf, p);
strcat(socklist[ret].handler.sock.inbuf, xx);
len2 = strlen(p);
socklist[ret].handler.sock.inbuf = nmalloc(len2 + strlen(xx) + 1);
memcpy(socklist[ret].handler.sock.inbuf, p, len2);
strcpy(socklist[ret].handler.sock.inbuf + len2, xx);
nfree(p);
if (strlen(socklist[ret].handler.sock.inbuf) < READMAX + 2) {
strcpy(xx, socklist[ret].handler.sock.inbuf);
Expand Down Expand Up @@ -1277,10 +1278,11 @@ int sockgets(char *s, int *len)
/* Prepend old data back */
if (socklist[ret].handler.sock.inbuf != NULL) {
p = socklist[ret].handler.sock.inbuf;
socklist[ret].handler.sock.inbuflen = strlen(p) + strlen(xx);
len2 = strlen(xx);
socklist[ret].handler.sock.inbuflen = len2 + strlen(p);
socklist[ret].handler.sock.inbuf = nmalloc(socklist[ret].handler.sock.inbuflen + 1);
strcpy(socklist[ret].handler.sock.inbuf, xx);
strcat(socklist[ret].handler.sock.inbuf, p);
memcpy(socklist[ret].handler.sock.inbuf, xx, len2);
strcpy(socklist[ret].handler.sock.inbuf + len2, p);
nfree(p);
} else {
socklist[ret].handler.sock.inbuflen = strlen(xx);
Expand Down

0 comments on commit 31b360e

Please sign in to comment.