Commit 1ab830c1f6d0bac77a2fc49ae92847c0870dd433

Stefan Sperling 2020-02-03T08:28:36

fix fread(3) error check added in previous commit

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 5e2390d..f6c445d 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1446,7 +1446,7 @@ gw_get_repo_description(char **description, struct gw_trans *gw_trans,
 	FILE *f = NULL;
 	char *d_file = NULL;
 	unsigned int len;
-	ssize_t n;
+	size_t n;
 
 	*description = NULL;
 	if (gw_trans->gw_conf->got_show_repo_description == 0)
@@ -1483,10 +1483,8 @@ gw_get_repo_description(char **description, struct gw_trans *gw_trans,
 	}
 
 	n = fread(*description, 1, len, f);
-	if (n == -1) {
+	if (n == 0 && ferror(f))
 		error = got_ferror(f, GOT_ERR_IO);
-		goto done;
-	}
 done:
 	if (f != NULL && fclose(f) == -1 && error == NULL)
 		error = got_error_from_errno("fclose");