git-restrict

simple utility for git repo permission management
git clone https://git.parazyd.org/git-restrict
Log | Files | Refs | README | LICENSE

commit 519b8e62121e2f23966f8133d0384710af8c21e7
parent e5234c68bbc2fc29304994afba04eb5a1c9b86d6
Author: parazyd <parazyd@dyne.org>
Date:   Wed, 31 Mar 2021 10:50:38 +0200

Check malloc and use snprintf in for loop.

Diffstat:
Mgit-restrict.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-restrict.c b/git-restrict.c @@ -49,8 +49,12 @@ int main(int argc, char *argv[]) repo[strlen(repo) - 1] = 0; for (i = 1; i < argc; i++) { - buf = malloc(strlen(repo) + 4); - sprintf(buf, "%s.git", argv[i]); + if ((buf = malloc(strlen(repo) + 4)) == NULL) { + perror("malloc"); + return 1; + } + + snprintf(buf, strlen(repo) + 4, "%s.git", argv[i]); if (!strcmp(argv[i], repo) || !strcmp(buf, repo)) { authorized = 1;