4 ms·
> well the solution is to validate user input Oh come on, what do you think the purpose of reallocarray is? It's exactly to include that boilerplate for you s
by clarry 12y ago
> well the solution is to validate user input
Oh come on, what do you think the purpose of reallocarray is? It's exactly to include that boilerplate for you so that you don't have write your own "validation" before every alloc.
- Dylan16807 12y agoThe user can still consume 99.9% of your address space. It is not a substitute for validation.
- clarry 12y agoLetting the user (try) use as much as he needs can be perfectly okay. Even if it weren't, it doesn't necessarily mean the program itself needs to impose some limit to check the inputs against. There are other means, e.g. rlimits (which are enabled by default on OpenBSD). What reallocarray does is the bare minimum validation that shoud always be done. And in many cases that is enough, though not always.