cmdline: check size of result buffer to avoid overflow