From: Volker Lendecke Date: Sun, 19 Jan 2020 11:29:56 +0000 (+0100) Subject: dsdb: Use write_data() to write to the password check script X-Git-Tag: samba-4.12.0rc1~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b274bc698ed26c6897beee6051532244bc30d2ec;p=thirdparty%2Fsamba.git dsdb: Use write_data() to write to the password check script 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 Reviewed-by: Jeremy Allison --- diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 4050ace40c1..d88688a8ec1 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -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);