From 4681b3aee447ba85c63043355699042253599d88 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 13:40:20 +0000 Subject: [PATCH 1/9] ntlmclient: update to latest version Ensure that we declare variables at the top of the block for broad compatibility with old compilers. --- deps/ntlmclient/crypt_commoncrypto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/ntlmclient/crypt_commoncrypto.c b/deps/ntlmclient/crypt_commoncrypto.c index 4ff57edd29a..3c20469f58d 100644 --- a/deps/ntlmclient/crypt_commoncrypto.c +++ b/deps/ntlmclient/crypt_commoncrypto.c @@ -59,11 +59,12 @@ bool ntlm_des_encrypt( ntlm_des_block *plaintext, ntlm_des_block *key) { + CCCryptorStatus result; size_t written; NTLM_UNUSED(ntlm); - CCCryptorStatus result = CCCrypt(kCCEncrypt, + result = CCCrypt(kCCEncrypt, kCCAlgorithmDES, kCCOptionECBMode, key, sizeof(ntlm_des_block), NULL, plaintext, sizeof(ntlm_des_block), From b882e9e7a6e142ce4cf26ea15905f0ff06c11eb8 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 13:40:57 +0000 Subject: [PATCH 2/9] stream: use an unsigned int for a bitmask --- include/git2/sys/stream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/git2/sys/stream.h b/include/git2/sys/stream.h index 3d28d09b321..3277088c99c 100644 --- a/include/git2/sys/stream.h +++ b/include/git2/sys/stream.h @@ -29,8 +29,8 @@ GIT_BEGIN_DECL typedef struct git_stream { int version; - int encrypted : 1, - proxy_support : 1; + unsigned int encrypted : 1, + proxy_support : 1; /** * Timeout for read and write operations; can be set to `0` to From de9a76b92c5805033ce3b477a8a65957465c8625 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 13:41:17 +0000 Subject: [PATCH 3/9] config: properly handle multiline quotes Pass a pointer to the quote counts so that we can increment it. --- src/libgit2/config_parse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libgit2/config_parse.c b/src/libgit2/config_parse.c index 06931368e7b..1431bed36db 100644 --- a/src/libgit2/config_parse.c +++ b/src/libgit2/config_parse.c @@ -279,8 +279,7 @@ static int skip_bom(git_parse_ctx *parser) */ /* '\"' -> '"' etc */ -static int unescape_line( - char **out, bool *is_multi, const char *ptr, int quote_count) +static int unescape_line(char **out, bool *is_multi, const char *ptr, int *quote_count) { char *str, *fixed, *esc; size_t ptr_len = strlen(ptr), alloc_len; @@ -296,7 +295,8 @@ static int unescape_line( while (*ptr != '\0') { if (*ptr == '"') { - quote_count++; + if (quote_count) + (*quote_count)++; } else if (*ptr != '\\') { *fixed++ = *ptr; } else { @@ -358,7 +358,7 @@ static int parse_multiline_variable(git_config_parser *reader, git_str *value, i goto next; if ((error = unescape_line(&proc_line, &multiline, - line, in_quotes)) < 0) + line, &in_quotes)) < 0) goto out; /* Add this line to the multiline var */ @@ -445,7 +445,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var while (git__isspace(value_start[0])) value_start++; - if ((error = unescape_line(&value, &multiline, value_start, 0)) < 0) + if ((error = unescape_line(&value, &multiline, value_start, NULL)) < 0) goto out; if (multiline) { From 9ed52434b718d3f06637e1b953dda98d93711c34 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 13:41:49 +0000 Subject: [PATCH 4/9] refdb: use an unsigned int for a bitfield --- src/libgit2/refdb_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libgit2/refdb_fs.c b/src/libgit2/refdb_fs.c index e34a71455cb..6952548046c 100644 --- a/src/libgit2/refdb_fs.c +++ b/src/libgit2/refdb_fs.c @@ -62,8 +62,8 @@ typedef struct refdb_fs_backend { git_oid_t oid_type; - int fsync : 1, - sorted : 1; + unsigned int fsync : 1, + sorted : 1; int peeling_mode; git_iterator_flag_t iterator_flags; uint32_t direach_flags; From 18aa18bee17fcc45f87b556b5bde2aebb3a3a40a Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 13:42:01 +0000 Subject: [PATCH 5/9] smart: use an unsigned int for a bitfield --- src/libgit2/transports/smart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libgit2/transports/smart.h b/src/libgit2/transports/smart.h index 52c7553a1d7..f49827eb698 100644 --- a/src/libgit2/transports/smart.h +++ b/src/libgit2/transports/smart.h @@ -203,7 +203,7 @@ int git_smart__update_heads(transport_smart *t, git_vector *symrefs); /* smart_pkt.c */ typedef struct { git_oid_t oid_type; - int seen_capabilities: 1; + unsigned int seen_capabilities: 1; } git_pkt_parse_data; int git_pkt_parse_line(git_pkt **head, const char **endptr, const char *line, size_t linelen, git_pkt_parse_data *data); From 60c68e7e03aa7c5b827ceb8cd9e0d506a87e743f Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 14:06:51 +0000 Subject: [PATCH 6/9] cli: use the latest version of adopt --- src/cli/opt.c | 2 +- src/cli/opt.h | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cli/opt.c b/src/cli/opt.c index 25c97746f1d..2b08dc219a3 100644 --- a/src/cli/opt.c +++ b/src/cli/opt.c @@ -10,7 +10,7 @@ * This file was produced by using the `rename.pl` script included with * adopt. The command-line specified was: * - * ./rename.pl cli_opt --filename=opt --include=cli.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage + * ./rename.pl cli_opt --filename=opt --include=common.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage */ #include diff --git a/src/cli/opt.h b/src/cli/opt.h index 7133307b4f7..226f74db8bc 100644 --- a/src/cli/opt.h +++ b/src/cli/opt.h @@ -10,7 +10,7 @@ * This file was produced by using the `rename.pl` script included with * adopt. The command-line specified was: * - * ./rename.pl cli_opt --filename=opt --include=cli.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage + * ./rename.pl cli_opt --filename=opt --include=common.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage */ #ifndef CLI_opt_h__ @@ -275,8 +275,8 @@ typedef struct cli_opt_parser { size_t arg_idx; size_t in_args; size_t in_short; - int needs_sort : 1, - in_literal : 1; + unsigned int needs_sort : 1, + in_literal : 1; } cli_opt_parser; /** @@ -300,6 +300,16 @@ cli_opt_status_t cli_opt_parse( size_t args_len, unsigned int flags); +/** + * Quickly executes the given callback for each argument. + * + * @param specs A NULL-terminated array of `cli_opt_spec`s that can be parsed + * @param args The arguments that will be parsed + * @param args_len The length of arguments to be parsed + * @param flags The `cli_opt_flag_t flags for parsing + * @param callback The callback to invoke for each specified option + * @param callback_data Data to be provided to the callback + */ int cli_opt_foreach( const cli_opt_spec specs[], char **args, From 2098c490c8b8bfb88adab30575ff82fa157e52a3 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 14:07:03 +0000 Subject: [PATCH 7/9] net: use an unsigned int for a bitfield --- src/util/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/net.c b/src/util/net.c index 24782d2af09..4474564511b 100644 --- a/src/util/net.c +++ b/src/util/net.c @@ -22,7 +22,7 @@ #define GIT_NET_URL_PARSER_INIT { 0 } typedef struct { - int hierarchical : 1; + unsigned int hierarchical : 1; const char *scheme; const char *user; From 6fb234b5fbd1e999685bf545013d64c42550d110 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 14:17:24 +0000 Subject: [PATCH 8/9] process: use unsigned int for bitfields --- src/util/process.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/process.h b/src/util/process.h index 9310652c325..3ada6696d22 100644 --- a/src/util/process.h +++ b/src/util/process.h @@ -11,10 +11,10 @@ typedef struct git_process git_process; typedef struct { - int capture_in : 1, - capture_out : 1, - capture_err : 1, - exclude_env : 1; + unsigned int capture_in : 1, + capture_out : 1, + capture_err : 1, + exclude_env : 1; char *cwd; } git_process_options; From 839b249525b46f2894b8cd574d02b06ef9933f8e Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 14 Dec 2023 14:26:09 +0000 Subject: [PATCH 9/9] tests: update to latest clar --- tests/clar/clar.c | 2 ++ tests/clar/clar/fixtures.h | 2 +- tests/clar/clar/fs.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/clar/clar.c b/tests/clar/clar.c index c9c3fde3827..3fc2c768158 100644 --- a/tests/clar/clar.c +++ b/tests/clar/clar.c @@ -94,8 +94,10 @@ static void fs_rm(const char *_source); static void fs_copy(const char *_source, const char *dest); +#ifdef CLAR_FIXTURE_PATH static const char * fixture_path(const char *base, const char *fixture_name); +#endif struct clar_error { const char *file; diff --git a/tests/clar/clar/fixtures.h b/tests/clar/clar/fixtures.h index 77033d36507..6ec6423484d 100644 --- a/tests/clar/clar/fixtures.h +++ b/tests/clar/clar/fixtures.h @@ -1,3 +1,4 @@ +#ifdef CLAR_FIXTURE_PATH static const char * fixture_path(const char *base, const char *fixture_name) { @@ -20,7 +21,6 @@ fixture_path(const char *base, const char *fixture_name) return _path; } -#ifdef CLAR_FIXTURE_PATH const char *cl_fixture(const char *fixture_name) { return fixture_path(CLAR_FIXTURE_PATH, fixture_name); diff --git a/tests/clar/clar/fs.h b/tests/clar/clar/fs.h index 44ede457258..a6eda5e5dc2 100644 --- a/tests/clar/clar/fs.h +++ b/tests/clar/clar/fs.h @@ -295,7 +295,9 @@ fs_copy(const char *_source, const char *_dest) void cl_fs_cleanup(void) { +#ifdef CLAR_FIXTURE_PATH fs_rm(fixture_path(_clar_path, "*")); +#endif } #else