Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Dec 2017 03:17:29 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r327407 - stable/11/usr.bin/xinstall
Message-ID:  <201712310317.vBV3HTiF091252@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun Dec 31 03:17:28 2017
New Revision: 327407
URL: https://svnweb.freebsd.org/changeset/base/327407

Log:
  MFC r324547:
  
      xinstall: plug an infinite loop in directory creation
  
      If stat continues to fail with ENOENT and mkdir with EEXIST the code wont
      finish. In particular this can show up when the target path follows through
      a symlink to a non-existent directory.

Modified:
  stable/11/usr.bin/xinstall/xinstall.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/xinstall/xinstall.c
==============================================================================
--- stable/11/usr.bin/xinstall/xinstall.c	Sun Dec 31 03:15:45 2017	(r327406)
+++ stable/11/usr.bin/xinstall/xinstall.c	Sun Dec 31 03:17:28 2017	(r327407)
@@ -1292,17 +1292,19 @@ install_dir(char *path)
 {
 	char *p;
 	struct stat sb;
-	int ch;
+	int ch, tried_mkdir;
 
 	for (p = path;; ++p)
 		if (!*p || (p != path && *p  == '/')) {
+			tried_mkdir = 0;
 			ch = *p;
 			*p = '\0';
 again:
 			if (stat(path, &sb) < 0) {
-				if (errno != ENOENT)
+				if (errno != ENOENT || tried_mkdir)
 					err(EX_OSERR, "stat %s", path);
 				if (mkdir(path, 0755) < 0) {
+					tried_mkdir = 1;
 					if (errno == EEXIST)
 						goto again;
 					err(EX_OSERR, "mkdir %s", path);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712310317.vBV3HTiF091252>