Go to Post It is an honor and a privilege to be associated with such an outstanding group of people. And Arefin. - Gary Dillard [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 08-03-2004, 01:34
WizardOfAz's Avatar
WizardOfAz WizardOfAz is offline
Lead Mentor
AKA: Bill Bennett
FRC #1011 (CRUSH)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Tucson, AZ
Posts: 101
WizardOfAz will become famous soon enough
Send a message via AIM to WizardOfAz
printf bug - beware!

Well, perhaps not exactly a bug, but at minimum, a land mine.

If you code
prinft("some long string of more than 80 bytes.....\n");
you'll likely begin to have errors elsewhere in your program that are hard to explain or find. This is because the "long string" is copied from program memory (where the compiler puts constant strings) to a ram buffer of 80 bytes, but no length checking is done on the source string. If it exceeds the size of the targer buffer, it is copied in its entirety anyway, trampling other variables in the process.

I modified IFI's printf_lib.c to check for this problem and print an error rather than trampling memory. Anyone who wants the source, I'll be happy to share it.

If you don't want my fix and don't want to do your own, at least be warned that long print strings can lead to really hard to find bugs.....

Bill
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
printf and newlines Jeff McCune Programming 5 21-02-2004 21:09
Printf warning during compile? actorindp Programming 4 20-02-2004 17:02
printf isn't printf-ing. Help! Meandmyself Programming 14 15-02-2004 16:27
clear printf box? telefragger2000 Programming 6 05-02-2004 17:40
Last Call for bug reports rbayer Programming 0 08-01-2003 02:48


All times are GMT -5. The time now is 22:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi