lib: Add separator argument to find_snapshot_token()
authorVolker Lendecke <vl@samba.org>
Sat, 17 Sep 2022 20:48:31 +0000 (13:48 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 19 Sep 2022 17:23:31 +0000 (17:23 +0000)
We'll use the logic for \ based strings next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/util_path.c

index 6d2161caf84ca1f87d4ad4021d3a40d18cc0da96..43d7ec4de578a64534060aa84cd8d3f6c090e1f9 100644 (file)
@@ -208,6 +208,7 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 
 static bool find_snapshot_token(
        const char *filename,
+       char sep,
        const char **_start,
        const char **_next_component,
        NTTIME *twrp)
@@ -223,7 +224,7 @@ static bool find_snapshot_token(
                return false;
        }
 
-       if ((start > filename) && (start[-1] != '/')) {
+       if ((start > filename) && (start[-1] != sep)) {
                /* the GMT-token does not start a path-component */
                return false;
        }
@@ -234,7 +235,7 @@ static bool find_snapshot_token(
                return false;
        }
 
-       if ((end[0] != '\0') && (end[0] != '/')) {
+       if ((end[0] != '\0') && (end[0] != sep)) {
                /*
                 * It is not a complete path component, i.e. the path
                 * component continues after the gmt-token.
@@ -251,7 +252,7 @@ static bool find_snapshot_token(
 
        *_start = start;
 
-       if (end[0] == '/') {
+       if (end[0] == sep) {
                end += 1;
        }
        *_next_component = end;
@@ -266,7 +267,7 @@ bool extract_snapshot_token(char *fname, NTTIME *twrp)
        size_t remaining;
        bool found;
 
-       found = find_snapshot_token(fname, &start, &next, twrp);
+       found = find_snapshot_token(fname, '/', &start, &next, twrp);
        if (!found) {
                return false;
        }