From 08e13a3ac58896fd9a0a2e5a004f9b180d1dfeeb Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 18 Jun 2021 20:34:11 +0100 Subject: Replace identify-msg support with solanum.chat/identify-msg. --- plugins/fishlim/plugin_hexchat.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins') diff --git a/plugins/fishlim/plugin_hexchat.c b/plugins/fishlim/plugin_hexchat.c index 83286e28..93e28487 100644 --- a/plugins/fishlim/plugin_hexchat.c +++ b/plugins/fishlim/plugin_hexchat.c @@ -418,8 +418,6 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) { g_assert(hexchat_set_context(ph, query_ctx) == 1); dh_message++; /* : prefix */ - if (*dh_message == '+' || *dh_message == '-') - dh_message++; /* identify-msg */ if (g_strcmp0 (word[6], "CBC") == 0) mode = FISH_CBC_MODE; -- cgit 1.4.1 From fee86de499314eda81111b7c7293fcacf8ca8db1 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Thu, 15 Jul 2021 20:30:45 -0500 Subject: fish: Misc test cleanups --- plugins/fishlim/tests/fake/keystore.c | 47 -------- plugins/fishlim/tests/meson.build | 10 +- plugins/fishlim/tests/mock-keystore.c | 51 +++++++++ plugins/fishlim/tests/old_version/fish.c | 155 -------------------------- plugins/fishlim/tests/old_version/fish.h | 37 ------ plugins/fishlim/tests/old_version/meson.build | 4 - plugins/fishlim/tests/tests.c | 107 ++++++++---------- 7 files changed, 103 insertions(+), 308 deletions(-) delete mode 100644 plugins/fishlim/tests/fake/keystore.c create mode 100644 plugins/fishlim/tests/mock-keystore.c delete mode 100644 plugins/fishlim/tests/old_version/fish.c delete mode 100644 plugins/fishlim/tests/old_version/fish.h delete mode 100644 plugins/fishlim/tests/old_version/meson.build (limited to 'plugins') diff --git a/plugins/fishlim/tests/fake/keystore.c b/plugins/fishlim/tests/fake/keystore.c deleted file mode 100644 index 854f38dc..00000000 --- a/plugins/fishlim/tests/fake/keystore.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - - Copyright (c) 2010 Samuel Lidén Borell - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -#include "../../fish.h" - - -/** - * Extracts a key from the key store file. - */ -char *keystore_get_key(const char *nick, enum fish_mode *mode) { - return NULL; -} - -/** - * Sets a key in the key store file. - */ -gboolean keystore_store_key(const char *nick, const char *key, enum fish_mode mode) { - return TRUE; -} - -/** - * Deletes a nick from the key store. - */ -gboolean keystore_delete_nick(const char *nick) { - return TRUE; -} diff --git a/plugins/fishlim/tests/meson.build b/plugins/fishlim/tests/meson.build index 3b75018e..60eddc18 100644 --- a/plugins/fishlim/tests/meson.build +++ b/plugins/fishlim/tests/meson.build @@ -1,17 +1,15 @@ -subdir('old_version') - fishlim_test_sources = [ 'tests.c', - 'fake/keystore.c', + 'mock-keystore.c', '../fish.c', '../utils.c', ] fishlim_tests = executable('fishlim_tests', fishlim_test_sources, - dependencies: [libgio_dep, libssl_dep], - link_with : fishlim_old_lib + dependencies: [libgio_dep, libssl_dep, hexchat_plugin_dep], + include_directories: include_directories('..'), ) test('Fishlim Tests', fishlim_tests, - timeout: 90 + protocol: 'tap', ) diff --git a/plugins/fishlim/tests/mock-keystore.c b/plugins/fishlim/tests/mock-keystore.c new file mode 100644 index 00000000..57a98847 --- /dev/null +++ b/plugins/fishlim/tests/mock-keystore.c @@ -0,0 +1,51 @@ +/* + Copyright (c) 2010 Samuel Lidén Borell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +#include "fish.h" + +/** + * Extracts a key from the key store file. + */ +char * +keystore_get_key(const char *nick, enum fish_mode *mode) +{ + return NULL; +} + +/** + * Sets a key in the key store file. + */ +gboolean +keystore_store_key(const char *nick, const char *key, enum fish_mode mode) +{ + return TRUE; +} + +/** + * Deletes a nick from the key store. + */ +gboolean +keystore_delete_nick(const char *nick) +{ + return TRUE; +} diff --git a/plugins/fishlim/tests/old_version/fish.c b/plugins/fishlim/tests/old_version/fish.c deleted file mode 100644 index 99601398..00000000 --- a/plugins/fishlim/tests/old_version/fish.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - - Copyright (c) 2010 Samuel Lidén Borell - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -#ifdef __APPLE__ -#define __AVAILABILITYMACROS__ -#define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER -#endif - -#include -#include -#include - -#include "fish.h" - -#define IB 64 -static const char fish_base64[64] = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -static const signed char fish_unbase64[256] = { - IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB, - IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB, -/* ! " # $ % & ' ( ) * + , - . / */ - IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB, 0, 1, -/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ - 2, 3, 4, 5, 6, 7, 8, 9, 10,11,IB,IB,IB,IB,IB,IB, -/* @ A B C D E F G H I J K L M N O */ - IB,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52, -/* P Q R S T U V W X Y Z [ \ ] ^ _*/ - 53,54,55,56,57,58,59,60, 61,62,63,IB,IB,IB,IB,IB, -/* ` a b c d e f g h i j k l m n o */ - IB,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26, -/* p q r s t u v w x y z { | } ~ */ - 27,28,29,30,31,32,33,34, 35,36,37,IB,IB,IB,IB,IB, -}; - -#define GET_BYTES(dest, source) do { \ - *((dest)++) = ((source) >> 24) & 0xFF; \ - *((dest)++) = ((source) >> 16) & 0xFF; \ - *((dest)++) = ((source) >> 8) & 0xFF; \ - *((dest)++) = (source) & 0xFF; \ -} while (0); - - -char *__old_fish_encrypt(const char *key, size_t keylen, const char *message) { - BF_KEY bfkey; - size_t messagelen; - size_t i; - int j; - char *encrypted; - char *end; - unsigned char bit; - unsigned char word; - unsigned char d; - BF_set_key(&bfkey, keylen, (const unsigned char*)key); - - messagelen = strlen(message); - if (messagelen == 0) return NULL; - encrypted = g_malloc(((messagelen - 1) / 8) * 12 + 12 + 1); /* each 8-byte block becomes 12 bytes */ - end = encrypted; - - while (*message) { - /* Read 8 bytes (a Blowfish block) */ - BF_LONG binary[2] = { 0, 0 }; - unsigned char c; - for (i = 0; i < 8; i++) { - c = message[i]; - binary[i >> 2] |= c << 8*(3 - (i&3)); - if (c == '\0') break; - } - message += 8; - - /* Encrypt block */ - BF_encrypt(binary, &bfkey); - - /* Emit FiSH-BASE64 */ - bit = 0; - word = 1; - for (j = 0; j < 12; j++) { - d = fish_base64[(binary[word] >> bit) & 63]; - *(end++) = d; - bit += 6; - if (j == 5) { - bit = 0; - word = 0; - } - } - - /* Stop if a null terminator was found */ - if (c == '\0') break; - } - *end = '\0'; - return encrypted; -} - - -char *__old_fish_decrypt(const char *key, size_t keylen, const char *data) { - BF_KEY bfkey; - size_t i; - char *decrypted; - char *end; - unsigned char bit; - unsigned char word; - unsigned char d; - BF_set_key(&bfkey, keylen, (const unsigned char*)key); - - decrypted = g_malloc(strlen(data) + 1); - end = decrypted; - - while (*data) { - /* Convert from FiSH-BASE64 */ - BF_LONG binary[2] = { 0, 0 }; - bit = 0; - word = 1; - for (i = 0; i < 12; i++) { - d = fish_unbase64[(const unsigned char)*(data++)]; - if (d == IB) goto decrypt_end; - binary[word] |= (unsigned long)d << bit; - bit += 6; - if (i == 5) { - bit = 0; - word = 0; - } - } - - /* Decrypt block */ - BF_decrypt(binary, &bfkey); - - /* Copy to buffer */ - GET_BYTES(end, binary[0]); - GET_BYTES(end, binary[1]); - } - - decrypt_end: - *end = '\0'; - return decrypted; -} \ No newline at end of file diff --git a/plugins/fishlim/tests/old_version/fish.h b/plugins/fishlim/tests/old_version/fish.h deleted file mode 100644 index 7037782b..00000000 --- a/plugins/fishlim/tests/old_version/fish.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Copyright (c) 2010 Samuel Lidén Borell - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -#ifndef FISH_OLD_H -#define FISH_OLD_H - -#include - -#include - -char *__old_fish_encrypt(const char *key, size_t keylen, const char *message); -char *__old_fish_decrypt(const char *key, size_t keylen, const char *data); - -#endif - - diff --git a/plugins/fishlim/tests/old_version/meson.build b/plugins/fishlim/tests/old_version/meson.build deleted file mode 100644 index 54647d71..00000000 --- a/plugins/fishlim/tests/old_version/meson.build +++ /dev/null @@ -1,4 +0,0 @@ -fishlim_old_lib = shared_library('fishlim_old_lib', - ['fish.c'], - dependencies: [libgio_dep, libssl_dep], -) diff --git a/plugins/fishlim/tests/tests.c b/plugins/fishlim/tests/tests.c index bb841c5e..0d385221 100644 --- a/plugins/fishlim/tests/tests.c +++ b/plugins/fishlim/tests/tests.c @@ -1,5 +1,4 @@ /* - Copyright (c) 2020 Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,22 +21,19 @@ */ -#ifndef PLUGIN_HEXCHAT_FISHLIM_TEST_H -#define PLUGIN_HEXCHAT_FISHLIM_TEST_H - -// Libs #include -// Project Libs -#include "../fish.h" -#include "../utils.h" -#include "old_version/fish.h" + +#include "fish.h" +#include "utils.h" /** * Auxiliary function: Generate a random string * @param out Preallocated string to fill * @param len Size of bytes to fill */ -void random_string(char *out, size_t len) { +static void +random_string(char *out, size_t len) +{ GRand *rand = NULL; int i = 0; @@ -51,13 +47,14 @@ void random_string(char *out, size_t len) { g_rand_free(rand); } - /** - * Check encrypt and decrypt in ECB mode and compare with old implementation + * Check encrypt and decrypt in ECB mode */ -void __ecb(void) { - char *bo64 = NULL, *b64 = NULL; - char *deo = NULL, *de = NULL; +static void +test_ecb(void) +{ + char *b64 = NULL; + char *de = NULL; int key_len, message_len = 0; char key[57]; char message[1000]; @@ -71,36 +68,20 @@ void __ecb(void) { random_string(message, message_len); /* Encrypt */ - bo64 = __old_fish_encrypt(key, key_len, message); - g_assert_nonnull(bo64); b64 = fish_encrypt(key, key_len, message, message_len, FISH_ECB_MODE); g_assert_nonnull(b64); - g_assert_cmpuint(g_strcmp0(b64, bo64), == , 0); /* Decrypt */ /* Linear */ - deo = __old_fish_decrypt(key, key_len, bo64); de = fish_decrypt_str(key, key_len, b64, FISH_ECB_MODE); - g_assert_nonnull(deo); - g_assert_nonnull(de); - g_assert_cmpuint(g_strcmp0(de, message), == , 0); - g_assert_cmpuint(g_strcmp0(deo, message), == , 0); - g_assert_cmpuint(g_strcmp0(de, deo), == , 0); - g_free(deo); + g_assert_cmpstr (de, ==, message); g_free(de); + /* Mixed */ - deo = __old_fish_decrypt(key, key_len, b64); - de = fish_decrypt_str(key, key_len, bo64, FISH_ECB_MODE); - g_assert_nonnull(deo); - g_assert_nonnull(de); - g_assert_cmpuint(g_strcmp0(de, message), == , 0); - g_assert_cmpuint(g_strcmp0(deo, message), == , 0); - g_assert_cmpuint(g_strcmp0(de, deo), == , 0); - g_free(deo); + de = fish_decrypt_str(key, key_len, b64, FISH_ECB_MODE); + g_assert_cmpstr (de, ==, message); g_free(de); - /* Free */ - g_free(bo64); g_free(b64); } } @@ -109,7 +90,9 @@ void __ecb(void) { /** * Check encrypt and decrypt in CBC mode */ -void __cbc(void) { +static void +test_cbc(void) +{ char *b64 = NULL; char *de = NULL; int key_len, message_len = 0; @@ -131,11 +114,9 @@ void __cbc(void) { /* Decrypt */ /* Linear */ de = fish_decrypt_str(key, key_len, b64, FISH_CBC_MODE); - g_assert_nonnull(de); - g_assert_cmpuint(g_strcmp0(de, message), == , 0); + g_assert_cmpstr (de, ==, message); g_free(de); - /* Free */ g_free(b64); } } @@ -144,13 +125,14 @@ void __cbc(void) { /** * Check the calculation of final length from an encoded string in Base64 */ -void __base64_len(void) { +static void +test_base64_len (void) +{ char *b64 = NULL; int i, message_len = 0; char message[1000]; for (i = 0; i < 10; ++i) { - for (message_len = 1; message_len < 1000; ++message_len) { random_string(message, message_len); b64 = g_base64_encode((const unsigned char *) message, message_len); @@ -164,7 +146,9 @@ void __base64_len(void) { /** * Check the calculation of final length from an encoded string in BlowcryptBase64 */ -void __base64_fish_len(void) { +static void +test_base64_fish_len (void) +{ char *b64 = NULL; int i, message_len = 0; char message[1000]; @@ -181,11 +165,12 @@ void __base64_fish_len(void) { } } - /** * Check the calculation of final length from an encrypted string in ECB mode */ -void __base64_ecb_len(void) { +static void +test_base64_ecb_len(void) +{ char *b64 = NULL; int key_len, message_len = 0; char key[57]; @@ -209,7 +194,9 @@ void __base64_ecb_len(void) { /** * Check the calculation of final length from an encrypted string in CBC mode */ -void __base64_cbc_len(void) { +static void +test_base64_cbc_len(void) +{ char *b64 = NULL; int key_len, message_len = 0; char key[57]; @@ -233,7 +220,9 @@ void __base64_cbc_len(void) { /** * Check the calculation of length limit for a plaintext in each encryption mode */ -void __max_text_command_len(void) { +static void +test_max_text_command_len(void) +{ int max_encoded_len, plaintext_len; enum fish_mode mode; @@ -248,7 +237,9 @@ void __max_text_command_len(void) { /** * Check the calculation of length limit for a plaintext in each encryption mode */ -void __foreach_utf8_data_chunks(void) { +static void +test_foreach_utf8_data_chunks(void) +{ GRand *rand = NULL; GString *chunks = NULL; int tests, max_chunks_len, chunks_len; @@ -277,21 +268,19 @@ void __foreach_utf8_data_chunks(void) { } } - -int main(int argc, char *argv[]) { +int +main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); - g_test_add_func("/fishlim/__ecb", __ecb); - g_test_add_func("/fishlim/__cbc", __ecb); - g_test_add_func("/fishlim/__base64_len", __base64_len); - g_test_add_func("/fishlim/__base64_fish_len", __base64_fish_len); - g_test_add_func("/fishlim/__base64_ecb_len", __base64_ecb_len); - g_test_add_func("/fishlim/__base64_cbc_len", __base64_cbc_len); - g_test_add_func("/fishlim/__max_text_command_len", __max_text_command_len); - g_test_add_func("/fishlim/__foreach_utf8_data_chunks", __foreach_utf8_data_chunks); + g_test_add_func("/fishlim/ecb", test_ecb); + g_test_add_func("/fishlim/cbc", test_cbc); + g_test_add_func("/fishlim/base64_len", test_base64_len); + g_test_add_func("/fishlim/base64_fish_len", test_base64_fish_len); + g_test_add_func("/fishlim/base64_ecb_len", test_base64_ecb_len); + g_test_add_func("/fishlim/base64_cbc_len", test_base64_cbc_len); + g_test_add_func("/fishlim/max_text_command_len", test_max_text_command_len); + g_test_add_func("/fishlim/foreach_utf8_data_chunks", test_foreach_utf8_data_chunks); return g_test_run(); } - -#endif //PLUGIN_HEXCHAT_FISHLIM_TEST_H \ No newline at end of file -- cgit 1.4.1 From 3f07670b34512c9242ae2c20984f38cb453ce51f Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Fri, 1 Oct 2021 12:15:26 -0500 Subject: win32: Update to OpenSSL 1.1 --- .github/workflows/windows-build.yml | 2 +- meson.build | 2 +- plugins/fishlim/fishlim.vcxproj | 4 ++-- src/common/server.c | 2 +- src/common/ssl.c | 21 ++++++++++----------- src/common/ssl.h | 2 +- win32/copy/copy.vcxproj | 4 ++-- win32/hexchat.props | 4 ++-- win32/installer/hexchat.iss.tt | 9 +++++++-- 9 files changed, 27 insertions(+), 23 deletions(-) (limited to 'plugins') diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 4ce03c00..f5e20e12 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -28,7 +28,7 @@ jobs: Invoke-WebRequest https://dl.hexchat.net/misc/idpsetup-1.5.1.exe -OutFile deps\idpsetup.exe & deps\idpsetup.exe /VERYSILENT - Invoke-WebRequest https://dl.hexchat.net/gtk/gtk-${{ matrix.platform }}-2018-08-29.7z -OutFile deps\gtk-${{ matrix.arch }}.7z + Invoke-WebRequest https://dl.hexchat.net/gtk/gtk-${{ matrix.platform }}-2018-08-29-openssl1.1.7z -OutFile deps\gtk-${{ matrix.arch }}.7z & 7z.exe x deps\gtk-${{ matrix.arch }}.7z -oC:\gtk-build\gtk Invoke-WebRequest https://dl.hexchat.net/gtk-win32/gendef-20111031.7z -OutFile deps\gendef.7z diff --git a/meson.build b/meson.build index fe5f245d..9330abf3 100644 --- a/meson.build +++ b/meson.build @@ -22,7 +22,7 @@ dbus_glib_dep = dependency('dbus-glib-1', required: get_option('dbus')) global_deps = [] if cc.get_id() == 'msvc' - libssl_dep = cc.find_library('libeay32') + libssl_dep = cc.find_library('libssl') else libssl_dep = dependency('openssl', version: '>= 0.9.8', required: get_option('tls')) diff --git a/plugins/fishlim/fishlim.vcxproj b/plugins/fishlim/fishlim.vcxproj index 579c2436..3661e1e6 100644 --- a/plugins/fishlim/fishlim.vcxproj +++ b/plugins/fishlim/fishlim.vcxproj @@ -29,7 +29,7 @@ - WIN32;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;HAVE_DH_SET0_PQG;HAVE_DH_GET0_KEY;HAVE_DH_SET0_KEY;%(PreprocessorDefinitions) $(DepsRoot)\include;$(Glib);..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories) @@ -40,7 +40,7 @@ - WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions) + WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;HAVE_DH_SET0_PQG;HAVE_DH_GET0_KEY;HAVE_DH_SET0_KEY;%(PreprocessorDefinitions) $(DepsRoot)\include;$(Glib);..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories) diff --git a/src/common/server.c b/src/common/server.c index 1825117c..f90ce28f 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -772,7 +772,7 @@ server_connect_success (server *serv) /* it'll be a memory leak, if connection isn't terminated by server_cleanup() */ - if ((err = _SSL_set_verify (serv->ctx, ssl_cb_verify, NULL))) + if ((err = _SSL_set_verify (serv->ctx, ssl_cb_verify))) { EMIT_SIGNAL (XP_TE_CONNFAIL, serv->server_session, err, NULL, NULL, NULL, 0); diff --git a/src/common/ssl.c b/src/common/ssl.c index 0eb78bd7..e7f7e0a8 100644 --- a/src/common/ssl.c +++ b/src/common/ssl.c @@ -321,23 +321,22 @@ _SSL_socket (SSL_CTX *ctx, int sd) char * -_SSL_set_verify (SSL_CTX *ctx, void *verify_callback, char *cacert) +_SSL_set_verify (SSL_CTX *ctx, void *verify_callback) { - if (!SSL_CTX_set_default_verify_paths (ctx)) +#ifdef DEFAULT_CERT_FILE + if (!SSL_CTX_load_verify_locations (ctx, DEFAULT_CERT_FILE, NULL)) { - __SSL_fill_err_buf ("SSL_CTX_set_default_verify_paths"); + __SSL_fill_err_buf ("SSL_CTX_load_verify_locations"); return (err_buf); } -/* - if (cacert) +#else + if (!SSL_CTX_set_default_verify_paths (ctx)) { - if (!SSL_CTX_load_verify_locations (ctx, cacert, NULL)) - { - __SSL_fill_err_buf ("SSL_CTX_load_verify_locations"); - return (err_buf); - } + __SSL_fill_err_buf ("SSL_CTX_set_default_verify_paths"); + return (err_buf); } -*/ +#endif + SSL_CTX_set_verify (ctx, SSL_VERIFY_PEER, verify_callback); return (NULL); diff --git a/src/common/ssl.h b/src/common/ssl.h index e722f831..bea2f440 100644 --- a/src/common/ssl.h +++ b/src/common/ssl.h @@ -45,7 +45,7 @@ SSL_CTX *_SSL_context_init (void (*info_cb_func)); #define _SSL_context_free(a) SSL_CTX_free(a); SSL *_SSL_socket (SSL_CTX *ctx, int sd); -char *_SSL_set_verify (SSL_CTX *ctx, void *(verify_callback), char *cacert); +char *_SSL_set_verify (SSL_CTX *ctx, void *(verify_callback)); /* int SSL_connect(SSL *); int SSL_accept(SSL *); diff --git a/win32/copy/copy.vcxproj b/win32/copy/copy.vcxproj index b26d7e28..2fc7437b 100644 --- a/win32/copy/copy.vcxproj +++ b/win32/copy/copy.vcxproj @@ -40,7 +40,8 @@ - + + @@ -50,7 +51,6 @@ - diff --git a/win32/hexchat.props b/win32/hexchat.props index f40c794a..038873b1 100644 --- a/win32/hexchat.props +++ b/win32/hexchat.props @@ -15,7 +15,7 @@ - GTK_DISABLE_DEPRECATED;GDK_PIXBUF_DISABLE_DEPRECATED;G_DISABLE_SINGLE_INCLUDES;GDK_PIXBUF_DISABLE_SINGLE_INCLUDES;GTK_DISABLE_SINGLE_INCLUDES;HAVE_STRTOULL;strtoull=_strtoui64;strcasecmp=stricmp;strncasecmp=strnicmp;__inline__=__inline + GTK_DISABLE_DEPRECATED;GDK_PIXBUF_DISABLE_DEPRECATED;G_DISABLE_SINGLE_INCLUDES;GDK_PIXBUF_DISABLE_SINGLE_INCLUDES;GTK_DISABLE_SINGLE_INCLUDES;HAVE_X509_GET_SIGNATURE_NID;HAVE_SSL_CTX_GET_SSL_METHOD;DEFAULT_CERT_FILE="cert.pem";HAVE_STRTOULL;strtoull=_strtoui64;strcasecmp=stricmp;strncasecmp=strnicmp;__inline__=__inline $(YourDepsPath)\$(PlatformName)\release $(YourGendefPath) @@ -33,7 +33,7 @@ lua51 $(DepsRoot)\include\glib-2.0;$(DepsRoot)\lib\glib-2.0\include;$(DepsRoot)\include\libxml2 $(DepsRoot)\include\gtk-2.0;$(DepsRoot)\lib\gtk-2.0\include;$(DepsRoot)\include\atk-1.0;$(DepsRoot)\include\cairo;$(DepsRoot)\include\pango-1.0;$(DepsRoot)\include\gdk-pixbuf-2.0 - gtk-win32-2.0.lib;gdk-win32-2.0.lib;atk-1.0.lib;gio-2.0.lib;gdk_pixbuf-2.0.lib;pangowin32-1.0.lib;pangocairo-1.0.lib;pango-1.0.lib;cairo.lib;gobject-2.0.lib;gmodule-2.0.lib;glib-2.0.lib;intl.lib;libxml2.lib;libeay32.lib;ssleay32.lib;wininet.lib;winmm.lib;ws2_32.lib + gtk-win32-2.0.lib;gdk-win32-2.0.lib;atk-1.0.lib;gio-2.0.lib;gdk_pixbuf-2.0.lib;pangowin32-1.0.lib;pangocairo-1.0.lib;pango-1.0.lib;cairo.lib;gobject-2.0.lib;gmodule-2.0.lib;glib-2.0.lib;intl.lib;libxml2.lib;libcrypto.lib;libssl.lib;ssleay32.lib;wininet.lib;winmm.lib;ws2_32.lib $(SolutionDir)..\data\\ $(SolutionDir)..\..\hexchat-build $(HexChatBuild)\$(PlatformName)\bin\ diff --git a/win32/installer/hexchat.iss.tt b/win32/installer/hexchat.iss.tt index be985384..1671988d 100644 --- a/win32/installer/hexchat.iss.tt +++ b/win32/installer/hexchat.iss.tt @@ -138,7 +138,13 @@ Source: "gspawn-win32-helper-console.exe"; DestDir: "{app}"; Flags: ignoreversio Source: "gthread-2.0-0.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "gtk-win32-2.0.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "iconv.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs -Source: "libeay32.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs +#if APPARCH == "x64" +Source: "libcrypto-1_1-x64.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs +Source: "libssl-1_1-x64.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs +#else +Source: "libcrypto-1_1.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs +Source: "libssl-1_1.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs +#endif Source: "libenchant.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "ffi-7.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "intl.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs @@ -148,7 +154,6 @@ Source: "pango-1.0-0.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: l Source: "pangocairo-1.0-0.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "pangoft2-1.0-0.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "pangowin32-1.0-0.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs -Source: "ssleay32.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "plugins\hcnotifications-winrt.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: libs -- cgit 1.4.1 From 6fd8a8f9bf48562fbbc42f908321b67d436c097e Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Sat, 2 Oct 2021 09:49:17 -0500 Subject: python: Open all scripts with utf-8 encoding --- plugins/python/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/python/python.py b/plugins/python/python.py index 7bd327e3..1adcde98 100644 --- a/plugins/python/python.py +++ b/plugins/python/python.py @@ -146,7 +146,7 @@ class Plugin: def loadfile(self, filename): try: self.filename = filename - with open(filename) as f: + with open(filename, encoding='utf-8') as f: data = f.read() compiled = compile_file(data, filename) exec(compiled, self.globals) -- cgit 1.4.1 From 4f3ef3505a5f34c85e0935dc1ca4d14f27590ae5 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Wed, 3 Nov 2021 09:59:24 -0500 Subject: fishlim: Minor test improvements - Don't have tests repeat themselves, meson has a `--repeat` flag - Fix a minor leak of a GRand - Speed up a test - Increase timeout This still needs a lot of improvements, it runs at lot of loops within loops generating random strings that could be optimized. This means it can take a very long time on some computers. Closes #2629 --- plugins/fishlim/tests/meson.build | 1 + plugins/fishlim/tests/tests.c | 65 ++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 35 deletions(-) (limited to 'plugins') diff --git a/plugins/fishlim/tests/meson.build b/plugins/fishlim/tests/meson.build index 60eddc18..1a0394a3 100644 --- a/plugins/fishlim/tests/meson.build +++ b/plugins/fishlim/tests/meson.build @@ -12,4 +12,5 @@ fishlim_tests = executable('fishlim_tests', fishlim_test_sources, test('Fishlim Tests', fishlim_tests, protocol: 'tap', + timeout: 600, ) diff --git a/plugins/fishlim/tests/tests.c b/plugins/fishlim/tests/tests.c index 0d385221..393194d8 100644 --- a/plugins/fishlim/tests/tests.c +++ b/plugins/fishlim/tests/tests.c @@ -129,17 +129,17 @@ static void test_base64_len (void) { char *b64 = NULL; - int i, message_len = 0; char message[1000]; + int message_end = sizeof (message) - 1; - for (i = 0; i < 10; ++i) { - for (message_len = 1; message_len < 1000; ++message_len) { - random_string(message, message_len); - b64 = g_base64_encode((const unsigned char *) message, message_len); - g_assert_nonnull(b64); - g_assert_cmpuint(strlen(b64), == , base64_len(message_len)); - g_free(b64); - } + random_string(message, message_end); + + for (; message_end >= 0; --message_end) { + message[message_end] = '\0'; /* Truncate instead of generating new strings */ + b64 = g_base64_encode((const unsigned char *) message, message_end); + g_assert_nonnull(b64); + g_assert_cmpuint(strlen(b64), == , base64_len(message_end)); + g_free(b64); } } @@ -150,18 +150,15 @@ static void test_base64_fish_len (void) { char *b64 = NULL; - int i, message_len = 0; + int message_len = 0; char message[1000]; - for (i = 0; i < 10; ++i) { - - for (message_len = 1; message_len < 1000; ++message_len) { - random_string(message, message_len); - b64 = fish_base64_encode(message, message_len); - g_assert_nonnull(b64); - g_assert_cmpuint(strlen(b64), == , base64_fish_len(message_len)); - g_free(b64); - } + for (message_len = 1; message_len < 1000; ++message_len) { + random_string(message, message_len); + b64 = fish_base64_encode(message, message_len); + g_assert_nonnull(b64); + g_assert_cmpuint(strlen(b64), == , base64_fish_len(message_len)); + g_free(b64); } } @@ -242,30 +239,28 @@ test_foreach_utf8_data_chunks(void) { GRand *rand = NULL; GString *chunks = NULL; - int tests, max_chunks_len, chunks_len; + int max_chunks_len, chunks_len; char ascii_message[1001]; char *data_chunk = NULL; rand = g_rand_new(); + max_chunks_len = g_rand_int_range(rand, 2, 301); + random_string(ascii_message, 1000); - for (tests = 0; tests < 1000; ++tests) { + data_chunk = ascii_message; - max_chunks_len = g_rand_int_range(rand, 2, 301); - random_string(ascii_message, 1000); + chunks = g_string_new(NULL); - data_chunk = ascii_message; - - chunks = g_string_new(NULL); - - while (foreach_utf8_data_chunks(data_chunk, max_chunks_len, &chunks_len)) { - g_string_append(chunks, g_strndup(data_chunk, chunks_len)); - /* Next chunk */ - data_chunk += chunks_len; - } - /* Check data loss */ - g_assert_cmpstr(chunks->str, == , ascii_message); - g_string_free(chunks, TRUE); + while (foreach_utf8_data_chunks(data_chunk, max_chunks_len, &chunks_len)) { + g_string_append(chunks, g_strndup(data_chunk, chunks_len)); + /* Next chunk */ + data_chunk += chunks_len; } + /* Check data loss */ + g_assert_cmpstr(chunks->str, == , ascii_message); + + g_string_free(chunks, TRUE); + g_rand_free (rand); } int -- cgit 1.4.1 From f93b13a6a3ae0adf01257b265d2b7caa1d98c5a1 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Thu, 11 Nov 2021 10:24:39 -0600 Subject: Add missing string.h includes Closes #2652 --- plugins/fishlim/tests/tests.c | 1 + plugins/fishlim/utils.c | 2 ++ 2 files changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/fishlim/tests/tests.c b/plugins/fishlim/tests/tests.c index 393194d8..f3e852d2 100644 --- a/plugins/fishlim/tests/tests.c +++ b/plugins/fishlim/tests/tests.c @@ -21,6 +21,7 @@ */ +#include #include #include "fish.h" diff --git a/plugins/fishlim/utils.c b/plugins/fishlim/utils.c index 4052995a..17ed4c2e 100644 --- a/plugins/fishlim/utils.c +++ b/plugins/fishlim/utils.c @@ -22,6 +22,8 @@ */ +#include + #include "utils.h" #include "fish.h" -- cgit 1.4.1 From bbd60a96ecd0e190625c68bedca4e46928ee2b4d Mon Sep 17 00:00:00 2001 From: Simon Chopin Date: Tue, 30 Nov 2021 13:56:56 +0100 Subject: fish: enable the legacy provider if build against OpenSSL3 OpenSSL 3.0 disables a number of "legacy" algorithms by default, and we need to enable them manually using their provider system. Note that explicitly loading a provider will disable the implicit default provider, which is why we need to load it explicitly. Closes #2629 Signed-off-by: Simon Chopin V2: * use a local OSSL_LIB_CTX to avoid leaking the legacy algorithms into the main SSL context. * Simplify the fish_init() error paths by calling fish_deinit() --- plugins/fishlim/fish.c | 58 ++++++++++++++++++++++++++++++++++++++++ plugins/fishlim/fish.h | 2 ++ plugins/fishlim/plugin_hexchat.c | 4 +++ plugins/fishlim/tests/tests.c | 5 +++- 4 files changed, 68 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/fishlim/fish.c b/plugins/fishlim/fish.c index c2c2b9da..5a27e4cb 100644 --- a/plugins/fishlim/fish.c +++ b/plugins/fishlim/fish.c @@ -87,6 +87,54 @@ static const signed char fish_unbase64[256] = { dest |= (uint8_t)*((source)++); \ } while (0); +#if OPENSSL_VERSION_NUMBER >= 0x30000000L +#include +static OSSL_PROVIDER *legacy_provider; +static OSSL_PROVIDER *default_provider; +static OSSL_LIB_CTX* *ossl_ctx; +#endif + +int fish_init(void) +{ +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + ossl_ctx = OSSL_LIB_CTX_new(); + if (!ossl_ctx) + return 0; + + legacy_provider = OSSL_PROVIDER_load(ossl_ctx, "legacy"); + if (!legacy_provider) { + fish_deinit(); + return 0; + } + + default_provider = OSSL_PROVIDER_load(ossl_ctx, "default"); + if (!default_provider) { + fish_deinit(); + return 0; + } +#endif + return 1; +} + +void fish_deinit(void) +{ +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + if (legacy_provider) { + OSSL_PROVIDER_unload(legacy_provider); + legacy_provider = NULL; + } + + if (default_provider) { + OSSL_PROVIDER_unload(default_provider); + default_provider = NULL; + } + + if (ossl_ctx) { + OSSL_LIB_CTX_free(ossl_ctx); + ossl_ctx = NULL; + } +#endif +} /** * Encode ECB FiSH Base64 @@ -228,9 +276,19 @@ char *fish_cipher(const char *plaintext, size_t plaintext_len, const char *key, plaintext_len -= 8; } +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + cipher = EVP_CIPHER_fetch(ossl_ctx, "BF-CBC", NULL); +#else cipher = (EVP_CIPHER *) EVP_bf_cbc(); +#endif + } else if (mode == EVP_CIPH_ECB_MODE) { + +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + cipher = EVP_CIPHER_fetch(ossl_ctx, "BF-ECB", NULL); +#else cipher = (EVP_CIPHER *) EVP_bf_ecb(); +#endif } /* Zero Padding */ diff --git a/plugins/fishlim/fish.h b/plugins/fishlim/fish.h index 6a2e911c..75829061 100644 --- a/plugins/fishlim/fish.h +++ b/plugins/fishlim/fish.h @@ -35,6 +35,8 @@ enum fish_mode { FISH_CBC_MODE = 0x2 }; +int fish_init(void); +void fish_deinit(void); char *fish_base64_encode(const char *message, size_t message_len); char *fish_base64_decode(const char *message, size_t *final_len); char *fish_encrypt(const char *key, size_t keylen, const char *message, size_t message_len, enum fish_mode mode); diff --git a/plugins/fishlim/plugin_hexchat.c b/plugins/fishlim/plugin_hexchat.c index 93e28487..a8b127f2 100644 --- a/plugins/fishlim/plugin_hexchat.c +++ b/plugins/fishlim/plugin_hexchat.c @@ -815,6 +815,9 @@ int hexchat_plugin_init(hexchat_plugin *plugin_handle, hexchat_hook_server_attrs(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL); hexchat_hook_server_attrs(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL); + if (!fish_init()) + return 0; + if (!dh1080_init()) return 0; @@ -828,6 +831,7 @@ int hexchat_plugin_init(hexchat_plugin *plugin_handle, int hexchat_plugin_deinit(void) { g_clear_pointer(&pending_exchanges, g_hash_table_destroy); dh1080_deinit(); + fish_deinit(); hexchat_printf(ph, "%s plugin unloaded\n", plugin_name); return 1; diff --git a/plugins/fishlim/tests/tests.c b/plugins/fishlim/tests/tests.c index f3e852d2..12b10d1d 100644 --- a/plugins/fishlim/tests/tests.c +++ b/plugins/fishlim/tests/tests.c @@ -278,5 +278,8 @@ main(int argc, char *argv[]) { g_test_add_func("/fishlim/max_text_command_len", test_max_text_command_len); g_test_add_func("/fishlim/foreach_utf8_data_chunks", test_foreach_utf8_data_chunks); - return g_test_run(); + fish_init(); + int ret = g_test_run(); + fish_deinit(); + return ret; } -- cgit 1.4.1 From 9c7109b57869881660fefeaf98a10b7911118117 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Tue, 11 Jan 2022 21:51:52 +0530 Subject: meson: Fix exported functions for python plugin This fixes loading python plugin in Windows by exporting functions using python.def file. Otherwise, hexchat_plugin_init symbol error is shown. --- plugins/python/meson.build | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/python/meson.build b/plugins/python/meson.build index 5fd7ec2f..1e9b41ad 100644 --- a/plugins/python/meson.build +++ b/plugins/python/meson.build @@ -28,4 +28,5 @@ shared_module('python', python3_source, install: true, install_dir: plugindir, name_prefix: '', + vs_module_defs: 'python.def' ) -- cgit 1.4.1 From 1de339dfbcbc167f14345a75512b1e2658eafdad Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 21 Jan 2022 12:11:19 +0530 Subject: meson: Fix exported functions in plugins This adds DEF file names in meson. Without the DEF files, every functions are exproted from plugins. --- plugins/checksum/meson.build | 1 + plugins/exec/meson.build | 3 ++- plugins/fishlim/meson.build | 1 + plugins/perl/meson.build | 1 + plugins/sysinfo/meson.build | 1 + plugins/upd/meson.build | 1 + plugins/winamp/meson.build | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/checksum/meson.build b/plugins/checksum/meson.build index 25835457..e3008f75 100644 --- a/plugins/checksum/meson.build +++ b/plugins/checksum/meson.build @@ -3,4 +3,5 @@ shared_module('checksum', 'checksum.c', install: true, install_dir: plugindir, name_prefix: '', + vs_module_defs: 'checksum.def', ) diff --git a/plugins/exec/meson.build b/plugins/exec/meson.build index 3f9e8a32..782814da 100644 --- a/plugins/exec/meson.build +++ b/plugins/exec/meson.build @@ -1,5 +1,6 @@ shared_module('exec', 'exec.c', dependencies: hexchat_plugin_dep, install: true, - install_dir: plugindir + install_dir: plugindir, + vs_module_defs: 'exec.def', ) diff --git a/plugins/fishlim/meson.build b/plugins/fishlim/meson.build index 65ccc9ea..232c9a33 100644 --- a/plugins/fishlim/meson.build +++ b/plugins/fishlim/meson.build @@ -19,4 +19,5 @@ shared_module('fishlim', fishlim_sources, install: true, install_dir: plugindir, name_prefix: '', + vs_module_defs: 'fishlim.def', ) diff --git a/plugins/perl/meson.build b/plugins/perl/meson.build index 06ffd54b..ebcf35bb 100644 --- a/plugins/perl/meson.build +++ b/plugins/perl/meson.build @@ -88,4 +88,5 @@ shared_module('perl', install_dir: plugindir, install_rpath: perl_rpath, name_prefix: '', + vs_module_defs: 'perl.def', ) diff --git a/plugins/sysinfo/meson.build b/plugins/sysinfo/meson.build index 7e2cdb6c..08f08c2c 100644 --- a/plugins/sysinfo/meson.build +++ b/plugins/sysinfo/meson.build @@ -57,4 +57,5 @@ shared_module('sysinfo', sysinfo_sources, install: true, install_dir: plugindir, name_prefix: '', + vs_module_defs: 'sysinfo.def', ) diff --git a/plugins/upd/meson.build b/plugins/upd/meson.build index 7ab9d830..68217b31 100644 --- a/plugins/upd/meson.build +++ b/plugins/upd/meson.build @@ -5,4 +5,5 @@ shared_module('upd', 'upd.c', install: true, install_dir: plugindir, name_prefix: '', + vs_module_defs: 'upd.def', ) diff --git a/plugins/winamp/meson.build b/plugins/winamp/meson.build index b07e7071..8d298651 100644 --- a/plugins/winamp/meson.build +++ b/plugins/winamp/meson.build @@ -3,4 +3,5 @@ shared_module('winamp', 'winamp.c', install: true, install_dir: plugindir, name_prefix: '', + vs_module_defs: 'winamp.def', ) -- cgit 1.4.1 From ccf6f431bbd96f04369875d72a61976bb6609a69 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Wed, 16 Feb 2022 10:24:40 -0500 Subject: Return userdata from pluginprefs __pairs metamethod to avoid immediate GC. --- plugins/lua/lua.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c index d1370eaf..f8f051f4 100644 --- a/plugins/lua/lua.c +++ b/plugins/lua/lua.c @@ -957,16 +957,21 @@ static int api_hexchat_pluginprefs_meta_pairs(lua_State *L) hexchat_plugin *h; if(!script->name) + return luaL_error(L, "cannot use hexchat.pluginprefs before registering with hexchat.register"); dest = lua_newuserdata(L, 4096); + h = script->handle; if(!hexchat_pluginpref_list(h, dest)) strcpy(dest, ""); lua_pushlightuserdata(L, dest); lua_pushlightuserdata(L, dest); lua_pushcclosure(L, api_hexchat_pluginprefs_meta_pairs_closure, 2); - return 1; + lua_insert(L, -2); // Return the userdata (second return value from pairs), + // even though it's not used by the closure (first return + // value from pairs), so that Lua knows not to GC it. + return 2; } static int api_attrs_meta_index(lua_State *L) @@ -1764,4 +1769,3 @@ G_MODULE_EXPORT int hexchat_plugin_deinit(hexchat_plugin *plugin_handle) g_clear_pointer(&expand_buffer, g_free); return 1; } - -- cgit 1.4.1