2631. [bug] Handle "//", "/./" and "/../" in mkdirpath().

[RT #19926 ]
This commit is contained in:
Mark Andrews
2009-07-15 00:36:37 +00:00
parent 3e12c54de2
commit fb8db7fc3f
2 changed files with 13 additions and 1 deletions

View File

@@ -1,3 +1,6 @@
2631. [bug] Handle "//", "/./" and "/../" in mkdirpath().
[RT #19926 ]
2630. [func] Improved syntax for DDNS autoconfiguration: use
"update-policy local;" to switch on local DDNS in a
zone. [RT #19875]

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: os.c,v 1.98 2009/07/14 23:47:54 tbox Exp $ */
/* $Id: os.c,v 1.99 2009/07/15 00:36:37 marka Exp $ */
/*! \file */
@@ -692,6 +692,15 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
}
if (mkdirpath(filename, report) == -1)
goto error;
/*
* Handle "//", "/./" and "/../" in path.
*/
if (!strcmp(slash + 1, "") ||
!strcmp(slash + 1, ".") ||
!strcmp(slash + 1, "..")) {
*slash = '/';
return (0);
}
mode = S_IRUSR | S_IWUSR | S_IXUSR; /* u=rwx */
mode |= S_IRGRP | S_IXGRP; /* g=rx */
mode |= S_IROTH | S_IXOTH; /* o=rx */