Commit Diff


commit - f6852d460b7949c591420eadb61ddf8e211c03a6
commit + dd4c419722fe06a0e79fc39e303003908f7feceb
blob - df4695a5b57ce3e383d90c391233f0970172ace7
blob + c7b9dbea6bfeb4a26988cf2367b2492119b8242f
--- lib/repository.c
+++ lib/repository.c
@@ -2437,6 +2437,10 @@ write_tree(struct got_object_id **new_tree_id, const c
 	 * during import then we have a racy situation no matter what.
 	 */
 	pos = telldir(dir);
+	if (pos == -1) {
+		err = got_error_from_errno2("telldir", path_dir);
+		goto done;
+	}
 	while ((de = readdir(dir)) != NULL) {
 		if (strcmp(de->d_name, ".") != 0 &&
 		    strcmp(de->d_name, "..") != 0) {
@@ -2445,6 +2449,10 @@ write_tree(struct got_object_id **new_tree_id, const c
 				goto done;
 		}
 		pos = telldir(dir);
+		if (pos == -1) {
+			err = got_error_from_errno2("telldir", path_dir);
+			goto done;
+		}
 	}
 
 	nentries = 0;