aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-01-31 04:36:16 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-01-31 04:36:16 +0000
commitc5c5233e04b9ad1ff9e3746b4995e95d75e8d64e (patch)
tree3cdce9b8a9743e9a0acc19e4bf8ef8aedc897a66
parentce3f46e52475daccbc1348ad05a43f99f5fb57ac (diff)
downloadfetchmail-c5c5233e04b9ad1ff9e3746b4995e95d75e8d64e.tar.gz
fetchmail-c5c5233e04b9ad1ff9e3746b4995e95d75e8d64e.tar.bz2
fetchmail-c5c5233e04b9ad1ff9e3746b4995e95d75e8d64e.zip
Have reply_hack alter its input buffer in place.
svn path=/trunk/; revision=851
-rw-r--r--rfc822.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/rfc822.c b/rfc822.c
index 9fbf9845..4900c503 100644
--- a/rfc822.c
+++ b/rfc822.c
@@ -22,9 +22,8 @@ void reply_hack(buf, host)
char *buf; /* header to be hacked */
const char *host; /* server hostname */
{
- const char *from;
+ char *from, *cp;
int parendepth, state, has_host_part;
- char mycopy[MSGBUFSIZE+1];
if (strncmp("From: ", buf, 6)
&& strncmp("To: ", buf, 4)
@@ -34,10 +33,9 @@ const char *host; /* server hostname */
return;
}
- strcpy(mycopy, buf);
parendepth = state = 0;
has_host_part = FALSE;
- for (from = mycopy; *from; from++)
+ for (from = buf; *from; from++)
{
#ifdef TESTMAIN
printf("state %d: %s", state, mycopy);
@@ -66,15 +64,17 @@ const char *host; /* server hostname */
state = 2;
else if ((*from == ',' || HEADER_END(from)) && !has_host_part)
{
+ int hostlen;
+
while (isspace(*from))
--from;
from++;
- while (isspace(*buf))
- --buf;
- buf++;
- strcpy(buf, "@");
- strcat(buf, host);
- buf += strlen(buf);
+ hostlen = strlen(host);
+ for (cp = from + strlen(from); cp >= from; --cp)
+ cp[hostlen+1] = *cp;
+ *from++ = '@';
+ memcpy(from, host, hostlen);
+ from += strlen(from);
has_host_part = TRUE;
}
break;
@@ -89,19 +89,19 @@ const char *host; /* server hostname */
has_host_part = TRUE;
else if (*from == '>' && !has_host_part)
{
- strcpy(buf, "@");
- strcat(buf, host);
- buf += strlen(buf);
+ int hostlen;
+
+ hostlen = strlen(host);
+ for (cp = from + strlen(from); cp >= from; --cp)
+ cp[hostlen+1] = *cp;
+ *from++ = '@';
+ memcpy(from, host, hostlen);
+ from += strlen(from);
has_host_part = TRUE;
}
break;
}
-
- /* all characters from the old buffer get copied to the new one */
- *buf++ = *from;
}
-
- *buf = '\0';
}
char *nxtaddr(hdr)