Commit ef68ca6f52da8c840d10d8c483c77fcac614c371

Stefan Sperling 2020-07-23T14:21:29

add missing dirname(3) error check; found by semarie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/lib/worktree.c b/lib/worktree.c
index d893d9c..7ac3e89 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -989,6 +989,10 @@ install_symlink(struct got_worktree *worktree, const char *ondisk_path,
 	 */
 	if (!got_path_is_absolute(target_path)) {
 		char *parent = dirname(ondisk_path);
+		if (parent == NULL) {
+			err = got_error_from_errno2("dirname", ondisk_path);
+			goto done;
+		}
 		if (asprintf(&abspath, "%s/%s",  parent, target_path) == -1) {
 			err = got_error_from_errno("asprintf");
 			goto done;