diff options
| author | Taylor Blau <me@ttaylorr.com> | 2022-10-06 17:42:55 -0400 |
|---|---|---|
| committer | Taylor Blau <me@ttaylorr.com> | 2022-10-06 17:42:55 -0400 |
| commit | 478a426f14b92cef92fc09df442b356a53f6fa8f (patch) | |
| tree | 1f2dcc827b46b148cc2305f48f35bb233d437fa7 /alias.c | |
| parent | Git 2.34.4 (diff) | |
| parent | Git 2.33.5 (diff) | |
| download | git-478a426f14b92cef92fc09df442b356a53f6fa8f.tar.gz git-478a426f14b92cef92fc09df442b356a53f6fa8f.zip | |
Sync with 2.33.5
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'alias.c')
| -rw-r--r-- | alias.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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; |
