summaryrefslogtreecommitdiff
path: root/source3/smbd/message.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2003-03-20 16:42:39 +0000
committerJelmer Vernooij <jelmer@samba.org>2003-03-20 16:42:39 +0000
commitc7e720c87bf1dae8ec4ca4bad47a7324c89b7c05 (patch)
tree69da232c0fd7c081cd80122deacc2e1962946915 /source3/smbd/message.c
parent9ba6be2e703e92971c8102f55fd840ef24ecf208 (diff)
downloadsamba-c7e720c87bf1dae8ec4ca4bad47a7324c89b7c05.tar.gz
samba-c7e720c87bf1dae8ec4ca4bad47a7324c89b7c05.tar.bz2
samba-c7e720c87bf1dae8ec4ca4bad47a7324c89b7c05.zip
Patch from Samuel Thibault to convert messages from unix to dos charset. Works
on 2000. sending messages to 9x needs to be fixed, but that didn't work anyway (This used to be commit ca066502a2a3dbdd8943d515c9c6d21e62d757b6)
Diffstat (limited to 'source3/smbd/message.c')
-rw-r--r--source3/smbd/message.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index ba646f12aa..233848d2d6 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -41,6 +41,8 @@ static void msg_deliver(void)
pstring name;
int i;
int fd;
+ char *msg;
+ int len;
if (! (*lp_msg_command()))
{
@@ -61,16 +63,23 @@ static void msg_deliver(void)
/*
* Incoming message is in DOS codepage format. Convert to UNIX.
*/
-
- if(msgpos > 0) {
- msgbuf[msgpos] = '\0'; /* Ensure null terminated. */
- }
-
- for (i=0;i<msgpos;) {
- if (msgbuf[i]=='\r' && i<(msgpos-1) && msgbuf[i+1]=='\n') {
- i++; continue;
+
+ if ((len = convert_string_allocate(CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg)) < 0 || !msg) {
+ DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n"));
+ for (i = 0; i < msgpos;) {
+ if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') {
+ i++; continue;
+ }
+ write(fd, &msgbuf[i++], 1);
+ }
+ } else {
+ for (i = 0; i < len;) {
+ if (msg[i] == '\r' && i < (len-1) && msg[i+1] == '\n') {
+ i++; continue;
+ }
+ write(fd, &msg[i++],1);
}
- write(fd,&msgbuf[i++],1);
+ SAFE_FREE(msg);
}
close(fd);