From 715984299881265e3659c412d68139255d8c64e7 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 19 Nov 2006 00:43:35 +0000 Subject: Fix all the _FORTIFY_SOURCE warnings except "punned pointer". We CANNOT fix this, as it is the recommended (and only) way to dlsym a symbol from a .so file. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5770 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/configreader.cpp') diff --git a/src/configreader.cpp b/src/configreader.cpp index c854d2ec4..71fd9e6b9 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1310,7 +1310,7 @@ int ServerConfig::ConfVarEnum(ConfigDataHash &target, const std::string &tag, in */ bool ServerConfig::ReadFile(file_cache &F, const char* fname) { - FILE* file; + FILE* file = NULL; char linebuf[MAXBUF]; F.clear(); @@ -1334,8 +1334,10 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname) { while (!feof(file)) { - fgets(linebuf, sizeof(linebuf), file); - linebuf[strlen(linebuf)-1] = 0; + if (fgets(linebuf, sizeof(linebuf), file)) + linebuf[strlen(linebuf)-1] = 0; + else + *linebuf = 0; if (!feof(file)) { @@ -1399,12 +1401,14 @@ bool ServerConfig::DirValid(const char* dirandfile) if (getcwd(buffer, MAXBUF ) == NULL ) return false; - chdir(work); + if (chdir(work) == -1) + return false; if (getcwd(otherdir, MAXBUF ) == NULL ) return false; - chdir(buffer); + if (chdir(buffer) == -1) + return false; size_t t = strlen(work); @@ -1451,12 +1455,15 @@ std::string ServerConfig::GetFullProgDir(char** argv, int argc) if (getcwd(buffer, MAXBUF) == NULL) return ""; - chdir(work); + if (chdir(work) == -1) + return ""; if (getcwd(otherdir, MAXBUF) == NULL) return ""; - chdir(buffer); + if (chdir(buffer) == -1) + return ""; + return otherdir; } -- cgit v1.3.1-10-gc9f91