This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [BZ 24544] Use support_install_prefix in elf/tst-pldd.c
On 09/05/2019 18:52, Romain Geissler wrote:
> Hi,
>
> This should fix BZ 24544 by using support_install_prefix as suggested by Carlos. Tested on my use case with --prefix, I have not tried without --prefix, is support_install_prefix equal to "/usr" by default, or is it "/", or is it empty ?
>
> Cheers,
> Romain
>
>
> 2019-05-09 Romain Geissler <romain.geissler@amadeus.com>
>
> [BZ #24544]
> * elf/tst-pldd.c: Include <support/support.h>.
> (PATH_MAX) [!PATH_MAX]: Define PATH_MAX macro.
> (do_test): Use support_install_prefix to compute pldd path.
>
>
>
> From 9a311911c3a74ef11626aaf1b1950d89d0ea20be Mon Sep 17 00:00:00 2001
> From: Romain Geissler <romain.geissler@amadeus.com>
> Date: Thu, 9 May 2019 21:38:42 +0000
> Subject: [PATCH] [BZ #24544] Use support_install_prefix in elf/tst-pldd.c
>
> ---
> elf/tst-pldd.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/elf/tst-pldd.c b/elf/tst-pldd.c
> index 2a9f58936f0..534e28ed502 100644
> --- a/elf/tst-pldd.c
> +++ b/elf/tst-pldd.c
> @@ -25,10 +25,15 @@
> #include <array_length.h>
> #include <gnu/lib-names.h>
>
> +#include <support/support.h>
> #include <support/subprocess.h>
> #include <support/capture_subprocess.h>
> #include <support/check.h>
>
> +#ifndef PATH_MAX
> +# define PATH_MAX 4096
> +#endif
> +
> static void
> target_process (void *arg)
> {
> @@ -60,7 +65,9 @@ do_test (void)
> char pid[3 * sizeof (uint32_t) + 1];
> snprintf (pid, array_length (pid), "%d", target.pid);
>
> - const char prog[] = "/usr/bin/pldd";
> + char prog[PATH_MAX] = "";
> + strcpy(prog, support_install_prefix);
> + strcat(prog, "/bin/pldd");
Use snprintf instead (there is no need to actually initialize
prog as well):
snprintf (prog, sizeof prog, "%s/bin/pldd", support_install_prefix)
LGTM with the change.
(as a side note, I think we might include a xsnprintf).
>
> pldd = support_capture_subprogram (prog,
> (char *const []) { (char *) prog, pid, NULL });
>