Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/libcli/auth/msrpc_parse.c

    r414 r745  
    4141  C = constant ascii string
    4242 */
    43 bool msrpc_gen(TALLOC_CTX *mem_ctx,
     43NTSTATUS msrpc_gen(TALLOC_CTX *mem_ctx,
    4444               DATA_BLOB *blob,
    4545               const char *format, ...)
     
    5858
    5959        pointers = talloc_array(mem_ctx, DATA_BLOB, strlen(format));
     60        if (!pointers) {
     61                return NT_STATUS_NO_MEMORY;
     62        }
    6063        intargs = talloc_array(pointers, int, strlen(format));
     64        if (!intargs) {
     65                return NT_STATUS_NO_MEMORY;
     66        }
    6167
    6268        /* first scan the format to work out the header and body size */
     
    7379                        if (!ret) {
    7480                                va_end(ap);
    75                                 return false;
     81                                return map_nt_error_from_unix(errno);
    7682                        }
    7783                        pointers[i].length = n;
     
    8793                        if (!ret) {
    8894                                va_end(ap);
    89                                 return false;
     95                                return map_nt_error_from_unix(errno);
    9096                        }
    9197                        pointers[i].length = n;
     
    103109                        if (!ret) {
    104110                                va_end(ap);
    105                                 return false;
     111                                return map_nt_error_from_unix(errno);
    106112                        }
    107113                        pointers[i].length = n;
     
    133139                        head_size += pointers[i].length;
    134140                        break;
     141                default:
     142                        va_end(ap);
     143                        return NT_STATUS_INVALID_PARAMETER;
    135144                }
    136145        }
    137146        va_end(ap);
     147
     148        if (head_size + data_size == 0) {
     149                return NT_STATUS_INVALID_PARAMETER;
     150        }
    138151
    139152        /* allocate the space, then scan the format again to fill in the values */
    140153        *blob = data_blob_talloc(mem_ctx, NULL, head_size + data_size);
    141 
     154        if (!blob->data) {
     155                return NT_STATUS_NO_MEMORY;
     156        }
    142157        head_ofs = 0;
    143158        data_ofs = head_size;
     
    175190                case 'b':
    176191                        n = pointers[i].length;
    177                         memcpy(blob->data + head_ofs, pointers[i].data, n);
     192                        if (pointers[i].data && n) {
     193                                /* don't follow null pointers... */
     194                                memcpy(blob->data + head_ofs, pointers[i].data, n);
     195                        }
    178196                        head_ofs += n;
    179197                        break;
     
    183201                        head_ofs += n;
    184202                        break;
     203                default:
     204                        va_end(ap);
     205                        return NT_STATUS_INVALID_PARAMETER;
    185206                }
    186207        }
     
    189210        talloc_free(pointers);
    190211
    191         return true;
     212        return NT_STATUS_OK;
    192213}
    193214
     
    229250        bool ret = true;
    230251
     252        if (!p) {
     253                return false;
     254        }
     255
    231256        va_start(ap, format);
    232257        for (i=0; format[i]; i++) {
     
    334359                case 'b':
    335360                        b = (DATA_BLOB *)va_arg(ap, void *);
    336                         len1 = va_arg(ap, uint_t);
     361                        len1 = va_arg(ap, unsigned int);
    337362                        /* make sure its in the right format - be strict */
    338363                        NEED_DATA(len1);
Note: See TracChangeset for help on using the changeset viewer.