|
| 1 | +From cf7fb47788dfb83bb5d8bd0bffdb582e381a2f0a Mon Sep 17 00:00:00 2001 |
| 2 | +From: Thomas Egerer <thomas.egerer@secunet.com> |
| 3 | +Date: Fri, 6 Sep 2024 13:29:40 +0200 |
| 4 | +Subject: [PATCH] array: Don't use realloc() with zero size in array_compress() |
| 5 | + |
| 6 | +The behavior of realloc(3) with zero size was apparently implementation |
| 7 | +defined. While glibc documents the behavior as equivalent to free(3), |
| 8 | +that might not apply to other C libraries. With C17, this behavior has |
| 9 | +been deprecated, and with C23, the behavior is now undefined. It's also |
| 10 | +why valgrind warns about this use. |
| 11 | + |
| 12 | +Hence, when array_compress() would call realloc() with a zero size, we |
| 13 | +now call free() explicitly and set the pointer to NULL. |
| 14 | + |
| 15 | +Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> |
| 16 | +--- |
| 17 | + src/libstrongswan/collections/array.c | 12 +++++++++++- |
| 18 | + 1 file changed, 11 insertions(+), 1 deletion(-) |
| 19 | + |
| 20 | +diff --git a/src/libstrongswan/collections/array.c b/src/libstrongswan/collections/array.c |
| 21 | +index 8acc8051d53..8b6c6d7397e 100644 |
| 22 | +--- a/src/libstrongswan/collections/array.c |
| 23 | ++++ b/src/libstrongswan/collections/array.c |
| 24 | +@@ -197,7 +197,17 @@ void array_compress(array_t *array) |
| 25 | + } |
| 26 | + if (tail) |
| 27 | + { |
| 28 | +- array->data = realloc(array->data, get_size(array, array->count)); |
| 29 | ++ size_t size = get_size(array, array->count); |
| 30 | ++ |
| 31 | ++ if (size) |
| 32 | ++ { |
| 33 | ++ array->data = realloc(array->data, size); |
| 34 | ++ } |
| 35 | ++ else |
| 36 | ++ { |
| 37 | ++ free(array->data); |
| 38 | ++ array->data = NULL; |
| 39 | ++ } |
| 40 | + array->tail = 0; |
| 41 | + } |
| 42 | + } |
| 43 | +--- |
| 44 | + |
| 45 | +From f1f0bd9de60e2697a712e72b7ae9f79763a0901d Mon Sep 17 00:00:00 2001 |
| 46 | +From: Tobias Brunner <tobias@strongswan.org> |
| 47 | +Date: Thu, 9 Jan 2025 16:05:39 +0100 |
| 48 | +Subject: [PATCH] ctr: Remove parameter-less constructor prototype |
| 49 | + |
| 50 | +Useless and causes a compiler warning/error: |
| 51 | + |
| 52 | + error: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent declaration [-Werror,-Wdeprecated-non-prototype] |
| 53 | +--- |
| 54 | + src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.h | 5 ----- |
| 55 | + 1 file changed, 5 deletions(-) |
| 56 | + |
| 57 | +diff --git a/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.h b/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.h |
| 58 | +index e9421a1be9f..3814465e48b 100644 |
| 59 | +--- a/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.h |
| 60 | ++++ b/src/libstrongswan/plugins/ctr/ctr_ipsec_crypter.h |
| 61 | +@@ -37,11 +37,6 @@ struct ctr_ipsec_crypter_t { |
| 62 | + crypter_t crypter; |
| 63 | + }; |
| 64 | + |
| 65 | +-/** |
| 66 | +- * Create a ctr_ipsec_crypter instance. |
| 67 | +- */ |
| 68 | +-ctr_ipsec_crypter_t *ctr_ipsec_crypter_create(); |
| 69 | +- |
| 70 | + /** |
| 71 | + * Create a ctr_ipsec_crypter instance. |
| 72 | + * |
| 73 | +--- |
| 74 | + |
| 75 | +From 227d7ef9a24b8c62d6965c1c1690252bde7c698d Mon Sep 17 00:00:00 2001 |
| 76 | +From: Tobias Brunner <tobias@strongswan.org> |
| 77 | +Date: Fri, 10 Jan 2025 15:43:11 +0100 |
| 78 | +Subject: [PATCH] tnc-imv: Add missing argument to IMV recommendations |
| 79 | + constructor |
| 80 | + |
| 81 | +This avoids the following warning/error: |
| 82 | + |
| 83 | +tnc_imv_manager.c:244:39: error: passing arguments to 'tnc_imv_recommendations_create' without a prototype is deprecated in all versions of C and is not supported in C23 [-Werror,-Wdeprecated-non-prototype] |
| 84 | + 244 | return tnc_imv_recommendations_create(this->imvs); |
| 85 | + | ^ |
| 86 | +--- |
| 87 | + src/libtnccs/plugins/tnc_imv/tnc_imv_recommendations.h | 7 +++++-- |
| 88 | + 1 file changed, 5 insertions(+), 2 deletions(-) |
| 89 | + |
| 90 | +diff --git a/src/libtnccs/plugins/tnc_imv/tnc_imv_recommendations.h b/src/libtnccs/plugins/tnc_imv/tnc_imv_recommendations.h |
| 91 | +index f7178876cfd..60272978ad3 100644 |
| 92 | +--- a/src/libtnccs/plugins/tnc_imv/tnc_imv_recommendations.h |
| 93 | ++++ b/src/libtnccs/plugins/tnc_imv/tnc_imv_recommendations.h |
| 94 | +@@ -27,8 +27,11 @@ |
| 95 | + #include <collections/linked_list.h> |
| 96 | + |
| 97 | + /** |
| 98 | +- * Create an IMV empty recommendations instance |
| 99 | ++ * Create an empty IMV recommendations instance |
| 100 | ++ * |
| 101 | ++ * @param imv_list list of IMVs that could provide recommendations |
| 102 | ++ * @return created instance |
| 103 | + */ |
| 104 | +-recommendations_t *tnc_imv_recommendations_create(); |
| 105 | ++recommendations_t *tnc_imv_recommendations_create(linked_list_t *imv_list); |
| 106 | + |
| 107 | + #endif /** TNC_IMV_RECOMMENDATIONS_H_ @}*/ |
| 108 | +--- |
| 109 | + |
0 commit comments