Just wondering if someone can give me some advice on preventing a buffer overflow when dealing with strings being passed as arguments.
If I have a function prototype such as:
That argument bar - is intended to take a pointer to a buffer of x characters in length. Inside that function, I can't get the size of that buffer, as bar is now just a pointer to a char. I COULD just make the user of this function pass a length parameter, but there is no guarantee that would be correct. Is there a bullet proof way of detecting that the user has provided a buffer that is too small?Code:void foobar(char *bar);