* [PATCH] gcc/c-family/c-cppbuiltin.c: Add two bytes for avoiding memory overflow issue
@ 2014-11-16 15:06 Chen Gang
2014-11-16 15:52 ` Chen Gang
0 siblings, 1 reply; 2+ messages in thread
From: Chen Gang @ 2014-11-16 15:06 UTC (permalink / raw)
To: Joseph S. Myers, rth, Jeff Law; +Cc: gcc-patches List
When 'is_str' is true, need consider about 2 '"' for the extra space, or
will cause memory overflow.
2014-11-16 Chen Gang <gang.chen.5i5j@gmail.com>
* c-family/c-cppbuiltin.c (builtin_define_with_value): Add two
bytes for avoiding memory overflow issue.
---
gcc/c-family/c-cppbuiltin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 8e8cec4..cc3d90b 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -1282,7 +1282,7 @@ builtin_define_with_value (const char *macro, const char *expansion, int is_str)
char *buf;
size_t mlen = strlen (macro);
size_t elen = strlen (expansion);
- size_t extra = 2; /* space for an = and a NUL */
+ size_t extra = 4; /* space for an =, a NUL, and 2 '"' when is_str is true */
if (is_str)
{
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gcc/c-family/c-cppbuiltin.c: Add two bytes for avoiding memory overflow issue
2014-11-16 15:06 [PATCH] gcc/c-family/c-cppbuiltin.c: Add two bytes for avoiding memory overflow issue Chen Gang
@ 2014-11-16 15:52 ` Chen Gang
0 siblings, 0 replies; 2+ messages in thread
From: Chen Gang @ 2014-11-16 15:52 UTC (permalink / raw)
To: Joseph S. Myers, rth, Jeff Law; +Cc: gcc-patches List
Oh, sorry, it is incorrect, original code is already add 2 bytes for it.
Thanks.
On 11/16/2014 10:32 PM, Chen Gang wrote:
> When 'is_str' is true, need consider about 2 '"' for the extra space, or
> will cause memory overflow.
>
> 2014-11-16 Chen Gang <gang.chen.5i5j@gmail.com>
>
> * c-family/c-cppbuiltin.c (builtin_define_with_value): Add two
> bytes for avoiding memory overflow issue.
> ---
> gcc/c-family/c-cppbuiltin.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
> index 8e8cec4..cc3d90b 100644
> --- a/gcc/c-family/c-cppbuiltin.c
> +++ b/gcc/c-family/c-cppbuiltin.c
> @@ -1282,7 +1282,7 @@ builtin_define_with_value (const char *macro, const char *expansion, int is_str)
> char *buf;
> size_t mlen = strlen (macro);
> size_t elen = strlen (expansion);
> - size_t extra = 2; /* space for an = and a NUL */
> + size_t extra = 4; /* space for an =, a NUL, and 2 '"' when is_str is true */
>
> if (is_str)
> {
>
--
Chen Gang
Open share and attitude like air water and life which God blessed
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-16 14:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-16 15:06 [PATCH] gcc/c-family/c-cppbuiltin.c: Add two bytes for avoiding memory overflow issue Chen Gang
2014-11-16 15:52 ` Chen Gang
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).