Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Feb 2001 04:23:49 +0100
From:      Andrea Campi <andrea@webcom.it>
To:        Brian Somers <brian@Awfulhak.org>
Cc:        domi@saargate.de, freebsd-current@freebsd.org
Subject:   Re: Strange fopen() behaviour (was: xsane patch to maintainer)
Message-ID:  <20010206042348.A9639@webcom.it>
In-Reply-To: <200102060319.f163J2610146@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Tue, Feb 06, 2001 at 03:19:01AM %2B0000
References:  <brian@Awfulhak.org> <200102060319.f163J2610146@hak.lan.Awfulhak.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> lstat("/tmp//preview-level-0-15-b924dc",0xbfbfe894) ERR#2 'No such file or directory'
             ^^

surely this is not nice!! My guess is that the double slash is confusing
everything...

Anyway, I'm more interested in below:

> @@ -2830,9 +2831,17 @@
>      if (preview_make_image_path(p, sizeof(filename), filename, i)>=0)
>      {
>        umask(0177);			/* create temporary file with "-rw-------" permissions */
> -      fclose(fopen(filename, "wb"));	/* make sure file exists, b = binary mode for win32 */
> -      umask(XSANE_DEFAULT_UMASK);	/* define new file permissions */
> -      p->filename[i] = strdup(filename);/* store filename */
> +      fp = fopen(filename, "wb");	/* make sure file exists, b = binary mode for win32 */
> +      if (fp == NULL) {
> +        fprintf(stderr, "%s: could not create for preview-level %d: %s\n", filename, i, strerror(errno));
> +        p->filename[i] = NULL;
> +      }
> +      else
> +      {
> +        fclose(fp);
> +        umask(XSANE_DEFAULT_UMASK);	/* define new file permissions */
> +        p->filename[i] = strdup(filename);/* store filename */
> +      }


I REALLY hope above code is NEVER EVER run as root, as this is a great
recipe for interesting failures...

/me hands Brian a few symlinks to /etc/master.passwd from /tmp

If you are patching it, make sure you get it right, you'd do
everybody a big favor.

Bye,
	Andrea

-- 
            It is easier to fix Unix than to live with NT.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010206042348.A9639>