Fix compiler warning. Add interfaces of POSIX passwd.h and pwd.h to posix.cfg

This commit is contained in:
Alexander Mai 2015-02-18 20:56:44 +01:00
parent e251a99817
commit 6a7605271a
3 changed files with 115 additions and 9 deletions

View File

@ -739,4 +739,110 @@
<podtype name="sigset_t"/>
<podtype name="termios"/>
<podtype name="intptr_t"/>
<!-- http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pwd.h.html -->
<podtype name="passwd"/>
<!--void endpwent(void); -->
<function name="endpwent">
<noreturn>false</noreturn>
</function>
<!--struct passwd *getpwent(void); -->
<function name="getpwent">
<noreturn>false</noreturn>
<use-retval/>
</function>
<!--struct passwd *getpwnam(const char *); -->
<function name="getpwnam">
<arg nr="1">
<not-uninit/>
</arg>
<noreturn>false</noreturn>
<use-retval/>
</function>
<!--int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); -->
<function name="getpwnam_r">
<arg nr="1">
<not-uninit/>
</arg>
<noreturn>false</noreturn>
<use-retval/>
</function>
<!-- struct passwd *getpwuid(uid_t uid); -->
<function name="getpwuid">
<arg nr="1">
<not-uninit/>
</arg>
<noreturn>false</noreturn>
<use-retval/>
</function>
<!-- int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **); -->
<function name="getpwuid_r">
<noreturn>false</noreturn>
</function>
<!-- void setpwent(void); -->
<function name="setpwent">
<noreturn>false</noreturn>
</function>
<!-- http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/regex.h.html -->
<podtype name="regex_t"/>
<!-- int regcomp(regex_t *restrict, const char *restrict, int); -->
<function name="regcomp">
<noreturn>false</noreturn>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<not-uninit/>
</arg>
<arg nr="3">
<not-uninit/>
</arg>
</function>
<!-- size_t regerror(int, const regex_t *restrict, char *restrict, size_t); -->
<function name="regerror">
<noreturn>false</noreturn>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<not-uninit/>
</arg>
<arg nr="3">
<not-null/>
<not-uninit/>
</arg>
<arg nr="4">
<not-uninit/>
</arg>
</function>
<!-- int regexec(const regex_t *restrict, const char *restrict, size_t, regmatch_t [restrict], int); -->
<function name="regexec">
<noreturn>false</noreturn>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3">
<not-uninit/>
</arg>
<arg nr="4">
<not-uninit/>
</arg>
<arg nr="5">
<not-uninit/>
</arg>
</function>
<!-- void regfree(regex_t *); -->
<function name="regfree">
<noreturn>false</noreturn>
<arg nr="1">
<not-null/>
<not-uninit/>
</arg>
</function>
</def>

View File

@ -328,7 +328,7 @@ static bool checkMinSizes(const std::list<Library::ArgumentChecks::MinSize> &min
else
parameters.push_back(nullptr);
}
const MathLib::bigint len = CheckBufferOverrun::countSprintfLength(formatstr, parameters);
const MathLib::biguint len = CheckBufferOverrun::countSprintfLength(formatstr, parameters);
if (len > arraySize + 2U)
error = true;
} else {
@ -1359,12 +1359,12 @@ void CheckBufferOverrun::bufferOverrun2()
}
//---------------------------------------------------------------------------
MathLib::bigint CheckBufferOverrun::countSprintfLength(const std::string &input_string, const std::list<const Token*> &parameters)
MathLib::biguint CheckBufferOverrun::countSprintfLength(const std::string &input_string, const std::list<const Token*> &parameters)
{
bool percentCharFound = false;
std::size_t input_string_size = 1;
bool handleNextParameter = false;
std::string digits_string = "";
std::string digits_string;
bool i_d_x_f_found = false;
std::list<const Token*>::const_iterator paramIter = parameters.begin();
std::size_t parameterLength = 0;
@ -1457,7 +1457,7 @@ MathLib::bigint CheckBufferOverrun::countSprintfLength(const std::string &input_
}
}
return (MathLib::bigint)input_string_size;
return (MathLib::biguint)input_string_size;
}
@ -1521,7 +1521,7 @@ void CheckBufferOverrun::checkBufferAllocatedWithStrlen()
void CheckBufferOverrun::checkStringArgument()
{
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
std::size_t functions = symbolDatabase->functionScopes.size();
const std::size_t functions = symbolDatabase->functionScopes.size();
for (std::size_t functionIndex = 0; functionIndex < functions; ++functionIndex) {
const Scope * const scope = symbolDatabase->functionScopes[functionIndex];
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
@ -1560,7 +1560,7 @@ void CheckBufferOverrun::checkInsecureCmdLineArgs()
{
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
std::size_t functions = symbolDatabase->functionScopes.size();
const std::size_t functions = symbolDatabase->functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Function * function = symbolDatabase->functionScopes[i]->function;
if (function) {
@ -1653,7 +1653,7 @@ CheckBufferOverrun::ArrayInfo::ArrayInfo(unsigned int id, const std::string &nam
CheckBufferOverrun::ArrayInfo CheckBufferOverrun::ArrayInfo::limit(MathLib::bigint value) const
{
MathLib::bigint uvalue = std::max(MathLib::bigint(0), value);
const MathLib::bigint uvalue = std::max(MathLib::bigint(0), value);
MathLib::bigint n = 1;
for (std::size_t i = 0; i < _num.size(); ++i)
n *= _num[i];
@ -1677,7 +1677,7 @@ void CheckBufferOverrun::arrayIndexThenCheck()
if (Token::Match(tok, "%name% [ %var% ]")) {
tok = tok->tokAt(2);
unsigned int indexID = tok->varId();
const unsigned int indexID = tok->varId();
const std::string& indexName(tok->str());
// skip array index..

View File

@ -80,7 +80,7 @@ public:
* @param parameters given parameters to sprintf
* @return minimum length of resulting string
*/
static MathLib::bigint countSprintfLength(const std::string &input_string, const std::list<const Token*> &parameters);
static MathLib::biguint countSprintfLength(const std::string &input_string, const std::list<const Token*> &parameters);
/** Check for buffer overruns - locate struct variables and check them with the .._CheckScope function */
void checkStructVariable();