commit 3179741908f46f3c1711b053ad2ab839c746a5bf from: Omar Polo via: Thomas Adam date: Fri Sep 02 15:54:01 2022 UTC gotwebd: fix possible leaks when handling errors all very unlikely. part of a bigger diff that's ok stsp@ commit - 6b42af1e1d379806c1ef2cccfa084a7b8de605f1 commit + 3179741908f46f3c1711b053ad2ab839c746a5bf blob - 666bccbe101c17a74289291ee61102b8a25c7017 blob + 0e595b8cf284b38d7e38818d5b0098211ae9e414 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -350,12 +350,14 @@ got_get_repo_commits(struct request *c, int limit) return got_error_from_errno("asprintf"); if (asprintf(&repo_path, "%s/%s", srv->repos_path, - repo_dir->name) == -1) - return got_error_from_errno("asprintf"); + repo_dir->name) == -1) { + error = got_error_from_errno("asprintf"); + goto done; + } error = got_init_repo_commit(&repo_commit); if (error) - return error; + goto done; /* * XXX: jumping directly to a commit id via blob - d53434630171a876941517eff6fb77fb26a15bea blob + a2dac356c51f861fae48abc66f39d4227b784edb --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -2073,9 +2073,8 @@ gotweb_get_repo_description(char **description, struct f = fopen(d_file, "r"); if (f == NULL) { - if (errno == ENOENT || errno == EACCES) - return NULL; - error = got_error_from_errno2("fopen", d_file); + if (errno != ENOENT && errno != EACCES) + error = got_error_from_errno2("fopen", d_file); goto done; } @@ -2092,7 +2091,7 @@ gotweb_get_repo_description(char **description, struct if (len == 0) { *description = strdup(""); if (*description == NULL) - return got_error_from_errno("strdup"); + error = got_error_from_errno("strdup"); goto done; }