Commit Diff


commit - c0586da31b5b4f2503675a9d22a951eb68e54d4a
commit + ebdd042fb1f20d323eda3c34ef4fa6715288bb70
blob - 169d68adf1edeb5a8126017d8c850731d2689ad6
blob + 970c453b4aadefcce999872345ba3cd36aa16b80
--- lib/repository.c
+++ lib/repository.c
@@ -2440,6 +2440,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) {
@@ -2448,6 +2452,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;