mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-28 06:35:34 +07:00
udev: silence TOCTOU warning when creating a directory
CID#979416. There is no real race here to fix, but lets make coverity happy and rework the code. Note that we still fail if the directory is removed _after_ we ran mkdir(), so the same race is still there. Coverity is complaining, though. Rewrite the code to make it happy. (David: rewrote the commit-message to note that this is not a race. If I'm wrong, blame me, not Ronny!) Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
This commit is contained in:
parent
6740579367
commit
9f5d1bc3cd
@ -90,12 +90,12 @@ static void usage(void)
|
||||
*/
|
||||
static int prepare(char *dir, char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
char buf[512];
|
||||
int fd;
|
||||
int r, fd;
|
||||
|
||||
if (stat(dir, &statbuf) < 0)
|
||||
mkdir(dir, 0700);
|
||||
r = mkdir(dir, 0700);
|
||||
if (r < 0 && errno != EEXIST)
|
||||
return -errno;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", dir, filename);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user