Re: Minor patch to correct buffer overrun

Chris Sutcliffe <[email protected]>
Newsgroups gmane.comp.gnu.make.windows
Message-ID <[email protected]>
On 18 August 2010 13:19, Eli Zaretskii wrote:
> Can you explain what exactly was the problem with the original code?
> The value of p was computed earlier as
>
>      p = name + strlen (name);

I added:

        printf("p: %d\n", p - name + 1);

given that was the value originally used:

        memcpy (tem, name, p - name + 1);

when run with the problematic Makefile I supplied earlier, the results
were as follows (all in one run):

p: 2
p: 2
p: 46
p: 20
p: 11
p: 25
p: 43
p: 37
p: 26
p: 29
p: 27
p: 4
p: 5
p: 322
p: 326
p: 327
p: 345
p: 23
p: 27
p: 349
p: 28
p: 350

As you can see, the 259 bytes for 'tem' were significantly exceeded.

Chris

-- 
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.