Skip site navigation (1) Skip section navigation (2)

Re: COPY when 'filename' is a directory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Brent Verner <brent(at)rcfile(dot)org>,Douglas Trainor <trainor(at)uic(dot)edu>, pgsql-bugs(at)postgresql(dot)org,pgsql-patches(at)postgresql(dot)org
Subject: Re: COPY when 'filename' is a directory
Date: 2002-02-24 01:27:47
Message-ID: 27606.1014514067@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-patches
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>   		{
> +       struct stat st;
>   			fp = AllocateFile(filename, PG_BINARY_R);
> ! 			
> !       if (fp == NULL)
>   				elog(ERROR, "COPY command, running in backend with "
>   					 "effective uid %d, could not open file '%s' for "
>   					 "reading.  Errno = %s (%d).",
>   					 (int) geteuid(), filename, strerror(errno), errno);
> +       
> +       fstat(fileno(fp),&st);
> +       if( S_ISDIR(st.st_mode) ){
> +         fclose(fp);
> +         elog(ERROR,"COPY: %s is a directory.",filename);
> +       }

This coding is WRONG.  You do not use fclose() to release a file
opened with AllocateFile.

[ several other instances of same error in patch... ]

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Brent VernerDate: 2002-02-24 01:56:22
Subject: Re: COPY when 'filename' is a directory
Previous:From: Bruce MomjianDate: 2002-02-23 21:45:45
Subject: Re: COPY when 'filename' is a directory

pgsql-patches by date

Next:From: Brent VernerDate: 2002-02-24 01:56:22
Subject: Re: COPY when 'filename' is a directory
Previous:From: Bruce MomjianDate: 2002-02-23 21:49:00
Subject: Re: Cygwin plperl patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group