]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_preopen: only reset the queue state if preopen_parse_fname() found matching digits
authorStefan Metzmacher <metze@samba.org>
Fri, 11 Jun 2021 20:03:49 +0000 (20:03 +0000)
committerStefan Metzmacher <metze@samba.org>
Thu, 1 Jul 2021 13:02:31 +0000 (13:02 +0000)
Otherwise there's no point in stopping the existing queue to continue
via pending preopen_helper_readable() invocations.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_preopen.c

index c897ddeeee4fcdec24d2985bcc69b4c5b2ec83bd..5640c30d66664441f39d687c7de97726d1e27345 100644 (file)
@@ -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