All of lore.kernel.org
 help / color / mirror / Atom feed
* SIGSEGV in resolving hostname
@ 2006-10-22 17:44 Benoit DOLEZ
  0 siblings, 0 replies; 3+ messages in thread
From: Benoit DOLEZ @ 2006-10-22 17:44 UTC (permalink / raw)
  To: mlmmj

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

Hi,

When there is not reverse for the hostname, the gethostbyname return 
NULL. There is no check of the return value in the function 
hostnamestr() (strgen:144). Because of the SIGSEGV generated, the normal 
might not working.

Here you can find a patch, the hostname is used in the HELO part. It 
might be interesting to specify the hostname in the config, for the 
moment, I had a patch that use the non reversed hostname if the 
hostnamestr return NULL.

Under Slakware, the hostname command return the first part of the FQDN 
hostname.

Benoit

-- 
Benoit DOLEZ
GSM: +33 6 21 05 91 69                mailto:bdolez@ant-computing.com

[-- Attachment #2: mlmmj-hostname-no-reverse.patch --]
[-- Type: text/x-patch, Size: 1321 bytes --]

diff -r -u mlmmj-1.2.12-RC4/src/mlmmj-send.c mlmmj-1.2.12-RC4-flx0.1/src/mlmmj-send.c
--- mlmmj-1.2.12-RC4/src/mlmmj-send.c	2006-06-21 23:50:48.000000000 +0200
+++ mlmmj-1.2.12-RC4-flx0.1/src/mlmmj-send.c	2006-10-22 19:23:19.000000000 +0200
@@ -326,7 +326,19 @@
 	int retval = 0;
 	char *reply = NULL;
 	char *myhostname = hostnamestr();
-	
+
+        if (!myhostname) {
+              char tmp[256];
+              if (gethostname(tmp, 256) != 0) {
+                   perror("FATAL: gethostname()");
+                   exit(1);
+              }
+              if (!(myhostname = mystrdup(tmp))) {
+                   perror("FATAL: mystrdup()");
+                   exit(1);
+              }
+        }      
+
 	init_sockfd(sockfd, relayhost, port);
 	
 	if((reply = checkwait_smtpreply(*sockfd, MLMMJ_CONNECT)) != NULL) {
diff -r -u mlmmj-1.2.12-RC4/src/strgen.c mlmmj-1.2.12-RC4-flx0.1/src/strgen.c
--- mlmmj-1.2.12-RC4/src/strgen.c	2006-09-03 14:11:14.000000000 +0200
+++ mlmmj-1.2.12-RC4-flx0.1/src/strgen.c	2006-10-22 19:16:08.000000000 +0200
@@ -144,7 +144,7 @@
         hostname[sizeof(hostname)-1] = '\0';
         hostlookup = gethostbyname(hostname);
 
-        return mystrdup(hostlookup->h_name);
+        return (hostlookup ? mystrdup(hostlookup->h_name) : NULL);
 }
 
 char *mydirname(const char *path)

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: SIGSEGV in resolving hostname
@ 2006-11-06 20:08 Morten K. Poulsen
  0 siblings, 0 replies; 3+ messages in thread
From: Morten K. Poulsen @ 2006-11-06 20:08 UTC (permalink / raw)
  To: mlmmj


Hi Benoit,

Benoit DOLEZ <bdolez@ant-computing.com> wrote:
> When there is not reverse for the hostname, the
> gethostbyname return NULL. There is no check of
> the return value in the function hostnamestr()
> (strgen:144). Because of the SIGSEGV generated,
> the normal might not working.

Thanks for your patch. I will merge it after the release of mlmmj-1.2.12.

Morten

-- 
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/


^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: SIGSEGV in resolving hostname
@ 2006-12-06 13:41 Morten K. Poulsen
  0 siblings, 0 replies; 3+ messages in thread
From: Morten K. Poulsen @ 2006-12-06 13:41 UTC (permalink / raw)
  To: mlmmj


Hi Benoit,

Benoit DOLEZ <bdolez@ant-computing.com> wrote:
> When there is not reverse for the hostname, the gethostbyname return
> NULL. There is no check of the return value in the function
> hostnamestr() (strgen:144). Because of the SIGSEGV generated, the normal
> might not working.

Thanks for your patch.

I've moved the code into hostnamestr() and used the opportunity to remove the static buffer from the function.

The patch, with my changes, is available here:

http://mlmmj.mmj.dk/~mortenp/patch-mlmmj-1.2.12-hostnamestr.diff

It will be included in the next release of mlmmj.


Morten

-- 
Morten K. Poulsen <morten@afdelingp.dk>
http://www.afdelingp.dk/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-12-06 13:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-22 17:44 SIGSEGV in resolving hostname Benoit DOLEZ
  -- strict thread matches above, loose matches on Subject: below --
2006-11-06 20:08 Morten K. Poulsen
2006-12-06 13:41 Morten K. Poulsen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.