Patchwork [3,of,3] chg: check type read from S channel

login
register
mail settings
Submitter Jun Wu
Date Jan. 6, 2017, 4:17 p.m.
Message ID <779b9e867ff7f6e0c0b1.1483719478@x1c>
Download mbox | patch
Permalink /patch/18124/
State Accepted
Headers show

Comments

Jun Wu - Jan. 6, 2017, 4:17 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1483719292 0
#      Fri Jan 06 16:14:52 2017 +0000
# Node ID 779b9e867ff7f6e0c0b12e700195dff97408a16d
# Parent  703fee4099efac592f6ae1c48bfebf806dfd95bf
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 779b9e867ff7
chg: check type read from S channel

The previous patch added the check server-side. This patch added it
client-side.
Sean Farley - Jan. 6, 2017, 7:22 p.m.
Jun Wu <quark@fb.com> writes:

> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1483719292 0
> #      Fri Jan 06 16:14:52 2017 +0000
> # Node ID 779b9e867ff7f6e0c0b12e700195dff97408a16d
> # Parent  703fee4099efac592f6ae1c48bfebf806dfd95bf
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 779b9e867ff7
> chg: check type read from S channel
>
> The previous patch added the check server-side. This patch added it
> client-side.

This seems like a good and fairly straight-forward refactor to me.
Thanks!
Yuya Nishihara - Jan. 9, 2017, 12:40 p.m.
On Fri, 06 Jan 2017 11:22:32 -0800, Sean Farley wrote:
> Jun Wu <quark@fb.com> writes:
> > # HG changeset patch
> > # User Jun Wu <quark@fb.com>
> > # Date 1483719292 0
> > #      Fri Jan 06 16:14:52 2017 +0000
> > # Node ID 779b9e867ff7f6e0c0b12e700195dff97408a16d
> > # Parent  703fee4099efac592f6ae1c48bfebf806dfd95bf
> > # Available At https://bitbucket.org/quark-zju/hg-draft
> > #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 779b9e867ff7
> > chg: check type read from S channel
> >
> > The previous patch added the check server-side. This patch added it
> > client-side.
> 
> This seems like a good and fairly straight-forward refactor to me.
> Thanks!

Yeah, queued these, thanks.

Patch

diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
--- a/contrib/chg/hgclient.c
+++ b/contrib/chg/hgclient.c
@@ -240,12 +240,16 @@  static void handlesystemrequest(hgclient
 	if (!args[0] || !args[1] || !args[2])
 		abortmsg("missing type or command or cwd in system request");
-	debugmsg("run '%s' at '%s'", args[1], args[2]);
-	int32_t r = runshellcmd(args[1], args + 3, args[2]);
-	free(args);
+	if (strcmp(args[0], "system") == 0) {
+		debugmsg("run '%s' at '%s'", args[1], args[2]);
+		int32_t r = runshellcmd(args[1], args + 3, args[2]);
+		free(args);
 
-	uint32_t r_n = htonl(r);
-	memcpy(ctx->data, &r_n, sizeof(r_n));
-	ctx->datasize = sizeof(r_n);
-	writeblock(hgc);
+		uint32_t r_n = htonl(r);
+		memcpy(ctx->data, &r_n, sizeof(r_n));
+		ctx->datasize = sizeof(r_n);
+		writeblock(hgc);
+	} else {
+		abortmsg("unknown type in system request: %s", args[0]);
+	}
 }