Commit 80c5c120285b0b38cf25a37858e737047c570a98

Stefan Sperling 2019-02-19T13:38:08

missing fread(3) error check in get_file_status()

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 f6e70aa..4f18b2a 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1003,6 +1003,10 @@ get_file_status(unsigned char *status, struct stat *sb,
 			break;
 		/* Skip length of blob object header first time around. */
 		flen = fread(fbuf, 1, sizeof(fbuf) - hdrlen, f);
+		if (flen == 0 && ferror(f)) {
+			err = got_error_from_errno();
+			break;
+		}
 		if (blen == 0) {
 			if (flen != 0)
 				*status = GOT_STATUS_MODIFY;