IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Running past end
It looks to me like that weird for loop is running you past the end of the string you get and into the next.

The environment variables are probably held one after another in memory, like this "value0another0this0" with the 0 terminator between them. The for loop is trying to find an "=" sign in the environment variable, probably because the original code expects something like "chars=aeiou." But when it doesn't find one it just pushes past the end, and you end up reading the next environment variable when you print the string.

Just a guess, I don't have time to test that theory right now.

Jay
New CGI Shell hack
I snooped around his site a bit, and it looks like he's using the easiest hack he could to pass the information into his program.

The HTML front is using a GET to pass the information to the CGI shell, so it arrives like this "key=whatever" and he's just sticking the whole thing into an environment variable. This means at the Unix Shell level he has "QUERY_STRING=key=whatever" so when he gets the value of QUERY_STRING he has to throw out the first bit to get just the characters.

I was basically right about why this causes it to read the next variable. Unix environment values are stored in an array of pointers to strings. If the strings end up in the simplest configuration, one after another, you will end up with "key=value0another=something0and=soon0" in the shell memory. C will gladly let you read past the end of a string into the next bit of memory, which will read into the next environment variable 99.99% of the time.

He tries to test of any empty string where he has query_string in the for loop. But I think he needs to be using *query_string here because he wants to test the value of what is being pointed to not the value of the pointer.

Jay
New That all makes sense
I gues sit kinda shows that it was done in 1996, when the whole idea was relatively new. Regardless, the new de-crapped version of the program works a treat, solves the word puzzles easily, though only once so far has been able to get more answers than I have. It's heaps faster than I am, though :)

On and on and on and on,
and on and on and on goes John.
     Is it me or is it Tru64? - (Meerkat) - (7)
         Um. Do a man getenv. - (static) - (2)
             Well I did say I wasn't a C coder. - (Meerkat) - (1)
                 Yeah, that's what I thought. - (static)
         Running past end - (JayMehaffey) - (2)
             CGI Shell hack - (JayMehaffey) - (1)
                 That all makes sense - (Meerkat)
         Please tell me Tru64 doesn't have that whacked a getenv. - (wharris2)

Same LRPD time, same LRPD channel.
40 ms