[PATCH grout] api: fix external clients build
Robin Jarry
rjarry at redhat.com
Tue Mar 24 13:15:54 CET 2026
Hey Andrei,
Andrei Rybchenko, Mar 24, 2026 at 12:20:
> gr_string.h is now used in API headers. So, it must be installed and
> provided in grout-headers package.
>
> Fixes: 88c63f8871f7 ("api: replace direct memccpy with gr_strcpy for safe string copy")
> Signed-off-by: Andrei Rybchenko <rybchenko.andrei at gmail.com>
> ---
> api/meson.build | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/api/meson.build b/api/meson.build
> index ce8340c8..f734a65b 100644
> --- a/api/meson.build
> +++ b/api/meson.build
> @@ -10,6 +10,7 @@ api_headers += files(
> 'gr_macro.h',
> 'gr_net_compat.h',
> 'gr_net_types.h',
> + 'gr_string.h',
> )
> api_headers += configure_file(
> output: 'gr_version.h',
Hmm, I hadn't considered this. The issue here is that some functions
declared in gr_string.h are implemented in api/string.c which isn't
shipped as grout headers.
Installing gr_string.h isn't the correct solution. We should remove the
include from gr_api_client_impl.h instead:
diff --git api/gr_api_client_impl.h api/gr_api_client_impl.h
index ca9a0f84e1b7..14b4a79d3087 100644
--- api/gr_api_client_impl.h
+++ api/gr_api_client_impl.h
@@ -8,7 +8,6 @@
#include <gr_api.h>
#include <gr_errno.h>
#include <gr_macro.h>
-#include <gr_string.h>
#include <gr_version.h>
#include <assert.h>
@@ -50,8 +49,11 @@ struct gr_api_client *gr_api_client_connect(const char *sock_path) {
goto err;
addr.un.sun_family = AF_UNIX;
- if (gr_strcpy(addr.un.sun_path, sizeof(addr.un.sun_path), sock_path) < 0)
+ unsigned ret = snprintf(addr.un.sun_path, sizeof(addr.un.sun_path), "%s", sock_path);
+ if (ret < 0 || ret >= sizeof(addr.un.sun_path)) {
+ errno = ENAMETOOLONG;
goto err;
+ }
if (connect(client->sock_fd, &addr.a, sizeof(addr.un)) < 0)
goto err;
More information about the grout
mailing list