]> git.armaanb.net Git - opendoas.git/commitdiff
persist_timestamp: create timestamp file with O_NOFOLLOW and don't leak the name
authorDuncaen <mail@duncano.de>
Tue, 12 Dec 2017 15:42:11 +0000 (16:42 +0100)
committerDuncaen <mail@duncano.de>
Tue, 12 Dec 2017 15:44:48 +0000 (16:44 +0100)
persist_timestamp.c

index c30b8f350947dffe1eaa3ab92dc22a257dac8e3f..81ea273ce4f0fe4d54c4705eb54845083972ea51 100644 (file)
@@ -262,11 +262,12 @@ persist_open(int *valid, int secs)
 
        if ((fd = openat(dirfd, name, (O_RDWR), (S_IRUSR|S_IWUSR))) == -1)
                if (errno != ENOENT)
-                       err(1, "open: %s", name);
+                       err(1, "open timestamp file");
 
        if (fd == -1) {
-               if ((fd = openat(dirfd, name, (O_RDWR|O_CREAT|O_EXCL), (S_IRUSR|S_IWUSR))) == -1)
-                       err(1, "open: %s", name);
+               if ((fd = openat(dirfd, name, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW),
+                   (S_IRUSR|S_IWUSR))) == -1)
+                       err(1, "open timestamp file");
        }
 
        size_t tssize;