]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:net: Load ODJ blob from file only if "loadfile" parameter is present
authorSamuel Cabrero <scabrero@samba.org>
Wed, 30 Aug 2023 18:25:17 +0000 (20:25 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 5 Sep 2023 21:18:32 +0000 (21:18 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13577

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/utils/net_offlinejoin.c

index 20d4de6e4d841626f2a8279a5fb95600fe163746..abb4e77bd15972c56d36249ddb320fce8a5b1300 100644 (file)
@@ -257,7 +257,6 @@ int net_offlinejoin_requestodj(struct net_context *c,
        uint8_t *provision_bin_data = NULL;
        size_t provision_bin_data_size = 0;
        uint32_t options = NETSETUP_PROVISION_ONLINE_CALLER;
-       const char *loadfile = NULL;
        const char *windows_path = NULL;
        int i;
 
@@ -270,10 +269,23 @@ int net_offlinejoin_requestodj(struct net_context *c,
        for (i = 0; i < argc; i++) {
 
                if (strnequal(argv[i], "loadfile", strlen("loadfile"))) {
+                       const char *loadfile = NULL;
+
                        loadfile = get_string_param(argv[i]);
                        if (loadfile == NULL) {
                                return -1;
                        }
+
+                       provision_bin_data =
+                               (uint8_t *)file_load(loadfile,
+                                                    &provision_bin_data_size,
+                                                    0,
+                                                    c);
+                       if (provision_bin_data == NULL) {
+                               d_printf("Failed to read loadfile: %s\n",
+                               loadfile);
+                               return -1;
+                       }
                }
 #if 0
                if (strnequal(argv[i], "localos", strlen("localos"))) {
@@ -282,10 +294,8 @@ int net_offlinejoin_requestodj(struct net_context *c,
 #endif
        }
 
-       provision_bin_data =
-               (uint8_t *)file_load(loadfile, &provision_bin_data_size, 0, c);
-       if (provision_bin_data == NULL) {
-               d_printf("Failed to read loadfile: %s\n", loadfile);
+       if (provision_bin_data == NULL || provision_bin_data_size == 0) {
+               d_printf("Please provide provision data\n");
                return -1;
        }
        if (provision_bin_data_size > UINT32_MAX) {