shithub: git9

Download patch

ref: 0491a616b567c7115ef931a9c0197a19286044ec
parent: ee1a32c4292f76e457751d0063182a824ff3d8de
author: Ori Bernstein <[email protected]>
date: Mon Feb 10 21:24:15 EST 2020

move symlink check to where it belongs

--- a/save.c
+++ b/save.c
@@ -168,8 +168,6 @@
 
 	if((d->mode & DMDIR) != 0)
 		sysfatal("not file: %s", path);
-	if(*mode == 0)
-		sysfatal("symlinks may not be modified: %s", path);
 	*mode = d->mode;
 	nh = snprint(h, sizeof(h), "%T %lld", GBlob, d->length) + 1;
 	if((f = open(path, OREAD)) == -1)
@@ -263,6 +261,8 @@
 				break;
 		}
 		e = dirent(&ent, &nent, elt);
+		if(e->islink)
+			sysfatal("symlinks may not be modified: %s", *path);
 		if(isdir){
 			e->mode = DMDIR | 0755;
 			sub[nsub] = readobject(e->h);