[DTrace-devel] [PATCH 05/14] probe: get the size of the hash-lookup key right
Nick Alcock
nick.alcock at oracle.com
Thu Oct 24 11:37:49 UTC 2024
This was allocated with alloca() but then snprintf()ed with a size of
INT_MAX. This makes _FORTIFY_SOURCE rightly unhappy.
Passing in the size we actually allocated is trivial.
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Bug: https://github.com/oracle/dtrace-utils/issues/78
---
libdtrace/dt_probe.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libdtrace/dt_probe.c b/libdtrace/dt_probe.c
index 686e2a661253..bb1773ee60d4 100644
--- a/libdtrace/dt_probe.c
+++ b/libdtrace/dt_probe.c
@@ -180,9 +180,9 @@ dt_probe_keylen(const dtrace_probedesc_t *pdp)
}
static char *
-dt_probe_key(const dtrace_probedesc_t *pdp, char *s)
+dt_probe_key(const dtrace_probedesc_t *pdp, char *s, size_t len)
{
- snprintf(s, INT_MAX, "%s:%s:%s", pdp->mod, pdp->fun, pdp->prb);
+ snprintf(s, len, "%s:%s:%s", pdp->mod, pdp->fun, pdp->prb);
return s;
}
@@ -204,7 +204,7 @@ dt_probe_lookup2(dt_provider_t *pvp, const char *s)
return NULL; /* dt_errno is set for us */
keylen = dt_probe_keylen(&pd);
- key = dt_probe_key(&pd, alloca(keylen));
+ key = dt_probe_key(&pd, alloca(keylen), keylen);
/*
* If the probe is already declared, then return the dt_probe_t from
--
2.46.0.278.g36e3a12567
More information about the DTrace-devel
mailing list