s3-talloc Change TALLOC_ZERO_P() to talloc_zero()
[nivanova/samba-autobuild/.git] / source3 / smbd / message.c
index 65eaeca777bc76493014bc7c3ab8352793354db4..63b08e126203148718bd3552f9a82b797ba26566 100644 (file)
@@ -23,6 +23,9 @@
 
 
 #include "includes.h"
+#include "smbd/smbd.h"
+#include "smbd/globals.h"
+#include "smbprofile.h"
 
 extern userdom_struct current_user_info;
 
@@ -32,8 +35,6 @@ struct msg_state {
        char *msg;
 };
 
-static struct msg_state *smbd_msg_state;
-
 /****************************************************************************
  Deliver the message.
 ****************************************************************************/
@@ -60,7 +61,7 @@ static void msg_deliver(struct msg_state *state)
        if (!name) {
                goto done;
        }
-       fd = smb_mkstemp(name);
+       fd = mkstemp(name);
 
        if (fd == -1) {
                DEBUG(1, ("can't open message file %s: %s\n", name,
@@ -74,7 +75,7 @@ static void msg_deliver(struct msg_state *state)
 
        if (!convert_string_talloc(talloc_tos(), CH_DOS, CH_UNIX, state->msg,
                                   talloc_get_size(state->msg), (void *)&msg,
-                                  &len, true)) {
+                                  &len)) {
                DEBUG(3, ("Conversion failed, delivering message in DOS "
                          "codepage format\n"));
                msg = state->msg;
@@ -146,7 +147,7 @@ void reply_sends(struct smb_request *req)
        START_PROFILE(SMBsends);
 
        if (!(*lp_msg_command())) {
-               reply_doserror(req, ERRSRV, ERRmsgoff);
+               reply_nterror(req, NT_STATUS_REQUEST_NOT_ACCEPTED);
                END_PROFILE(SMBsends);
                return;
        }
@@ -194,14 +195,14 @@ void reply_sendstrt(struct smb_request *req)
        START_PROFILE(SMBsendstrt);
 
        if (!(*lp_msg_command())) {
-               reply_doserror(req, ERRSRV, ERRmsgoff);
+               reply_nterror(req, NT_STATUS_REQUEST_NOT_ACCEPTED);
                END_PROFILE(SMBsendstrt);
                return;
        }
 
        TALLOC_FREE(smbd_msg_state);
 
-       smbd_msg_state = TALLOC_ZERO_P(NULL, struct msg_state);
+       smbd_msg_state = talloc_zero(NULL, struct msg_state);
 
        if (smbd_msg_state == NULL) {
                reply_nterror(req, NT_STATUS_NO_MEMORY);
@@ -241,12 +242,12 @@ void reply_sendtxt(struct smb_request *req)
        START_PROFILE(SMBsendtxt);
 
        if (! (*lp_msg_command())) {
-               reply_doserror(req, ERRSRV, ERRmsgoff);
+               reply_nterror(req, NT_STATUS_REQUEST_NOT_ACCEPTED);
                END_PROFILE(SMBsendtxt);
                return;
        }
 
-       if (smbd_msg_state == NULL) {
+       if ((smbd_msg_state == NULL) || (req->buflen < 3)) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                END_PROFILE(SMBsendtxt);
                return;
@@ -258,7 +259,7 @@ void reply_sendtxt(struct smb_request *req)
 
        len = MIN(SVAL(msg, 0), smbreq_bufrem(req, msg+2));
 
-       tmp = TALLOC_REALLOC_ARRAY(smbd_msg_state, smbd_msg_state->msg,
+       tmp = talloc_realloc(smbd_msg_state, smbd_msg_state->msg,
                                   char, old_len + len);
 
        if (tmp == NULL) {
@@ -289,7 +290,7 @@ void reply_sendend(struct smb_request *req)
        START_PROFILE(SMBsendend);
 
        if (! (*lp_msg_command())) {
-               reply_doserror(req, ERRSRV, ERRmsgoff);
+               reply_nterror(req, NT_STATUS_REQUEST_NOT_ACCEPTED);
                END_PROFILE(SMBsendend);
                return;
        }