Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Administrivia: List Announcement

From: Bernie Cosell <bernie(at)fantasyfarm.com>
Date: Tue May 13 2003 - 15:11:05 EDT


On 13 May 2003 at 10:25, Dave McKinney wrote:

> ... The basic idea is that people are presented with a

> We'll kick this off with the first challenge, which was devised by Aaron

I have to confess that I've not done hardly any C programming in a LOT of years, but there's at least one obvious problem in this little program:

> char *buf1 = malloc(SIZE);
>
> for (i = 0; i <= SIZE && p1[i] != '\0'; i++)

                      ^^^^^^^^^

> buf1[i] = p1[i];

that's clearly off by one and so the loop will run at least one char past the end of buf1, clobbering one byte beyond the end of the chunk of space that got malloc'ed for buf1.

What harm that causes is hard to evaluate, though, isn't it? Doesn't it depend a lot on how a particular C compiler lays things out and how the libraries (in particular, malloc) work and what else the program has been doing?

  /Bernie\

-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com     Pearisburg, VA
    -->  Too many people, too few sheep  <--       
Received on Tue May 13 18:19:53 2003
Do you need help?X

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:07:39 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library