Re: [PATCH v7 2/2] http-backend: respect CONTENT_LENGTH for receive-pack

3 messages, 3 authors, 2018-06-05 · open the first message on its own page

Re: [PATCH v7 2/2] http-backend: respect CONTENT_LENGTH for receive-pack

From: Junio C Hamano <hidden>
Date: 2018-06-04 04:32:03

Max Kirillov [off-list ref] writes:
quoted hunk
+static void pipe_fixed_length(const char *prog_name, int out, size_t req_len)
+{
+	unsigned char buf[8192];
+	size_t remaining_len = req_len;
+
+	while (remaining_len > 0) {
+		size_t chunk_length = remaining_len > sizeof(buf) ? sizeof(buf) : remaining_len;
+		size_t n = xread(0, buf, chunk_length);
+		if (n < 0)
+			die_errno("Reading request failed");
n that is of type size_t is unsigned and cannot be negative here.

Re: [PATCH v7 2/2] http-backend: respect CONTENT_LENGTH for receive-pack

From: Max Kirillov <hidden>
Date: 2018-06-04 17:06:47

On Mon, Jun 04, 2018 at 01:31:58PM +0900, Junio C Hamano wrote:
Max Kirillov [off-list ref] writes:
quoted
+		size_t n = xread(0, buf, chunk_length);
+		if (n < 0)
+			die_errno("Reading request failed");
n that is of type size_t is unsigned and cannot be negative here.
Thanks, fixing it
Do you think sanity check for n <= chunk_length (the code
will go mad in this case) is needed? As far as I can see n
returns straight from system's read()

Re: [PATCH v7 2/2] http-backend: respect CONTENT_LENGTH for receive-pack

From: Ramsay Jones <hidden>
Date: 2018-06-05 02:30:30


On 04/06/18 18:06, Max Kirillov wrote:
On Mon, Jun 04, 2018 at 01:31:58PM +0900, Junio C Hamano wrote:
quoted
Max Kirillov [off-list ref] writes:
quoted
+		size_t n = xread(0, buf, chunk_length);
+		if (n < 0)
+			die_errno("Reading request failed");
n that is of type size_t is unsigned and cannot be negative here.
Hmm, xread() returns an ssize_t, which is a signed type ...
Thanks, fixing it
Do you think sanity check for n <= chunk_length (the code
will go mad in this case) is needed? As far as I can see n
returns straight from system's read()
ATB,
Ramsay Jones
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help