From: Jeremy Allison Date: Thu, 4 Jun 2020 03:48:23 +0000 (-0700) Subject: s3: libsmb: Change cli_setpathinfo_ext() to take 32-bit attributes. X-Git-Tag: ldb-2.2.0~199 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b42f04d6ae828a1814273a0d6b24dbb143db10;p=thirdparty%2Fsamba.git s3: libsmb: Change cli_setpathinfo_ext() to take 32-bit attributes. Fix the callers. Note the special casing of mapping (uint16)-1 -> (uint32_t)-1 in SMBC_setatr() where we can't change the ABI. Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke --- diff --git a/source3/client/client.c b/source3/client/client.c index f423b5d3d58..69f6fd688dc 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -5282,7 +5282,8 @@ static int cmd_utimes(void) timespec_string_buf(×[3], false, &tbuf[3]))); status = cli_setpathinfo_ext( - cli, fname, times[0], times[1], times[2], times[3], -1); + cli, fname, times[0], times[1], times[2], times[3], + (uint32_t)-1); if (!NT_STATUS_IS_OK(status)) { d_printf("cli_setpathinfo_ext failed: %s\n", nt_errstr(status)); diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 85d1327650a..ab7e085e80c 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -688,7 +688,7 @@ static void prep_basic_information_buf( struct timespec access_time, struct timespec write_time, struct timespec change_time, - uint16_t attr) + uint32_t attr) { char *p = (char *)buf; /* @@ -710,7 +710,7 @@ static void prep_basic_information_buf( TIMESTAMP_SET_NT_OR_BETTER, p, &change_time); p += 8; - if (attr == (uint16_t)-1 || attr == FILE_ATTRIBUTE_NORMAL) { + if (attr == (uint32_t)-1 || attr == FILE_ATTRIBUTE_NORMAL) { /* No change. */ attr = 0; } else if (attr == 0) { @@ -735,7 +735,7 @@ NTSTATUS cli_setpathinfo_ext(struct cli_state *cli, const char *fname, struct timespec access_time, struct timespec write_time, struct timespec change_time, - uint16_t attr) + uint32_t attr) { uint8_t buf[40]; @@ -797,7 +797,7 @@ struct tevent_req *cli_setfileinfo_ext_send( access_time, write_time, change_time, - attr); + (uint32_t)attr); if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { state->in_data = (DATA_BLOB) { diff --git a/source3/libsmb/clirap.h b/source3/libsmb/clirap.h index d93cc838889..170876160a8 100644 --- a/source3/libsmb/clirap.h +++ b/source3/libsmb/clirap.h @@ -62,7 +62,7 @@ NTSTATUS cli_setpathinfo_ext(struct cli_state *cli, const char *fname, struct timespec access_time, struct timespec write_time, struct timespec change_time, - uint16_t attr); + uint32_t attr); struct tevent_req *cli_setfileinfo_ext_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 5f50439c41b..540f80d5058 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -592,8 +592,22 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, { uint16_t fd; int ret; + uint32_t lattr = (uint32_t)attr; TALLOC_CTX *frame = talloc_stackframe(); + if (attr == (uint16_t)-1) { + /* + * External ABI only passes in + * 16-bits of attribute. Make + * sure we correctly map to + * (uint32_t)-1 meaning don't + * change attributes if attr was + * passed in as 16-bit -1. + */ + lattr = (uint32_t)-1; + } + + /* * First, try setpathinfo (if qpathinfo succeeded), for it is the * modern function for "new code" to be using, and it works given a @@ -606,7 +620,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, access_time, write_time, change_time, - attr))) { + lattr))) { /* * setpathinfo is not supported; go to plan B. diff --git a/source3/torture/torture.c b/source3/torture/torture.c index a4ffc25de4c..00fc7529c50 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -4126,7 +4126,7 @@ static bool run_attrtest(int dummy) (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, /* access */ (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, /* write */ (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, /* change */ - (uint16_t)-1); + (uint32_t)-1); if (!NT_STATUS_IS_OK(status)) { printf("cli_setpathinfo_ext failed with %s\n", nt_errstr(status));