1ecf125d3f
The SECURE_ESCAPE_ARGS() macro solves several potential problems (although we found no problematic calls to the escape*() functions in procps's code-base, but had to thoroughly review every call; and this is library code): 1/ off-by-one overflows if the size of the destination buffer is 0; 2/ buffer overflows if this size (or "maxroom") is negative; 3/ integer overflows (for example, "*maxcells+1"); 4/ always null-terminate the destination buffer (unless its size is 0). ---------------------------- adapted for newlib branch . the escape.c now has just a single exported function . thus SECURE_ESCAPE_ARGS() is needed in only 2 places . unlike that original patch, macro is executed 1 time ( not like 'escape_command' calling 'escape_strlist' ) ( which might then call 'escape_str' multiple times! ) Signed-off-by: Jim Warner <james.warner@comcast.net>