Changeset 988 for vendor/current/source3/smbd/srvstr.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/srvstr.c
r740 r988 25 25 /* Make sure we can't write a string past the end of the buffer */ 26 26 27 size_t srvstr_push_fn(const char *function, unsigned int line, 28 const char *base_ptr, uint16 smb_flags2, void *dest, 29 const char *src, int dest_len, int flags) 27 NTSTATUS srvstr_push_fn(const char *base_ptr, uint16_t smb_flags2, void *dest, 28 const char *src, int dest_len, int flags, size_t *ret_len) 30 29 { 30 size_t len; 31 int saved_errno; 32 NTSTATUS status; 33 31 34 if (dest_len < 0) { 32 return 0;35 return NT_STATUS_INVALID_PARAMETER; 33 36 } 34 37 38 saved_errno = errno; 39 errno = 0; 40 35 41 /* 'normal' push into size-specified buffer */ 36 return push_string_base(function, line,base_ptr, smb_flags2, dest, src,42 len = push_string_base(base_ptr, smb_flags2, dest, src, 37 43 dest_len, flags); 44 45 if (errno != 0) { 46 /* 47 * Special case E2BIG, EILSEQ, EINVAL 48 * as they mean conversion errors here, 49 * but we don't generically map them as 50 * they can mean different things in 51 * generic filesystem calls (such as 52 * read xattrs). 53 */ 54 if (errno == E2BIG || errno == EILSEQ || errno == EINVAL) { 55 status = NT_STATUS_ILLEGAL_CHARACTER; 56 } else { 57 status = map_nt_error_from_unix_common(errno); 58 /* 59 * Paranoia - Filter out STATUS_MORE_ENTRIES. 60 * I don't think we can get this but it has a 61 * specific meaning to the client. 62 */ 63 if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { 64 status = NT_STATUS_UNSUCCESSFUL; 65 } 66 } 67 DEBUG(10,("character conversion failure " 68 "on string (%s) (%s)\n", 69 src, strerror(errno))); 70 } else { 71 /* Success - restore untouched errno. */ 72 errno = saved_errno; 73 *ret_len = len; 74 status = NT_STATUS_OK; 75 } 76 return status; 38 77 } 39 78 … … 43 82 ********************************************************************/ 44 83 45 ssize_t message_push_string(uint8 **outbuf, const char *str, int flags)84 ssize_t message_push_string(uint8_t **outbuf, const char *str, int flags) 46 85 { 47 86 size_t buf_size = smb_len(*outbuf) + 4; 48 87 size_t grow_size; 49 size_t result; 50 uint8 *tmp; 88 size_t result = 0; 89 uint8_t *tmp; 90 NTSTATUS status; 51 91 52 92 /* … … 58 98 grow_size = (strlen(str) + 2) * 4; 59 99 60 if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, *outbuf, uint8,100 if (!(tmp = talloc_realloc(NULL, *outbuf, uint8_t, 61 101 buf_size + grow_size))) { 62 102 DEBUG(0, ("talloc failed\n")); … … 64 104 } 65 105 66 result= srvstr_push((char *)tmp, SVAL(tmp, smb_flg2),67 tmp + buf_size, str, grow_size, flags );106 status = srvstr_push((char *)tmp, SVAL(tmp, smb_flg2), 107 tmp + buf_size, str, grow_size, flags, &result); 68 108 69 if ( result == (size_t)-1) {109 if (!NT_STATUS_IS_OK(status)) { 70 110 DEBUG(0, ("srvstr_push failed\n")); 71 111 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.