summaryrefslogtreecommitdiff
path: root/imap/src/osdep/unix
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2013-11-02 02:51:18 -0600
committerEduardo Chappa <chappa@washington.edu>2013-11-02 02:51:18 -0600
commit7fe712882b909931088a318c08041b0e7974a000 (patch)
tree2770f9b084e2efc7fc55e96e9bf4352cf2ff33a3 /imap/src/osdep/unix
parentbdfc834badee92ceeb2befe02f1d065ced5b9ddf (diff)
downloadalpine-7fe712882b909931088a318c08041b0e7974a000.tar.xz
* Update to version 2.19.1
* Upgrade UW-IMAP to Panda IMAP from https://github.com/jonabbey/panda-imap. * Replace tabs by spaces in From and Subject fields to control for size in screen of these fields. Change only in index screen display.
Diffstat (limited to 'imap/src/osdep/unix')
-rw-r--r--imap/src/osdep/unix/Makefile44
-rw-r--r--imap/src/osdep/unix/dummy.c36
-rw-r--r--imap/src/osdep/unix/env_unix.c64
-rw-r--r--imap/src/osdep/unix/env_unix.h31
-rw-r--r--imap/src/osdep/unix/flocklnx.c29
-rw-r--r--imap/src/osdep/unix/ip4_unix.c47
-rw-r--r--imap/src/osdep/unix/ip6_unix.c141
-rw-r--r--imap/src/osdep/unix/ipo_unix.c181
-rw-r--r--imap/src/osdep/unix/mbx.c8
-rw-r--r--imap/src/osdep/unix/mh.c35
-rw-r--r--imap/src/osdep/unix/mix.c91
-rw-r--r--imap/src/osdep/unix/os_bsf.c30
-rw-r--r--imap/src/osdep/unix/os_bsf.h33
-rw-r--r--imap/src/osdep/unix/os_bsi.c30
-rw-r--r--imap/src/osdep/unix/os_bsi.h34
-rw-r--r--imap/src/osdep/unix/os_lnx.c30
-rw-r--r--imap/src/osdep/unix/os_lnx.h33
-rw-r--r--imap/src/osdep/unix/os_osx.c31
-rw-r--r--imap/src/osdep/unix/os_osx.h35
-rw-r--r--imap/src/osdep/unix/os_qn6.c67
-rw-r--r--imap/src/osdep/unix/os_qn6.h76
-rw-r--r--imap/src/osdep/unix/os_slx.c30
-rw-r--r--imap/src/osdep/unix/os_slx.h33
-rw-r--r--imap/src/osdep/unix/scandir.c32
-rw-r--r--imap/src/osdep/unix/ssl_none.c43
-rw-r--r--imap/src/osdep/unix/ssl_unix.c50
-rw-r--r--imap/src/osdep/unix/sslstdio.c48
-rw-r--r--imap/src/osdep/unix/tcp_unix.c119
28 files changed, 769 insertions, 692 deletions
diff --git a/imap/src/osdep/unix/Makefile b/imap/src/osdep/unix/Makefile
index 78913acc..a38d15fb 100644
--- a/imap/src/osdep/unix/Makefile
+++ b/imap/src/osdep/unix/Makefile
@@ -1,15 +1,7 @@
# ========================================================================
-# Copyright 1988-2007 University of Washington
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-#
+# Copyright 2008-2011 Mark Crispin
# ========================================================================
-
+#
# Program: C client makefile
#
# Author: Mark Crispin
@@ -21,7 +13,17 @@
# Internet: MRC@CAC.Washington.EDU
#
# Date: 11 May 1989
-# Last Edited: 17 December 2007
+# Last Edited: 29 August 2011
+#
+# Previous versions of this file were
+#
+# Copyright 1988-2008 University of Washington
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
# Command line build parameters
@@ -199,7 +201,7 @@ a41: # AIX 4.1 for RS/6000
BASECFLAGS="-g -Dunix=1 -D_BSD -qro -qroconst" \
BASELDFLAGS="-ls"
-a52: # Attempt at AIX 5.2
+a52: # AIX 5.2
$(BUILD) `$(CAT) SPECIALS` OS=$@ \
SIGTYPE=psx CHECKPW=a41 CRXTYPE=nfs \
SPOOLDIR=/var/spool \
@@ -437,7 +439,7 @@ gso: os_sol.h # GCC Solaris
ACTIVEFILE=/usr/share/news/active \
RSHPATH=/usr/bin/rsh \
BASECFLAGS="$(GCCCFLAGS)" \
- BASELDFLAGS="-lsocket -lnsl -lgen" \
+ BASELDFLAGS="-lsocket -lnsl -lgen -R/usr/local/ssl/lib" \
RANLIB=true CC=gcc
gsu: # GCC SUN-OS
@@ -608,6 +610,14 @@ pyr: # Pyramid
CRXTYPE=nfs \
BASECFLAGS="-g -Dconst="
+qn6: # QNX 6
+ $(BUILD) `$(CAT) SPECIALS` OS=$@ \
+ CRXTYPE=nfs \
+ SPOOLDIR=/var/spool \
+ ACTIVEFILE=/var/lib/news/active \
+ RSHPATH=/usr/bin/rsh \
+ BASECFLAGS="$(GCCFLAGS)"
+
qnx: # QNX
$(BUILD) `$(CAT) SPECIALS` OS=$@ \
CHECKPW=psx LOGINPW=old \
@@ -725,7 +735,7 @@ soc: os_sol.h # Solaris with cc
ACTIVEFILE=/usr/share/news/active \
RSHPATH=/usr/bin/rsh \
BASECFLAGS="-g -O -w" \
- BASELDFLAGS="-lsocket -lnsl -lgen" \
+ BASELDFLAGS="-lsocket -lnsl -lgen -R/usr/local/ssl/lib" \
RANLIB=true CC=/opt/SUNWspro/bin/cc
@@ -773,7 +783,7 @@ sol: os_sol.h # Solaris
ACTIVEFILE=/usr/share/news/active \
RSHPATH=/usr/bin/rsh \
BASECFLAGS="-g -O2" \
- BASELDFLAGS="-lsocket -lnsl -lgen" \
+ BASELDFLAGS="-lsocket -lnsl -lgen -R/usr/local/ssl/lib" \
RANLIB=true CC=ucbcc
sos: # Secure OSF/1
@@ -859,8 +869,8 @@ all: $(ARCHIVE)
$(ARCHIVE): $(BINARIES)
sh -c '$(RM) $(ARCHIVE) || true'
- @$(CAT) ARCHIVE
- @$(SH) ARCHIVE
+ @$(CAT) ./ARCHIVE
+ @$(SH) ./ARCHIVE
.c.o:
`$(CAT) CCTYPE` -c `$(CAT) CFLAGS` $*.c
diff --git a/imap/src/osdep/unix/dummy.c b/imap/src/osdep/unix/dummy.c
index b003a0ba..cb3b45bd 100644
--- a/imap/src/osdep/unix/dummy.c
+++ b/imap/src/osdep/unix/dummy.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2011 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Dummy routines
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 9 May 1991
- * Last Edited: 1 June 2007
+ * Last Edited: 8 April 2011
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
@@ -216,10 +213,10 @@ void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
{
void *sdb = NIL;
- char *s,*t,test[MAILTMPLEN],tmp[MAILTMPLEN];
+ char *s,*t,test[MAILTMPLEN],tmp[MAILTMPLEN],tmpx[MAILTMPLEN];
int showuppers = pat[strlen (pat) - 1] == '%';
/* get canonical form of name */
- if (dummy_canonicalize (test,ref,pat) && (s = sm_read (&sdb))) do
+ if (dummy_canonicalize (test,ref,pat) && (s = sm_read (tmpx,&sdb))) do
if (*s != '{') {
if (!compare_cstring (s,"INBOX") &&
pmatch ("INBOX",ucase (strcpy (tmp,test))))
@@ -230,7 +227,8 @@ void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
if (pmatch_full (s,test,'/')) mm_lsub (stream,'/',s,LATT_NOSELECT);
}
}
- while (s = sm_read (&sdb)); /* until no more subscriptions */
+ /* until no more subscriptions */
+ while (s = sm_read (tmpx,&sdb));
}
diff --git a/imap/src/osdep/unix/env_unix.c b/imap/src/osdep/unix/env_unix.c
index 6b2c4471..b13d5066 100644
--- a/imap/src/osdep/unix/env_unix.c
+++ b/imap/src/osdep/unix/env_unix.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2008 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2010 Mark Crispin
* ========================================================================
*/
@@ -15,13 +7,20 @@
* Program: UNIX environment routines
*
* Author: Mark Crispin
- * UW Technology
- * University of Washington
- * Seattle, WA 98195
- * Internet: MRC@Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 23 February 2009
+ * Last Edited: 15 November 2010
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2008 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include <grp.h>
@@ -77,7 +76,7 @@ static char *sslCApath = NIL; /* non-standard CA path */
static short anonymous = NIL; /* is anonymous */
static short blackBox = NIL; /* is a black box */
static short closedBox = NIL; /* is a closed box (uses chroot() jail) */
-static short restrictBox = NIL; /* is a restricted box */
+static long restrictBox = NIL; /* is a restricted box */
static short has_no_life = NIL; /* is a cretin with no life */
/* block environment init */
static short block_env_init = NIL;
@@ -398,6 +397,10 @@ void *env_parameters (long function,void *value)
case GET_SHAREDDIRPROTECTION:
ret = (void *) shared_dir_protection;
break;
+ case SET_RESTRICTIONS:
+ restrictBox = (long) value;
+ case GET_RESTRICTIONS:
+ ret = (void *) restrictBox;
case SET_LOCKTIMEOUT:
locktimeout = (long) value;
@@ -618,14 +621,17 @@ void server_init (char *server,char *service,char *sslservice,
long server_input_wait (long seconds)
{
+ int err;
fd_set rfd,efd;
struct timeval tmo;
- FD_ZERO (&rfd);
- FD_ZERO (&efd);
- FD_SET (0,&rfd);
- FD_SET (0,&efd);
- tmo.tv_sec = seconds; tmo.tv_usec = 0;
- return select (1,&rfd,0,&efd,&tmo) ? LONGT : NIL;
+ do {
+ FD_ZERO (&rfd);
+ FD_ZERO (&efd);
+ FD_SET (0,&rfd);
+ FD_SET (0,&efd);
+ tmo.tv_sec = seconds; tmo.tv_usec = 0;
+ } while (((err = select (1,&rfd,0,&efd,&tmo)) < 0) && (errno = EINTR));
+ return err ? LONGT : NIL;
}
/* Return UNIX password entry for user name
@@ -933,16 +939,14 @@ char *mylocalhost ()
{
if (!myLocalHost) {
char *s,tmp[MAILTMPLEN];
- char *t = "unknown";
tmp[0] = tmp[MAILTMPLEN-1] = '\0';
if (!gethostname (tmp,MAILTMPLEN-1) && tmp[0]) {
/* sanity check of name */
for (s = tmp; (*s > 0x20) && (*s < 0x7f); ++s);
- if (!*s) t = tcp_canonical (tmp);
+ if (!*s) myLocalHost = tcp_canonical (tmp);
}
- myLocalHost = cpystr (t);
}
- return myLocalHost;
+ return myLocalHost ? myLocalHost : "unknown";
}
/* Return my home directory name
@@ -1071,9 +1075,13 @@ char *mailboxfile (char *dst,char *name)
}
else sprintf (dst,"%s/%s",blackBoxDir,name+1);
}
- else if ((restrictBox & RESTRICTROOT) && strcmp (name,sysinbox ()))
- dst = NIL; /* restricted and not access to sysinbox */
- else strcpy (dst,name); /* unrestricted, copy root name */
+ else {
+ size_t i = strlen (mymailboxdir ());
+ if ((restrictBox & RESTRICTROOT) && strcmp (name,sysinbox ()) &&
+ (!i || strncmp (name,mymailboxdir (),i) || (name[i] !='/')))
+ dst = NIL; /* restricted and not sysinbox or home */
+ else strcpy (dst,name); /* unrestricted, copy root name */
+ }
break;
case '~': /* other user access */
/* bad syntax or anonymous can't win */
diff --git a/imap/src/osdep/unix/env_unix.h b/imap/src/osdep/unix/env_unix.h
index 365e5128..087430ab 100644
--- a/imap/src/osdep/unix/env_unix.h
+++ b/imap/src/osdep/unix/env_unix.h
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2010 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: UNIX environment routines
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 30 August 2006
+ * Last Edited: 15 November 2010
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
@@ -68,7 +65,7 @@ char *myusername_full (unsigned long *flags);
#define MU_ANONYMOUS 2
#define myusername() \
myusername_full (NIL)
-char *sysinbox ();
+char *sysinbox (void);
char *mailboxdir (char *dst,char *dir,char *name);
long dotlock_lock (char *file,DOTLOCK *base,int fd);
long dotlock_unlock (DOTLOCK *base);
diff --git a/imap/src/osdep/unix/flocklnx.c b/imap/src/osdep/unix/flocklnx.c
index 06940b8d..3dc6b5dc 100644
--- a/imap/src/osdep/unix/flocklnx.c
+++ b/imap/src/osdep/unix/flocklnx.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Safe File Lock for Linux
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 20 April 2005
- * Last Edited: 30 August 2006
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#undef flock
diff --git a/imap/src/osdep/unix/ip4_unix.c b/imap/src/osdep/unix/ip4_unix.c
index 23d399e1..4ebb32b1 100644
--- a/imap/src/osdep/unix/ip4_unix.c
+++ b/imap/src/osdep/unix/ip4_unix.c
@@ -1,4 +1,18 @@
/* ========================================================================
+ * Copyright 2008-2011 Mark Crispin
+ * ========================================================================
+ */
+
+/*
+ * Program: UNIX IPv4 routines
+ *
+ * Author: Mark Crispin
+ *
+ * Date: 18 December 2003
+ * Last Edited: 23 May 2011
+ *
+ * Previous versions of this file were:
+ *
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,20 +25,6 @@
* ========================================================================
*/
-/*
- * Program: UNIX IPv4 routines
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 18 December 2003
- * Last Edited: 30 August 2006
- */
#define SADRLEN sizeof (struct sockaddr)
@@ -37,22 +37,23 @@
/* IP abstraction layer */
-char *ip_sockaddrtostring (struct sockaddr *sadr);
+char *ip_sockaddrtostring (struct sockaddr *sadr,char *buf);
long ip_sockaddrtoport (struct sockaddr *sadr);
void *ip_stringtoaddr (char *text,size_t *len,int *family);
struct sockaddr *ip_newsockaddr (size_t *len);
struct sockaddr *ip_sockaddr (int family,void *adr,size_t adrlen,
unsigned short port,size_t *len);
-char *ip_sockaddrtoname (struct sockaddr *sadr);
+char *ip_sockaddrtoname (struct sockaddr *sadr,char *buf);
void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
- void **next);
+ void **next,void **cleanup);
/* Return IP address string from socket address
* Accepts: socket address
+ * buffer
* Returns: IP address as name string
*/
-char *ip_sockaddrtostring (struct sockaddr *sadr)
+char *ip_sockaddrtostring (struct sockaddr *sadr,char *buf)
{
return (sadr->sa_family == PF_INET) ?
inet_ntoa (SADR4ADR (sadr)) : "NON-IPv4";
@@ -133,10 +134,11 @@ struct sockaddr *ip_sockaddr (int family,void *adr,size_t adrlen,
/* Return name from socket address
* Accepts: socket address
+ * buffer
* Returns: canonical name for that address or NIL if none
*/
-char *ip_sockaddrtoname (struct sockaddr *sadr)
+char *ip_sockaddrtoname (struct sockaddr *sadr,char *buf)
{
struct hostent *he;
return ((sadr->sa_family == PF_INET) &&
@@ -151,14 +153,17 @@ char *ip_sockaddrtoname (struct sockaddr *sadr)
* pointer to previous/returned address family
* pointer to previous/returned canonical name
* pointer to previous/return state for next-address calls
+ * pointer to cleanup
* Returns: address with length/family/canonical updated if needed, or NIL
*/
void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
- void **next)
+ void **next,void **cleanup)
{
char **adl,tmp[MAILTMPLEN];
struct hostent *he;
+ /* cleanup data never permitted */
+ if (cleanup && *cleanup) abort ();
if (name) { /* first lookup? */
/* yes, do case-independent lookup */
if ((strlen (name) < MAILTMPLEN) &&
@@ -166,7 +171,7 @@ void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
adl = he->h_addr_list;
if (len) *len = he->h_length;
if (family) *family = he->h_addrtype;
- if (canonical) *canonical = (char *) he->h_name;
+ if (canonical) *canonical = cpystr ((char *) he->h_name);
if (next) *next = (void *) adl;
}
else { /* error */
diff --git a/imap/src/osdep/unix/ip6_unix.c b/imap/src/osdep/unix/ip6_unix.c
index c15dfbc0..2727adb2 100644
--- a/imap/src/osdep/unix/ip6_unix.c
+++ b/imap/src/osdep/unix/ip6_unix.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2011 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,19 @@
* Program: UNIX IPv6 routines
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 18 December 2003
- * Last Edited: 30 August 2006
+ * Last Edited: 30 July 2011
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*/
@@ -61,32 +57,32 @@
/* IP abstraction layer */
-char *ip_sockaddrtostring (struct sockaddr *sadr);
+char *ip_sockaddrtostring (struct sockaddr *sadr,char buf[NI_MAXHOST]);
long ip_sockaddrtoport (struct sockaddr *sadr);
void *ip_stringtoaddr (char *text,size_t *len,int *family);
struct sockaddr *ip_newsockaddr (size_t *len);
struct sockaddr *ip_sockaddr (int family,void *adr,size_t adrlen,
unsigned short port,size_t *len);
-char *ip_sockaddrtoname (struct sockaddr *sadr);
+char *ip_sockaddrtoname (struct sockaddr *sadr,char buf[NI_MAXHOST]);
void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
- void **next);
+ void **next,void **cleanup);
/* Return IP address string from socket address
* Accepts: socket address
+ * buffer
* Returns: IP address as name string
*/
-char *ip_sockaddrtostring (struct sockaddr *sadr)
+char *ip_sockaddrtostring (struct sockaddr *sadr,char buf[NI_MAXHOST])
{
- static char tmp[NI_MAXHOST];
switch (sadr->sa_family) {
case PF_INET: /* IPv4 */
- if (!getnameinfo (sadr,SADR4LEN,tmp,NI_MAXHOST,NIL,NIL,NI_NUMERICHOST))
- return tmp;
+ if (!getnameinfo (sadr,SADR4LEN,buf,NI_MAXHOST,NIL,NIL,NI_NUMERICHOST))
+ return buf;
break;
case PF_INET6: /* IPv6 */
- if (!getnameinfo (sadr,SADR6LEN,tmp,NI_MAXHOST,NIL,NIL,NI_NUMERICHOST))
- return tmp;
+ if (!getnameinfo (sadr,SADR6LEN,buf,NI_MAXHOST,NIL,NIL,NI_NUMERICHOST))
+ return buf;
break;
}
return "NON-IP";
@@ -120,20 +116,18 @@ void *ip_stringtoaddr (char *text,size_t *len,int *family)
{
char tmp[MAILTMPLEN];
- static struct addrinfo *hints;
+ struct addrinfo hints;
struct addrinfo *ai;
void *adr = NIL;
- if (!hints) { /* hints set up yet? */
- hints = (struct addrinfo *) /* one-time setup */
- memset (fs_get (sizeof (struct addrinfo)),0,sizeof (struct addrinfo));
- hints->ai_family = AF_UNSPEC;/* allow any address family */
- hints->ai_socktype = SOCK_STREAM;
+ /* initialize hints */
+ memset (&hints,NIL,sizeof (hints));
+ hints.ai_family = AF_UNSPEC;/* allow any address family */
+ hints.ai_socktype = SOCK_STREAM;
/* numeric name only */
- hints->ai_flags = AI_NUMERICHOST;
- }
+ hints.ai_flags = AI_NUMERICHOST;
/* case-independent lookup */
if (text && (strlen (text) < MAILTMPLEN) &&
- (!getaddrinfo (lcase (strcpy (tmp,text)),NIL,hints,&ai))) {
+ (!getaddrinfo (lcase (strcpy (tmp,text)),NIL,&hints,&ai))) {
switch (*family = ai->ai_family) {
case AF_INET: /* IPv4 */
adr = fs_get (*len = ADR4LEN);
@@ -199,20 +193,20 @@ struct sockaddr *ip_sockaddr (int family,void *adr,size_t adrlen,
/* Return name from socket address
* Accepts: socket address
+ * buffer
* Returns: canonical name for that address or NIL if none
*/
-char *ip_sockaddrtoname (struct sockaddr *sadr)
+char *ip_sockaddrtoname (struct sockaddr *sadr,char buf[NI_MAXHOST])
{
- static char tmp[NI_MAXHOST];
switch (sadr->sa_family) {
case PF_INET: /* IPv4 */
- if (!getnameinfo (sadr,SADR4LEN,tmp,NI_MAXHOST,NIL,NIL,NI_NAMEREQD))
- return tmp;
+ if (!getnameinfo (sadr,SADR4LEN,buf,NI_MAXHOST,NIL,NIL,NI_NAMEREQD))
+ return buf;
break;
case PF_INET6: /* IPv6 */
- if (!getnameinfo (sadr,SADR6LEN,tmp,NI_MAXHOST,NIL,NIL,NI_NAMEREQD))
- return tmp;
+ if (!getnameinfo (sadr,SADR6LEN,buf,NI_MAXHOST,NIL,NIL,NI_NAMEREQD))
+ return buf;
break;
}
return NIL;
@@ -224,38 +218,40 @@ char *ip_sockaddrtoname (struct sockaddr *sadr)
* pointer to previous/returned address family
* pointer to previous/returned canonical name
* pointer to previous/return state for next-address calls
+ * pointer to cleanup (or NIL to get canonical name only)
* Returns: address with length/family/canonical updated if needed, or NIL
*/
void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
- void **next)
+ void **next,void **cleanup)
{
+ char tmp[MAILTMPLEN];
struct addrinfo *cur = NIL;
- static struct addrinfo *hints;
- static struct addrinfo *ai = NIL;
- static char lcname[MAILTMPLEN];
- if (!hints) { /* hints set up yet? */
- hints = (struct addrinfo *) /* one-time setup */
- memset (fs_get (sizeof (struct addrinfo)),0,sizeof (struct addrinfo));
+ struct addrinfo hints;
+ void *ret = NIL;
+ /* initialize hints */
+ memset (&hints,NIL,sizeof (hints));
/* allow any address family */
- hints->ai_family = AF_UNSPEC;
- hints->ai_socktype = SOCK_STREAM;
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
/* need canonical name */
- hints->ai_flags = AI_CANONNAME;
- }
+ hints.ai_flags = AI_CANONNAME;
if (name) { /* name supplied? */
- if (ai) {
- freeaddrinfo (ai); /* free old addrinfo */
- ai = NIL;
+ struct addrinfo *aitmp = NIL;
+ if (!cleanup) cleanup = (void **) &aitmp;
+ else if (*cleanup) {
+ freeaddrinfo (*cleanup); /* free old addrinfo */
+ *cleanup = NIL;
}
/* case-independent lookup */
if ((strlen (name) < MAILTMPLEN) &&
- (!getaddrinfo (lcase (strcpy (lcname,name)),NIL,hints,&ai))) {
- cur = ai; /* current block */
+ (!getaddrinfo (lcase (strcpy (tmp,name)),NIL,&hints,
+ (struct addrinfo **) cleanup))) {
+ cur = *cleanup; /* current block */
if (canonical) /* set canonical name */
- *canonical = cur->ai_canonname ? cur->ai_canonname : lcname;
+ *canonical = cpystr (cur->ai_canonname ? cur->ai_canonname : tmp);
/* remember as next block */
- if (next) *next = (void *) ai;
+ if (next) *next = (void *) cur;
}
else { /* error */
cur = NIL;
@@ -264,25 +260,42 @@ void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
if (canonical) *canonical = NIL;
if (next) *next = NIL;
}
+ if (aitmp) { /* special call to get canonical name */
+ freeaddrinfo (aitmp);
+ if (len) *len = 0;
+ if (family) *family = 0;
+ if (next) *next = NIL;
+ return VOIDT; /* return only needs to be non-NIL */
+ }
}
+
/* return next in series */
else if (next && (cur = ((struct addrinfo *) *next)->ai_next)) {
*next = cur; /* set as last address */
/* set canonical in case changed */
- if (canonical && cur->ai_canonname) *canonical = cur->ai_canonname;
+ if (canonical && cur->ai_canonname) {
+ if (*canonical) fs_give ((void **) canonical);
+ *canonical = cpystr (cur->ai_canonname);
+ }
+ }
+ else if (*cleanup) {
+ freeaddrinfo (*cleanup); /* free old addrinfo */
+ *cleanup = NIL;
}
-
if (cur) { /* got data? */
if (family) *family = cur->ai_family;
switch (cur->ai_family) {
case AF_INET:
if (len) *len = ADR4LEN;
- return (void *) &SADR4ADR (cur->ai_addr);
+ ret = (void *) &SADR4ADR (cur->ai_addr);
+ break;
case AF_INET6:
if (len) *len = ADR6LEN;
- return (void *) &SADR6ADR (cur->ai_addr);
+ ret = (void *) &SADR6ADR (cur->ai_addr);
+ break;
+ default:
+ if (len) *len = 0; /* error return */
}
}
- if (len) *len = 0; /* error return */
- return NIL;
+ return ret;
}
diff --git a/imap/src/osdep/unix/ipo_unix.c b/imap/src/osdep/unix/ipo_unix.c
deleted file mode 100644
index 665fb2e8..00000000
--- a/imap/src/osdep/unix/ipo_unix.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
- * ========================================================================
- */
-
-/*
- * Program: UNIX IPv4 old routines
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 18 December 2003
- * Last Edited: 30 August 2006
- */
-
-#define SADRLEN sizeof (struct sockaddr)
-
-#define SADR4(sadr) ((struct sockaddr_in *) sadr)
-#define SADR4LEN sizeof (struct sockaddr_in)
-#define SADR4ADR(sadr) SADR4 (sadr)->sin_addr
-#define ADR4LEN sizeof (struct in_addr)
-#define SADR4PORT(sadr) SADR4 (sadr)->sin_port
-
-
-/* IP abstraction layer */
-
-char *ip_sockaddrtostring (struct sockaddr *sadr);
-long ip_sockaddrtoport (struct sockaddr *sadr);
-void *ip_stringtoaddr (char *text,size_t *len,int *family);
-struct sockaddr *ip_newsockaddr (size_t *len);
-struct sockaddr *ip_sockaddr (int family,void *adr,size_t adrlen,
- unsigned short port,size_t *len);
-char *ip_sockaddrtoname (struct sockaddr *sadr);
-void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
- void **next);
-
-/* Return IP address string from socket address
- * Accepts: socket address
- * Returns: IP address as name string
- */
-
-char *ip_sockaddrtostring (struct sockaddr *sadr)
-{
- return (sadr->sa_family == PF_INET) ?
- inet_ntoa (SADR4ADR (sadr)) : "NON-IPv4";
-}
-
-
-/* Return port from socket address
- * Accepts: socket address
- * Returns: port number or -1 if can't determine it
- */
-
-long ip_sockaddrtoport (struct sockaddr *sadr)
-{
- return (sadr->sa_family == PF_INET) ? ntohs (SADR4PORT (sadr)) : -1;
-}
-
-
-/* Return IP address from string
- * Accepts: name string
- * pointer to returned length
- * pointer to returned address family
- * Returns: address if valid, length and family updated, or NIL
- */
-
-void *ip_stringtoaddr (char *text,size_t *len,int *family)
-{
- unsigned long adr;
- struct in_addr *ret;
- /* get address */
- if ((adr = inet_addr (text)) == -1) ret = NIL;
- else { /* make in_addr */
- ret = (struct in_addr *) fs_get (*len = ADR4LEN);
- *family = AF_INET; /* IPv4 */
- ret->s_addr = adr; /* set address */
- }
- return (void *) ret;
-}
-
-/* Create a maximum-size socket address
- * Accepts: pointer to return maximum socket address length
- * Returns: new, empty socket address of maximum size
- */
-
-struct sockaddr *ip_newsockaddr (size_t *len)
-{
- return (struct sockaddr *) memset (fs_get (SADRLEN),0,*len = SADRLEN);
-}
-
-
-/* Stuff a socket address
- * Accepts: address family
- * IPv4 address
- * length of address (always 4 in IPv4)
- * port number
- * pointer to return socket address length
- * Returns: socket address or NIL if error
- */
-
-struct sockaddr *ip_sockaddr (int family,void *adr,size_t adrlen,
- unsigned short port,size_t *len)
-{
- struct sockaddr *sadr = ip_newsockaddr (len);
- switch (family) { /* build socket address based upon family */
- case AF_INET: /* IPv4 */
- sadr->sa_family = PF_INET;
- /* copy host address */
- memcpy (&SADR4ADR (sadr),adr,adrlen);
- /* copy port number in network format */
- SADR4PORT (sadr) = htons (port);
- *len = SADR4LEN;
- break;
- default: /* non-IP?? */
- sadr->sa_family = PF_UNSPEC;
- break;
- }
- return sadr;
-}
-
-/* Return name from socket address
- * Accepts: socket address
- * Returns: canonical name for that address or NIL if none
- */
-
-char *ip_sockaddrtoname (struct sockaddr *sadr)
-{
- struct hostent *he;
- return ((sadr->sa_family == PF_INET) &&
- (he = gethostbyaddr ((char *) &SADR4ADR (sadr),ADR4LEN,AF_INET))) ?
- (char *) he->h_name : NIL;
-}
-
-
-/* Return address from name
- * Accepts: name or NIL to return next address
- * pointer to previous/returned length
- * pointer to previous/returned address family
- * pointer to previous/returned canonical name
- * pointer to previous/return state for next-address calls
- * Returns: address with length/family/canonical updated if needed, or NIL
- */
-
-void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical,
- void **next)
-{
- char tmp[MAILTMPLEN];
- struct hostent *he;
- void *ret = NIL;
- if (name) { /* first lookup? */
- /* yes, do case-independent lookup */
- if ((strlen (name) < MAILTMPLEN) &&
- (he = gethostbyname (lcase (strcpy (tmp,name))))) {
- if (len) *len = he->h_length;
- if (family) *family = he->h_addrtype;
- if (canonical) *canonical = (char *) he->h_name;
- if (next) *next = 0;
- ret = he->h_addr; /* set result to this one and only block */
- }
- else { /* error */
- if (len) *len = 0;
- if (family) *family = 0;
- if (canonical) *canonical = NIL;
- if (next) *next = NIL;
- }
- }
- return ret; /* return result */
-}
diff --git a/imap/src/osdep/unix/mbx.c b/imap/src/osdep/unix/mbx.c
index 1ece5d8d..dc902b20 100644
--- a/imap/src/osdep/unix/mbx.c
+++ b/imap/src/osdep/unix/mbx.c
@@ -1,5 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
+ * Copyright 1988-2012 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
* Internet: MRC@CAC.Washington.EDU
*
* Date: 3 October 1995
- * Last Edited: 11 October 2007
+ * Last Edited: 21 February 2012
*/
@@ -1178,8 +1178,8 @@ long mbx_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
else { /* write message */
size_t j;
if (!message->cursize) SETPOS (message,GETPOS (message));
- while (i && (j = fwrite (message->curpos,1,message->cursize,df))) {
- i -= j;
+ for (errno = 0; !errno && i &&
+ (j = fwrite (message->curpos,1,message->cursize,df)); i -= j) {
SETPOS (message,GETPOS (message) + j);
}
/* get next message */
diff --git a/imap/src/osdep/unix/mh.c b/imap/src/osdep/unix/mh.c
index 0226b7af..005000d6 100644
--- a/imap/src/osdep/unix/mh.c
+++ b/imap/src/osdep/unix/mh.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2011 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: MH mail routines
*
* Author(s): Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 23 February 1992
- * Last Edited: 11 October 2007
+ * Last Edited: 8 April 2011
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
@@ -400,11 +397,11 @@ void mh_list (MAILSTREAM *stream,char *ref,char *pat)
void mh_lsub (MAILSTREAM *stream,char *ref,char *pat)
{
void *sdb = NIL;
- char *s,test[MAILTMPLEN];
+ char *s,test[MAILTMPLEN],tmp[MAILTMPLEN];
/* get canonical form of name */
- if (mh_canonicalize (test,ref,pat) && (s = sm_read (&sdb))) {
+ if (mh_canonicalize (test,ref,pat) && (s = sm_read (tmp,&sdb))) {
do if (pmatch_full (s,test,'/')) mm_lsub (stream,'/',s,NIL);
- while (s = sm_read (&sdb)); /* until no more subscriptions */
+ while (s = sm_read (tmp,&sdb)); /* until no more subscriptions */
}
}
diff --git a/imap/src/osdep/unix/mix.c b/imap/src/osdep/unix/mix.c
index fbf4a023..63009bb2 100644
--- a/imap/src/osdep/unix/mix.c
+++ b/imap/src/osdep/unix/mix.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2008 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2012 Mark Crispin
* ========================================================================
*/
@@ -15,13 +7,19 @@
* Program: MIX mail routines
*
* Author(s): Mark Crispin
- * UW Technology
- * University of Washington
- * Seattle, WA 98195
- * Internet: MRC@Washington.EDU
*
* Date: 1 March 2006
- * Last Edited: 7 May 2008
+ * Last Edited: 15 February 2012
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2008 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*/
@@ -417,7 +415,7 @@ long mix_create (MAILSTREAM *stream,char *mailbox)
strerror (errno));
else { /* success, write initial metadata */
fprintf (f,SEQFMT,now);
- fprintf (f,MTAFMT,now,0,now);
+ fprintf (f,MTAFMT,now,(unsigned long) 0,now);
for (i = 0, c = 'K'; (i < NUSERFLAGS) &&
(t = (stream && stream->user_flags[i]) ? stream->user_flags[i] :
default_user_flag (i)) && *t; ++i) {
@@ -1040,7 +1038,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options)
/* expunge unless just burping */
if (!burponly) for (i = 1; i <= stream->nmsgs;) {
elt = mail_elt (stream,i);/* need to expunge this message? */
- if (sequence ? elt->sequence : elt->deleted) {
+ if (elt->deleted && (sequence ? elt->sequence : T)) {
++nexp; /* yes, make it so */
mail_expunged (stream,i);
}
@@ -1061,7 +1059,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options)
/* another file found */
if (cur) cur = cur->next = nxt;
else cur = burp = nxt;
- cur->name = names[i]->d_name;
+ cur->name = cpystr (names[i]->d_name);
cur->fileno = strtoul (cur->name + sizeof (MIXNAME) - 1,NIL,16);
cur->tail = &cur->set;
fs_give ((void **) &names[i]);
@@ -1104,6 +1102,12 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options)
MM_LOG (LOCAL->buf,WARN);
}
}
+ while (burp) { /* flush the burp list */
+ cur = burp->next;
+ if (burp->name) fs_give ((void **) &burp->name);
+ fs_give ((void **) &burp);
+ burp = cur;
+ }
}
else MM_LOG ("No mix message files found during expunge",WARN);
/* free directory list */
@@ -1116,7 +1120,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options)
/* Do this step even if ret is NIL (meaning some burp problem)! */
if (nexp || reclaimed) { /* rewrite index and status if changed */
LOCAL->indexseq = mix_modseq (LOCAL->indexseq);
- if (mix_index_update (stream,idxf,NIL)) {
+ if (ret = mix_index_update (stream,idxf,NIL)) {
LOCAL->statusseq = mix_modseq (LOCAL->statusseq);
/* set failure if update fails */
ret = mix_status_update (stream,statf,NIL);
@@ -1269,7 +1273,7 @@ long mix_burp (MAILSTREAM *stream,MIXBURP *burp,unsigned long *reclaimed)
return NIL; /* burp fails for this file */
}
/* burp out each old message */
- for (set = &burp->set, wpos = 0; set; set = set->next) {
+ for (set = &burp->set, rpos = wpos = 0; set; set = set->next) {
/* move down this range */
for (rpos = set->first, size = set->last - set->first;
size; size -= wsize) {
@@ -1288,8 +1292,8 @@ long mix_burp (MAILSTREAM *stream,MIXBURP *burp,unsigned long *reclaimed)
MM_DISKERROR (stream,errno,T);
}
/* and especially not here */
- for (s = LOCAL->buf, wpending = wsize; wpending; wpending -= written)
- if (!(written = fwrite (LOCAL->buf,1,wpending,f))) {
+ for (s = LOCAL->buf, wpending = wsize; wpending; s += written, wpending -= written)
+ if (!(written = fwrite (s,1,wpending,f))) {
MM_NOTIFY (stream,strerror (errno),WARN);
MM_DISKERROR (stream,errno,T);
}
@@ -1390,7 +1394,8 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
if (local->indexseq > seq) seq = local->indexseq + 1;
if (local->statusseq > seq) seq = local->statusseq + 1;
/* calculate size of per-message header */
- sprintf (local->buf,MSRFMT,MSGTOK,0,0,0,0,0,0,0,'+',0,0,0);
+ sprintf (local->buf,MSRFMT,MSGTOK,(unsigned long) 0,0,0,0,0,0,0,'+',0,0,
+ (unsigned long) 0);
hdrsize = strlen (local->buf);
MM_CRITICAL (stream); /* go critical */
@@ -1547,7 +1552,8 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
if (local->indexseq > seq) seq = local->indexseq + 1;
if (local->statusseq > seq) seq = local->statusseq + 1;
/* calculate size of per-message header */
- sprintf (local->buf,MSRFMT,MSGTOK,0,0,0,0,0,0,0,'+',0,0,0);
+ sprintf (local->buf,MSRFMT,MSGTOK,(unsigned long) 0,0,0,0,0,0,0,'+',0,0,
+ (unsigned long) 0);
hdrsize = strlen (local->buf);
MM_CRITICAL (astream); /* go critical */
astream->silent = T; /* no events here */
@@ -1631,6 +1637,7 @@ long mix_append_msg (MAILSTREAM *stream,FILE *f,char *flags,MESSAGECACHE *delt,
int c,cs;
unsigned long i,j,k,uf,hoff;
long sf;
+ void *s;
stream->kwd_create = NIL; /* don't copy unknown keywords */
sf = mail_parse_flags (stream,flags,&uf);
/* swell the cache */
@@ -1669,8 +1676,8 @@ long mix_append_msg (MAILSTREAM *stream,FILE *f,char *flags,MESSAGECACHE *delt,
for (cs = 0; SIZE (msg); ) { /* copy message */
if (elt->private.msg.header.text.size) {
if (msg->cursize) /* blat entire chunk if have it */
- for (j = msg->cursize; j; j -= k)
- if (!(k = fwrite (msg->curpos,1,j,f))) return NIL;
+ for (s = msg->curpos,j = msg->cursize; j; s += k, j -= k)
+ if (!(k = fwrite (s,1,j,f))) return NIL;
SETPOS (msg,GETPOS (msg) + msg->cursize);
}
else { /* still searching for delimiter */
@@ -1813,6 +1820,7 @@ FILE *mix_parse (MAILSTREAM *stream,FILE **idxf,long iflags,long sflags)
}
/* sequence changed from last time? */
else if (j || (i > LOCAL->indexseq)) {
+ unsigned long prevuid = 0;
unsigned long uid,nmsgs,curfile,curfilesize,curpos;
char *t,*msg,tmp[MAILTMPLEN];
/* start with no messages */
@@ -1870,6 +1878,12 @@ FILE *mix_parse (MAILSTREAM *stream,FILE **idxf,long iflags,long sflags)
/* ignore expansion values */
if (*s++ == ':') {
MESSAGECACHE *elt;
+ if(prevuid > uid) {
+ sprintf (tmp,"mix index backwards UID: %lx",uid);
+ MM_LOG (tmp,ERROR);
+ return NIL;
+ }
+ prevuid = uid;
++nmsgs; /* this is another mesage */
/* within current known range of messages? */
while (nmsgs <= stream->nmsgs) {
@@ -2234,7 +2248,9 @@ long mix_index_update (MAILSTREAM *stream,FILE *idxf,long flag)
for (i = 1, size = 0; i <= stream->nmsgs; ++i)
if (!mail_elt (stream,i)->private.ghost) ++size;
if (size) { /* Winston Smith's first dairy entry */
- sprintf (tmp,IXRFMT,0,14,4,4,13,0,0,'+',0,0,0,0,0,0,0);
+ sprintf (tmp,IXRFMT,(unsigned long) 0,14,4,4,13,0,0,'+',0,0,
+ (unsigned long) 0,(unsigned long) 0,(unsigned long) 0,
+ (unsigned long) 0,(unsigned long) 0);
size *= strlen (tmp);
}
/* calculate file size we need */
@@ -2315,7 +2331,8 @@ long mix_status_update (MAILSTREAM *stream,FILE *statf,long flag)
for (i = 1, size = 0; i <= stream->nmsgs; ++i)
if (!mail_elt (stream,i)->private.ghost) ++size;
if (size) { /* number of living messages */
- sprintf (tmp,STRFMT,0,0,0,0);
+ sprintf (tmp,STRFMT,(unsigned long) 0,(unsigned long) 0,0,
+ (unsigned long) 0);
size *= strlen (tmp);
}
sprintf (tmp,SEQFMT,LOCAL->statusseq);
@@ -2408,14 +2425,30 @@ FILE *mix_data_open (MAILSTREAM *stream,int *fd,long *size,
if (curend > sbuf.st_size) {
char tmp[MAILTMPLEN];
sprintf (tmp,"short mix message file %.08lx (%ld > %ld), rolling",
- LOCAL->newmsg,curend,sbuf.st_size);
+ LOCAL->newmsg,curend,(unsigned long) sbuf.st_size);
MM_LOG (tmp,WARN); /* shouldn't happen */
}
close (*fd); /* roll to a new file */
+ errno = NIL;
while ((*fd = open (mix_file_data
(LOCAL->buf,stream->mailbox,
LOCAL->newmsg = mix_modseq (LOCAL->newmsg)),
- O_RDWR | O_CREAT | O_EXCL,sbuf.st_mode)) < 0);
+ O_RDWR | O_CREAT | O_EXCL,sbuf.st_mode)) < 0) {
+ switch(errno) {
+ case EEXIST: /* always retry if path exists or interrupt */
+ case EINTR:
+ errno = NIL;
+ break;
+ default: /* probably EDQUOT */
+ {
+ char tmp[MAILTMPLEN];
+ sprintf (tmp,"data file %.08lx creation failure: %.80s",
+ LOCAL->newmsg,strerror (errno));
+ MM_LOG (tmp,ERROR); /* shouldn't happen */
+ return NIL;
+ }
+ }
+ }
*size = 0; /* brand new file */
fchmod (*fd,sbuf.st_mode);/* with same mode as previous file */
}
diff --git a/imap/src/osdep/unix/os_bsf.c b/imap/src/osdep/unix/os_bsf.c
index afe26e23..f32b1fb2 100644
--- a/imap/src/osdep/unix/os_bsf.c
+++ b/imap/src/osdep/unix/os_bsf.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- BSDI BSD/386 version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 16 August 2007
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include "tcp_unix.h" /* must be before osdep includes tcp.h */
@@ -52,3 +49,4 @@ extern int errno; /* just in case */
#include "tcp_unix.c"
#include "gr_waitp.c"
#include "tz_bsd.c"
+#include "utime.c"
diff --git a/imap/src/osdep/unix/os_bsf.h b/imap/src/osdep/unix/os_bsf.h
index af18d567..914192de 100644
--- a/imap/src/osdep/unix/os_bsf.h
+++ b/imap/src/osdep/unix/os_bsf.h
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- FreeBSD version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 5 March 1993
- * Last Edited: 30 August 2006
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include <stdlib.h>
@@ -32,12 +29,16 @@
#include <sys/types.h>
#include <dirent.h>
#include <fcntl.h>
+#include <utime.h>
#include <syslog.h>
#include <sys/file.h>
#define direct dirent
+#define utime portable_utime
+int portable_utime (char *file,time_t timep[2]);
+
#include "env_unix.h"
#include "fs.h"
diff --git a/imap/src/osdep/unix/os_bsi.c b/imap/src/osdep/unix/os_bsi.c
index afe26e23..f32b1fb2 100644
--- a/imap/src/osdep/unix/os_bsi.c
+++ b/imap/src/osdep/unix/os_bsi.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- BSDI BSD/386 version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 16 August 2007
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include "tcp_unix.h" /* must be before osdep includes tcp.h */
@@ -52,3 +49,4 @@ extern int errno; /* just in case */
#include "tcp_unix.c"
#include "gr_waitp.c"
#include "tz_bsd.c"
+#include "utime.c"
diff --git a/imap/src/osdep/unix/os_bsi.h b/imap/src/osdep/unix/os_bsi.h
index 15f371a3..f2d9f75d 100644
--- a/imap/src/osdep/unix/os_bsi.h
+++ b/imap/src/osdep/unix/os_bsi.h
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- BSDI BSD/386 version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 5 March 1993
- * Last Edited: 30 August 2006
+ * Last Edited: 2 September 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include <stdlib.h>
@@ -32,9 +29,14 @@
#include <sys/types.h>
#include <sys/dir.h>
#include <fcntl.h>
+#include <time.h>
+#include <utime.h>
#include <syslog.h>
#include <sys/file.h>
+#define utime portable_utime
+int portable_utime (char *file,time_t timep[2]);
+
#include "env_unix.h"
#include "fs.h"
diff --git a/imap/src/osdep/unix/os_lnx.c b/imap/src/osdep/unix/os_lnx.c
index 03fd17d9..e95b2ac2 100644
--- a/imap/src/osdep/unix/os_lnx.c
+++ b/imap/src/osdep/unix/os_lnx.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- old Linux version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1993
- * Last Edited: 16 August 2007
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include "tcp_unix.h" /* must be before osdep includes tcp.h */
@@ -52,3 +49,4 @@ extern int errno; /* just in case */
#include "gr_waitp.c"
#include "tz_sv4.c"
#include "flocklnx.c"
+#include "utime.c"
diff --git a/imap/src/osdep/unix/os_lnx.h b/imap/src/osdep/unix/os_lnx.h
index b5f39ffa..4656b12c 100644
--- a/imap/src/osdep/unix/os_lnx.h
+++ b/imap/src/osdep/unix/os_lnx.h
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- Linux version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 10 September 1993
- * Last Edited: 30 August 2006
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
/*
@@ -47,6 +44,7 @@
#include <dirent.h>
#include <time.h> /* for struct tm */
#include <fcntl.h>
+#include <utime.h>
#include <syslog.h>
#include <sys/file.h>
@@ -59,6 +57,9 @@
#define flock safe_flock
+#define utime portable_utime
+int portable_utime (char *file,time_t timep[2]);
+
#include "env_unix.h"
#include "fs.h"
diff --git a/imap/src/osdep/unix/os_osx.c b/imap/src/osdep/unix/os_osx.c
index 25eb1a7d..e09806c2 100644
--- a/imap/src/osdep/unix/os_osx.c
+++ b/imap/src/osdep/unix/os_osx.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,21 @@
* Program: Operating-system dependent routines -- Mac OS X version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 16 August 2007
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
*/
#include "tcp_unix.h" /* must be before osdep includes tcp.h */
@@ -52,3 +50,4 @@ extern int errno; /* just in case */
#include "tcp_unix.c"
#include "gr_wait4.c"
#include "tz_bsd.c"
+#include "utime.c"
diff --git a/imap/src/osdep/unix/os_osx.h b/imap/src/osdep/unix/os_osx.h
index 3480e14a..6fcb014d 100644
--- a/imap/src/osdep/unix/os_osx.h
+++ b/imap/src/osdep/unix/os_osx.h
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- Mac OS X version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 26 October 2007
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include <stdlib.h>
@@ -32,6 +29,7 @@
#include <sys/types.h>
#include <sys/dir.h>
#include <fcntl.h>
+#include <utime.h>
#include <syslog.h>
#include <sys/file.h>
@@ -49,6 +47,11 @@
#define checkpw Checkpw
+
+#define utime portable_utime
+int portable_utime (char *file,time_t timep[2]);
+
+
#include "env_unix.h"
#include "fs.h"
#include "ftl.h"
diff --git a/imap/src/osdep/unix/os_qn6.c b/imap/src/osdep/unix/os_qn6.c
new file mode 100644
index 00000000..ded8c848
--- /dev/null
+++ b/imap/src/osdep/unix/os_qn6.c
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * Copyright 2008-2009 Mark Crispin
+ * ========================================================================
+ */
+
+/*
+ * Program: Operating-system dependent routines -- QNX 6 version
+ *
+ * Author: Mark Crispin
+ *
+ * Date: 1 August 1993
+ * Last Edited: 17 April 2009
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+
+#include "tcp_unix.h" /* must be before osdep includes tcp.h */
+#include "mail.h"
+#include "osdep.h"
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <errno.h>
+extern int errno; /* just in case */
+#include <pwd.h>
+#include <shadow.h>
+#include <sys/select.h>
+#include "misc.h"
+
+#define DIR_SIZE(d) d->d_reclen
+
+#include "fs_unix.c"
+#include "ftl_unix.c"
+#include "nl_unix.c"
+#include "env_unix.c"
+#include "tcp_unix.c"
+#include "gr_wait.c"
+#include "tz_sv4.c"
+#include "gethstid.c"
+#include "flocksim.c"
+#include "utime.c"
+
+/* QNX local ustat()
+ * Accepts: device id
+ * returned statistics
+ * Returns: 0 if success, -1 if failure with errno set
+ */
+
+int ustat (dev_t dev,struct ustat *ub)
+{
+ errno = ENOSYS; /* fstatvfs() should have been tried first */
+ return -1;
+}
diff --git a/imap/src/osdep/unix/os_qn6.h b/imap/src/osdep/unix/os_qn6.h
new file mode 100644
index 00000000..9d4f379c
--- /dev/null
+++ b/imap/src/osdep/unix/os_qn6.h
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * Copyright 2008-2009 Mark Crispin
+ * ========================================================================
+ */
+
+/*
+ * Program: Operating-system dependent routines -- QNX 6 version
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 10 September 1993
+ * Last Edited: 17 April 2009
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/dir.h>
+#include <sys/types.h>
+#include <time.h>
+#include <utime.h>
+#include <ustat.h>
+
+
+/* QNX gets this wrong */
+
+#define setpgrp setpgid
+#define FNDELAY O_NONBLOCK
+
+
+/* Different names, equivalent things in BSD and SysV */
+
+#ifndef L_SET
+#define L_SET SEEK_SET
+#endif
+#ifndef L_INCR
+#define L_INCR SEEK_CUR
+#endif
+#ifndef L_XTND
+#define L_XTND SEEK_END
+#endif
+
+
+#define utime portable_utime
+int portable_utime (char *file,time_t timep[2]);
+
+long gethostid (void);
+typedef int (*select_t) (struct direct *name);
+typedef int (*compar_t) (void *d1,void *d2);
+
+#include "env_unix.h"
+#include "fs.h"
+#include "ftl.h"
+#include "nl.h"
+#include "tcp.h"
+#include "flocksim.h"
diff --git a/imap/src/osdep/unix/os_slx.c b/imap/src/osdep/unix/os_slx.c
index c94d6322..95c586af 100644
--- a/imap/src/osdep/unix/os_slx.c
+++ b/imap/src/osdep/unix/os_slx.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2007 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- modern Linux version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1993
- * Last Edited: 16 August 2007
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include "tcp_unix.h" /* must be before osdep includes tcp.h */
@@ -54,3 +51,4 @@ extern int errno; /* just in case */
#include "gr_waitp.c"
#include "tz_sv4.c"
#include "flocklnx.c"
+#include "utime.c"
diff --git a/imap/src/osdep/unix/os_slx.h b/imap/src/osdep/unix/os_slx.h
index b5f39ffa..4656b12c 100644
--- a/imap/src/osdep/unix/os_slx.h
+++ b/imap/src/osdep/unix/os_slx.h
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Operating-system dependent routines -- Linux version
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 10 September 1993
- * Last Edited: 30 August 2006
+ * Last Edited: 18 May 2009
+ *
+ * Previous versions of this file were:
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
/*
@@ -47,6 +44,7 @@
#include <dirent.h>
#include <time.h> /* for struct tm */
#include <fcntl.h>
+#include <utime.h>
#include <syslog.h>
#include <sys/file.h>
@@ -59,6 +57,9 @@
#define flock safe_flock
+#define utime portable_utime
+int portable_utime (char *file,time_t timep[2]);
+
#include "env_unix.h"
#include "fs.h"
diff --git a/imap/src/osdep/unix/scandir.c b/imap/src/osdep/unix/scandir.c
index 878343e8..c5e4541b 100644
--- a/imap/src/osdep/unix/scandir.c
+++ b/imap/src/osdep/unix/scandir.c
@@ -1,4 +1,18 @@
/* ========================================================================
+ * Copyright 2008-2009 Mark Crispin
+ * ========================================================================
+ */
+
+/*
+ * Program: Scan directories
+ *
+ * Author: Mark Crispin
+ *
+ * Date: 1 August 1988
+ * Last Edited: 12 June 2009
+ *
+ * Previous versions of this file were:
+ *
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -10,21 +24,6 @@
*
* ========================================================================
*/
-
-/*
- * Program: Scan directories
- *
- * Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
- *
- * Date: 1 August 1988
- * Last Edited: 15 September 2006
- */
/* Emulator for BSD scandir() call
* Accepts: directory name
@@ -43,7 +42,8 @@ int scandir (char *dirname,struct direct ***namelist,select_t select,
long nlmax;
DIR *dirp = opendir (dirname);/* open directory and get status poop */
if ((!dirp) || (fstat (dirp->dd_fd,&stb) < 0)) return -1;
- nlmax = stb.st_size / 24; /* guesstimate at number of files */
+ /* guesstimate at number of files */
+ nlmax = max (stb.st_size / 24,32);
names = (struct direct **) fs_get (nlmax * sizeof (struct direct *));
nitems = 0; /* initially none found */
while (d = readdir (dirp)) { /* read directory item */
diff --git a/imap/src/osdep/unix/ssl_none.c b/imap/src/osdep/unix/ssl_none.c
index e4dedda7..a87c4be6 100644
--- a/imap/src/osdep/unix/ssl_none.c
+++ b/imap/src/osdep/unix/ssl_none.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: Dummy (no SSL) authentication/encryption module
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 7 February 2001
- * Last Edited: 30 August 2006
+ * Last Edited: 19 November 2008
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
/* Init server for SSL
@@ -53,7 +50,12 @@ char *ssl_start_tls (char *server)
int PBIN (void)
{
- return getchar ();
+ int ret;
+ do {
+ clearerr (stdin);
+ ret = getchar ();
+ } while ((ret == EOF) && !feof (stdin) && ferror (stdin) &&(errno == EINTR));
+ return ret;
}
@@ -65,7 +67,12 @@ int PBIN (void)
char *PSIN (char *s,int n)
{
- return fgets (s,n,stdin);
+ char *ret;
+ do {
+ clearerr (stdin);
+ ret = fgets (s,n,stdin);
+ } while (!ret && !feof (stdin) && ferror (stdin) && (errno == EINTR));
+ return ret;
}
diff --git a/imap/src/osdep/unix/ssl_unix.c b/imap/src/osdep/unix/ssl_unix.c
index 3f6bcce9..d77ed719 100644
--- a/imap/src/osdep/unix/ssl_unix.c
+++ b/imap/src/osdep/unix/ssl_unix.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2008 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2009 Mark Crispin
* ========================================================================
*/
@@ -15,18 +7,24 @@
* Program: SSL authentication/encryption module
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 22 September 1998
- * Last Edited: 13 January 2007
+ * Last Edited: 8 November 2009
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2008 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#define crypt ssl_private_crypt
+#define STRING OPENSSL_STRING
#include <x509v3.h>
#include <ssl.h>
#include <err.h>
@@ -35,11 +33,27 @@
#include <bio.h>
#include <crypto.h>
#include <rand.h>
+#undef STRING
#undef crypt
#define SSLBUFLEN 8192
-#define SSLCIPHERLIST "ALL:!LOW"
+/*
+ * PCI auditing compliance, disable:
+ * SSLv2
+ * anonymous D-H (no certificate
+ * export encryption ciphers (40 and 56 bits)
+ * low encryption cipher suites (40 and 56 bits, excluding export)
+ * null encryption (disabling implied by "ALL")
+ *
+ * UW imapd just disables low-grade and null ("ALL:!LOW"). This setting
+ * will break clients that attempt to use the newly-prohibited mechanisms.
+ *
+ * I question the value of disabling SSLv2, as opposed to disabling the SSL
+ * ports (e.g., 993 for IMAP, 995 for POP3) and using TLS exclusively.
+ */
+
+#define SSLCIPHERLIST "ALL:!SSLv2:!ADH:!EXP:!LOW"
/* SSL I/O stream */
@@ -635,7 +649,7 @@ static long ssl_abort (SSLSTREAM *stream)
char *ssl_host (SSLSTREAM *stream)
{
- return tcp_host (stream->tcpstream);
+ return stream ? tcp_host (stream->tcpstream) : "UNKNOWN";
}
diff --git a/imap/src/osdep/unix/sslstdio.c b/imap/src/osdep/unix/sslstdio.c
index 4059a859..3d3b1e06 100644
--- a/imap/src/osdep/unix/sslstdio.c
+++ b/imap/src/osdep/unix/sslstdio.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2006 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008 Mark Crispin
* ========================================================================
*/
@@ -15,15 +7,20 @@
* Program: SSL standard I/O routines for server use
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 22 September 1998
- * Last Edited: 30 August 2006
+ * Last Edited: 19 November 2008
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
/* Get character
@@ -32,7 +29,15 @@
int PBIN (void)
{
- if (!sslstdio) return getchar ();
+ if (!sslstdio) {
+ int ret;
+ do {
+ clearerr (stdin);
+ ret = getchar ();
+ } while ((ret == EOF) && !feof (stdin) && ferror (stdin) &&
+ (errno == EINTR));
+ return ret;
+ }
if (!ssl_getdata (sslstdio->sslstream)) return EOF;
/* one last byte available */
sslstdio->sslstream->ictr--;
@@ -53,7 +58,14 @@ char *PSIN (char *s,int n)
ssl_server_init (start_tls);/* enter the mode */
start_tls = NIL; /* don't do this again */
}
- if (!sslstdio) return fgets (s,n,stdin);
+ if (!sslstdio) {
+ char *ret;
+ do {
+ clearerr (stdin);
+ ret = fgets (s,n,stdin);
+ } while (!ret && !feof (stdin) && ferror (stdin) && (errno == EINTR));
+ return ret;
+ }
for (i = c = 0, n-- ; (c != '\n') && (i < n); sslstdio->sslstream->ictr--) {
if ((sslstdio->sslstream->ictr <= 0) && !ssl_getdata (sslstdio->sslstream))
return NIL; /* read error */
diff --git a/imap/src/osdep/unix/tcp_unix.c b/imap/src/osdep/unix/tcp_unix.c
index 127cf2ae..652f1250 100644
--- a/imap/src/osdep/unix/tcp_unix.c
+++ b/imap/src/osdep/unix/tcp_unix.c
@@ -1,13 +1,5 @@
/* ========================================================================
- * Copyright 1988-2008 University of Washington
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *
+ * Copyright 2008-2011 Mark Crispin
* ========================================================================
*/
@@ -15,20 +7,30 @@
* Program: UNIX TCP/IP routines
*
* Author: Mark Crispin
- * Networks and Distributed Computing
- * Computing & Communications
- * University of Washington
- * Administration Building, AG-44
- * Seattle, WA 98195
- * Internet: MRC@CAC.Washington.EDU
*
* Date: 1 August 1988
- * Last Edited: 13 January 2008
+ * Last Edited: 29 August 2011
+ *
+ * Previous versions of this file were
+ *
+ * Copyright 1988-2008 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
*/
#include "ip_unix.c"
#undef write /* don't use redefined write() */
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
static tcptimeout_t tmoh = NIL; /* TCP timeout handler routine */
static long ttmo_open = 0; /* TCP timeouts, in seconds */
@@ -155,9 +157,11 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
int ctr = 0;
int silent = (port & NET_SILENT) ? T : NIL;
int *ctrp = (port & NET_NOOPENTIMEOUT) ? NIL : &ctr;
- char *s,*hostname,tmp[MAILTMPLEN];
+ char *s,tmp[MAILTMPLEN];
+ char *hostname = NIL;
void *adr;
size_t adrlen;
+ void *cleanup = NIL;
struct servent *sv = NIL;
blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL);
void *data,*next;
@@ -175,7 +179,8 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
if (adr = ip_stringtoaddr (tmp,&adrlen,&family)) {
(*bn) (BLOCK_TCPOPEN,NIL);
/* get an open socket for this system */
- sock = tcp_socket_open (family,adr,adrlen,port,tmp,ctrp,hostname = host);
+ sock = tcp_socket_open (family,adr,adrlen,port,tmp,ctrp,
+ hostname = cpystr(host));
(*bn) (BLOCK_NONE,NIL);
fs_give ((void **) &adr);
}
@@ -189,7 +194,7 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
}
(*bn) (BLOCK_DNSLOOKUP,NIL);/* quell alarms */
data = (*bn) (BLOCK_SENSITIVE,NIL);
- if (!(s = ip_nametoaddr (host,&adrlen,&family,&hostname,&next)))
+ if (!(s = ip_nametoaddr (host,&adrlen,&family,&hostname,&next,&cleanup)))
sprintf (tmp,"No such host as %.80s",host);
(*bn) (BLOCK_NONSENSITIVE,data);
(*bn) (BLOCK_NONE,NIL);
@@ -199,13 +204,19 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
(*bn) (BLOCK_TCPOPEN,NIL);
if (((sock = tcp_socket_open (family,s,adrlen,port,tmp,ctrp,
hostname)) < 0) &&
- (s = ip_nametoaddr (NIL,&adrlen,&family,&hostname,&next)) &&
- !silent) mm_log (tmp,WARN);
+ (s = ip_nametoaddr (NIL,&adrlen,&family,&hostname,&next,
+ &cleanup)) && !silent)
+ mm_log (tmp,WARN);
(*bn) (BLOCK_NONE,NIL);
} while ((sock < 0) && s);/* repeat until success or no more addreses */
}
+ ip_nametoaddr (NIL,NIL,NIL,NIL,NIL,&cleanup);
+ }
+ if (sock < 0) { /* lost? */
+ if (!silent) mm_log (tmp,ERROR);
+ if (hostname) fs_give ((void **) &hostname);
}
- if (sock >= 0) { /* won */
+ else { /* won */
stream = (TCPSTREAM *) memset (fs_get (sizeof (TCPSTREAM)),0,
sizeof (TCPSTREAM));
stream->port = port; /* port number */
@@ -213,11 +224,9 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
stream->tcpsi = stream->tcpso = sock;
/* stash in the snuck-in byte */
if (stream->ictr = ctr) *(stream->iptr = stream->ibuf) = tmp[0];
- /* copy official host name */
- stream->host = cpystr (hostname);
+ stream->host = hostname; /* copy official host name */
if (tcpdebug) mm_log ("Stream open and ready for read",TCPDEBUG);
}
- else if (!silent) mm_log (tmp,ERROR);
return stream; /* return success */
}
@@ -238,17 +247,17 @@ int tcp_socket_open (int family,void *adr,size_t adrlen,unsigned short port,
int i,ti,sock,flgs;
size_t len;
time_t now;
- struct protoent *pt = getprotobyname ("tcp");
- fd_set fds,efds;
+ fd_set rfds,wfds,efds;
+ char buf[NI_MAXHOST];
struct timeval tmo;
struct sockaddr *sadr = ip_sockaddr (family,adr,adrlen,port,&len);
blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL);
/* fetid Solaris */
void *data = (*bn) (BLOCK_SENSITIVE,NIL);
- sprintf (tmp,"Trying IP address [%s]",ip_sockaddrtostring (sadr));
+ sprintf (tmp,"Trying IP address [%s]",ip_sockaddrtostring (sadr,buf));
mm_log (tmp,NIL);
/* make a socket */
- if ((sock = socket (sadr->sa_family,SOCK_STREAM,pt ? pt->p_proto : 0)) < 0) {
+ if ((sock = socket (sadr->sa_family,SOCK_STREAM,0)) < 0) {
sprintf (tmp,"Unable to create TCP socket: %s",strerror (errno));
(*bn) (BLOCK_NONSENSITIVE,data);
}
@@ -285,13 +294,15 @@ int tcp_socket_open (int family,void *adr,size_t adrlen,unsigned short port,
now = time (0); /* open timeout */
ti = ttmo_open ? now + ttmo_open : 0;
tmo.tv_usec = 0;
- FD_ZERO (&fds); /* initialize selection vector */
+ FD_ZERO (&rfds); /* initialize selection vector */
+ FD_ZERO (&wfds);
FD_ZERO (&efds); /* handle errors too */
- FD_SET (sock,&fds); /* block for error or readable */
+ FD_SET (sock,&rfds); /* block for readable, writeable, or error */
+ FD_SET (sock,&wfds);
FD_SET (sock,&efds);
do { /* block under timeout */
tmo.tv_sec = ti ? ti - now : 0;
- i = select (sock+1,&fds,NIL,&efds,ti ? &tmo : NIL);
+ i = select (sock+1,&rfds,&wfds,&efds,ti ? &tmo : NIL);
now = time (0); /* fake timeout if interrupt & time expired */
if ((i < 0) && (errno == EINTR) && ti && (ti <= now)) i = 0;
} while ((i < 0) && (errno == EINTR));
@@ -300,7 +311,8 @@ int tcp_socket_open (int family,void *adr,size_t adrlen,unsigned short port,
fcntl (sock,F_SETFL,flgs);
/* This used to be a zero-byte read(), but that crashes Solaris */
/* get socket status */
- while (((i = *ctr = read (sock,tmp,1)) < 0) && (errno == EINTR));
+ if(FD_ISSET(sock,&rfds))
+ while (((i = *ctr = read (sock,tmp,1)) < 0) && (errno == EINTR));
}
if (i <= 0) { /* timeout or error? */
i = i ? errno : ETIMEDOUT;/* determine error code */
@@ -366,7 +378,10 @@ TCPSTREAM *tcp_aopen (NETMBX *mb,char *service,char *usrbuf)
return NIL;
}
}
- else strcpy (host,tcp_canonical (mb->host));
+ else {
+ strcpy (host,r = tcp_canonical (mb->host));
+ fs_give((void **) &r);
+ }
if (*service == '*') /* build ssh command */
sprintf (tmp,sshcommand,sshpath,host,
@@ -765,7 +780,8 @@ long tcp_abort (TCPSTREAM *stream)
char *tcp_host (TCPSTREAM *stream)
{
- return stream->host; /* use tcp_remotehost() if want guarantees */
+ /* use tcp_remotehost() if want guarantees */
+ return stream ? stream->host : "UNKNOWN";
}
@@ -825,12 +841,13 @@ char *tcp_localhost (TCPSTREAM *stream)
char *tcp_clientaddr ()
{
if (!myClientAddr) {
+ char buf[NI_MAXHOST];
size_t sadrlen;
struct sockaddr *sadr = ip_newsockaddr (&sadrlen);
if (getpeername (0,sadr,(void *) &sadrlen))
myClientAddr = cpystr ("UNKNOWN");
else { /* get stdin's peer name */
- myClientAddr = cpystr (ip_sockaddrtostring (sadr));
+ myClientAddr = cpystr (ip_sockaddrtostring (sadr,buf));
if (myClientPort < 0) myClientPort = ip_sockaddrtoport (sadr);
}
fs_give ((void **) &sadr);
@@ -846,6 +863,7 @@ char *tcp_clientaddr ()
char *tcp_clienthost ()
{
if (!myClientHost) {
+ char buf[NI_MAXHOST];
size_t sadrlen;
struct sockaddr *sadr = ip_newsockaddr (&sadrlen);
if (getpeername (0,sadr,(void *) &sadrlen)) {
@@ -861,7 +879,7 @@ char *tcp_clienthost ()
}
else { /* get stdin's peer name */
myClientHost = tcp_name (sadr,T);
- if (!myClientAddr) myClientAddr = cpystr (ip_sockaddrtostring (sadr));
+ if (!myClientAddr) myClientAddr = cpystr (ip_sockaddrtostring(sadr,buf));
if (myClientPort < 0) myClientPort = ip_sockaddrtoport (sadr);
}
fs_give ((void **) &sadr);
@@ -887,12 +905,13 @@ long tcp_clientport ()
char *tcp_serveraddr ()
{
if (!myServerAddr) {
+ char buf[NI_MAXHOST];
size_t sadrlen;
struct sockaddr *sadr = ip_newsockaddr (&sadrlen);
if (getsockname (0,sadr,(void *) &sadrlen))
myServerAddr = cpystr ("UNKNOWN");
else { /* get stdin's name */
- myServerAddr = cpystr (ip_sockaddrtostring (sadr));
+ myServerAddr = cpystr (ip_sockaddrtostring (sadr,buf));
if (myServerPort < 0) myServerPort = ip_sockaddrtoport (sadr);
}
fs_give ((void **) &sadr);
@@ -908,6 +927,7 @@ char *tcp_serveraddr ()
char *tcp_serverhost ()
{
if (!myServerHost) { /* once-only */
+ char buf[NI_MAXHOST];
size_t sadrlen;
struct sockaddr *sadr = ip_newsockaddr (&sadrlen);
/* get stdin's name */
@@ -915,7 +935,7 @@ char *tcp_serverhost ()
myServerHost = cpystr (mylocalhost ());
else { /* get stdin's name */
myServerHost = tcp_name (sadr,NIL);
- if (!myServerAddr) myServerAddr = cpystr (ip_sockaddrtostring (sadr));
+ if (!myServerAddr) myServerAddr = cpystr (ip_sockaddrtostring(sadr,buf));
if (myServerPort < 0) myServerPort = ip_sockaddrtoport (sadr);
}
fs_give ((void **) &sadr);
@@ -953,7 +973,7 @@ char *tcp_canonical (char *name)
mm_log (host,TCPDEBUG);
}
/* get canonical name */
- if (!ip_nametoaddr (name,NIL,NIL,&ret,NIL)) ret = name;
+ if (!ip_nametoaddr (name,NIL,NIL,&ret,NIL,NIL)) ret = cpystr (name);
(*bn) (BLOCK_NONSENSITIVE,data);
(*bn) (BLOCK_NONE,NIL); /* alarms OK now */
if (tcpdebug) mm_log ("DNS canonicalization done",TCPDEBUG);
@@ -968,8 +988,8 @@ char *tcp_canonical (char *name)
char *tcp_name (struct sockaddr *sadr,long flag)
{
- char *ret,*t,adr[MAILTMPLEN],tmp[MAILTMPLEN];
- sprintf (ret = adr,"[%.80s]",ip_sockaddrtostring (sadr));
+ char *ret,*t,adr[MAILTMPLEN],tmp[MAILTMPLEN],buf[NI_MAXHOST];
+ sprintf (ret = adr,"[%.80s]",ip_sockaddrtostring (sadr,buf));
if (allowreversedns) {
blocknotify_t bn = (blocknotify_t)mail_parameters(NIL,GET_BLOCKNOTIFY,NIL);
void *data;
@@ -980,7 +1000,7 @@ char *tcp_name (struct sockaddr *sadr,long flag)
(*bn) (BLOCK_DNSLOOKUP,NIL);/* quell alarms */
data = (*bn) (BLOCK_SENSITIVE,NIL);
/* translate address to name */
- if (t = tcp_name_valid (ip_sockaddrtoname (sadr))) {
+ if (t = tcp_name_valid (ip_sockaddrtoname (sadr,buf))) {
/* produce verbose form if needed */
if (flag) sprintf (ret = tmp,"%s %s",t,adr);
else ret = t;
@@ -1023,18 +1043,23 @@ long tcp_isclienthost (char *host)
int family;
size_t adrlen,sadrlen,len;
void *adr,*next;
+ char buf[NI_MAXHOST];
struct sockaddr *sadr;
+ void *cleanup = NIL;
long ret = NIL;
/* make sure that myClientAddr is set */
- if (tcp_clienthost () && myClientAddr)
+ if (tcp_clienthost () && myClientAddr) {
/* get sockaddr of client */
- for (adr = ip_nametoaddr (host,&adrlen,&family,NIL,&next); adr && !ret;
- adr = ip_nametoaddr (NIL,&adrlen,&family,NIL,&next)) {
+ for (adr = ip_nametoaddr (host,&adrlen,&family,NIL,&next,&cleanup);
+ adr && !ret;
+ adr = ip_nametoaddr (NIL,&adrlen,&family,NIL,&next,&cleanup)) {
/* build sockaddr of given address */
sadr = ip_sockaddr (family,adr,adrlen,1,&len);
- if (!strcmp (myClientAddr,ip_sockaddrtostring (sadr))) ret = LONGT;
+ if (!strcmp (myClientAddr,ip_sockaddrtostring (sadr,buf))) ret = LONGT;
fs_give ((void **) &sadr); /* done with client sockaddr */
}
+ ip_nametoaddr (NIL,NIL,NIL,NIL,NIL,&cleanup);
+ }
return ret;
}