From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
To: "Łukasz Żak" <lzak@kplabs.pl>
Cc: "newlib@sourceware.org" <newlib@sourceware.org>
Subject: Re: [PATCH] MSP430: Fix message in sbrk.c printing binary character
Date: Thu, 3 Sep 2020 14:02:23 +0100 [thread overview]
Message-ID: <20200903130223.yq62ydnjp4ajpci5@jozef-acer-manjaro> (raw)
In-Reply-To: <AM4PR1001MB1443D8A3FAE5B681AF364412D32C0@AM4PR1001MB1443.EURPRD10.PROD.OUTLOOK.COM>
[-- Attachment #1: Type: text/plain, Size: 558 bytes --]
On Thu, Sep 03, 2020 at 12:14:45PM +0000, Łukasz Żak wrote:
> I would like to point out that this patch is in fact incorrect.
>
> >+ const char * const msg = "Heap and stack collision\n";
> >+ write (1, msg, sizeof (msg) - 1);
>
> As msg is pointer then sizeof(msg) will be the size of pointer and not the length of the actual string literal,
> therefore the write call will capture only the beginning of the message.
Whoops, my mistake, thanks for spotting that.
Fixed in the attached patch.
Thanks,
Jozef
>
> Regards,
> Łukasz Żak
>
[-- Attachment #2: 0001-MSP430-Fix-calculation-of-string-length-in-sbrk.c.patch --]
[-- Type: text/plain, Size: 726 bytes --]
From 32a56f154205b179512cfab2a7523fb855898a8a Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Thu, 3 Sep 2020 14:00:32 +0100
Subject: [PATCH] MSP430: Fix calculation of string length in sbrk.c
---
libgloss/msp430/sbrk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgloss/msp430/sbrk.c b/libgloss/msp430/sbrk.c
index 8e4339f6e..01d13b792 100644
--- a/libgloss/msp430/sbrk.c
+++ b/libgloss/msp430/sbrk.c
@@ -24,7 +24,7 @@ _sbrk (int adj)
if (heap + adj > sp)
{
- const char * const msg = "Heap and stack collision\n";
+ const char msg[] = "Heap and stack collision\n";
write (1, msg, sizeof (msg) - 1);
abort ();
}
--
2.28.0
next prev parent reply other threads:[~2020-09-03 13:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 10:23 Jozef Lawrynowicz
2020-09-03 11:44 ` Corinna Vinschen
2020-09-03 12:14 ` Łukasz Żak
2020-09-03 13:02 ` Jozef Lawrynowicz [this message]
2020-09-04 13:05 ` Corinna Vinschen
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=20200903130223.yq62ydnjp4ajpci5@jozef-acer-manjaro \
--to=jozef.l@mittosystems.com \
--cc=lzak@kplabs.pl \
--cc=newlib@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: link
Be 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).