[Coco] getenv bug in cgfx explanation

Gene Heskett gene.heskett at verizon.net
Sat Dec 12 10:45:06 EST 2009


On Saturday 12 December 2009, Willard Goosey wrote:
>Humm, doing this backwards...
>
>Anyway, the bug in the cgfx7 getenv() is that it does a
>shortest-substring match on the request variable name.  The easiest
>way to demonstrate:
>getenv("PALET10") returns the value of PALET1.  Indeed,
>getenv("PALET75") returns the value of PALET7!
>
>New version fixes that by using a string-compare limited by the length
>of the name it's searching for, not the length of the name we're
>checking.
>
>I am really amazed that no-one's caught this before.
>
>I am equally befuddled by how best to distribute this.
>
>And I appologize for the tone of my last message.  I was... slightly
>annoyed... but some food made it much better. :-)
>
>Willard

Thank you very much Willard.  For those who would like a copy of his original 
email, I've placed it in the 3rdparty tree of the nitros9 link on my web 
page, commented such that it should compile, as cgfx7-fix.c.

20 minutes later, after I've cleaned it up by adding older c style
/*
 *
 *
 */
comments and renamed it to cgfx7-fix.c so it could be fed directly to the os9 
compiler, I see that question is moot since there is only one 'lib' in the 
whole tree, alib.

I think I have the tools yet to do this on my coco3.  Stay tuned.  If 
successful, I will put the fixed cgfx7.l in that 3rdparty/lib tree.

As for your comment re there being 3 copies of the mouse in there, I would 
suspect they are all identical, and this is caused by c.link only making one 
pass over the library(s) looking for dependencies.  Because it is difficult 
to predict backward dependency's, I have been forced to add 2nd copies of 
stuff in the libraries I built back then myself, trig.l in particular.  Maybe 
we should redo c.link to make another pass, say up to 3, over all the 
libraries given if at the eof of the current pass, there are still un-
resolved dependencies?  (Note, it will make more passes if the library to be 
linked from is named more than once too) If after 3 passes it hasn't been 
found, it likely is a real error and never will be, report it and die.

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
The NRA is offering FREE Associate memberships to anyone who wants them.
<https://www.nrahq.org/nrabonus/accept-membership.asp>

"Today, of course, it is considered very poor taste to use the F-word
except in major motion pictures."
		-- Dave Barry, "$#$%#^%!^%&@%@!"



More information about the Coco mailing list