shithub: unionfs

Download patch

ref: 745a16c328434404726892f67c398f5878d114b0
parent: 4c2cb616bcb71ab56667b083657ab6d2a35b3d52
author: kvik <kvik@a-b.xyz>
date: Fri Jul 5 09:32:02 EDT 2019

sanity check the branch arguments

--- a/unionfs.c
+++ b/unionfs.c
@@ -737,6 +737,7 @@
 	int c, i;
 	int mflag;
 	char *mtpt, *srv;
+	Dir *d;
 	Union *u;
 
 	c = 0;
@@ -778,11 +779,22 @@
 			c++;
 			continue;
 		}
+		if(strcmp(argv[i], mtpt) == 0){
+			fprint(2, "%s: mountpoint cycle, skipping branch %s\n", argv0, argv[i]);
+			continue;
+		}
+		if((d = dirstat(argv[i])) == nil){
+			fprint(2, "%s: %s does not exist, skipping\n", argv0, argv[i]);
+			continue;
+		}
+		free(d);
 		u = emalloc(sizeof(*u));
 		u->create = c == 1 ? c : 0;
 		u->root = mkpath(argv[i], nil);
 		unionlink(unionlist, u);
 	}
+	if(unionlist->next == unionlist->prev)
+		sysfatal("empty branch list");
 	if(c == 0)
 		unionlist->next->create = 1;