smbcacls/smbcquotas: check for valid UNC path
authorBjörn Jacke <bj@sernet.de>
Tue, 10 Jan 2023 11:25:35 +0000 (12:25 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 6 Jun 2023 09:33:47 +0000 (09:33 +0000)
we used to strip the first two characters of the path and used that.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=2312

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Jun  6 09:33:47 UTC 2023 on atb-devel-224

source3/utils/smbcacls.c
source3/utils/smbcquotas.c

index 71cd93b8bc725ab94fa9c6e857cda1f7da63e5a7..6e6a5d932bece6b44f78b1b35adf284324efff80 100644 (file)
@@ -1736,6 +1736,11 @@ int main(int argc, char *argv[])
                return -1;
        }
 
+       if (strncmp(path, "\\\\", 2) && strncmp(path, "//", 2)) {
+               printf("Invalid argument: %s\n", path);
+               return -1;
+       }
+
        if(!poptPeekArg(pc)) {
                poptPrintUsage(pc, stderr, 0);
                return -1;
index 748334a04a63eba47d024aae7787d3950f67578c..ce8ca2fafd0baec0e823b14db07cd787f8daa0e5 100644 (file)
@@ -760,6 +760,11 @@ int main(int argc, char *argv[])
                exit(EXIT_PARSE_ERROR);
        }
 
+       if (strncmp(path, "\\\\", 2) && strncmp(path, "//", 2)) {
+               printf("Invalid argument: %s\n", path);
+               return -1;
+       }
+
        poptFreeContext(pc);
        samba_cmdline_burn(argc, argv);