Skip to content

Commit 363f629

Browse files
Remove newline on outgoing botnet message
Found by: michaelortmann Patch by: michaelortmann
1 parent 2d65b4a commit 363f629

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/dcc.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,30 +451,24 @@ static void free_dcc_bot_(int n, void *x)
451451
static void out_dcc_bot(int idx, char *buf, void *x)
452452
{
453453
size_t len = strlen(buf);
454-
/* We don't really use x here, so "use it" for the compiler */
455-
(void)x;
456454

457455
if (raw_log) {
458456
/* strip \n from end as putlog appends this */
459457
char *p = buf, *fnd = NULL;
460-
461458
if (len && buf[len - 1] == '\n') {
462459
/* Make a copy as buf could be const */
463-
fnd = nmalloc(len + 1);
464-
strcpy(fnd, buf);
460+
fnd = nmalloc(len);
461+
memcpy(fnd, buf, len - 1);
462+
fnd[len - 1] = 0;
465463
p = fnd;
466464
}
467-
468465
if (!strncmp(p, "s ", 2))
469466
putlog(LOG_BOTSHROUT, "*", "{b->%s} %s", dcc[idx].nick, p + 2);
470467
else
471468
putlog(LOG_BOTNETOUT, "*", "[b->%s] %s", dcc[idx].nick, p);
472-
473469
if (fnd)
474470
nfree(fnd);
475-
476471
}
477-
478472
tputs(dcc[idx].sock, buf, len);
479473
}
480474

0 commit comments

Comments
 (0)