1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 05:45:42 +02:00

xfer: fix DCC file receive on Termux (closes #1811)

This fixes such error displayed on Termux when receiving a DCC file:

xfer: invalid address "96747949": error 8 hostname nor servname provided, or not known
This commit is contained in:
Sébastien Helleu
2022-09-03 22:29:46 +02:00
parent 7cf9399616
commit e8524ea2c4
12 changed files with 193 additions and 67 deletions
+1
View File
@@ -51,6 +51,7 @@ Bug fixes::
* xfer: fix crash when closing DCC chat buffer
* xfer: disconnect all active DCC chats and files on `/upgrade`
* xfer: fix refresh of xfer buffer after `/upgrade`
* xfer: fix DCC file receive on Termux (issue #1811)
Tests::
+1
View File
@@ -455,6 +455,7 @@ WeeChat "core" is located in following directories:
|             test-relay-auth.cpp | Tests: clients authentication.
|          xfer/ | Root of unit tests for Xfer plugin.
|             test-xfer-file.cpp | Tests: file functions.
|             test-xfer-network.cpp | Tests: network functions.
|===
[[documentation_translations]]
+1
View File
@@ -457,6 +457,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|             test-relay-auth.cpp | Tests : authentification des clients.
|          xfer/ | Racine des tests unitaires pour l'extension Xfer.
|             test-xfer-file.cpp | Tests : fonctions sur les fichiers.
|             test-xfer-network.cpp | Tests : fonctions réseau.
|===
[[documentation_translations]]
+2
View File
@@ -510,6 +510,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
|          xfer/ | Root of unit tests for Xfer plugin.
// TRANSLATION MISSING
|             test-xfer-file.cpp | Tests: file functions.
// TRANSLATION MISSING
|             test-xfer-network.cpp | Tests: network functions.
|===
[[documentation_translations]]
+2
View File
@@ -459,6 +459,8 @@ WeeChat „језгро” се налази у следећим директо
|          xfer/ | Root of unit tests for Xfer plugin.
// TRANSLATION MISSING
|             test-xfer-file.cpp | Tests: file functions.
// TRANSLATION MISSING
|             test-xfer-network.cpp | Tests: network functions.
|===
[[documentation_translations]]
+1
View File
@@ -445,6 +445,7 @@ weechat_startup_message ()
gui_chat_printf (NULL, "---");
gui_chat_printf (NULL, "");
}
gui_chat_printf (NULL, "TEST SEB xfer termux");
}
/*
File diff suppressed because it is too large Load Diff
+7
View File
@@ -20,6 +20,13 @@
#ifndef WEECHAT_PLUGIN_XFER_NETWORK_H
#define WEECHAT_PLUGIN_XFER_NETWORK_H
#include <sys/socket.h>
extern int xfer_network_resolve_addr (const char *str_address,
const char *str_port,
struct sockaddr *addr,
socklen_t *addr_len,
int ai_flags);
extern void xfer_network_write_pipe (struct t_xfer *xfer, int status,
int error);
extern void xfer_network_connect_init (struct t_xfer *xfer);
+10 -65
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -104,6 +104,7 @@ endif()
if(ENABLE_XFER)
list(APPEND LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC
unit/plugins/xfer/test-xfer-file.cpp
unit/plugins/xfer/test-xfer-network.cpp
)
endif()
+2 -1
View File
@@ -108,7 +108,8 @@ tests_typing = unit/plugins/typing/test-typing.cpp \
endif
if PLUGIN_XFER
tests_xfer = unit/plugins/xfer/test-xfer-file.cpp
tests_xfer = unit/plugins/xfer/test-xfer-file.cpp \
unit/plugins/xfer/test-xfer-network.cpp
endif
lib_weechat_unit_tests_plugins_la_SOURCES = unit/plugins/test-plugins.cpp \
@@ -0,0 +1,58 @@
/*
* test-xfer-network.cpp - test xfer network functions
*
* Copyright (C) 2022 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CppUTest/TestHarness.h"
#include "tests/tests.h"
extern "C"
{
#include "src/plugins/xfer/xfer-network.h"
extern char *xfer_network_convert_integer_to_ipv4 (const char *str_address);
}
TEST_GROUP(XferNetwork)
{
};
/*
* Tests functions:
* xfer_network_convert_integer_to_ipv4
*/
TEST(XferNetwork, ConvertIntegerToIpv4)
{
char *str;
POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 (NULL));
POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 (""));
POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 ("abc"));
POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 ("0"));
POINTERS_EQUAL(NULL, xfer_network_convert_integer_to_ipv4 ("-1"));
WEE_TEST_STR("0.0.0.1", xfer_network_convert_integer_to_ipv4 ("1"));
WEE_TEST_STR("0.0.1.0", xfer_network_convert_integer_to_ipv4 ("256"));
WEE_TEST_STR("0.1.0.0", xfer_network_convert_integer_to_ipv4 ("65536"));
WEE_TEST_STR("1.0.0.0", xfer_network_convert_integer_to_ipv4 ("16777216"));
WEE_TEST_STR("127.0.0.1", xfer_network_convert_integer_to_ipv4 ("2130706433"));
WEE_TEST_STR("192.168.1.2", xfer_network_convert_integer_to_ipv4 ("3232235778"));
}