summaryrefslogtreecommitdiffstats
path: root/remote-curl.c
diff options
context:
space:
mode:
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 1930f83cc7..f8c6bd0826 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -60,9 +60,9 @@ struct options {
static struct options options;
static struct string_list cas_options = STRING_LIST_INIT_DUP;
-static int set_option(const char *name, const char *value)
+static int set_option(const char *name, size_t namelen, const char *value)
{
- if (!strcmp(name, "verbosity")) {
+ if (!strncmp(name, "verbosity", namelen)) {
char *end;
int v = strtol(value, &end, 10);
if (value == end || *end)
@@ -70,7 +70,7 @@ static int set_option(const char *name, const char *value)
options.verbosity = v;
return 0;
}
- else if (!strcmp(name, "progress")) {
+ else if (!strncmp(name, "progress", namelen)) {
if (!strcmp(value, "true"))
options.progress = 1;
else if (!strcmp(value, "false"))
@@ -79,7 +79,7 @@ static int set_option(const char *name, const char *value)
return -1;
return 0;
}
- else if (!strcmp(name, "depth")) {
+ else if (!strncmp(name, "depth", namelen)) {
char *end;
unsigned long v = strtoul(value, &end, 10);
if (value == end || *end)
@@ -87,15 +87,15 @@ static int set_option(const char *name, const char *value)
options.depth = v;
return 0;
}
- else if (!strcmp(name, "deepen-since")) {
+ else if (!strncmp(name, "deepen-since", namelen)) {
options.deepen_since = xstrdup(value);
return 0;
}
- else if (!strcmp(name, "deepen-not")) {
+ else if (!strncmp(name, "deepen-not", namelen)) {
string_list_append(&options.deepen_not, value);
return 0;
}
- else if (!strcmp(name, "deepen-relative")) {
+ else if (!strncmp(name, "deepen-relative", namelen)) {
if (!strcmp(value, "true"))
options.deepen_relative = 1;
else if (!strcmp(value, "false"))
@@ -104,7 +104,7 @@ static int set_option(const char *name, const char *value)
return -1;
return 0;
}
- else if (!strcmp(name, "followtags")) {
+ else if (!strncmp(name, "followtags", namelen)) {
if (!strcmp(value, "true"))
options.followtags = 1;
else if (!strcmp(value, "false"))
@@ -113,7 +113,7 @@ static int set_option(const char *name, const char *value)
return -1;
return 0;
}
- else if (!strcmp(name, "dry-run")) {
+ else if (!strncmp(name, "dry-run", namelen)) {
if (!strcmp(value, "true"))
options.dry_run = 1;
else if (!strcmp(value, "false"))
@@ -122,7 +122,7 @@ static int set_option(const char *name, const char *value)
return -1;
return 0;
}
- else if (!strcmp(name, "check-connectivity")) {
+ else if (!strncmp(name, "check-connectivity", namelen)) {
if (!strcmp(value, "true"))
options.check_self_contained_and_connected = 1;
else if (!strcmp(value, "false"))
@@ -131,7 +131,7 @@ static int set_option(const char *name, const char *value)
return -1;
return 0;
}
- else if (!strcmp(name, "cas")) {
+ else if (!strncmp(name, "cas", namelen)) {
struct strbuf val = STRBUF_INIT;
strbuf_addstr(&val, "--force-with-lease=");
if (*value != '"')
@@ -141,7 +141,7 @@ static int set_option(const char *name, const char *value)
string_list_append(&cas_options, val.buf);
strbuf_release(&val);
return 0;
- } else if (!strcmp(name, TRANS_OPT_FORCE_IF_INCLUDES)) {
+ } else if (!strncmp(name, TRANS_OPT_FORCE_IF_INCLUDES, namelen)) {
if (!strcmp(value, "true"))
options.force_if_includes = 1;
else if (!strcmp(value, "false"))
@@ -149,7 +149,7 @@ static int set_option(const char *name, const char *value)
else
return -1;
return 0;
- } else if (!strcmp(name, "cloning")) {
+ } else if (!strncmp(name, "cloning", namelen)) {
if (!strcmp(value, "true"))
options.cloning = 1;
else if (!strcmp(value, "false"))
@@ -157,7 +157,7 @@ static int set_option(const char *name, const char *value)
else
return -1;
return 0;
- } else if (!strcmp(name, "update-shallow")) {
+ } else if (!strncmp(name, "update-shallow", namelen)) {
if (!strcmp(value, "true"))
options.update_shallow = 1;
else if (!strcmp(value, "false"))
@@ -165,7 +165,7 @@ static int set_option(const char *name, const char *value)
else
return -1;
return 0;
- } else if (!strcmp(name, "pushcert")) {
+ } else if (!strncmp(name, "pushcert", namelen)) {
if (!strcmp(value, "true"))
options.push_cert = SEND_PACK_PUSH_CERT_ALWAYS;
else if (!strcmp(value, "false"))
@@ -175,7 +175,7 @@ static int set_option(const char *name, const char *value)
else
return -1;
return 0;
- } else if (!strcmp(name, "atomic")) {
+ } else if (!strncmp(name, "atomic", namelen)) {
if (!strcmp(value, "true"))
options.atomic = 1;
else if (!strcmp(value, "false"))
@@ -183,7 +183,7 @@ static int set_option(const char *name, const char *value)
else
return -1;
return 0;
- } else if (!strcmp(name, "push-option")) {
+ } else if (!strncmp(name, "push-option", namelen)) {
if (*value != '"')
string_list_append(&options.push_options, value);
else {
@@ -194,7 +194,7 @@ static int set_option(const char *name, const char *value)
strbuf_detach(&unquoted, NULL));
}
return 0;
- } else if (!strcmp(name, "family")) {
+ } else if (!strncmp(name, "family", namelen)) {
if (!strcmp(value, "ipv4"))
git_curl_ipresolve = CURL_IPRESOLVE_V4;
else if (!strcmp(value, "ipv6"))
@@ -204,16 +204,16 @@ static int set_option(const char *name, const char *value)
else
return -1;
return 0;
- } else if (!strcmp(name, "from-promisor")) {
+ } else if (!strncmp(name, "from-promisor", namelen)) {
options.from_promisor = 1;
return 0;
- } else if (!strcmp(name, "refetch")) {
+ } else if (!strncmp(name, "refetch", namelen)) {
options.refetch = 1;
return 0;
- } else if (!strcmp(name, "filter")) {
+ } else if (!strncmp(name, "filter", namelen)) {
options.filter = xstrdup(value);
return 0;
- } else if (!strcmp(name, "object-format")) {
+ } else if (!strncmp(name, "object-format", namelen)) {
options.object_format = 1;
if (strcmp(value, "true"))
die(_("unknown value for object-format: %s"), value);
@@ -1607,15 +1607,16 @@ int cmd_main(int argc, const char **argv)
parse_push(&buf);
} else if (skip_prefix(buf.buf, "option ", &arg)) {
- char *value = strchr(arg, ' ');
+ const char *value = strchrnul(arg, ' ');
+ size_t arglen = value - arg;
int result;
- if (value)
- *value++ = '\0';
+ if (*value)
+ value++; /* skip over SP */
else
value = "true";
- result = set_option(arg, value);
+ result = set_option(arg, arglen, value);
if (!result)
printf("ok\n");
else if (result < 0)