[DTrace-devel] [PATCH] Write 0 rather than '\0' in *.S files
Kris Van Hees
kris.van.hees at oracle.com
Thu Dec 2 18:50:36 UTC 2021
On Thu, Dec 02, 2021 at 01:44:52PM -0500, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> Apparently, when one uses stb in a bpf/*.S file to write a '\0',
> one writes a literal '0'. This problem was not seen until the
> basename/dirname patches were combined with
> cf1e9df28b95 Optimize dt_cg_store_val() for string values
> Prior to that, we trusted the string-length prefix and truncated the
> string before the literal '0'.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> bpf/basename.S | 4 ++--
> bpf/dirname.S | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/bpf/basename.S b/bpf/basename.S
> index 3ddb3bbf..2839614c 100644
> --- a/bpf/basename.S
> +++ b/bpf/basename.S
> @@ -107,7 +107,7 @@ dt_basename :
> */
> mov LEN, 1
> stb [DST+DT_STRLEN_BYTES], '.'
> - stb [DST+(DT_STRLEN_BYTES+1)], '\0'
> + stb [DST+(DT_STRLEN_BYTES+1)], 0
> ja .Lcoda
>
> .Lslash:
> @@ -116,7 +116,7 @@ dt_basename :
> */
> mov LEN, 1
> stb [DST+DT_STRLEN_BYTES], '/'
> - stb [DST+(DT_STRLEN_BYTES+1)], '\0'
> + stb [DST+(DT_STRLEN_BYTES+1)], 0
> ja .Lcoda
> #undef SRC
> #undef DST
> diff --git a/bpf/dirname.S b/bpf/dirname.S
> index 1ab676ce..908fa68a 100644
> --- a/bpf/dirname.S
> +++ b/bpf/dirname.S
> @@ -123,7 +123,7 @@ dt_dirname :
> */
> mov LEN, 1
> stb [DST+DT_STRLEN_BYTES], '.'
> - stb [DST+(DT_STRLEN_BYTES+1)], '\0'
> + stb [DST+(DT_STRLEN_BYTES+1)], 0
> ja .Lcoda
>
> .Lslash:
> @@ -132,7 +132,7 @@ dt_dirname :
> */
> mov LEN, 1
> stb [DST+DT_STRLEN_BYTES], '/'
> - stb [DST+(DT_STRLEN_BYTES+1)], '\0'
> + stb [DST+(DT_STRLEN_BYTES+1)], 0
> ja .Lcoda
> #undef SRC
> #undef DST
> --
> 2.18.4
>
>
> _______________________________________________
> 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