aboutsummaryrefslogtreecommitdiff
path: root/alias.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-10-17 15:46:09 -0700
committerJunio C Hamano <gitster@pobox.com>2022-10-17 15:46:09 -0700
commit9c32cfb49c60fa8173b9666db02efe3b45a8522f (patch)
tree0f74dce4f7278f25cd61bd87baeb400f127ac1b1 /alias.c
parent4732897cf0a255a23dca9e97b65cea40cd06c5a8 (diff)
parentd5b41391a472dcf9486055fd5b8517f893e88daf (diff)
downloadgit-9c32cfb49c60fa8173b9666db02efe3b45a8522f.tar.xz
Sync with v2.38.1
Diffstat (limited to 'alias.c')
-rw-r--r--alias.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/alias.c b/alias.c
index c471538020..00abde0817 100644
--- a/alias.c
+++ b/alias.c
@@ -46,14 +46,16 @@ void list_aliases(struct string_list *list)
#define SPLIT_CMDLINE_BAD_ENDING 1
#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
+#define SPLIT_CMDLINE_ARGC_OVERFLOW 3
static const char *split_cmdline_errors[] = {
N_("cmdline ends with \\"),
- N_("unclosed quote")
+ N_("unclosed quote"),
+ N_("too many arguments"),
};
int split_cmdline(char *cmdline, const char ***argv)
{
- int src, dst, count = 0, size = 16;
+ size_t src, dst, count = 0, size = 16;
char quoted = 0;
ALLOC_ARRAY(*argv, size);
@@ -96,6 +98,11 @@ int split_cmdline(char *cmdline, const char ***argv)
return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
}
+ if (count >= INT_MAX) {
+ FREE_AND_NULL(*argv);
+ return -SPLIT_CMDLINE_ARGC_OVERFLOW;
+ }
+
ALLOC_GROW(*argv, count + 1, size);
(*argv)[count] = NULL;