security - Is it good or bad manner to oversecure? -


if function proper checks inside, should check before calling it, or better not? security redundancy considered practice?

example (in sort of c#-like pseudocode by-reference arguments passing):

  dosomething(vector v) {   ...;   v.clear;   usecleanvector(v) }  usecleanvector(vector v) {   if(!v.isclean) v.clear;   ... }  

what matters document preconditions, , exceptional conditions in obvious way. seems sensible.

/**  * precondition : id must id of flarg.  *   * myfunc return -1 if value outside valid 0-10 range.  */ int myfunc( int id, int value ); 

this lets me code this

 int flarg_id = ...  if (! is_flarg( flarg_id ) ) { printf("bad flarg"); exit(1); }  int value = ...  int rv = myfunc( flarg_id, value );  if( rv == -1 )  { printf("bad value"); exit(1); } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -