From 6ad5d24e0d3d364fc0f74e3f3218e26bf331b998 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 3 Feb 2001 17:38:01 +0000 Subject: [PATCH] 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 --- src/irc/dcc/dcc-get.c | 14 +++++++++----- src/irc/dcc/dcc-resume.c | 26 ++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c index 0ebf3e20..36da43f4 100644 --- a/src/irc/dcc/dcc-get.c +++ b/src/irc/dcc/dcc-get.c @@ -176,9 +176,11 @@ static void sig_dccget_connected(DCC_REC *dcc) } 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) { - signal_emit("dcc error file create", 2, dcc, dcc->file); + signal_emit("dcc error file create", 2, + dcc, dcc->file); dcc_destroy(dcc); return; } @@ -205,9 +207,11 @@ void dcc_get_connect(DCC_REC *dcc) dcc->handle = net_connect_ip(&dcc->addr, dcc->port, source_host_ok ? source_host_ip : NULL); if (dcc->handle != NULL) { - dcc->tagconn = g_input_add(dcc->handle, - G_INPUT_WRITE | G_INPUT_READ, - (GInputFunction) sig_dccget_connected, dcc); + dcc->tagconn = + g_input_add(dcc->handle, + G_INPUT_WRITE | G_INPUT_READ, + (GInputFunction) sig_dccget_connected, + dcc); } else { /* error connecting */ signal_emit("dcc error connect", 1, dcc); diff --git a/src/irc/dcc/dcc-resume.c b/src/irc/dcc/dcc-resume.c index 3fa884bb..3404a092 100644 --- a/src/irc/dcc/dcc-resume.c +++ b/src/irc/dcc/dcc-resume.c @@ -90,11 +90,10 @@ static void ctcp_msg_dcc_resume(IRC_SERVER_REC *server, const char *data, char *str; 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, nick, addr, target); - - if (dcc != NULL && dcc_resume_file_check(dcc, server, size)) { + } else if (dcc != NULL && dcc_resume_file_check(dcc, server, size)) { str = g_strdup_printf(dcc->file_quoted ? "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; 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, nick, addr, target); - - if (dcc != NULL && dcc_resume_file_check(dcc, server, size)) + } else if (dcc != NULL && dcc_resume_file_check(dcc, server, size)) dcc_get_connect(dcc); } @@ -145,15 +143,15 @@ static void dcc_send_resume(DCC_REC *dcc) /* already received whole file */ dcc->starttime = time(NULL); dcc_reject(dcc, NULL); - return; + } else { + str = g_strdup_printf(dcc->file_quoted ? + "DCC RESUME \"%s\" %d %lu" : + "DCC RESUME %s %d %lu", + dcc->arg, dcc->port, dcc->transfd); + dcc_ctcp_message(dcc->server, dcc->nick, + dcc->chat, FALSE, str); + g_free(str); } - - str = g_strdup_printf(dcc->file_quoted ? - "DCC RESUME \"%s\" %d %lu" : - "DCC RESUME %s %d %lu", - dcc->arg, dcc->port, dcc->transfd); - dcc_ctcp_message(dcc->server, dcc->nick, dcc->chat, FALSE, str); - g_free(str); } /* SYNTAX: DCC RESUME [ []] */