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/ipc.c

    r740 r988  
    8080}
    8181
     82NTSTATUS nt_status_np_pipe(NTSTATUS status)
     83{
     84        if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_DISCONNECTED)) {
     85                status = NT_STATUS_PIPE_DISCONNECTED;
     86        } else if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
     87                status = NT_STATUS_PIPE_BROKEN;
     88        }
     89
     90        return status;
     91}
     92
    8293/****************************************************************************
    8394 Send a trans reply.
     
    97108        int ldata  = rdata  ? rdata_len : 0;
    98109        int lparam = rparam ? rparam_len : 0;
    99         struct smbd_server_connection *sconn = req->sconn;
    100         int max_send = sconn->smb1.sessions.max_send;
     110        struct smbXsrv_connection *xconn = req->xconn;
     111        int max_send = xconn->smb1.sessions.max_send;
     112        /* HACK: make sure we send at least 128 byte in one go */
     113        int hdr_overhead = SMB_BUFFER_SIZE_MIN - 128;
    101114
    102115        if (buffer_too_large)
    103116                DEBUG(5,("send_trans_reply: buffer %d too large\n", ldata ));
    104117
    105         this_lparam = MIN(lparam,max_send - 500); /* hack */
    106         this_ldata  = MIN(ldata,max_send - (500+this_lparam));
     118        this_lparam = MIN(lparam,max_send - hdr_overhead);
     119        this_ldata  = MIN(ldata,max_send - (hdr_overhead+this_lparam));
    107120
    108121        align = ((this_lparam)%4);
     
    139152
    140153        show_msg((char *)req->outbuf);
    141         if (!srv_send_smb(sconn, (char *)req->outbuf,
     154        if (!srv_send_smb(xconn, (char *)req->outbuf,
    142155                          true, req->seqnum+1,
    143156                          IS_CONN_ENCRYPTED(conn), &req->pcd)) {
     
    153166        {
    154167                this_lparam = MIN(lparam-tot_param_sent,
    155                                   max_send - 500); /* hack */
     168                                  max_send - hdr_overhead);
    156169                this_ldata  = MIN(ldata -tot_data_sent,
    157                                   max_send - (500+this_lparam));
     170                                  max_send - (hdr_overhead+this_lparam));
    158171
    159172                if(this_lparam < 0)
     
    199212
    200213                show_msg((char *)req->outbuf);
    201                 if (!srv_send_smb(sconn, (char *)req->outbuf,
     214                if (!srv_send_smb(xconn, (char *)req->outbuf,
    202215                                  true, req->seqnum+1,
    203216                                  IS_CONN_ENCRYPTED(conn), &req->pcd))
     
    269282        state->max_read = max_read;
    270283
    271         subreq = np_write_send(state, smbd_event_context(), state->handle,
     284        subreq = np_write_send(state, req->sconn->ev_ctx, state->handle,
    272285                               state->data, length);
    273286        if (subreq == NULL) {
     
    291304        status = np_write_recv(subreq, &nwritten);
    292305        TALLOC_FREE(subreq);
    293         if (!NT_STATUS_IS_OK(status) || (nwritten != state->num_data)) {
    294                 DEBUG(10, ("Could not write to pipe: %s (%d/%d)\n",
    295                            nt_errstr(status), (int)state->num_data,
    296                            (int)nwritten));
    297                 reply_nterror(req, NT_STATUS_PIPE_NOT_AVAILABLE);
     306        if (!NT_STATUS_IS_OK(status)) {
     307                NTSTATUS old = status;
     308                status = nt_status_np_pipe(old);
     309
     310                DEBUG(10, ("Could not write to pipe: %s%s%s\n",
     311                           nt_errstr(old),
     312                           NT_STATUS_EQUAL(old, status)?"":" => ",
     313                           NT_STATUS_EQUAL(old, status)?"":nt_errstr(status)));
     314                reply_nterror(req, status);
    298315                goto send;
    299316        }
    300 
    301         state->data = TALLOC_REALLOC_ARRAY(state, state->data, uint8_t,
     317        if (nwritten != state->num_data) {
     318                status = NT_STATUS_PIPE_NOT_AVAILABLE;
     319                DEBUG(10, ("Could not write to pipe: (%d/%d) => %s\n",
     320                           (int)state->num_data,
     321                           (int)nwritten, nt_errstr(status)));
     322                reply_nterror(req, status);
     323                goto send;
     324        }
     325
     326        state->data = talloc_realloc(state, state->data, uint8_t,
    302327                                           state->max_read);
    303328        if (state->data == NULL) {
     
    306331        }
    307332
    308         subreq = np_read_send(req->conn, smbd_event_context(),
     333        subreq = np_read_send(state, req->sconn->ev_ctx,
    309334                              state->handle, state->data, state->max_read);
    310335        if (subreq == NULL) {
     
    317342 send:
    318343        if (!srv_send_smb(
    319                     req->sconn, (char *)req->outbuf,
     344                    req->xconn, (char *)req->outbuf,
    320345                    true, req->seqnum+1,
    321346                    IS_CONN_ENCRYPTED(req->conn) || req->encrypted,
     
    341366
    342367        if (!NT_STATUS_IS_OK(status)) {
    343                 DEBUG(10, ("Could not read from to pipe: %s\n",
    344                            nt_errstr(status)));
     368                NTSTATUS old = status;
     369                status = nt_status_np_pipe(old);
     370
     371                DEBUG(10, ("Could not read from to pipe: %s%s%s\n",
     372                           nt_errstr(old),
     373                           NT_STATUS_EQUAL(old, status)?"":" => ",
     374                           NT_STATUS_EQUAL(old, status)?"":nt_errstr(status)));
    345375                reply_nterror(req, status);
    346376
    347                 if (!srv_send_smb(req->sconn, (char *)req->outbuf,
     377                if (!srv_send_smb(req->xconn, (char *)req->outbuf,
    348378                                  true, req->seqnum+1,
    349379                                  IS_CONN_ENCRYPTED(req->conn)
     
    422452 ****************************************************************************/
    423453
    424 static void api_fd_reply(connection_struct *conn, uint16 vuid,
     454static void api_fd_reply(connection_struct *conn, uint64_t vuid,
    425455                         struct smb_request *req,
    426                          uint16 *setup, uint8_t *data, char *params,
     456                         uint16_t *setup, uint8_t *data, char *params,
    427457                         int suwcnt, int tdscnt, int tpscnt,
    428458                         int mdrcnt, int mprcnt)
     
    466496
    467497        if (vuid != fsp->vuid) {
    468                 DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %d, "
    469                           "expected %d\n", pnum, vuid, fsp->vuid));
     498                DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %llu, "
     499                          "expected %llu\n", pnum, (unsigned long long)vuid,
     500                          (unsigned long long)fsp->vuid));
    470501                reply_nterror(req, NT_STATUS_INVALID_HANDLE);
    471502                return;
     
    502533****************************************************************************/
    503534
    504 static void named_pipe(connection_struct *conn, uint16 vuid,
     535static void named_pipe(connection_struct *conn, uint64_t vuid,
    505536                       struct smb_request *req,
    506                        const char *name, uint16 *setup,
     537                       const char *name, uint16_t *setup,
    507538                       char *data, char *params,
    508539                       int suwcnt, int tdscnt,int tpscnt,
     
    603634
    604635        if (state->close_on_completion) {
    605                 close_cnum(conn,state->vuid);
     636                struct smbXsrv_tcon *tcon;
     637                NTSTATUS status;
     638
     639                tcon = conn->tcon;
    606640                req->conn = NULL;
     641                conn = NULL;
     642
     643                /*
     644                 * TODO: cancel all outstanding requests on the tcon
     645                 */
     646                status = smbXsrv_tcon_disconnect(tcon, state->vuid);
     647                if (!NT_STATUS_IS_OK(status)) {
     648                        DEBUG(0, ("handle_trans: "
     649                                  "smbXsrv_tcon_disconnect() failed: %s\n",
     650                                  nt_errstr(status)));
     651                        /*
     652                         * If we hit this case, there is something completely
     653                         * wrong, so we better disconnect the transport connection.
     654                         */
     655                        exit_server(__location__ ": smbXsrv_tcon_disconnect failed");
     656                        return;
     657                }
     658
     659                TALLOC_FREE(tcon);
    607660        }
    608661
     
    646699        }
    647700
    648         if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
     701        if ((state = talloc(conn, struct trans_state)) == NULL) {
    649702                DEBUG(0, ("talloc failed\n"));
    650703                reply_nterror(req, NT_STATUS_NO_MEMORY);
     
    743796                }
    744797
    745                 if((state->setup = TALLOC_ARRAY(
    746                             state, uint16, state->setup_count)) == NULL) {
     798                if((state->setup = talloc_array(
     799                            state, uint16_t, state->setup_count)) == NULL) {
    747800                        DEBUG(0,("reply_trans: setup malloc fail for %u "
    748801                                 "bytes !\n", (unsigned int)
    749                                  (state->setup_count * sizeof(uint16))));
     802                                 (state->setup_count * sizeof(uint16_t))));
    750803                        SAFE_FREE(state->data);
    751804                        SAFE_FREE(state->param);
     
    809862        START_PROFILE(SMBtranss);
    810863
    811         show_msg((char *)req->inbuf);
     864        show_msg((const char *)req->inbuf);
    812865
    813866        if (req->wct < 8) {
Note: See TracChangeset for help on using the changeset viewer.