[DTrace-devel] [PATCH 3/4] Perform string constant truncation without using string length prefix
Kris Van Hees
kris.van.hees at oracle.com
Wed Jan 26 16:29:03 UTC 2022
The string constant truncation processing was reading the string length
from the 2-byte prefix. The new approach uses strlen() on the string
data.
This patch prepares for the removal of the string length prefix support.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_bpf.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
index cfd7c6d7..ccdce2c0 100644
--- a/libdtrace/dt_bpf.c
+++ b/libdtrace/dt_bpf.c
@@ -329,14 +329,12 @@ dt_bpf_gmap_create(dtrace_hdl_t *dtp)
buf = (uint8_t *)strtab;
end = buf + dtp->dt_strlen;
while (buf < end) {
- uint_t len = (buf[0] << 8) | buf[1];
+ uint_t len = strlen((char *)buf + DT_STRLEN_BYTES);
- if (len > strsize) {
- buf[0] = strsize >> 8;
- buf[1] = strsize & 0xff;
- buf[2 + strsize] = '\0';
- }
- buf += 2 + len + 1;
+ if (len > strsize)
+ buf[DT_STRLEN_BYTES + strsize] = '\0';
+
+ buf += DT_STRLEN_BYTES + len + 1;
}
st_mapfd = create_gmap(dtp, "strtab", BPF_MAP_TYPE_ARRAY,
--
2.34.1
More information about the DTrace-devel
mailing list