From 2f0660544b42584f3874a2ac3fa4174b85742e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tvrd=C3=ADk?= Date: Mon, 19 Oct 2015 11:03:16 +0200 Subject: [PATCH] Fix check_file_readability function Thanks to Martin Mares for warning. --- conf/confbase.Y | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/conf/confbase.Y b/conf/confbase.Y index 6780bd83..3bea75ee 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -10,7 +10,7 @@ CF_HDR #define PARSER 1 -#include +#include #include "nest/bird.h" #include "conf/conf.h" @@ -45,8 +45,11 @@ check_u16(unsigned val) static void check_file_readability(const char *file_path) { - if(access(file_path, R_OK) == -1) - cf_error("File %s cannot be open for read: %m", file_path); + FILE *file = fopen(file_path, "r"); + if (file) + fclose(file); + else + cf_error("File '%s' cannot be open for read: %m", file_path); } CF_DECLS