bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exim4 problems


From: Thomas Schwinge
Subject: Re: Exim4 problems
Date: Tue, 17 May 2011 01:03:18 +0200
User-agent: Notmuch/0.5-77-g335dd52 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu)

Hallo!

On Tue, 17 May 2011 00:42:12 +0200, Svante Signell <svante.signell@telia.com> 
wrote:
> On Tue, 2011-05-17 at 00:13 +0200, Thomas Schwinge wrote:
> > > static int rda_exists(uschar *filename, uschar **error)
> > 
> > Please continue here: what is this function doing?  (You didn't past that
> > one.)  Does it make sense what it is doing if filename == NULL -- if
> > we're assuming that is a valid thing to happen?  (Which I can't tell
> > either, but it may be valid.)
> 
> Below is the description:
> 
> /*************************************************
> *         Check for existence of file            *
> *************************************************/
> 
> /* First of all, we stat the file. [...]

> Argument:
>   filename   the file name
>   error      for message on error
> 
> Returns:     FILE_EXIST          the file exists
>              FILE_NOT_EXIST      the file does not exist
>              FILE_EXIST_UNCLEAR  cannot determine existence
> */
> static int
> rda_exists(uschar *filename, uschar **error)
> {
> int rc, saved_errno;
> uschar *slash;
> struct stat statbuf;
> 
> if ((rc = Ustat(filename, &statbuf)) >= 0) return FILE_EXIST;

(I'm assuming that Ustat uses the C library's stat function.)  If
filename is NULL (and it's still undetermined whether that is supposed to
happen or not, but let's assume that it is what they're meaning to do),
this is likely the reason for the SEGFAULT on GNU/Hurd.  On GNU/Linux you
happen to get ENOENT (or something else), and on Hurd you get a SEGFAULT.
It's not valid to call stat, access, etc. with NULL filename arguments.

What happens if you change the code like this, to catch this issue before
the first Ustat statement, and then rebuild the package?

> static int
> rda_exists(uschar *filename, uschar **error)
> {
> int rc, saved_errno;
> uschar *slash;
> struct stat statbuf;

    if (filename == NULL)
      goto out;

> if ((rc = Ustat(filename, &statbuf)) >= 0) return FILE_EXIST;
> saved_errno = errno;
> 
> Ustrncpy(big_buffer, filename, big_buffer_size - 3);
> [...]
>   *error = string_sprintf("failed to stat %s (%s)", big_buffer,
>     sigalrm_seen? "timeout" : strerror(saved_errno));
>   return FILE_EXIST_UNCLEAR;
>   }
> 
    out:
> *error = string_sprintf("%s does not exist", filename);
> DEBUG(D_route) debug_printf("%s\n", *error);
> return FILE_NOT_EXIST;
> }


Grüße,
 Thomas

Attachment: pgpWETNGSd_e5.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]