Hacker News new | ask | show | jobs
by frabert 1115 days ago
Never heard of a serious buffer overflow caused by _constant_ indices. Does it work with AT(arr, i), or only with AT(arr, 10)?
2 comments

"'Brother,' says he, 'greetings. Didn't I see you in Southern Missouri last summer selling colored sand at half-a-dollar a teaspoonful to put into lamps to keep the oil from exploding?'

"'Oil,' says I, 'never explodes. It's the gas that forms that explodes.' But I shakes hands with him, anyway.

...

"'Listen,' says I. 'I instruct her to keep her lamp clean and well filled. If she does that it can't burst. And with the sand in it she knows it can't, and she don't worry.

— O. Henry, The Man Higher Up

Did you mean to reply somewhere else? This thread is about about bounds checking arrays in the C programming language.
You definitly didn't understood the message.
If you did understood it, then explain it so I can understood it too.
Somehow doesn't seem worth my time.
So it was worth your time to reply twice, but not to explain anything?
But it's absolutely true though: if only the C programmers right their code very carefully and in specific patterns, the buffer overflows and invalid dereferences won't happen and therefore, won't explode their programs! By the way, only today I have a silver bullet to sell with "runtime safety violations" written on it, anyone willing to buy it?
Yeap, that's the whole point of it
Huh I misinterpreted the error messages in the example, I thought those were compiler output. This is quite cool then.

EDIT: although, it seems like this looses much of its power once you start passing these buffers around to functions that do not use these macros.

> this looses much of its power once you start passing these buffers around to functions that do not use these macros.

Alas it's even worse: once you pass buffers around to functions, you can't use these macros!

0.0.2 update is live, and solves this issue. Check for updated README.