diff options
author | Volker Lendecke <vl@samba.org> | 2009-01-26 20:45:09 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-01-29 21:38:06 +0100 |
commit | 37da26a06ee0a51f2e6c7b93e2fefc2342613c84 (patch) | |
tree | 1c4667731ddc9756d7dfb2adc2622c3cce0f26c4 /source3/libsmb/clifile.c | |
parent | 89caa0e86be9e20702a24fea4f94a11e6e02cc93 (diff) | |
download | samba-37da26a06ee0a51f2e6c7b93e2fefc2342613c84.tar.gz samba-37da26a06ee0a51f2e6c7b93e2fefc2342613c84.tar.bz2 samba-37da26a06ee0a51f2e6c7b93e2fefc2342613c84.zip |
Add the strlen to push to smb_bytes_push_str, return the converted size
The pushed strlen replaces the STR_TERMINATE flag which I personally always
find very confusing.
Diffstat (limited to 'source3/libsmb/clifile.c')
-rw-r--r-- | source3/libsmb/clifile.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 02cd2108bf..3b6585b7e7 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -781,7 +781,9 @@ int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0); } -uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) +uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, + const char *str, size_t str_len, + size_t *pconverted_size) { size_t buflen; char *converted; @@ -806,7 +808,7 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) if (!convert_string_allocate(talloc_tos(), CH_UNIX, ucs2 ? CH_UTF16LE : CH_DOS, - str, strlen(str)+1, &converted, + str, str_len, &converted, &converted_size, true)) { return NULL; } @@ -821,6 +823,11 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) memcpy(buf + buflen, converted, converted_size); TALLOC_FREE(converted); + + if (pconverted_size) { + *pconverted_size = converted_size; + } + return buf; } @@ -890,12 +897,8 @@ struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, } bytes = talloc_array(talloc_tos(), uint8_t, 0); - if (bytes == NULL) { - return NULL; - } - - bytes = smb_bytes_push_str( - bytes, (cli->capabilities & CAP_UNICODE) != 0, fname); + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), fname, + strlen(fname)+1, NULL); if (bytes == NULL) { return NULL; } |