Date: Mon, 12 Apr 2010 22:49:52 -0700 From: Garrett Cooper <gcooper@FreeBSD.org> To: Tim Kientzle <kientzle@freebsd.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 176831 for review Message-ID: <l2y364299f41004122249q2f5734a7j89be807581e42dac@mail.gmail.com> In-Reply-To: <4BC3EB5B.5070801@freebsd.org> References: <201004121230.o3CCUsIX029146@repoman.freebsd.org> <4BC3EB5B.5070801@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Apr 12, 2010 at 8:56 PM, Tim Kientzle <kientzle@freebsd.org> wrote:
> Garrett Cooper wrote:
>>
>> +FILE*
>> +unpack_file_to_fd(const char *pkg, const char *file)
>> +{
>
> ....
>>
>> + r = archive_read_extract(archive,
>> archive_entry,
>> + EXTRACT_ARCHIVE_FLAGS);
>> + if (r == ARCHIVE_OK) {
>> + if (Verbose)
>> + printf("X - %s\n",
>> + entry_pathname);
>> + fd = fopen(entry_pathname, "r");
>
> This is potentially race-prone. I would suggest instead that
> you:
>
> int fd = open(entry_pathname, O_RDWR | O_CREAT, ...)
> archive_read_data_into_fd(a, fd);
>
> Then rewind the fd and return it. archive_read_extract()
> is handy but it's way overkill for this kind of simple
> operation. I would also put in a simple verification
> that the entry you found is a regular entry:
> archive_entry_filetype(entry) == AE_IFREG
Ok. What does a regular entry correspond to (I assume not a regular file)?
>> + * NOTE: the exit code is 0 / 1 so that this can be fed directly into
>> exit
>> + * when doing piped tar commands for copying hierarchies *hint*, *hint*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?l2y364299f41004122249q2f5734a7j89be807581e42dac>
