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 ++++++++++++++------- src/dns.cpp | 6 +++++- src/wildcard.cpp | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src') 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; } diff --git a/src/dns.cpp b/src/dns.cpp index 23e1dfcab..0e0f32874 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -731,7 +731,11 @@ DNSInfo DNSRequest::ResultIsReady(DNSHeader &header, int length) int curanswer, o; ResourceRecord rr; unsigned short ptr; - + + /* This is just to keep _FORTIFY_SOURCE happy */ + rr.type = DNS_QUERY_NONE; + rr.rdlength = 0; + if (!(header.flags1 & FLAGS_MASK_QR)) return std::make_pair((unsigned char*)NULL,"Not a query result"); diff --git a/src/wildcard.cpp b/src/wildcard.cpp index eacffcb04..57b1bab48 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -35,7 +35,7 @@ using irc::sockets::MatchCIDR; bool match(const char *str, const char *mask) { - unsigned char *cp, *mp; + unsigned char *cp = NULL, *mp = NULL; unsigned char* string = (unsigned char*)str; unsigned char* wild = (unsigned char*)mask; -- cgit v1.2.3