PERFORCE change 176831 for review

Garrett Cooper gcooper at FreeBSD.org
Tue Apr 13 05:49:55 UTC 2010


On Mon, Apr 12, 2010 at 8:56 PM, Tim Kientzle <kientzle at 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*


More information about the p4-projects mailing list