summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2017-11-29 21:17:09 -0600
committerYaakov Selkowitz <yselkowi@redhat.com>2017-11-30 12:09:03 -0600
commit1e43e181c2b4d135e2407b8df1e58ea5c1a9bb82 (patch)
tree837078a0336cc39f5a8b09a63381131768ac2ffe
parent0fd2c9bd1290c84d2160191d105147bf75629411 (diff)
downloadcygnal-1e43e181c2b4d135e2407b8df1e58ea5c1a9bb82.tar.gz
cygnal-1e43e181c2b4d135e2407b8df1e58ea5c1a9bb82.tar.bz2
cygnal-1e43e181c2b4d135e2407b8df1e58ea5c1a9bb82.zip
ssp: add Object Size Checking for stdlib.h
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
-rw-r--r--newlib/libc/include/ssp/stdlib.h30
-rw-r--r--newlib/libc/include/stdlib.h4
-rw-r--r--newlib/libc/ssp/ssp.tex4
3 files changed, 38 insertions, 0 deletions
diff --git a/newlib/libc/include/ssp/stdlib.h b/newlib/libc/include/ssp/stdlib.h
new file mode 100644
index 000000000..d5edb6d09
--- /dev/null
+++ b/newlib/libc/include/ssp/stdlib.h
@@ -0,0 +1,30 @@
+#ifndef _SSP_STDLIB_H_
+#define _SSP_STDLIB_H_
+
+#include <ssp/ssp.h>
+
+#if __SSP_FORTIFY_LEVEL > 0
+__BEGIN_DECLS
+
+__ssp_decl(size_t, mbstowcs, (wchar_t *__buf, const char *__src, size_t __n))
+{
+ if (__buf != NULL)
+ __ssp_check(__buf, __n * sizeof(wchar_t), __ssp_bos);
+ return __ssp_real_mbstowcs (__buf, __src, __n);
+}
+
+__ssp_redirect_raw(size_t, wcstombs, \
+ (char *__buf, const wchar_t *__src, size_t __len), \
+ (__buf, __src, __len), __buf != NULL, __ssp_bos);
+
+__ssp_decl(int, wctomb, (char *__buf, wchar_t __wc))
+{
+ if (__buf != NULL)
+ __ssp_check(__buf, MB_CUR_MAX, __ssp_bos);
+ return __ssp_real_wctomb (__buf, __wc);
+}
+
+__END_DECLS
+
+#endif /* __SSP_FORTIFY_LEVEL > 0 */
+#endif /* _SSP_STDLIB_H_ */
diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index af5bfecf1..c3c591d20 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -334,4 +334,8 @@ _Noreturn void
_END_STD_C
+#if __SSP_FORTIFY_LEVEL > 0
+#include <ssp/stdlib.h>
+#endif
+
#endif /* _STDLIB_H_ */
diff --git a/newlib/libc/ssp/ssp.tex b/newlib/libc/ssp/ssp.tex
index f8440bdf9..b30ecf159 100644
--- a/newlib/libc/ssp/ssp.tex
+++ b/newlib/libc/ssp/ssp.tex
@@ -39,6 +39,10 @@ fgets fread_unlocked sprintf
fgets_unlocked gets vsnprintf
fread snprintf vsprintf
+@exdent @emph{Stdlib functions:}
+mbstowcs wcstombs wctomb
+
@exdent @emph{System functions:}
getcwd read readlink
+
@end example