summaryrefslogtreecommitdiff
path: root/source3/smbd/notify.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-06-14 15:00:29 +0200
committerJeremy Allison <jra@samba.org>2016-07-20 05:21:07 +0200
commit99b9f5729a32f1b60bac150abe267da4daa1e7e2 (patch)
tree40d5316bef25ba8e38cfb1cafa0dc073898cf229 /source3/smbd/notify.c
parent3caa8a1bf1e55d09399c4d54c69b638955ed3b36 (diff)
downloadsamba-99b9f5729a32f1b60bac150abe267da4daa1e7e2.tar.gz
smbd: Protect notify_callback from stray pointers
This protection right now lives in notify_msg.c with the notify_list, but that will go. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/notify.c')
-rw-r--r--source3/smbd/notify.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index 7a436a9f56e..c2d5d40793b 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -240,13 +240,34 @@ void change_notify_reply(struct smb_request *req,
notify_buf->num_changes = 0;
}
+struct notify_fsp_state {
+ struct files_struct *notified_fsp;
+ struct timespec when;
+ const struct notify_event *e;
+};
+
+static struct files_struct *notify_fsp_cb(struct files_struct *fsp,
+ void *private_data)
+{
+ struct notify_fsp_state *state = private_data;
+
+ if (fsp == state->notified_fsp) {
+ DBG_DEBUG("notify_callback called for %s\n", fsp_str_dbg(fsp));
+ notify_fsp(fsp, state->when, state->e->action, state->e->path);
+ return fsp;
+ }
+
+ return NULL;
+}
+
void notify_callback(struct smbd_server_connection *sconn,
void *private_data, struct timespec when,
const struct notify_event *e)
{
- files_struct *fsp = (files_struct *)private_data;
- DEBUG(10, ("notify_callback called for %s\n", fsp_str_dbg(fsp)));
- notify_fsp(fsp, when, e->action, e->path);
+ struct notify_fsp_state state = {
+ .notified_fsp = private_data, .when = when, .e = e
+ };
+ files_forall(sconn, notify_fsp_cb, &state);
}
NTSTATUS change_notify_create(struct files_struct *fsp, uint32_t filter,