commit 23c35dae297d2eecd13e17118a547761314a578d from: Omar Polo date: Thu Jun 15 10:47:28 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 - a678036d5fc91d90d799f3ed394f0f721d227d12 commit + 23c35dae297d2eecd13e17118a547761314a578d blob - b0b81d728aae26ca8ade03729c3738e50a573ac3 blob + 61bee36696a4edd811768fba90d50e909418b91f --- 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 - 057b25c7ef680bcd1c7f35556e2adaa42ed3da38 blob + 31bcbde9268d51c10f8ed32e6080e1691e0473ec --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -510,7 +510,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 *,