Commit 9dc0b8bd authored by Matthias Andree's avatar Matthias Andree

merge Mirek's fetchmail-signed.patch

svn path=/branches/BRANCH_6-3/; revision=4734
parent 20a0097f
......@@ -50,6 +50,7 @@ fetchmail 6.3.3 (not yet released):
Lynch.
* ./configure --quiet is now quieter (no SSL and fallback-related output).
* fix bug in LMTP port validation (patch by Miloslav Trmac).
* Miloslav Trmac's patch (with minor changes) to fix char * sign consistency.
# CHANGES:
* --idle can now be specified on the command line, too.
......
......@@ -27,9 +27,11 @@ static const char base64val[] = {
};
#define DECODE64(c) (isascii((unsigned char)(c)) ? base64val[c] : BAD)
void to64frombits(unsigned char *out, const unsigned char *in, int inlen)
void to64frombits(char *out, const void *in_, int inlen)
/* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
{
const unsigned char *in = in_;
for (; inlen >= 3; inlen -= 3)
{
*out++ = base64digits[in[0] >> 2];
......@@ -53,12 +55,13 @@ void to64frombits(unsigned char *out, const unsigned char *in, int inlen)
*out = '\0';
}
int from64tobits(char *out, const char *in, int maxlen)
int from64tobits(void *out_, const char *in, int maxlen)
/* base 64 to raw bytes in quasi-big-endian order, returning count of bytes */
/* maxlen limits output buffer size, set to zero to ignore */
{
int len = 0;
register unsigned char digit1, digit2, digit3, digit4;
unsigned char *out = out_;
if (in[0] == '+' && in[1] == ' ')
in += 2;
......
......@@ -88,7 +88,8 @@ int is_host_alias(const char *name, struct query *ctl)
{
struct mxentry *mxp, *mxrecords;
struct idlist *idl;
int namelen, e;
size_t namelen;
int e;
struct addrinfo hints, *res, *res_st;
struct hostdata *lead_server =
......
......@@ -103,7 +103,7 @@ static void listdump(const char *name, struct idlist *list)
for (idp = list; idp; idp = idp->next)
if (idp->id)
{
fprintf(stdout, "\"%s\"", visbuf((const char *)idp->id));
fprintf(stdout, "\"%s\"", visbuf(idp->id));
if (idp->next)
fputs(", ", stdout);
}
......@@ -325,9 +325,9 @@ void dump_config(struct runctl *runp, struct query *querylist)
{
char namebuf[USERNAMELEN + 1];
strlcpy(namebuf, visbuf((const char *)idp->id), sizeof(namebuf));
strlcpy(namebuf, visbuf(idp->id), sizeof(namebuf));
if (idp->val.id2)
fprintf(stdout, "(\"%s\", %s)", namebuf, visbuf((const char *)idp->val.id2));
fprintf(stdout, "(\"%s\", %s)", namebuf, visbuf(idp->val.id2));
else
fprintf(stdout, "\"%s\"", namebuf);
if (idp->next)
......
......@@ -17,14 +17,14 @@
#include "i18n.h"
#include "md5.h"
void hmac_md5 (unsigned char *password, size_t pass_len,
unsigned char *challenge, size_t chal_len,
void hmac_md5 (char *password, size_t pass_len,
char *challenge, size_t chal_len,
unsigned char *response, size_t resp_len)
{
int i;
unsigned char ipad[64];
unsigned char opad[64];
unsigned char hash_passwd[16];
char hash_passwd[16];
MD5_CTX ctx;
......@@ -65,11 +65,11 @@ int do_cram_md5 (int sock, char *command, struct query *ctl, char *strip)
{
int result;
int len;
unsigned char buf1[1024];
unsigned char msg_id[768];
char buf1[1024];
char msg_id[768];
unsigned char response[16];
unsigned char reply[1024];
unsigned char *respdata;
char reply[1024];
char *respdata;
gen_send (sock, "%s CRAM-MD5", command);
......@@ -94,7 +94,7 @@ int do_cram_md5 (int sock, char *command, struct query *ctl, char *strip)
if (len < 0) {
report (stderr, GT_("could not decode BASE64 challenge\n"));
return PS_AUTHFAIL;
} else if (len < sizeof (msg_id)) {
} else if ((size_t)len < sizeof (msg_id)) {
msg_id[len] = 0;
} else {
msg_id[sizeof (msg_id)-1] = 0;
......
......@@ -358,7 +358,7 @@ static void send_size_warnings(struct query *ctl)
if (current->val.status.num == 0 && current->val.status.mark)
{
nbr = current->val.status.mark;
size = atoi((const char *)current->id);
size = atoi(current->id);
if (ctl->limitflush)
stuff_warning(NULL, ctl,
GT_(" %d msg %d octets long deleted by fetchmail."),
......@@ -1304,8 +1304,7 @@ is restored."));
/* compute # of messages and number of new messages waiting */
stage = STAGE_GETRANGE;
err = (ctl->server.base_protocol->getrange)(mailserver_socket, ctl, (const char *)idp->id, &count, &newm, &bytes);
if (err != 0)
err = (ctl->server.base_protocol->getrange)(mailserver_socket, ctl, idp->id, &count, &newm, &bytes);
goto cleanUp;
/* show user how many messages we downloaded */
......
......@@ -65,7 +65,7 @@ static int etrn_getrange(int sock, struct query *ctl, const char *id,
for (qnp = ctl->domainlist; qnp; qnp = qnp->next)
{
/* ship the actual poll and get the response */
gen_send(sock, "ETRN %s", (char *)qnp->id);
gen_send(sock, "ETRN %s", qnp->id);
if ((ok = gen_recv(sock, buf, sizeof(buf))))
return(ok);
......
......@@ -975,7 +975,7 @@ static int load_params(int argc, char **argv, int optind)
/* get the location of rcfile */
rcfiledir[0] = 0;
p = strrchr (rcfile, '/');
if (p && (p - rcfile) < sizeof (rcfiledir)) {
if (p && (size_t)(p - rcfile) < sizeof (rcfiledir)) {
*p = 0; /* replace '/' by '0' */
strlcpy (rcfiledir, rcfile, sizeof(rcfiledir));
*p = '/'; /* restore '/' */
......@@ -1254,7 +1254,7 @@ static int load_params(int argc, char **argv, int optind)
{
char *cp;
if (!(cp = strrchr((char *)idp->id, '/'))
if (!(cp = strrchr(idp->id, '/'))
|| (0 == strcmp(cp + 1, SMTP_PORT))
|| servport(cp + 1) == SMTP_PORT_NUM)
{
......@@ -1362,7 +1362,8 @@ static const int autoprobe[] =
static int query_host(struct query *ctl)
/* perform fetch transaction with single host */
{
int i, st = 0;
size_t i;
int st = 0;
/*
* If we're syslogging the progress messages are automatically timestamped.
......@@ -1607,7 +1608,7 @@ static void dump_params (struct runctl *runp,
printf(GT_(" Selected mailboxes are:"));
for (idp = ctl->mailboxes; idp; idp = idp->next)
printf(" %s", (char *)idp->id);
printf(" %s", idp->id);
printf("\n");
}
printf(ctl->fetchall
......@@ -1697,7 +1698,7 @@ static void dump_params (struct runctl *runp,
printf(GT_(" Domains for which mail will be fetched are:"));
for (idp = ctl->domainlist; idp; idp = idp->next)
{
printf(" %s", (char *)idp->id);
printf(" %s", idp->id);
if (!idp->val.status.mark)
printf(GT_(" (default)"));
}
......@@ -1717,7 +1718,7 @@ static void dump_params (struct runctl *runp,
ctl->listener);
for (idp = ctl->smtphunt; idp; idp = idp->next)
{
printf(" %s", (char *)idp->id);
printf(" %s", idp->id);
if (!idp->val.status.mark)
printf(GT_(" (default)"));
}
......@@ -1775,9 +1776,9 @@ static void dump_params (struct runctl *runp,
{
for (idp = ctl->localnames; idp; idp = idp->next)
if (idp->val.id2)
printf("\t%s -> %s\n", (char *)idp->id, (char *)idp->val.id2);
printf("\t%s -> %s\n", idp->id, idp->val.id2);
else
printf("\t%s\n", (char *)idp->id);
printf("\t%s\n", idp->id);
if (ctl->wildcard)
fputs("\t*\n", stdout);
}
......@@ -1816,7 +1817,7 @@ static void dump_params (struct runctl *runp,
printf(GT_(" Predeclared mailserver aliases:"));
for (idp = ctl->server.akalist; idp; idp = idp->next)
printf(" %s", (char *)idp->id);
printf(" %s", idp->id);
putchar('\n');
}
if (ctl->server.localdomains)
......@@ -1825,7 +1826,7 @@ static void dump_params (struct runctl *runp,
printf(GT_(" Local domains:"));
for (idp = ctl->server.localdomains; idp; idp = idp->next)
printf(" %s", (char *)idp->id);
printf(" %s", idp->id);
putchar('\n');
}
}
......@@ -1866,7 +1867,7 @@ static void dump_params (struct runctl *runp,
printf(GT_(" %d UIDs saved.\n"), count);
if (outlevel >= O_VERBOSE)
for (idp = ctl->oldsaved; idp; idp = idp->next)
printf("\t%s\n", (char *)idp->id);
printf("\t%s\n", idp->id);
}
}
......
......@@ -173,7 +173,7 @@ struct runctl
struct idlist
{
unsigned char *id;
char *id;
union
{
struct
......@@ -186,7 +186,7 @@ struct idlist
#define UID_EXPUNGED 3 /* this message has been expunged */
}
status;
unsigned char *id2;
char *id2;
} val;
struct idlist *next;
};
......@@ -559,8 +559,8 @@ void stuff_warning();
void close_warning_by_mail(struct query *, struct msgblk *);
/* rfc822.c: RFC822 header parsing */
unsigned char *reply_hack(unsigned char *, const unsigned char *, size_t *);
unsigned char *nxtaddr(const unsigned char *);
char *reply_hack(char *, const char *, size_t *);
char *nxtaddr(const char *);
/* uid.c: UID support */
extern int dofastuidl;
......@@ -593,17 +593,17 @@ int prc_parse_file(const char *, const flag);
int prc_filecheck(const char *, const flag);
/* base64.c */
void to64frombits(unsigned char *, const unsigned char *, int);
int from64tobits(char *, const char *, int maxlen);
void to64frombits(char *, const void *, int);
int from64tobits(void *, const char *, int maxlen);
/* unmime.c */
/* Bit-mask returned by MimeBodyType */
#define MSG_IS_7BIT 0x01
#define MSG_IS_8BIT 0x02
#define MSG_NEEDS_DECODE 0x80
extern void UnMimeHeader(unsigned char *buf);
extern int MimeBodyType(unsigned char *hdrs, int WantDecode);
extern int UnMimeBodyline(unsigned char **buf, flag delimited, flag issoftline);
extern void UnMimeHeader(char *buf);
extern int MimeBodyType(char *hdrs, int WantDecode);
extern int UnMimeBodyline(char **buf, flag delimited, flag issoftline);
/* interface.c */
void interface_init(void);
......@@ -644,8 +644,8 @@ struct query *hostalloc(struct query *);
int parsecmdline (int, char **, struct runctl *, struct query *);
char *prependdir (const char *, const char *);
char *MD5Digest (unsigned const char *);
void hmac_md5 (unsigned char *, size_t, unsigned char *, size_t, unsigned char *, size_t);
int POP3_auth_rpa(unsigned char *, unsigned char *, int socket);
void hmac_md5 (char *, size_t, char *, size_t, unsigned char *, size_t);
int POP3_auth_rpa(char *, char *, int socket);
typedef RETSIGTYPE (*SIGHANDLERTYPE) (int);
void deal_with_sigchld(void);
RETSIGTYPE null_signal_handler(int sig);
......
......@@ -69,7 +69,8 @@ int do_gssauth(int sock, char *command, char *service, char *hostname, char *use
else if (outlevel >= O_DEBUG) {
maj_stat = gss_display_name(&min_stat, target_name, &request_buf,
&mech_name);
report(stderr, GT_("Using service name [%s]\n"),request_buf.value);
report(stderr, GT_("Using service name [%s]\n"),
(char *)request_buf.value);
maj_stat = gss_release_buffer(&min_stat, &request_buf);
}
......@@ -126,7 +127,7 @@ int do_gssauth(int sock, char *command, char *service, char *hostname, char *use
return result;
}
request_buf.length = from64tobits(buf2, buf1 + 2, sizeof(buf2));
if (request_buf.length == -1) /* in case of bad data */
if ((int)request_buf.length == -1) /* in case of bad data */
request_buf.length = 0;
request_buf.value = buf2;
sec_token = &request_buf;
......@@ -141,7 +142,7 @@ int do_gssauth(int sock, char *command, char *service, char *hostname, char *use
return result;
request_buf.length = from64tobits(buf2, buf1 + 2, sizeof(buf2));
if (request_buf.length == -1) /* in case of bad data */
if ((int)request_buf.length == -1) /* in case of bad data */
request_buf.length = 0;
request_buf.value = buf2;
......
......@@ -233,7 +233,7 @@ static int do_imap_ntlm(int sock, struct query *ctl)
dumpSmbNtlmAuthRequest(stdout, &request);
memset(msgbuf,0,sizeof msgbuf);
to64frombits (msgbuf, (unsigned char*)&request, SmbLength(&request));
to64frombits (msgbuf, &request, SmbLength(&request));
if (outlevel >= O_MONITOR)
report(stdout, "IMAP> %s\n", msgbuf);
......@@ -244,7 +244,7 @@ static int do_imap_ntlm(int sock, struct query *ctl)
if ((gen_recv(sock, msgbuf, sizeof msgbuf)))
return result;
len = from64tobits ((char*)&challenge, msgbuf, sizeof(challenge));
len = from64tobits (&challenge, msgbuf, sizeof(challenge));
if (outlevel >= O_DEBUG)
dumpSmbNtlmAuthChallenge(stdout, &challenge);
......@@ -255,7 +255,7 @@ static int do_imap_ntlm(int sock, struct query *ctl)
dumpSmbNtlmAuthResponse(stdout, &response);
memset(msgbuf,0,sizeof msgbuf);
to64frombits (msgbuf, (unsigned char*)&response, SmbLength(&response));
to64frombits (msgbuf, &response, SmbLength(&response));
if (outlevel >= O_MONITOR)
report(stdout, "IMAP> %s\n", msgbuf);
......@@ -273,10 +273,10 @@ static int do_imap_ntlm(int sock, struct query *ctl)
}
#endif /* NTLM */
static int imap_canonicalize(char *result, char *raw, int maxlen)
static void imap_canonicalize(char *result, char *raw, size_t maxlen)
/* encode an IMAP password as per RFC1730's quoting conventions */
{
int i, j;
size_t i, j;
j = 0;
for (i = 0; i < strlen(raw) && i < maxlen; i++)
......@@ -286,8 +286,6 @@ static int imap_canonicalize(char *result, char *raw, int maxlen)
result[j++] = raw[i];
}
result[j] = '\0';
return(i);
}
static void capa_probe(int sock, struct query *ctl)
......
......@@ -216,7 +216,7 @@ int do_rfc1731(int sock, char *command, char *truename)
des_ecb_encrypt((des_cblock *)buf2, (des_cblock *)buf2, schedule, 0);
memcpy(challenge2.cstr, buf2, 4);
if (ntohl(challenge2.cint) != challenge1.cint + 1) {
if ((int32)ntohl(challenge2.cint) != challenge1.cint + 1) {
report(stderr, GT_("challenge mismatch\n"));
return PS_AUTHFAIL;
}
......@@ -236,7 +236,7 @@ int do_rfc1731(int sock, char *command, char *truename)
authenticator.dat[4] = 1;
len = strlen(tktuser);
strncpy(authenticator.dat+8, tktuser, len);
strncpy((char *)authenticator.dat+8, tktuser, len);
authenticator.length = len + 8 + 1;
while (authenticator.length & 7) {
authenticator.length++;
......
......@@ -118,12 +118,18 @@ void lock_or_die(void)
int e = 0;
if ((fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL, 0666)) != -1) {
ssize_t wr;
snprintf(tmpbuf, sizeof(tmpbuf), "%ld\n", (long)getpid());
if (write(fd, tmpbuf, strlen(tmpbuf)) < strlen(tmpbuf)) e = 1;
wr = write(fd, tmpbuf, strlen(tmpbuf));
if (wr == -1 || (size_t)wr != strlen(tmpbuf))
e = 1;
if (run.poll_interval)
{
snprintf(tmpbuf, sizeof(tmpbuf), "%d\n", run.poll_interval);
if (write(fd, tmpbuf, strlen(tmpbuf)) < strlen(tmpbuf)) e = 1;
wr = write(fd, tmpbuf, strlen(tmpbuf));
if (wr == -1 || (size_t)wr != strlen(tmpbuf))
e = 1;
}
if (fsync(fd)) e = 1;
if (close(fd)) e = 1;
......
......@@ -20,9 +20,8 @@ struct MD5Context {
};
void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, unsigned char const *buf,
unsigned len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Update(struct MD5Context *context, const void *buf, unsigned len);
void MD5Final(void *digest, struct MD5Context *context);
void MD5Transform(uint32 buf[4], uint32 const in[16]);
char *MD5Digest (unsigned const char *s);
......
......@@ -54,8 +54,9 @@ void MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
void MD5Update(struct MD5Context *ctx, const void *buf_, unsigned len)
{
const unsigned char *buf = buf_;
register uint32 t;
/* Update bitcount */
......@@ -102,7 +103,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
void MD5Final(void *digest, struct MD5Context *ctx)
{
unsigned int count;
unsigned char *p;
......
......@@ -4,8 +4,8 @@
struct mxentry
{
unsigned char *name;
int pref;
char *name;
int pref;
};
extern struct mxentry * getmxrecords(const char *);
......
......@@ -68,7 +68,7 @@ struct mxentry *getmxrecords(const char *name)
n = res_search(name, C_IN,T_MX, (unsigned char *)&answer, sizeof(answer));
if (n == -1)
return((struct mxentry *)NULL);
if (n > sizeof(answer))
if ((size_t)n > sizeof(answer))
n = sizeof(answer);
hp = (HEADER *)&answer;
......@@ -76,7 +76,7 @@ struct mxentry *getmxrecords(const char *name)
eom = answer + n;
h_errno = 0;
for (qdcount = ntohs(hp->qdcount); qdcount--; cp += n + QFIXEDSZ)
if ((n = dn_skipname(cp, eom)) < 0)
if ((n = dn_skipname((unsigned char *)cp, (unsigned char *)eom)) < 0)
return((struct mxentry *)NULL);
buflen = sizeof(MXHostBuf) - 1;
bp = MXHostBuf;
......@@ -84,7 +84,8 @@ struct mxentry *getmxrecords(const char *name)
ancount = ntohs(hp->ancount);
while (--ancount >= 0 && cp < eom)
{
if ((n = dn_expand(answer, eom, cp, bp, buflen)) < 0)
if ((n = dn_expand((unsigned char *)answer, (unsigned char *)eom,
(unsigned char *)cp, bp, buflen)) < 0)
break;
cp += n;
GETSHORT(type, cp);
......@@ -96,7 +97,8 @@ struct mxentry *getmxrecords(const char *name)
continue;
}
GETSHORT(pref, cp);
if ((n = dn_expand(answer, eom, cp, bp, buflen)) < 0)
if ((n = dn_expand((unsigned char *)answer, (unsigned char *)eom,
(unsigned char *)cp, bp, buflen)) < 0)
break;
cp += n;
......
......@@ -80,11 +80,11 @@ static int odmr_getrange(int sock, struct query *ctl, const char *id,
*/
buf[0] = '\0';
for (qnp = ctl->domainlist; qnp; qnp = qnp->next)
if (strlen(buf) + strlen((const char *)qnp->id) + 1 >= sizeof(buf))
if (strlen(buf) + strlen(qnp->id) + 1 >= sizeof(buf))
break;
else
{
strcat(buf, (const char *)qnp->id);
strcat(buf, qnp->id);
strcat(buf, ",");
}
buf[strlen(buf) - 1] = '\0'; /* nuke final comma */
......
......@@ -96,7 +96,7 @@ static int do_pop3_ntlm(int sock, struct query *ctl,
dumpSmbNtlmAuthRequest(stdout, &request);
memset(msgbuf,0,sizeof msgbuf);
to64frombits (msgbuf, (unsigned char*)&request, SmbLength(&request));
to64frombits (msgbuf, &request, SmbLength(&request));
if (outlevel >= O_MONITOR)
report(stdout, "POP3> %s\n", msgbuf);
......@@ -107,7 +107,7 @@ static int do_pop3_ntlm(int sock, struct query *ctl,
if ((gen_recv(sock, msgbuf, sizeof msgbuf)))
return result;
len = from64tobits ((unsigned char*)&challenge, msgbuf, sizeof(msgbuf));
len = from64tobits (&challenge, msgbuf, sizeof(msgbuf));
if (outlevel >= O_DEBUG)
dumpSmbNtlmAuthChallenge(stdout, &challenge);
......@@ -118,7 +118,7 @@ static int do_pop3_ntlm(int sock, struct query *ctl,
dumpSmbNtlmAuthResponse(stdout, &response);
memset(msgbuf,0,sizeof msgbuf);
to64frombits (msgbuf, (unsigned char*)&response, SmbLength(&response));
to64frombits (msgbuf, &response, SmbLength(&response));
if (outlevel >= O_MONITOR)
report(stdout, "POP3> %s\n", msgbuf);
......
......@@ -241,11 +241,11 @@ report_build (FILE *errfp, message, va_alist)
VA_START (args, message);
for ( ; ; )
{
n = vsnprintf (partial_message + partial_message_size_used,
partial_message_size - partial_message_size_used,
n = vsnprintf (partial_message + partial_message_size_used, partial_message_size - partial_message_size_used,
message, args);
if (n < partial_message_size - partial_message_size_used)
if (n >= 0
&& (unsigned)n < partial_message_size - partial_message_size_used)
{
partial_message_size_used += n;
break;
......@@ -262,7 +262,8 @@ report_build (FILE *errfp, message, va_alist)
partial_message_size - partial_message_size_used,
message, a1, a2, a3, a4, a5, a6, a7, a8);
if (n < partial_message_size - partial_message_size_used)
if (n >= 0
&& (unsigned)n < partial_message_size - partial_message_size_used)
{
partial_message_size_used += n;
break;
......@@ -310,7 +311,9 @@ report_complete (FILE *errfp, message, va_alist)
partial_message_size - partial_message_size_used,
message, args);
if (n < partial_message_size - partial_message_size_used)
/* old glibc versions return -1 for truncation */
if (n >= 0
&& (unsigned)n < partial_message_size - partial_message_size_used)
{
partial_message_size_used += n;
break;
......@@ -327,7 +330,8 @@ report_complete (FILE *errfp, message, va_alist)
partial_message_size - partial_message_size_used,
message, a1, a2, a3, a4, a5, a6, a7, a8);
if (n < partial_message_size - partial_message_size_used)
if (n >= 0
&& (unsigned)n < partial_message_size - partial_message_size_used)
{
partial_message_size_used += n;
break;
......
......@@ -41,13 +41,13 @@ char *program_name = "rfc822";
#define HEADER_END(p) ((p)[0] == '\n' && ((p)[1] != ' ' && (p)[1] != '\t'))
unsigned char *reply_hack(
unsigned char *buf /* header to be hacked */,
const unsigned char *host /* server hostname */,
char *reply_hack(
char *buf /* header to be hacked */,
const char *host /* server hostname */,
size_t *length)
/* hack message headers so replies will work properly */
{
unsigned char *from, *cp, last_nws = '\0', *parens_from = NULL;
char *from, *cp, last_nws = '\0', *parens_from = NULL;
int parendepth, state, has_bare_name_part, has_host_part;
#ifndef MAIN
int addresscount = 1;
......@@ -77,9 +77,9 @@ unsigned char *reply_hack(
/* make room to hack the address; buf must be malloced */
for (cp = buf; *cp; cp++)
if (*cp == ',' || isspace(*cp))
if (*cp == ',' || isspace((unsigned char)*cp))
addresscount++;
buf = (unsigned char *)xrealloc(buf, strlen(buf) + addresscount * (strlen(host) + 1) + 1);
buf = xrealloc(buf, strlen(buf) + addresscount * (strlen(host) + 1) + 1);
#endif /* MAIN */
/*
......@@ -95,7 +95,7 @@ unsigned char *reply_hack(
#ifdef MAIN
if (verbose)
{
printf("state %d: %s", state, (char *)buf);
printf("state %d: %s", state, buf);
printf("%*s^\n", from - buf + 10, " ");
}
#endif /* MAIN */
......@@ -116,7 +116,7 @@ unsigned char *reply_hack(
break;
case 1: /* we've seen the colon, we're looking for addresses */
if (!isspace(*from))
if (!isspace((unsigned char)*from))
last_nws = *from;
if (*from == '<')
state = 3;
......@@ -135,12 +135,12 @@ unsigned char *reply_hack(
&& last_nws != ';')
{
int hostlen;
unsigned char *p;
char *p;
p = from;
if (parens_from)
from = parens_from;
while (isspace(*from) || (*from == ','))
while (isspace((unsigned char)*from) || (*from == ','))
--from;
from++;
hostlen = strlen(host);
......@@ -158,7 +158,7 @@ unsigned char *reply_hack(
{
parens_from = from;
}
else if (!isspace(*from))
else if (!isspace((unsigned char)*from))
has_bare_name_part = TRUE;
break;
......@@ -215,15 +215,15 @@ unsigned char *reply_hack(
return(buf);
}
unsigned char *nxtaddr(const unsigned char *hdr /* header to be parsed, NUL to continue previous hdr */)
char *nxtaddr(const char *hdr /* header to be parsed, NUL to continue previous hdr */)
/* parse addresses in succession out of a specified RFC822 header */
{
static unsigned char address[BUFSIZ];
static int tp;
static const unsigned char *hp;
static char address[BUFSIZ];
static size_t tp;
static const char *hp;
static int state, oldstate;
#ifdef MAIN
static const unsigned char *orighdr;
static const char *orighdr;
#endif /* MAIN */
int parendepth = 0;
......@@ -252,7 +252,7 @@ unsigned char *nxtaddr(const unsigned char *hdr /* header to be parsed, NUL to c
#ifdef MAIN
if (verbose)
{
printf("state %d: %s", state, (char *)orighdr);
printf("state %d: %s", state, orighdr);
printf("%*s^\n", hp - orighdr + 10, " ");
}
#endif /* MAIN */
......@@ -264,13 +264,13 @@ unsigned char *nxtaddr(const unsigned char *hdr /* header to be parsed, NUL to c
state = ENDIT_ALL;
if (tp)
{
while (tp >= 0 && isspace(address[tp--]))
continue;
address[++tp] = '\0';
while (tp > 0 && isspace((unsigned char)address[tp - 1]))
tp--;
address[tp] = '\0';
tp = 0;
return (address);
}
return((unsigned char *)NULL);
return(NULL);
}
else if (*hp == '\\') /* handle RFC822 escaping */
{
......@@ -305,7 +305,7 @@ unsigned char *nxtaddr(const unsigned char *hdr /* header to be parsed, NUL to c
state = INSIDE_BRACKETS;
tp = 0;
}
else if (*hp != ',' && !isspace(*hp))
else if (*hp != ',' && !isspace((unsigned char)*hp))
{
--hp;
state = BARE_ADDRESS;
......@@ -340,7 +340,7 @@ unsigned char *nxtaddr(const unsigned char *hdr /* header to be parsed, NUL to c
state = INSIDE_DQUOTE;
address[NEXTTP()] = *hp;
}
else if (!isspace(*hp)) /* just take it, ignoring whitespace */
else if (!isspace((unsigned char)*hp)) /* just take it, ignoring whitespace */