Skip to content

Commit d640315

Browse files
Fix "echo off" issues
Found by: michaelortmann Patch by: michaelortmann - Fix "echo off" for command .su - Fix propagating telnet status for command .relay. The propagation is necessary, so that the destination bot can send telnet control codes like "echo off"
1 parent 028e756 commit d640315

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/botnet.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,8 @@ static void cont_tandem_relay(int idx, char *buf, int i)
14181418
check_tcl_chof(dcc[uidx].nick, dcc[uidx].sock);
14191419
dcc[uidx].type = &DCC_RELAYING;
14201420
dcc[uidx].u.relay = ri;
1421+
if (dcc[uidx].status & STAT_TELNET)
1422+
tputs(dcc[idx].sock, TLN_IAC_C TLN_DO_C TLN_STATUS_C, 3);
14211423
}
14221424

14231425
static void eof_dcc_relay(int idx)
@@ -1436,7 +1438,7 @@ static void eof_dcc_relay(int idx)
14361438
dcc[j].status = dcc[j].u.relay->old_status;
14371439
/* In case echo was off, turn it back on (send IAC WON'T ECHO): */
14381440
if (dcc[j].status & STAT_TELNET)
1439-
dprintf(j, TLN_IAC_C TLN_WONT_C TLN_ECHO_C "\n");
1441+
tputs(dcc[j].sock, TLN_IAC_C TLN_WONT_C TLN_ECHO_C, 3);
14401442
putlog(LOG_MISC, "*", "%s: %s -> %s", BOT_ENDRELAY1, dcc[j].nick,
14411443
dcc[idx].nick);
14421444
dprintf(j, "\n\n*** %s %s\n", BOT_ENDRELAY2, botnetnick);

src/cmds.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -2753,9 +2753,13 @@ static void cmd_su(struct userrec *u, int idx, char *par)
27532753
dcc[idx].user = u;
27542754
strcpy(dcc[idx].nick, par);
27552755
/* Display password prompt and turn off echo (send IAC WILL ECHO). */
2756-
dprintf(idx, "Enter password for %s%s\n", par,
2757-
(dcc[idx].status & STAT_TELNET) ? TLN_IAC_C TLN_WILL_C
2758-
TLN_ECHO_C : "");
2756+
if (dcc[idx].status & STAT_TELNET) {
2757+
char buf[512];
2758+
snprintf(buf, sizeof buf, "Enter password for %s" TLN_IAC_C TLN_WILL_C
2759+
TLN_ECHO_C "\r\n", par);
2760+
tputs(dcc[idx].sock, buf, strlen(buf));
2761+
} else
2762+
dprintf(idx, "Enter password for %s\n", par);
27592763
dcc[idx].type = &DCC_CHAT_PASS;
27602764
} else if (atr & USER_OWNER) {
27612765
if (dcc[idx].u.chat->channel < GLOBAL_CHANS)

src/dcc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1832,8 +1832,8 @@ static void dcc_telnet_pass(int idx, int atr)
18321832

18331833
/* Turn off remote telnet echo (send IAC WILL ECHO). */
18341834
if (dcc[idx].status & STAT_TELNET) {
1835-
char buf[1030];
1836-
egg_snprintf(buf, sizeof buf, "\n%s%s\r\n", escape_telnet(DCC_ENTERPASS),
1835+
char buf[512];
1836+
snprintf(buf, sizeof buf, "\n%s%s\r\n", escape_telnet(DCC_ENTERPASS),
18371837
TLN_IAC_C TLN_WILL_C TLN_ECHO_C);
18381838
tputs(dcc[idx].sock, buf, strlen(buf));
18391839
} else

0 commit comments

Comments
 (0)