Cast should not change writable
PATCH 1/1 Cast should not change writable
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
--- libdtrace/dt_parser.c | 4 ++++ test/unittest/types/tst.castwritable.d | 22 ++++++++++++++++++++++ test/unittest/types/tst.castwritable.r | 1 + 3 files changed, 27 insertions(+) create mode 100644 test/unittest/types/tst.castwritable.d create mode 100644 test/unittest/types/tst.castwritable.r
libdtrace/dt_parser.c +4 -0
@@ -4209,6 +4209,10 @@ asgn_common:dt_cook_taint_alloca (lp,NULL , rp);dt_node_type_propagate (lp, dnp);/* see K&R[A7.5] */ + +if (rp->dn_flags &DT_NF_WRITABLE ) + dnp->dn_flags |=DT_NF_WRITABLE ; +dt_node_attr_assign (dnp,dt_attr_min (lp->dn_attr, rp->dn_attr));break ; }
test/unittest/types/tst.castwritable.d new file +22 -0
@@ -0,0 +1,22 @@ +/* + * Oracle Linux DTrace. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +/* + * ASSERTION: casting keeps a variable writable. + * + * SECTION: Types, Operators, and Expressions/Constants + */ + +#pragma D option quiet + +BEGIN +{ + x = (char *) alloca(8); + *((long long*)x) = 0x0067666564636261; + trace(stringof(x)); + exit(0); +}
test/unittest/types/tst.castwritable.r new file +1 -0
@@ -0,0 +1 @@ +abcdefg
Signature · 1 line
2.43.5
Quoted 3 lines · On Tue, Oct 22, 2024 at 04:47:27PM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
Reviewed-by Kris Van Hees <[email protected]>
Quoted 61 lines
--- libdtrace/dt_parser.c | 4 ++++ test/unittest/types/tst.castwritable.d | 22 ++++++++++++++++++++++ test/unittest/types/tst.castwritable.r | 1 + 3 files changed, 27 insertions(+) create mode 100644 test/unittest/types/tst.castwritable.d create mode 100644 test/unittest/types/tst.castwritable.rlibdtrace/dt_parser.c +4
-0@@ -4209,6 +4209,10 @@ asgn_common:dt_cook_taint_alloca (lp,NULL , rp);dt_node_type_propagate (lp, dnp);/* see K&R[A7.5] */ + +if (rp->dn_flags &DT_NF_WRITABLE ) + dnp->dn_flags |=DT_NF_WRITABLE ; +dt_node_attr_assign (dnp,dt_attr_min (lp->dn_attr, rp->dn_attr));break ; }test/unittest/types/tst.castwritable.d new file +22
-0@@ -0,0 +1,22 @@ +/* + * Oracle Linux DTrace. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +/* + * ASSERTION: casting keeps a variable writable. + * + * SECTION: Types, Operators, and Expressions/Constants + */ + +#pragma D option quiet + +BEGIN +{ + x = (char *) alloca(8); + *((long long*)x) = 0x0067666564636261; + trace(stringof(x)); + exit(0); +}test/unittest/types/tst.castwritable.r new file +1
-0@@ -0,0 +1 @@ +abcdefgSignature · 1 line
2.43.5