Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-11-03 00:17:37 +0300
committerJunio C Hamano <gitster@pobox.com>2020-11-03 00:17:37 +0300
commit6b9f5096eb034cc59a0a71b86ae65eb9433c8ea8 (patch)
treebde79de138bb1039dda0b27b360969114b3610c5
parente2850a27a95c6f5b141dd88398b1702d2e524a81 (diff)
parent712b0377db60e0d3ac8bf3332022dfcd01e29afa (diff)
Merge branch 'js/avoid-split-sideband-message'
The side-band status report can be sent at the same time as the primary payload multiplexed, but the demultiplexer on the receiving end incorrectly split a single status report into two, which has been corrected. * js/avoid-split-sideband-message: test-pkt-line: drop colon from sideband identity sideband: report unhandled incomplete sideband messages as bugs sideband: avoid reporting incomplete sideband messages
-rw-r--r--pkt-line.c3
-rw-r--r--sideband.c2
-rw-r--r--t/helper/test-pkt-line.c23
-rwxr-xr-xt/t0070-fundamental.sh6
4 files changed, 33 insertions, 1 deletions
diff --git a/pkt-line.c b/pkt-line.c
index 844c253ccd..657a702927 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -471,6 +471,9 @@ int recv_sideband(const char *me, int in_stream, int out)
write_or_die(out, buf + 1, len - 1);
break;
default: /* errors: message already written */
+ if (scratch.len > 0)
+ BUG("unhandled incomplete sideband: '%s'",
+ scratch.buf);
return sideband_type;
}
}
diff --git a/sideband.c b/sideband.c
index 0a60662fa6..a5405b9aaa 100644
--- a/sideband.c
+++ b/sideband.c
@@ -190,7 +190,7 @@ int demultiplex_sideband(const char *me, char *buf, int len,
return 0;
case 1:
*sideband_type = SIDEBAND_PRIMARY;
- break;
+ return 1;
default:
strbuf_addf(scratch, "%s%s: protocol error: bad band #%d",
scratch->len ? "\n" : "", me, band);
diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c
index 69152958e5..5e638f0b97 100644
--- a/t/helper/test-pkt-line.c
+++ b/t/helper/test-pkt-line.c
@@ -84,6 +84,25 @@ static void unpack_sideband(void)
}
}
+static int send_split_sideband(void)
+{
+ const char *part1 = "Hello,";
+ const char *primary = "\001primary: regular output\n";
+ const char *part2 = " world!\n";
+
+ send_sideband(1, 2, part1, strlen(part1), LARGE_PACKET_MAX);
+ packet_write(1, primary, strlen(primary));
+ send_sideband(1, 2, part2, strlen(part2), LARGE_PACKET_MAX);
+ packet_response_end(1);
+
+ return 0;
+}
+
+static int receive_sideband(void)
+{
+ return recv_sideband("sideband", 0, 1);
+}
+
int cmd__pkt_line(int argc, const char **argv)
{
if (argc < 2)
@@ -95,6 +114,10 @@ int cmd__pkt_line(int argc, const char **argv)
unpack();
else if (!strcmp(argv[1], "unpack-sideband"))
unpack_sideband();
+ else if (!strcmp(argv[1], "send-split-sideband"))
+ send_split_sideband();
+ else if (!strcmp(argv[1], "receive-sideband"))
+ receive_sideband();
else
die("invalid argument '%s'", argv[1]);
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index 7b111a56fd..357201640a 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -34,4 +34,10 @@ test_expect_success 'check for a bug in the regex routines' '
test-tool regex --bug
'
+test_expect_success 'incomplete sideband messages are reassembled' '
+ test-tool pkt-line send-split-sideband >split-sideband &&
+ test-tool pkt-line receive-sideband <split-sideband 2>err &&
+ grep "Hello, world" err
+'
+
test_done