[v3,08/19] elf: Emit warning if tunable is ill-formatted

Message ID 20231106202552.3404059-9-adhemerval.zanella@linaro.org
State Committed
Commit eb9291aaa6ff6af158a1436b881ef8b834559621
Delegated to: Siddhesh Poyarekar
Headers
Series Improve loader environment variable handling |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Patch failed to apply

Commit Message

Adhemerval Zanella Netto Nov. 6, 2023, 8:25 p.m. UTC
  So caller knows that the tunable will be ignored.

Checked on x86_64-linux-gnu.
---
 elf/dl-tunables.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Siddhesh Poyarekar Nov. 20, 2023, 9:50 p.m. UTC | #1
On 2023-11-06 15:25, Adhemerval Zanella wrote:
> So caller knows that the tunable will be ignored.
> 
> Checked on x86_64-linux-gnu.
> ---

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

>   elf/dl-tunables.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
> index e1198869d6..6e3e6a2cf8 100644
> --- a/elf/dl-tunables.c
> +++ b/elf/dl-tunables.c
> @@ -235,6 +235,12 @@ parse_tunables (char *valstring)
>   {
>     struct tunable_toset_t tunables[tunables_list_size];
>     int ntunables = parse_tunables_string (valstring, tunables);
> +  if (ntunables == -1)
> +    {
> +      _dl_error_printf (
> +        "WARNING: ld.so: invalid GLIBC_TUNABLES `%s': ignored.\n", valstring);
> +      return;
> +    }
>   
>     for (int i = 0; i < ntunables; i++)
>       tunable_initialize (tunables[i].t, tunables[i].value);
  

Patch

diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index e1198869d6..6e3e6a2cf8 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -235,6 +235,12 @@  parse_tunables (char *valstring)
 {
   struct tunable_toset_t tunables[tunables_list_size];
   int ntunables = parse_tunables_string (valstring, tunables);
+  if (ntunables == -1)
+    {
+      _dl_error_printf (
+        "WARNING: ld.so: invalid GLIBC_TUNABLES `%s': ignored.\n", valstring);
+      return;
+    }
 
   for (int i = 0; i < ntunables; i++)
     tunable_initialize (tunables[i].t, tunables[i].value);