From c64c8af6d4b121b0fa7ebe13b5c7c28ee9cc8053 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Dec 2022 13:32:35 -0800 Subject: [PATCH] libsmb: Use clistr_smb2_extract_snapshot_token() in cli_smb2_create_fnum_send() Now that fname is writable, we can avoid a bit of complexity with clistr_smb2_extract_snapshot_token() Signed-off-by: Volker Lendecke Signed-off-by: Jeremy Allison --- source3/libsmb/cli_smb2_fnum.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 084aef283cb..6db9fca612c 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -224,8 +224,7 @@ struct tevent_req *cli_smb2_create_fnum_send( struct cli_smb2_create_fnum_state *state; char *fname = NULL; size_t fname_len = 0; - const char *startp = NULL; - const char *endp = NULL; + bool have_twrp; NTTIME ntt; NTSTATUS status; @@ -246,23 +245,8 @@ struct tevent_req *cli_smb2_create_fnum_send( } /* Check for @GMT- paths. Remove the @GMT and turn into TWrp if so. */ - fname_len = strlen(fname); - if (clistr_is_previous_version_path(fname, &startp, &endp, &ntt)) { - size_t len_before_gmt = startp - fname; - size_t len_after_gmt = fname + fname_len - endp; - - char *new_fname = talloc_array(state, char, - len_before_gmt + len_after_gmt + 1); - - if (tevent_req_nomem(new_fname, req)) { - return tevent_req_post(req, ev); - } - - memcpy(new_fname, fname, len_before_gmt); - memcpy(new_fname + len_before_gmt, endp, len_after_gmt + 1); - fname = new_fname; - fname_len = len_before_gmt + len_after_gmt; - + have_twrp = clistr_smb2_extract_snapshot_token(fname, &ntt); + if (have_twrp) { status = smb2_create_blob_add( state, &state->in_cblobs, -- 2.11.4.GIT