changeset 30728:7438cb35979a

chg: check type read from S channel The previous patch added the check server-side. This patch added it client-side.
author Jun Wu <quark@fb.com>
date Fri, 06 Jan 2017 16:14:52 +0000
parents 18eb63ec8475
children a4bc8fff67fc
files contrib/chg/hgclient.c
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/hgclient.c	Fri Jan 06 16:12:25 2017 +0000
+++ b/contrib/chg/hgclient.c	Fri Jan 06 16:14:52 2017 +0000
@@ -239,14 +239,18 @@
 	const char **args = unpackcmdargsnul(ctx);
 	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]);
+	}
 }
 
 /* Read response of command execution until receiving 'r'-esult */