Skip to content

Commit

Permalink
builtin-branch: use strbuf in delete_branches()
Browse files Browse the repository at this point in the history
In case the length of branch name is greather then PATH_MAX-7, we write
to unallocated memory otherwise.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Miklos Vajna authored and Junio C Hamano committed Nov 18, 2008
1 parent 4757745 commit 3c59c50
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
unsigned char sha1[20];
char *name = NULL;
const char *fmt, *remote;
char section[PATH_MAX];
int i;
int ret = 0;

Expand Down Expand Up @@ -165,11 +164,12 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
argv[i]);
ret = 1;
} else {
struct strbuf buf = STRBUF_INIT;
printf("Deleted %sbranch %s.\n", remote, argv[i]);
snprintf(section, sizeof(section), "branch.%s",
argv[i]);
if (git_config_rename_section(section, NULL) < 0)
strbuf_addf(&buf, "branch.%s", argv[i]);
if (git_config_rename_section(buf.buf, NULL) < 0)
warning("Update of config-file failed");
strbuf_release(&buf);
}
}

Expand Down

0 comments on commit 3c59c50

Please sign in to comment.