NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/55815: tar opens device files




> On Jun 5, 2021, at 7:18 AM, Christos Zoulas <christos%zoulas.com@localhost> wrote:
> 
> 
>> 
>> If we’re talking about “ensure the file we’re opening is a regular file”, won’t O_REGULAR do that you want?
> 
> Yes, but that suffers from TOCTOA too:
> 
> if (open(path, O_REGULAR) == -1)
> 	fstat(path, &st);
> 
> But that's probably good enough.

Sorry, I was looking at your example of:

	fd = open(...);
	fstat(...);
	if (device)
		bail;

What's the point if stat'ing the path if opening with O_REGULAR fails?  Isn't the point here to prevent tar from opening device files?

-- thorpej



Home | Main Index | Thread Index | Old Index