Improve sprintf usage.

Stop passing UDT's through (...) even in meta programs.
Fixes #5958.
Refs #5835.


[SVN r74897]
This commit is contained in:
John Maddock
2011-10-10 15:46:07 +00:00
parent 852bc502cf
commit f04f7605ce
4 changed files with 40 additions and 7 deletions

View File

@ -847,10 +847,16 @@ bool iswild(const char* mask, const char* name)
unsigned _fi_attributes(const char* root, const char* name)
{
char buf[MAX_PATH];
// verify that we can not overflow:
if(std::strlen(root) + std::strlen(_fi_sep) + std::strlen(name) >= MAX_PATH)
return 0;
int r;
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
(std::sprintf)(buf, "%s%s", root, name);
r = (std::sprintf)(buf, "%s%s", root, name);
else
(std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
if(r < 0)
return 0; // sprintf failed
DIR* d = opendir(buf);
if(d)
{