Mercurial > octave
changeset 26590:7f58079955b3 stable
mkdir.m: Prevent exceeding max recursion limit on bad input (bug #55540).
* mkdir.m: Fix documentation to use DIRNAME rather than DIR to refer to input
argument. Use @w{} to prevent Texinfo from breaking code block in docstring.
Add BIST test for bug #55540.
* mkdir.m (mkdir_recur): Check for an empty input argument parent and error
out if true.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 21 Jan 2019 22:07:16 -0800 |
parents | 21708bdc1c07 |
children | 088b8a2dcb06 |
files | scripts/miscellaneous/mkdir.m |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/mkdir.m Fri Jan 18 21:32:12 2019 -0500 +++ b/scripts/miscellaneous/mkdir.m Mon Jan 21 22:07:16 2019 -0800 @@ -24,15 +24,16 @@ ## Create a directory named @var{dirname} in the directory @var{parent}, ## creating any intermediate directories if necessary. ## -## If @var{dir} is a relative path, and no @var{parent} directory is specified, -## then the present working directory is used. +## If @var{dirname} is a relative path, and no @var{parent} directory is +## specified, then the present working directory is used. ## ## If successful, @var{status} is 1, and @var{msg} and @var{msgid} are empty ## strings (""). Otherwise, @var{status} is 0, @var{msg} contains a ## system-dependent error message, and @var{msgid} contains a unique message ## identifier. ## -## When creating a directory permissions will be set to @code{0777 - UMASK}. +## When creating a directory permissions will be set to +## @w{@code{0777 - UMASK}}. ## ## @seealso{rmdir, pwd, cd, umask} ## @end deftypefn @@ -71,6 +72,10 @@ status = 1; + if (isempty (parent)) + error ("mkdir: invalid PARENT"); + endif + if (! isfolder (parent)) [grandparent, name, ext] = fileparts (parent); [status, msg, msgid] = mkdir_recur (grandparent, [name, ext]); @@ -115,6 +120,9 @@ %! endif %! end_unwind_protect +%!test <*55540> +%! fail ('mkdir ("__%hello%__", "world")', "invalid PARENT"); + ## Test input validation %!error mkdir () %!error mkdir ("a", "b", "c")