]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fix check_file_readability function
authorPavel Tvrdík <pawel.tvrdik@gmail.cz>
Mon, 19 Oct 2015 09:03:16 +0000 (11:03 +0200)
committerPavel Tvrdík <pawel.tvrdik@gmail.cz>
Mon, 19 Oct 2015 09:03:16 +0000 (11:03 +0200)
Thanks to Martin Mares for warning.

conf/confbase.Y

index 6780bd838cca80f04613c3494f33a7ea90dec1fd..3bea75ee9a9bb01ed8d95e12c1acc74190080f0b 100644 (file)
@@ -10,7 +10,7 @@ CF_HDR
 
 #define PARSER 1
 
-#include <unistd.h>
+#include <stdio.h>
 
 #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