Follow us on Twitter!
Never in the field of human conflict was so much owed by so many to so few. - Winston Churchill
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 25
Guests Online: 20
Members Online: 5

Registered Members: 82895
Newest Member: kevy90
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Just out of curiosity

ellipsis
Member



Posts: 173
Location:
Joined: 13.06.09
Rank:
Uber Elite
Posted on 29-07-10 00:36
The following code prints all environment variables among other things..

Can someone please elaborate to me why that is?

Code

#include <iostream>
using namespace std;

string * GetArray()
{
    string asdf[3] = { "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" };
    return(asdf);
}

void foo(string array[], int size)
{
//    for (int i = size; i >= 0; i--)  /* for a different exception */
        cout << array[1] << endl;
}

int main()
{
    string * array = GetArray();
    foo(array, 2); // <-- required for error
   
    return(0);
}






10000101
Author

RE: Just out of curiosity


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-07-10 02:28
It's full of errors and won't compile. Besides, you're returning the address of a local variable. When you get out of the function, we're not sure what the pointer is pointing to. if I were you, I'd disassemble it and look at the value dereferenced by the pointer after the function call completes. Maybe it's a list of environment variables?

Edited by on 29-07-10 02:34
Author

RE: Just out of curiosity

hellboundhackersok
Member



Posts: 353
Location:
Joined: 20.09.07
Rank:
Moderate
Warn Level: 95
Posted on 29-07-10 08:11
ellipsis wrote:
The following code prints all environment variables among other things..

Can someone please elaborate to me why that is?


It doesn't.


i.imgur.com/qBWHo0R.png