Date: Wed, 12 May 2021 22:25:16 GMT From: Jan Beich <jbeich@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: aa34b0f42f0b - main - sysutils/lttng-tools: fix obtaining HOST_NAME_MAX Message-ID: <202105122225.14CMPGsL061105@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jbeich: URL: https://cgit.FreeBSD.org/ports/commit/?id=aa34b0f42f0b02560ef68a9bd952206c02869e64 commit aa34b0f42f0b02560ef68a9bd952206c02869e64 Author: Adam Wolk <a.wolk@fudosecurity.com> AuthorDate: 2021-04-30 15:16:05 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2021-05-12 22:22:37 +0000 sysutils/lttng-tools: fix obtaining HOST_NAME_MAX Using sysconf(3) API lead to accidental introduction of variable length arrays (VLA) in the port. Additionally one patch hardcoded 256 as the HOST_NAME_MAX even though the code doesn't expect an additional byte for the terminating NULL byte in the struct definition. Fall back to using _POSIX_HOST_NAME_MAX as the remaining code is not ready for introducing sysconf(3) as a patch. Remove #ifdef FreeBSD from our patches. Bump PORTREVISION to rebuild with the new patch. Sponsored by: Fudo Security Differential Revision: https://reviews.freebsd.org/D30048 --- sysutils/lttng-tools/Makefile | 2 +- .../files/patch-src_bin_lttng-sessiond_consumer.c | 21 ++++++++++++++------- .../files/patch-src_bin_lttng-sessiond_session.h | 11 ++++------- .../patch-src_bin_lttng-sessiond_ust-metadata.c | 22 +++++++++++++++------- .../files/patch-src_bin_lttng_commands_view.c | 19 +++++++++++++------ 5 files changed, 47 insertions(+), 28 deletions(-) diff --git a/sysutils/lttng-tools/Makefile b/sysutils/lttng-tools/Makefile index 6a2f6436e134..746d387046c8 100644 --- a/sysutils/lttng-tools/Makefile +++ b/sysutils/lttng-tools/Makefile @@ -2,7 +2,7 @@ PORTNAME= lttng-tools PORTVERSION= 2.9.3 -PORTREVISION= 5 +PORTREVISION= 6 CATEGORIES= sysutils MASTER_SITES= http://lttng.org/files/${PORTNAME}/ diff --git a/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_consumer.c b/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_consumer.c index e22db4d04fc2..cf2fe604f8a9 100644 --- a/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_consumer.c +++ b/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_consumer.c @@ -1,12 +1,19 @@ ---- src/bin/lttng-sessiond/consumer.c.orig 2016-11-29 22:48:37 UTC -+++ src/bin/lttng-sessiond/consumer.c -@@ -635,6 +635,9 @@ int consumer_set_network_uri(struct cons +--- src/bin/lttng-sessiond/consumer.c.orig 2017-01-09 19:26:28 UTC ++++ src/bin/lttng-sessiond/consumer.c +@@ -17,6 +17,7 @@ + + #define _LGPL_SOURCE + #include <assert.h> ++#include <limits.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +@@ -635,7 +636,7 @@ int consumer_set_network_uri(struct consumer_output *o { int ret; char tmp_path[PATH_MAX]; -+#if defined(__FreeBSD__) -+ const size_t HOST_NAME_MAX = sysconf(_SC_HOST_NAME_MAX); -+#endif - char hostname[HOST_NAME_MAX]; +- char hostname[HOST_NAME_MAX]; ++ char hostname[_POSIX_HOST_NAME_MAX]; struct lttng_uri *dst_uri = NULL; + /* Code flow error safety net. */ diff --git a/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_session.h b/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_session.h index b64470a2c107..2e98067379cb 100644 --- a/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_session.h +++ b/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_session.h @@ -1,14 +1,11 @@ ---- src/bin/lttng-sessiond/session.h.orig 2016-11-29 22:48:37 UTC +--- src/bin/lttng-sessiond/session.h.orig 2017-01-09 19:26:28 UTC +++ src/bin/lttng-sessiond/session.h -@@ -60,7 +60,11 @@ struct ltt_session_list { +@@ -60,7 +60,7 @@ struct ltt_session_list { */ struct ltt_session { char name[NAME_MAX]; -+#if defined(__FreeBSD__) -+ char hostname[256]; /* Local hostname. */ -+#else - char hostname[HOST_NAME_MAX]; /* Local hostname. */ -+#endif +- char hostname[HOST_NAME_MAX]; /* Local hostname. */ ++ char hostname[_POSIX_HOST_NAME_MAX]; /* Local hostname. */ struct ltt_kernel_session *kernel_session; struct ltt_ust_session *ust_session; /* diff --git a/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_ust-metadata.c b/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_ust-metadata.c index 00271f154e85..e95b52ac1382 100644 --- a/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_ust-metadata.c +++ b/sysutils/lttng-tools/files/patch-src_bin_lttng-sessiond_ust-metadata.c @@ -1,6 +1,6 @@ ---- src/bin/lttng-sessiond/ust-metadata.c.orig 2016-11-29 22:48:37 UTC +--- src/bin/lttng-sessiond/ust-metadata.c.orig 2017-01-09 19:26:28 UTC +++ src/bin/lttng-sessiond/ust-metadata.c -@@ -50,6 +50,7 @@ int _lttng_field_statedump(struct ust_re +@@ -50,6 +50,7 @@ int _lttng_field_statedump(struct ust_registry_session const struct ustctl_field *fields, size_t nr_fields, size_t *iter_field, size_t nesting); @@ -16,13 +16,21 @@ static inline int get_count_order(unsigned int count) -@@ -879,6 +881,9 @@ int ust_metadata_session_statedump(struc +@@ -879,7 +881,7 @@ int ust_metadata_session_statedump(struct ust_registry char uuid_s[UUID_STR_LEN], clock_uuid_s[UUID_STR_LEN]; int ret = 0; -+#if defined(__FreeBSD__) -+ const size_t HOST_NAME_MAX = sysconf(_SC_HOST_NAME_MAX); -+#endif - char hostname[HOST_NAME_MAX]; +- char hostname[HOST_NAME_MAX]; ++ char hostname[_POSIX_HOST_NAME_MAX]; assert(session); + +@@ -940,7 +942,7 @@ int ust_metadata_session_statedump(struct ust_registry + hostname[0] = '\0'; + ret = gethostname(hostname, sizeof(hostname)); + if (ret && errno == ENAMETOOLONG) +- hostname[HOST_NAME_MAX - 1] = '\0'; ++ hostname[_POSIX_HOST_NAME_MAX - 1] = '\0'; + ret = lttng_metadata_printf(session, + "env {\n" + " hostname = \"%s\";\n" diff --git a/sysutils/lttng-tools/files/patch-src_bin_lttng_commands_view.c b/sysutils/lttng-tools/files/patch-src_bin_lttng_commands_view.c index fba950a0426e..82f4d46c594a 100644 --- a/sysutils/lttng-tools/files/patch-src_bin_lttng_commands_view.c +++ b/sysutils/lttng-tools/files/patch-src_bin_lttng_commands_view.c @@ -1,12 +1,19 @@ ---- src/bin/lttng/commands/view.c.orig 2016-11-29 22:48:37 UTC +--- src/bin/lttng/commands/view.c.orig 2017-01-09 19:26:28 UTC +++ src/bin/lttng/commands/view.c -@@ -269,6 +269,9 @@ static char *build_live_path(char *sessi +@@ -17,6 +17,7 @@ + + #define _LGPL_SOURCE + #include <popt.h> ++#include <limits.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +@@ -269,7 +270,7 @@ static char *build_live_path(char *session_name) { int ret; char *path = NULL; -+#if defined(__FreeBSD__) -+ const size_t HOST_NAME_MAX = sysconf(_SC_HOST_NAME_MAX); -+#endif - char hostname[HOST_NAME_MAX]; +- char hostname[HOST_NAME_MAX]; ++ char hostname[_POSIX_HOST_NAME_MAX]; ret = gethostname(hostname, sizeof(hostname)); + if (ret < 0) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105122225.14CMPGsL061105>