Avoid manipulating paths in fixed-sized arrays.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118105 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc
index c1765b8..37ce00e 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -143,8 +143,7 @@
   // Linux and FreeBSD have it. Others probably won't.
   char pathname[] = "/tmp/llvm_XXXXXX";
   if (0 == mkdtemp(pathname)) {
-    MakeErrMsg(ErrMsg,
-      std::string(pathname) + ": can't create temporary directory");
+    MakeErrMsg(ErrMsg, pathname + ": can't create temporary directory");
     return Path();
   }
   Path result;
@@ -681,8 +680,7 @@
 bool
 Path::createDirectoryOnDisk( bool create_parents, std::string* ErrMsg ) {
   // Get a writeable copy of the path name
-  char pathname[MAXPATHLEN];
-  path.copy(pathname,MAXPATHLEN);
+  std::string pathname(path);
 
   // Null-terminate the last component
   size_t lastchar = path.length() - 1 ;
@@ -692,7 +690,7 @@
 
   pathname[lastchar] = '\0';
 
-  if (createDirectoryHelper(pathname, pathname+lastchar, create_parents))
+  if (createDirectoryHelper(&pathname[0], &pathname[lastchar], create_parents))
     return MakeErrMsg(ErrMsg,
                       std::string(pathname) + ": can't create directory");
 
@@ -759,17 +757,15 @@
   }
 
   // Otherwise, try to just remove the one directory.
-  char pathname[MAXPATHLEN];
-  path.copy(pathname, MAXPATHLEN);
+  std::string pathname(path);
   size_t lastchar = path.length() - 1;
   if (pathname[lastchar] == '/')
     pathname[lastchar] = '\0';
   else
     pathname[lastchar+1] = '\0';
 
-  if (rmdir(pathname) != 0)
-    return MakeErrMsg(ErrStr,
-      std::string(pathname) + ": can't erase directory");
+  if (rmdir(pathname.c_str()) != 0)
+    return MakeErrMsg(ErrStr, pathname + ": can't erase directory");
   return false;
 }