commit 6c24d194f2260b073d8e8ad3e756efa3ce20dd2e from: Omar Polo via: Thomas Adam date: Thu Jun 15 11:27:15 2023 UTC change got_get_repo_tags' limit argument to size_t The function already carefully avoids wrapping around zero. While here add a sanity check for limit == 0, like what was previously done for got_get_repo_commits(). commit - 90757f0a7eedde53f109f67061bb39256412dd60 commit + 6c24d194f2260b073d8e8ad3e756efa3ce20dd2e blob - 4b1d31115a72093e73d61604cd06935239a86044 blob + d87c6a8af195b8ced89fc29785a307e6156dba73 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -449,7 +449,7 @@ got_get_repo_commits(struct request *c, size_t limit) } const struct got_error * -got_get_repo_tags(struct request *c, int limit) +got_get_repo_tags(struct request *c, size_t limit) { const struct got_error *error = NULL; struct got_object_id *id = NULL; @@ -471,6 +471,9 @@ got_get_repo_tags(struct request *c, int limit) TAILQ_INIT(&refs); + if (limit == 0) + return got_error(GOT_ERR_RANGE); + if (asprintf(&repo_path, "%s/%s", srv->repos_path, repo_dir->name) == -1) return got_error_from_errno("asprintf"); blob - cfcd977e45fabb46eb8dc44a05b3bf82623e74e0 blob + 3286dbc6e6022af719d350d5ae32579808a5c37e --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -512,7 +512,7 @@ const struct got_error *got_get_repo_owner(char **, st const struct got_error *got_get_repo_age(time_t *, struct request *, const char *); const struct got_error *got_get_repo_commits(struct request *, size_t); -const struct got_error *got_get_repo_tags(struct request *, int); +const struct got_error *got_get_repo_tags(struct request *, size_t); const struct got_error *got_get_repo_heads(struct request *); const struct got_error *got_open_diff_for_output(FILE **, struct request *); int got_output_repo_tree(struct request *,