[DTrace-devel] [PATCH 3/4] Perform string constant truncation without using string length prefix
Kris Van Hees
kris.van.hees at oracle.com
Fri Jan 28 19:55:44 UTC 2022
On Fri, Jan 28, 2022 at 02:41:14PM -0500, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Thanks.
> with...
>
> On 1/26/22 11:29 AM, Kris Van Hees via DTrace-devel wrote:
> > diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
>
> I'm losing track, but doesn't this file need a refreshed Copyright year?
Done in patch 1/4.
> > @@ -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;
>
> Maybe the strlen prefix "should" still be retained in this patch (and dumped
> in the next one), but... not worth worrying about this.
No, I am deliberately not populating it here. Since we zalloc strtab, those
bytes will be zero, and that is what I want here. I.e. the prefix is still
there but (on purpose) 0 so it would be obvious if any code is still looking
at it.
> > - buf[2 + strsize] = '\0';
> > - }
> > - buf += 2 + len + 1;
> > + if (len > strsize)
> > + buf[DT_STRLEN_BYTES + strsize] = '\0';
> > +
> > + buf += DT_STRLEN_BYTES + len + 1;
> > }
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list