Mail Archives: djgpp/1995/09/04/18:38:19

From: Marc Singer <!sapien!elf>
Subject: Re: Patch for tmpnam() (v2)
To:!sapien!!kunst (Pieter Kunst)
Date: Mon, 4 Sep 1995 11:41:28 -0700 (PDT)
Cc:!sapien!!djgpp (DJGPP List Alias)

According to Pieter Kunst:
> In article <DDMwL1 DOT Iw5 AT jade DOT mv DOT net> Marc Singer <!sapien!elf> writes:
> >Ok.  It isn;t really a `patch'.  Here is a version of tmpname() that
> >does not bomb if $TMP doesn't end with a path separator.
> >
> [rest of code deleted...]
> This code might not work properly with the following sequence:
>     tmpnam();           /* tmp_dir points to getenv() static data buffer */
>     getenv("SOMEVAR");  /* subsequent call to getenv() fills static data */
>     tmpnam();           /* might fail due to static data overwrite */
>                         /* i.e. tmp_dir points to SOMEVAR getenv() result */
> Better make a local copy of the getenv() result.
> Pieter.

I am not sure you understand the code.  The getenv() call will not
clobber the buffer used by tmpnam().  It is true that successive
calls to tmpnam() with NULL parameters will clobber intermediate
results, but this is easily fixed by providing your own buffer.

The GNU compiler (with prototype checking) will not accept the code
you write because tmpnam() requires a parameter.

          Marc Singer       | "... but when you eat this ... pear, you
       elf AT netcom DOT com       |  are rarely aware of the fact that it was
   or  elf AT sapien DOT com       |  ... plucked from the branch of this ... 
< My comments are my own. > |  pear tree." -- Charlie V.

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019