projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into zelgadis_master
[synfig.git]
/
ETL
/
trunk
/
ETL
/
_stringf.h
diff --git
a/ETL/trunk/ETL/_stringf.h
b/ETL/trunk/ETL/_stringf.h
index
dfc4bcf
..
3d0c020
100644
(file)
--- a/
ETL/trunk/ETL/_stringf.h
+++ b/
ETL/trunk/ETL/_stringf.h
@@
-30,9
+30,14
@@
/* === H E A D E R S ======================================================= */
/* === H E A D E R S ======================================================= */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
#include <string>
#include <cstdarg>
#include <cstdlib>
#include <string>
#include <cstdarg>
#include <cstdlib>
+#include <cstdio>
/* === M A C R O S ========================================================= */
/* === M A C R O S ========================================================= */
@@
-58,22
+63,33
@@
_ETL_BEGIN_CDECLS
#define ETL_NO_THROW throw()
#endif
#define ETL_NO_THROW throw()
#endif
+// Prefer prototypes from glibc headers, since defining them ourselves
+// works around glibc security mechanisms
+
#ifdef HAVE_VASPRINTF // This is the preferred method
#ifdef HAVE_VASPRINTF // This is the preferred method
- extern int vasprintf(char **,const char *,va_list)ETL_NO_THROW;
+ #ifndef __GLIBC__
+ extern int vasprintf(char **,const char *,va_list)ETL_NO_THROW;
+ #endif
#else
# ifdef HAVE_VSNPRINTF // This is the secondary method
#else
# ifdef HAVE_VSNPRINTF // This is the secondary method
- extern int vsnprintf(char *,size_t,const char*,va_list)ETL_NO_THROW;
+ #ifndef __GLIBC__
+ extern int vsnprintf(char *,size_t,const char*,va_list)ETL_NO_THROW;
+ #endif
# endif
#endif
#ifdef HAVE_VSSCANF
# endif
#endif
#ifdef HAVE_VSSCANF
-extern int vsscanf(const char *,const char *,va_list)ETL_NO_THROW;
+ #ifndef __GLIBC__
+ extern int vsscanf(const char *,const char *,va_list)ETL_NO_THROW;
+ #endif
#else
#define ETL_NO_VSTRSCANF
#ifdef HAVE_SSCANF
#else
#define ETL_NO_VSTRSCANF
#ifdef HAVE_SSCANF
-extern int sscanf(const char *buf, const char *format, ...)ETL_NO_THROW;
+ #ifndef __GLIBC__
+ extern int sscanf(const char *buf, const char *format, ...)ETL_NO_THROW;
+ #endif
#endif
#endif
#endif
#endif
@@
-91,9
+107,12
@@
vstrprintf(const char *format, va_list args)
#ifdef HAVE_VASPRINTF // This is the preferred method (and safest)
char *buffer;
std::string ret;
#ifdef HAVE_VASPRINTF // This is the preferred method (and safest)
char *buffer;
std::string ret;
- vasprintf(&buffer,format,args);
- ret=buffer;
- free(buffer);
+ int i=vasprintf(&buffer,format,args);
+ if (i>-1)
+ {
+ ret=buffer;
+ free(buffer);
+ }
return ret;
#else
#ifdef HAVE_VSNPRINTF // This is the secondary method (Safe, but bulky)
return ret;
#else
#ifdef HAVE_VSNPRINTF // This is the secondary method (Safe, but bulky)
@@
-198,10
+217,12
@@
dirname(const std::string &str)
break;
if(iter==str.begin())
break;
if(iter==str.begin())
+ {
if (*iter==ETL_DIRECTORY_SEPARATOR)
return "/";
else
return ".";
if (*iter==ETL_DIRECTORY_SEPARATOR)
return "/";
else
return ".";
+ }
return std::string(str.begin(),iter);
}
return std::string(str.begin(),iter);
}