Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/srvstr.c

    r740 r988  
    2525/* Make sure we can't write a string past the end of the buffer */
    2626
    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)
     27NTSTATUS 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)
    3029{
     30        size_t len;
     31        int saved_errno;
     32        NTSTATUS status;
     33
    3134        if (dest_len < 0) {
    32                 return 0;
     35                return NT_STATUS_INVALID_PARAMETER;
    3336        }
    3437
     38        saved_errno = errno;
     39        errno = 0;
     40
    3541        /* '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,
    3743                                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;
    3877}
    3978
     
    4382********************************************************************/
    4483
    45 ssize_t message_push_string(uint8 **outbuf, const char *str, int flags)
     84ssize_t message_push_string(uint8_t **outbuf, const char *str, int flags)
    4685{
    4786        size_t buf_size = smb_len(*outbuf) + 4;
    4887        size_t grow_size;
    49         size_t result;
    50         uint8 *tmp;
     88        size_t result = 0;
     89        uint8_t *tmp;
     90        NTSTATUS status;
    5191
    5292        /*
     
    5898        grow_size = (strlen(str) + 2) * 4;
    5999
    60         if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, *outbuf, uint8,
     100        if (!(tmp = talloc_realloc(NULL, *outbuf, uint8_t,
    61101                                         buf_size + grow_size))) {
    62102                DEBUG(0, ("talloc failed\n"));
     
    64104        }
    65105
    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);
    68108
    69         if (result == (size_t)-1) {
     109        if (!NT_STATUS_IS_OK(status)) {
    70110                DEBUG(0, ("srvstr_push failed\n"));
    71111                return -1;
Note: See TracChangeset for help on using the changeset viewer.