4 ms·
He did harden the code by having an explicit range check.
by silon42 4y ago
He did harden the code by having an explicit range check.
- josefx 4y agoHe is checking if the output is in a sane range. Not if the input values where. This may be correct for a trivial toy example but bite you in actual production code. Fun things like malloc(ab) vs calloc(a,b) where ab overflows in a well defined way and gives you valid pointer to an unexpectedly tiny buffer.
- p0nce 4y agoOnly correct answer in this thread.