7
Koolstr
7y

I've just noticed, the rest of the world says things like "your check is null and void," as if those two things are one and the same.

Meanwhile, to us devs, they couldn't be any more different! Something can't be both null AND void! 😅

Comments
  • 0
    On the other hand, what's the return value of a void function
  • 0
    @Forside huh. That's a pretty good point... 🤔
  • 1
    @Forside a void function does not have a return value, whereas a null pointer is used when there's a possibility of a value, but you don't have a value at that time.
  • 1
    @Bikonja Not entirely true. Although they are not supposed to have a return value, internally a return value is nothing but what's stored at EAX. In C you can cast a void function to another deceleration so it becomes something returning an int for example. The return value will be, what's last stored to EAX inside the function.
  • 1
    @Forside that's a good point, but still, void is not a thing in assembler and registers are not a thing in C (afaik) so within the context of C, where void exists, there's still the difference, even though at assembler level you can get around that and nullify (no pun intended :)) the difference between the two
  • 1
    @Bikonja Also a good point. void is nothing but an instruction for the compiler, so it knows it should not look for a return value. I like C so much because of its low level capabilities like accessing and manipulating registers. We once had a task in class where the program should skip a line after a function call by manipulating the return address of the called function. Was supposed to be done by using the address of a variable inside the function to find the address of the return address. I thought fuck it and used an asm command to directly override the return address by using the esp (or ebp? Not sure anymore) register. Was fun.
  • 1
    @Forside sounds awesome :)
  • 2
    @Forside I like the intelligent discussion I've catalyzed. Oddly, I just took my operating systems class final a few days ago, and the first question on it was exactly on what you did. To take advantage of the buffer overflow exploit, you overwrite the esp register, that is correct. It's changing what's on the stack pointer, hence a stack overflow.
Add Comment