public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Yaakov Selkowitz <yselkowitz@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] ssp: add Object Size Checking for stdlib.h Date: Thu, 30 Nov 2017 18:09:00 -0000 [thread overview] Message-ID: <20171130180914.85999.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1e43e181c2b4d135e2407b8df1e58ea5c1a9bb82 commit 1e43e181c2b4d135e2407b8df1e58ea5c1a9bb82 Author: Yaakov Selkowitz <yselkowi@redhat.com> Date: Wed Nov 29 21:17:09 2017 -0600 ssp: add Object Size Checking for stdlib.h Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com> Diff: --- newlib/libc/include/ssp/stdlib.h | 30 ++++++++++++++++++++++++++++++ newlib/libc/include/stdlib.h | 4 ++++ newlib/libc/ssp/ssp.tex | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/newlib/libc/include/ssp/stdlib.h b/newlib/libc/include/ssp/stdlib.h new file mode 100644 index 0000000..d5edb6d --- /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 af5bfec..c3c591d 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 f8440bd..b30ecf1 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
reply other threads:[~2017-11-30 18:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20171130180914.85999.qmail@sourceware.org \ --to=yselkowitz@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).