[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Mailutils branch, patches-2.2, updated. release-2.2-10-g3edaa0
From: |
Sergey Poznyakoff |
Subject: |
[SCM] GNU Mailutils branch, patches-2.2, updated. release-2.2-10-g3edaa0f |
Date: |
Tue, 05 Oct 2010 13:13:04 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".
http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=3edaa0f6738e29773cc4fa92dd96900c3e4f351e
The branch, patches-2.2 has been updated
via 3edaa0f6738e29773cc4fa92dd96900c3e4f351e (commit)
via 3e13a4112af5136b08c4888f627151baee6a1aee (commit)
from dd13dedfe0580e391e2a082ff9d1ac842292a4eb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3edaa0f6738e29773cc4fa92dd96900c3e4f351e
Author: Sergey Poznyakoff <address@hidden>
Date: Tue Oct 5 15:44:04 2010 +0300
Remove the use of MAXHOSTNAMELEN macro.
* comsat/comsat.c (hostname): Change type.
(comsat_init): Use mu_get_host_name.
* comsat/comsat.h (hostname): Change declaration.
* mailbox/locker.c (lock_dotlock): Use mu_get_host_name.
* mailbox/mutil.c (mu_get_host_name): Rewrite.
* pop3d/pop3d.c (pop3d_mainloop): Remove unnecessary call to
gethostbyname.
* pop3d/pop3d.h (MAXHOSTNAMELEN): Remove definition.
commit 3e13a4112af5136b08c4888f627151baee6a1aee
Author: Sergey Poznyakoff <address@hidden>
Date: Tue Oct 5 15:40:57 2010 +0300
Fix uninitialized variables.
* mailbox/debug.c (mu_debug_print): Initialize ap.
* mailbox/list.c (list_itrctl): Initialize ptr.
* mailbox/mailer.c (send_fragments): Initialize status.
-----------------------------------------------------------------------
Summary of changes:
comsat/comsat.c | 18 ++++++-----
comsat/comsat.h | 2 +-
mailbox/debug.c | 1 +
mailbox/list.c | 1 +
mailbox/locker.c | 20 +++++++-----
mailbox/mailer.c | 2 +-
mailbox/mutil.c | 86 ++++++++++++++++++++++++++++++++++++++++++-----------
pop3d/pop3d.c | 20 ++++--------
pop3d/pop3d.h | 6 ----
9 files changed, 100 insertions(+), 56 deletions(-)
diff --git a/comsat/comsat.c b/comsat/comsat.c
index 82e8056..3fe9e36 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -100,12 +100,8 @@ static const char *comsat_argp_capa[] = {
#define NOT_HERE 1
#define PERMISSION_DENIED 2
-#ifndef MAXHOSTNAMELEN
-# define MAXHOSTNAMELEN 64
-#endif
-
int maxlines = 5;
-char hostname[MAXHOSTNAMELEN];
+char *hostname;
const char *username;
int require_tty;
mu_m_server_t server;
@@ -220,11 +216,17 @@ sig_hup (int sig)
void
comsat_init ()
{
+ int rc;
+
/* Register mailbox formats */
mu_register_all_mbox_formats ();
- gethostname (hostname, sizeof hostname);
-
+ rc = mu_get_host_name (&hostname);
+ if (rc)
+ {
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_get_host_name", NULL, rc);
+ exit (EXIT_FAILURE);
+ }
/* Set signal handlers */
signal (SIGTTOU, SIG_IGN);
signal (SIGCHLD, SIG_IGN);
@@ -586,7 +588,7 @@ main (int argc, char **argv)
if (mu_app_init (&argp, comsat_argp_capa, comsat_cfg_param, argc, argv, 0,
&ind, server))
- exit (1);
+ exit (EXIT_FAILURE);
if (test_mode)
{
diff --git a/comsat/comsat.h b/comsat/comsat.h
index d2a932c..f1aa604 100644
--- a/comsat/comsat.h
+++ b/comsat/comsat.h
@@ -75,7 +75,7 @@ extern time_t overflow_control_interval;
extern time_t overflow_delay_time;
extern int maxlines;
extern const char *username;
-extern char hostname[];
+extern char *hostname;
extern struct daemon_param daemon_param;
void run_user_action (FILE *tty, const char *cr, mu_message_t msg);
diff --git a/mailbox/debug.c b/mailbox/debug.c
index 37f9e47..b595a7f 100644
--- a/mailbox/debug.c
+++ b/mailbox/debug.c
@@ -234,6 +234,7 @@ mu_debug_print (mu_debug_t debug, mu_log_level_t level,
const char *format, ...)
{
va_list ap;
+ va_start (ap, format);
mu_debug_printv (debug, level, format, ap);
va_end (ap);
return 0;
diff --git a/mailbox/list.c b/mailbox/list.c
index f47af25..55802e2 100644
--- a/mailbox/list.c
+++ b/mailbox/list.c
@@ -599,6 +599,7 @@ list_itrctl (void *owner, enum mu_itrctl_req req, void *arg)
/* Replace current element */
if (!arg)
return EINVAL;
+ ptr = itr->cur;
if (req == mu_itrctl_replace)
DESTROY_ITEM (list, ptr);
ptr = itr->cur;
diff --git a/mailbox/locker.c b/mailbox/locker.c
index f752c16..4f0dcf2 100644
--- a/mailbox/locker.c
+++ b/mailbox/locker.c
@@ -704,14 +704,11 @@ destroy_dotlock (mu_locker_t locker)
free (locker->data.dot.nfslock);
}
-#ifndef MAXHOSTNAMELEN
-# define MAXHOSTNAMELEN 256
-#endif
-
static int
lock_dotlock (mu_locker_t locker, enum mu_locker_mode mode)
{
- char host[MAXHOSTNAMELEN + 1] = "localhost";
+ int rc;
+ char *host = NULL;
char pid[11]; /* 10 is strlen(2^32 = 4294967296) */
char now[11];
size_t sz = 0;
@@ -729,8 +726,9 @@ lock_dotlock (mu_locker_t locker, enum mu_locker_mode mode)
/* build the NFS hitching-post to the lock file */
- gethostname (host, sizeof (host));
- host[MAXHOSTNAMELEN] = 0;
+ rc = mu_get_host_name (&host);
+ if (rc)
+ return rc;
snprintf (now, sizeof (now), "%lu", (unsigned long) time (0));
now[sizeof (now) - 1] = 0;
@@ -746,10 +744,14 @@ lock_dotlock (mu_locker_t locker, enum mu_locker_mode
mode)
locker->data.dot.nfslock = malloc (sz);
if (!locker->data.dot.nfslock)
- return ENOMEM;
-
+ {
+ free (host);
+ return ENOMEM;
+ }
+
snprintf (locker->data.dot.nfslock, sz, "%s.%s.%s.%s",
locker->file, pid, now, host);
+ free (host);
fd = open (locker->data.dot.nfslock,
O_WRONLY | O_CREAT | O_EXCL, LOCKFILE_ATTR);
diff --git a/mailbox/mailer.c b/mailbox/mailer.c
index f2786c8..bd64683 100644
--- a/mailbox/mailer.c
+++ b/mailbox/mailer.c
@@ -487,7 +487,7 @@ send_fragments (mu_mailer_t mailer,
struct timeval *delay,
mu_address_t from, mu_address_t to)
{
- int status;
+ int status = 0;
size_t i;
char *msgid = NULL;
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 656a31f..5e2691d 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -291,30 +291,80 @@ mu_cpystr (char *dst, const char *src, size_t size)
return len;
}
+#ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 64
+#endif
+
int
mu_get_host_name (char **host)
{
- char hostname[MAXHOSTNAMELEN + 1];
- struct hostent *hp = NULL;
- char *domain = NULL;
-
- gethostname (hostname, sizeof hostname);
- hostname[sizeof (hostname) - 1] = 0;
-
- if ((hp = gethostbyname (hostname)))
- domain = hp->h_name;
- else
- domain = hostname;
-
- domain = strdup (domain);
-
- if (!domain)
- return ENOMEM;
+ char *hostname = NULL;
+ size_t size = 0;
+ char *p;
- *host = domain;
+ while (1)
+ {
+ if (size == 0)
+ {
+ size = MAXHOSTNAMELEN;
+ p = malloc (size);
+ }
+ else
+ {
+ size_t ns = size * 2;
+ if (ns < size)
+ {
+ free (hostname);
+ return ENOMEM;
+ }
+ size = ns;
+ p = realloc (hostname, size);
+ }
+ if (!p)
+ {
+ free (hostname);
+ return ENOMEM;
+ }
+ hostname = p;
+ hostname[size - 1] = 0;
+ if (gethostname (hostname, size - 1) == 0)
+ {
+ if (!hostname[size - 1])
+ break;
+ }
+ else if (errno != 0 && errno != ENAMETOOLONG && errno != EINVAL
+ && errno != ENOMEM)
+ {
+ int rc = errno;
+ free (hostname);
+ return rc;
+ }
+ }
+ /* Try to return fully qualified host name */
+ if (!strchr (hostname, '.'))
+ {
+ struct hostent *hp = gethostbyname (hostname);
+ if (hp)
+ {
+ size_t len = strlen (hp->h_name);
+ if (size < len + 1)
+ {
+ p = realloc (hostname, len + 1);
+ if (!p)
+ {
+ free (hostname);
+ return ENOMEM;
+ }
+ hostname = p;
+ }
+ strcpy (hostname, hp->h_name);
+ }
+ }
+
+ *host = hostname;
return 0;
-}
+}
/*
* Functions used to convert unix mailbox/user names into RFC822 addr-specs.
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index d0e7b60..75a5fe7 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -226,19 +226,13 @@ pop3d_mainloop (int fd, FILE *infile, FILE *outfile)
/* Prepare the shared secret for APOP. */
{
char *local_hostname;
- local_hostname = mu_alloc (MAXHOSTNAMELEN + 1);
-
- /* Get our canonical hostname. */
- {
- struct hostent *htbuf;
- gethostname (local_hostname, MAXHOSTNAMELEN);
- htbuf = gethostbyname (local_hostname);
- if (htbuf)
- {
- free (local_hostname);
- local_hostname = strdup (htbuf->h_name);
- }
- }
+
+ status = mu_get_host_name (&local_hostname);
+ if (status)
+ {
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_get_host_name", NULL, status);
+ exit (EXIT_FAILURE);
+ }
md5shared = mu_alloc (strlen (local_hostname) + 51);
diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h
index 1c1c7d6..ea773bc 100644
--- a/pop3d/pop3d.h
+++ b/pop3d/pop3d.h
@@ -137,12 +137,6 @@ extern int expire_on_exit;
#include <shadow.h>
#endif
-#ifndef MAXHOSTNAMELEN
-/* Maximum length of a hostname (is this defined somewhere else?). */
-/* MAXHOSTNAMELEN is already defined on Solaris. */
-# define MAXHOSTNAMELEN 64
-#endif
-
#define POP3_ATTRIBUTE_DELE 0x0001
#define POP3_ATTRIBUTE_RETR 0x0010
hooks/post-receive
--
GNU Mailutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Mailutils branch, patches-2.2, updated. release-2.2-10-g3edaa0f,
Sergey Poznyakoff <=