1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

DCC RESUME, DCC ACCEPT: we might have crashed with invalid parameters.

Some other "cleanups".


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1178 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-02-03 17:38:01 +00:00 committed by cras
parent e387516951
commit 6ad5d24e0d
2 changed files with 21 additions and 19 deletions

View File

@ -176,9 +176,11 @@ static void sig_dccget_connected(DCC_REC *dcc)
} }
if (dcc->get_type != DCC_GET_RESUME) { if (dcc->get_type != DCC_GET_RESUME) {
dcc->fhandle = open(dcc->file, O_WRONLY | O_TRUNC | O_CREAT, dcc_file_create_mode); dcc->fhandle = open(dcc->file, O_WRONLY | O_TRUNC | O_CREAT,
dcc_file_create_mode);
if (dcc->fhandle == -1) { if (dcc->fhandle == -1) {
signal_emit("dcc error file create", 2, dcc, dcc->file); signal_emit("dcc error file create", 2,
dcc, dcc->file);
dcc_destroy(dcc); dcc_destroy(dcc);
return; return;
} }
@ -205,9 +207,11 @@ void dcc_get_connect(DCC_REC *dcc)
dcc->handle = net_connect_ip(&dcc->addr, dcc->port, dcc->handle = net_connect_ip(&dcc->addr, dcc->port,
source_host_ok ? source_host_ip : NULL); source_host_ok ? source_host_ip : NULL);
if (dcc->handle != NULL) { if (dcc->handle != NULL) {
dcc->tagconn = g_input_add(dcc->handle, dcc->tagconn =
g_input_add(dcc->handle,
G_INPUT_WRITE | G_INPUT_READ, G_INPUT_WRITE | G_INPUT_READ,
(GInputFunction) sig_dccget_connected, dcc); (GInputFunction) sig_dccget_connected,
dcc);
} else { } else {
/* error connecting */ /* error connecting */
signal_emit("dcc error connect", 1, dcc); signal_emit("dcc error connect", 1, dcc);

View File

@ -90,11 +90,10 @@ static void ctcp_msg_dcc_resume(IRC_SERVER_REC *server, const char *data,
char *str; char *str;
long size; long size;
if (!dcc_ctcp_resume_parse(DCC_TYPE_RESUME, data, nick, &dcc, &size)) if (!dcc_ctcp_resume_parse(DCC_TYPE_RESUME, data, nick, &dcc, &size)) {
signal_emit("dcc error ctcp", 5, "RESUME", data, signal_emit("dcc error ctcp", 5, "RESUME", data,
nick, addr, target); nick, addr, target);
} else if (dcc != NULL && dcc_resume_file_check(dcc, server, size)) {
if (dcc != NULL && dcc_resume_file_check(dcc, server, size)) {
str = g_strdup_printf(dcc->file_quoted ? str = g_strdup_printf(dcc->file_quoted ?
"DCC ACCEPT \"%s\" %d %lu" : "DCC ACCEPT \"%s\" %d %lu" :
"DCC ACCEPT %s %d %lu", "DCC ACCEPT %s %d %lu",
@ -114,11 +113,10 @@ static void ctcp_msg_dcc_accept(IRC_SERVER_REC *server, const char *data,
long size; long size;
if (!dcc_ctcp_resume_parse(DCC_TYPE_ACCEPT, data, nick, &dcc, &size) || if (!dcc_ctcp_resume_parse(DCC_TYPE_ACCEPT, data, nick, &dcc, &size) ||
(dcc != NULL && dcc->get_type != DCC_GET_RESUME)) (dcc != NULL && dcc->get_type != DCC_GET_RESUME)) {
signal_emit("dcc error ctcp", 5, "ACCEPT", data, signal_emit("dcc error ctcp", 5, "ACCEPT", data,
nick, addr, target); nick, addr, target);
} else if (dcc != NULL && dcc_resume_file_check(dcc, server, size))
if (dcc != NULL && dcc_resume_file_check(dcc, server, size))
dcc_get_connect(dcc); dcc_get_connect(dcc);
} }
@ -145,16 +143,16 @@ static void dcc_send_resume(DCC_REC *dcc)
/* already received whole file */ /* already received whole file */
dcc->starttime = time(NULL); dcc->starttime = time(NULL);
dcc_reject(dcc, NULL); dcc_reject(dcc, NULL);
return; } else {
}
str = g_strdup_printf(dcc->file_quoted ? str = g_strdup_printf(dcc->file_quoted ?
"DCC RESUME \"%s\" %d %lu" : "DCC RESUME \"%s\" %d %lu" :
"DCC RESUME %s %d %lu", "DCC RESUME %s %d %lu",
dcc->arg, dcc->port, dcc->transfd); dcc->arg, dcc->port, dcc->transfd);
dcc_ctcp_message(dcc->server, dcc->nick, dcc->chat, FALSE, str); dcc_ctcp_message(dcc->server, dcc->nick,
dcc->chat, FALSE, str);
g_free(str); g_free(str);
} }
}
/* SYNTAX: DCC RESUME [<nick> [<file>]] */ /* SYNTAX: DCC RESUME [<nick> [<file>]] */
static void cmd_dcc_resume(const char *data) static void cmd_dcc_resume(const char *data)