From: Stefan Metzmacher Date: Fri, 11 Jun 2021 20:03:49 +0000 (+0000) Subject: vfs_preopen: only reset the queue state if preopen_parse_fname() found matching digits X-Git-Tag: tevent-0.11.0~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d34c291d98e6b0e061406e4d0760ce7db8e69a3f;p=thirdparty%2Fsamba.git vfs_preopen: only reset the queue state if preopen_parse_fname() found matching digits Otherwise there's no point in stopping the existing queue to continue via pending preopen_helper_readable() invocations. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c index c897ddeeee4..5640c30d666 100644 --- a/source3/modules/vfs_preopen.c +++ b/source3/modules/vfs_preopen.c @@ -404,6 +404,9 @@ static int preopen_openat(struct vfs_handle_struct *handle, int res; unsigned long num; NTSTATUS status; + char *new_template = NULL; + size_t new_start = 0; + int new_digits = -1; ssize_t match_idx = -1; DEBUG(10, ("preopen_open called on %s\n", smb_fname_str_dbg(smb_fname))); @@ -462,20 +465,24 @@ static int preopen_openat(struct vfs_handle_struct *handle, return res; } - TALLOC_FREE(state->template_fname); - state->template_fname = talloc_asprintf( + new_template = talloc_asprintf( state, "%s/%s", dirname, smb_fname->base_name); - if (state->template_fname == NULL) { + if (new_template == NULL) { return res; } - if (!preopen_parse_fname(state->template_fname, &num, - &state->number_start, &state->num_digits)) { - TALLOC_FREE(state->template_fname); + if (!preopen_parse_fname(new_template, &num, + &new_start, &new_digits)) { + TALLOC_FREE(new_template); return res; } + TALLOC_FREE(state->template_fname); + state->template_fname = new_template; + state->number_start = new_start; + state->num_digits = new_digits; + if (num > state->fnum_sent) { /* * Helpers were too slow, there's no point in reading