summaryrefslogtreecommitdiff
path: root/lib/fopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fopen.c')
-rw-r--r--lib/fopen.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/lib/fopen.c b/lib/fopen.c
index 72610bd9b4..781ce2c50d 100644
--- a/lib/fopen.c
+++ b/lib/fopen.c
@@ -68,35 +68,35 @@ rpl_fopen (const char *filename, const char *mode)
size_t len = strlen (filename);
if (len > 0 && filename[len - 1] == '/')
{
- int fd;
- struct stat statbuf;
- FILE *fp;
-
- if (mode[0] == 'w' || mode[0] == 'a')
- {
- errno = EISDIR;
- return NULL;
- }
-
- fd = open (filename, O_RDONLY);
- if (fd < 0)
- return NULL;
-
- if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
- {
- close (fd);
- errno = ENOTDIR;
- return NULL;
- }
-
- fp = fdopen (fd, mode);
- if (fp == NULL)
- {
- int saved_errno = errno;
- close (fd);
- errno = saved_errno;
- }
- return fp;
+ int fd;
+ struct stat statbuf;
+ FILE *fp;
+
+ if (mode[0] == 'w' || mode[0] == 'a')
+ {
+ errno = EISDIR;
+ return NULL;
+ }
+
+ fd = open (filename, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+
+ if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
+ {
+ close (fd);
+ errno = ENOTDIR;
+ return NULL;
+ }
+
+ fp = fdopen (fd, mode);
+ if (fp == NULL)
+ {
+ int saved_errno = errno;
+ close (fd);
+ errno = saved_errno;
+ }
+ return fp;
}
}
# endif