summaryrefslogtreecommitdiffstats
path: root/tapset-procfs.cxx
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2010-01-26 13:40:51 -0600
committerDavid Smith <dsmith@redhat.com>2010-01-26 13:40:51 -0600
commit6390a48a6dfb88c9692af877e1767ce6cc8030d0 (patch)
tree3eee6e605f49701ace44f5c130db8b2cedcb6d3f /tapset-procfs.cxx
parent9f49a9853caff67bcc5de7dfe2c52ab1ae7f3738 (diff)
downloadsystemtap-steved-6390a48a6dfb88c9692af877e1767ce6cc8030d0.tar.gz
systemtap-steved-6390a48a6dfb88c9692af877e1767ce6cc8030d0.tar.xz
systemtap-steved-6390a48a6dfb88c9692af877e1767ce6cc8030d0.zip
Fixed PR 11223 by null terminating strings in procfs write probes.
* tapset-procfs.cxx (procfs_var_expanding_visitor::visit_target_symbol): Correctly null terminate strings in procfs write probes. * testsuite/systemtap.base/procfs_write.exp: New test.
Diffstat (limited to 'tapset-procfs.cxx')
-rw-r--r--tapset-procfs.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/tapset-procfs.cxx b/tapset-procfs.cxx
index aa75af42..f5ab95f8 100644
--- a/tapset-procfs.cxx
+++ b/tapset-procfs.cxx
@@ -383,9 +383,10 @@ procfs_var_expanding_visitor::visit_target_symbol (target_symbol* e)
string locvalue = "CONTEXT->data";
if (! lvalue)
- ec->code = string("_stp_copy_from_user(THIS->__retvalue, ((struct _stp_procfs_data *)(")
- + locvalue + string("))->buffer, ((struct _stp_procfs_data *)(") + locvalue
- + string("))->count); /* pure */");
+ ec->code = string(" struct _stp_procfs_data *data = (struct _stp_procfs_data *)(") + locvalue + string("); /* pure */\n")
+
+ + string(" _stp_copy_from_user(THIS->__retvalue, data->buffer, data->count);\n")
+ + string(" THIS->__retvalue[data->count] = '\\0';\n");
else
ec->code = string("int bytes = 0;\n")
+ string(" struct _stp_procfs_data *data = (struct _stp_procfs_data *)(") + locvalue + string(");\n")