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

Jun Wu quark at fb.com
Fri Jan 6 11:17:58 EST 2017


# HG changeset patch
# User Jun Wu <quark at 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.

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]);
+	}
 }
 


More information about the Mercurial-devel mailing list