]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb: Use write_data() to write to the password check script
authorVolker Lendecke <vl@samba.org>
Sun, 19 Jan 2020 11:29:56 +0000 (12:29 +0100)
committerJeremy Allison <jra@samba.org>
Sun, 19 Jan 2020 18:29:39 +0000 (18:29 +0000)
A simple write() might be interrupted or do short writes. Highly
unlikely, but if it happens, it will be impossible to diagnose.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/dsdb/common/util.c

index 4050ace40c1c62f9a4641f98c78fc216fbfbd1fd..d88688a8ec1ed4a1b565d3fae357ce9d1b2108bb 100644 (file)
@@ -47,6 +47,7 @@
 #include "libds/common/flag_mapping.h"
 #include "lib/util/access.h"
 #include "lib/util/util_str_hex.h"
+#include "lib/util/sys_rw_data.h"
 #include "libcli/util/ntstatus.h"
 
 /*
@@ -2143,9 +2144,9 @@ enum samr_ValidationStatus samdb_check_password(TALLOC_CTX *mem_ctx,
 
                cps_stdin = samba_runcmd_export_stdin(req);
 
-               nwritten = write(cps_stdin, utf8_blob->data,
-                                utf8_blob->length);
-               if (nwritten != utf8_blob->length) {
+               nwritten = write_data(
+                       cps_stdin, utf8_blob->data, utf8_blob->length);
+               if (nwritten == -1) {
                        close(cps_stdin);
                        TALLOC_FREE(password_script);
                        TALLOC_FREE(event_ctx);