first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[kai/samba.git] / source3 / smbd / message.c
index 93a2d9d850a2c7be84e1ec7de311d1c658fbf55f..2f94bdf111b831cd3ed3d95e2ab5c707f86f160a 100644 (file)
@@ -2,7 +2,7 @@
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB messaging
-   Copyright (C) Andrew Tridgell 1992-1997
+   Copyright (C) Andrew Tridgell 1992-1998
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -53,10 +53,10 @@ static void msg_deliver(void)
     }
 
   /* put it in a temporary file */
-  sprintf(s,"%s/msg.XXXXXX",tmpdir());
-  strcpy(name,(char *)mktemp(s));
+  slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir());
+  fstrcpy(name,(char *)smbd_mktemp(s));
 
-  fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600);
+  fd = sys_open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600);
   if (fd == -1) {
     DEBUG(1,("can't open message file %s\n",name));
     return;
@@ -74,11 +74,14 @@ static void msg_deliver(void)
   /* run the command */
   if (*lp_msg_command())
     {
-      strcpy(s,lp_msg_command());
-      string_sub(s,"%s",name);
-      string_sub(s,"%f",msgfrom);
-      string_sub(s,"%t",msgto);
-      standard_sub(-1,s);
+      fstring alpha_msgfrom;
+      fstring alpha_msgto;
+
+      pstrcpy(s,lp_msg_command());
+      pstring_sub(s,"%s",name);
+      pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,sizeof(alpha_msgfrom)));
+      pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto)));
+      standard_sub_basic(s);
       smbrun(s,NULL,False);
     }
 
@@ -90,7 +93,8 @@ static void msg_deliver(void)
 /****************************************************************************
   reply to a sends
 ****************************************************************************/
-int reply_sends(char *inbuf,char *outbuf)
+int reply_sends(connection_struct *conn,
+               char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
 {
   int len;
   char *orig,*dest,*msg;
@@ -98,7 +102,6 @@ int reply_sends(char *inbuf,char *outbuf)
 
   msgpos = 0;
 
-
   if (! (*lp_msg_command()))
     return(ERROR(ERRSRV,ERRmsgoff));
 
@@ -108,16 +111,18 @@ int reply_sends(char *inbuf,char *outbuf)
   dest = skip_string(orig,1)+1;
   msg = skip_string(dest,1)+1;
 
-  strcpy(msgfrom,orig);
-  strcpy(msgto,dest);
+  fstrcpy(msgfrom,orig);
+  fstrcpy(msgto,dest);
 
   len = SVAL(msg,0);
-  len = MIN(len,1600-msgpos);
+  len = MIN(len,sizeof(msgbuf)-msgpos);
+
+  memset(msgbuf,'\0',sizeof(msgbuf));
 
   memcpy(&msgbuf[msgpos],msg+2,len);
   msgpos += len;
 
-  DEBUG(3,("%s SMBsends (from %s to %s)\n",timestring(),orig,dest));
+  DEBUG( 3, ( "SMBsends (from %s to %s)\n", orig, dest ) );
 
   msg_deliver();
 
@@ -128,7 +133,8 @@ int reply_sends(char *inbuf,char *outbuf)
 /****************************************************************************
   reply to a sendstrt
 ****************************************************************************/
-int reply_sendstrt(char *inbuf,char *outbuf)
+int reply_sendstrt(connection_struct *conn,
+                  char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
 {
   char *orig,*dest;
   int outsize = 0;
@@ -138,15 +144,16 @@ int reply_sendstrt(char *inbuf,char *outbuf)
 
   outsize = set_message(outbuf,1,0,True);
 
+  memset(msgbuf,'\0',sizeof(msgbuf));
   msgpos = 0;
 
   orig = smb_buf(inbuf)+1;
   dest = skip_string(orig,1)+1;
 
-  strcpy(msgfrom,orig);
-  strcpy(msgto,dest);
+  fstrcpy(msgfrom,orig);
+  fstrcpy(msgto,dest);
 
-  DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),orig,dest));
+  DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) );
 
   return(outsize);
 }
@@ -155,7 +162,8 @@ int reply_sendstrt(char *inbuf,char *outbuf)
 /****************************************************************************
   reply to a sendtxt
 ****************************************************************************/
-int reply_sendtxt(char *inbuf,char *outbuf)
+int reply_sendtxt(connection_struct *conn,
+                 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
 {
   int len;
   int outsize = 0;
@@ -169,12 +177,12 @@ int reply_sendtxt(char *inbuf,char *outbuf)
   msg = smb_buf(inbuf) + 1;
 
   len = SVAL(msg,0);
-  len = MIN(len,1600-msgpos);
+  len = MIN(len,sizeof(msgbuf)-msgpos);
 
   memcpy(&msgbuf[msgpos],msg+2,len);
   msgpos += len;
 
-  DEBUG(3,("%s SMBsendtxt\n",timestring()));
+  DEBUG( 3, ( "SMBsendtxt\n" ) );
 
   return(outsize);
 }
@@ -183,7 +191,8 @@ int reply_sendtxt(char *inbuf,char *outbuf)
 /****************************************************************************
   reply to a sendend
 ****************************************************************************/
-int reply_sendend(char *inbuf,char *outbuf)
+int reply_sendend(connection_struct *conn,
+                 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
 {
   int outsize = 0;
 
@@ -192,10 +201,9 @@ int reply_sendend(char *inbuf,char *outbuf)
 
   outsize = set_message(outbuf,0,0,True);
 
-  DEBUG(3,("%s SMBsendend\n",timestring()));
+  DEBUG(3,("SMBsendend\n"));
 
   msg_deliver();
 
   return(outsize);
 }
-