[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r10819 - trunk/subversion/libsvn_subr

From: Peter N. Lundblad <peter_at_famlundblad.se>
Date: 2004-09-08 09:51:00 CEST

On Sun, 5 Sep 2004 bliss@tigris.org wrote:

> Author: bliss
> Date: Sun Sep 5 10:32:02 2004
> New Revision: 10819
>
> Modified:
> trunk/subversion/libsvn_subr/cmdline.c
> Log:
> Prevent severe database corruption and other horrors on unix systems
> if e.g. svnadmin is run with it's standard input, standard output or
> standard error file descriptors closed.
>
> * subversion/libsvn_subr/cmdline.c
> (svn_cmdline_init): Open '/dev/null' for standard input, output and
> error if they are closed.
>
>
> Modified: trunk/subversion/libsvn_subr/cmdline.c
> Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/libsvn_subr/cmdline.c?view=diff&rev=10819&p1=trunk/subversion/libsvn_subr/cmdline.c&r1=10818&p2=trunk/subversion/libsvn_subr/cmdline.c&r2=10819
> ==============================================================================
> --- trunk/subversion/libsvn_subr/cmdline.c (original)
> +++ trunk/subversion/libsvn_subr/cmdline.c Sun Sep 5 10:32:02 2004
...
> svn_cmdline_init (const char *progname, FILE *error_stream)
> {
> apr_status_t status;
> +
> +#ifndef WIN32
> + {
> + struct stat st;
> +
> + /* The following makes sure that file descriptors 0 (stdin), 1
> + (stdout) and 2 (stderr) will not be "reused", because if
> + e.g. file descriptor 2 would be reused when opening a file, a
> + write to stderr would write to that file and most likely
> + corrupt it. */
> + if (fstat (0, &st) == -1)
> + open ("/dev/null", O_RDONLY);

Errors here should be rare, but to be sure, shouldn't you bail out on
errors?

//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Sep 8 20:41:43 2004

This is an archived mail posted to the Subversion Dev mailing list.