summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2017-02-08 04:14:13 +0000
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2017-02-08 04:14:13 +0000
commitcaf54ef23c3d2c6bd568bc9a10e668e6982d909e (patch)
tree8294fe26321e16d8f406ca8ce4bc4cd23b47a6b4
parent0912f6890925a9e9aa552fb841f9162ea6bd3d70 (diff)
downloadgcompat-caf54ef23c3d2c6bd568bc9a10e668e6982d909e.tar.gz
gcompat-caf54ef23c3d2c6bd568bc9a10e668e6982d909e.tar.bz2
gcompat-caf54ef23c3d2c6bd568bc9a10e668e6982d909e.tar.xz
gcompat-caf54ef23c3d2c6bd568bc9a10e668e6982d909e.zip
stdio: Fix __vasprintf_chk and add __sprintf_chk
-rw-r--r--stdio.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/stdio.c b/stdio.c
index bef7ef8..89bd677 100644
--- a/stdio.c
+++ b/stdio.c
@@ -45,6 +45,20 @@ int __fprintf_chk(FILE *stream, int flag, const char *format, ...)
return result;
}
+int __sprintf_chk(char *str, int flag, size_t strlen, const char *format, ...)
+{
+ va_list argp;
+ int result;
+
+ assert(strlen > 0);
+
+ va_start(argp, format);
+ result = vsnprintf(str, strlen, format, argp);
+ va_end(argp);
+
+ return result;
+}
+
int __snprintf_chk(char *str, size_t size, int flag, size_t strlen, const char *format, ...)
{
va_list argp;
@@ -52,7 +66,6 @@ int __snprintf_chk(char *str, size_t size, int flag, size_t strlen, const char *
if(flag > 0)
{
- assert(str != NULL);
assert(format != NULL);
}
// must always be done per LFS
@@ -72,7 +85,6 @@ int __swprintf_chk(wchar_t *wcs, size_t maxlen, int flag, size_t wcslen, const w
if(flag > 0)
{
- assert(wcs != NULL);
assert(format != NULL);
}
// must always be done per LFS
@@ -85,10 +97,13 @@ int __swprintf_chk(wchar_t *wcs, size_t maxlen, int flag, size_t wcslen, const w
return result;
}
-int __vasprintf_chk(char **strp, const char *fmt, va_list ap)
+int __vasprintf_chk(char **strp, int flag, const char *fmt, va_list ap)
{
- assert(strp != NULL);
- assert(fmt != NULL);
+ if(flag > 0)
+ {
+ assert(strp != NULL);
+ assert(fmt != NULL);
+ }
return vasprintf(strp, fmt, ap);
}
@@ -106,7 +121,6 @@ int __vsnprintf_chk(char *str, size_t size, int flag, size_t strlen, const char
{
if(flag > 0)
{
- assert(str != NULL);
assert(format != NULL);
}
// must always be done per LFS