projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.
[gnulib.git]
/
lib
/
makepath.c
diff --git
a/lib/makepath.c
b/lib/makepath.c
index
bb6a09c
..
f0303fa
100644
(file)
--- a/
lib/makepath.c
+++ b/
lib/makepath.c
@@
-19,14
+19,7
@@
Jim Meyering <meyering@cs.utexas.edu>. */
#ifdef HAVE_CONFIG_H
Jim Meyering <meyering@cs.utexas.edu>. */
#ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
- using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
- (which it would do because it found this file in $srcdir). */
#include <config.h>
#include <config.h>
-#else
-#include "config.h"
-#endif
#endif
#ifdef __GNUC__
#endif
#ifdef __GNUC__
@@
-50,11
+43,9
@@
char *alloca ();
#include <unistd.h>
#endif
#include <unistd.h>
#endif
-#ifdef STAT_MACROS_BROKEN
-#ifdef S_ISDIR
+#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#undef S_ISDIR
-#endif
-#endif /* STAT_MACROS_BROKEN. */
+#endif /* STAT_MACROS_BROKEN. */
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
@@
-86,6
+77,7
@@
typedef int uid_t;
typedef int gid_t;
#endif
typedef int gid_t;
#endif
+#include "safe-stat.h"
void error ();
/* Ensure that the directory ARGPATH exists.
void error ();
/* Ensure that the directory ARGPATH exists.
@@
-121,7
+113,7
@@
make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
dirpath = (char *) alloca (strlen (argpath) + 1);
strcpy (dirpath, argpath);
dirpath = (char *) alloca (strlen (argpath) + 1);
strcpy (dirpath, argpath);
- if (
stat
(dirpath, &stats))
+ if (
SAFE_STAT
(dirpath, &stats))
{
char *slash;
int tmp_mode; /* Initial perms for leading dirs. */
{
char *slash;
int tmp_mode; /* Initial perms for leading dirs. */
@@
-155,7
+147,7
@@
make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
while ((slash = index (slash, '/')))
{
*slash = '\0';
while ((slash = index (slash, '/')))
{
*slash = '\0';
- if (
stat
(dirpath, &stats))
+ if (
SAFE_STAT
(dirpath, &stats))
{
if (mkdir (dirpath, tmp_mode))
{
{
if (mkdir (dirpath, tmp_mode))
{
@@
-206,7
+198,10
@@
make_path (argpath, mode, parent_mode, owner, group, verbose_fmt_string)
/* We're done making leading directories.
Make the final component of the path. */
/* We're done making leading directories.
Make the final component of the path. */
- if (mkdir (dirpath, mode))
+ /* The path could end in "/." or contain "/..", so test
+ if we really have to create the directory. */
+
+ if (SAFE_STAT (dirpath, &stats) && mkdir (dirpath, mode))
{
error (0, errno, "cannot make directory `%s'", dirpath);
umask (oldmask);
{
error (0, errno, "cannot make directory `%s'", dirpath);
umask (oldmask);