gen_init_cpio: Avoid race between call to stat() and call to open()
authorJesper Juhl <jj@chaosbits.net>
Fri, 24 Dec 2010 20:28:56 +0000 (21:28 +0100)
committerMichal Marek <mmarek@suse.cz>
Wed, 29 Dec 2010 14:06:54 +0000 (15:06 +0100)
In usr/gen_init_cpio.c::cpio_mkfile() a call to stat() is made based on
pathname, subsequently the file is open()'ed and then the value of the
initial stat() call is used to allocate a buffer. This is not safe since
the file may change between the call to stat() and the call to open().
Safer to just open() the file and then do fstat() using the filedescriptor
returned by open.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>

No differences found