As far as my understanding of languages goes, a buffer is any portion of memory in which a data is stored like an int,float variables, character arrays etc. However, I was reading buffer overflows and came across this link while reading about stack http://www.tenouk.com/Bufferoverflowc/Bufferoverflow2a.html The diagram in this link separates buffer from local variables of a function. Is this correct? What's a buffer then?
Very abstract analogy: Local variables are what you're working with right now; they're what you're holding in your hands. A buffer is to a data source as a spoon is to a soup bowl, or a measuring cup is to a water tap. It's more practical to be holding a spoon in your hands than it is to be holding a soup bowl in your hands, and it's virtually impossible to be holding a running stream of water in your hands. In either case, you're using these utensils so that you can consume the soup/water in a pace that suits you.
More concretely, local variables are simply the variables that you've declared inside a function as opposed to outside. A buffer is a chunk of memory (usually an array) that's used to copy a small chunk of data from a huge data source, so you can process it at whatever pace your computer or program can handle. You might declare the buffer outside of your function if you want another function to fill it up, or you might declare it as a local variable if you're going to be filling it up and using it yourself. It's a really general term.
Some examples:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With