From 6e0452459640b892e8fc2ea7435f5e847cc33967 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 16 Nov 2007 21:31:03 +0000 Subject: switch-client command. --- server-msg.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'server-msg.c') diff --git a/server-msg.c b/server-msg.c index 7c132d7a..3af04de8 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.31 2007-11-16 21:12:31 nicm Exp $ */ +/* $Id: server-msg.c,v 1.32 2007-11-16 21:31:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -111,6 +111,8 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) char *name, *client, *cause; u_int i; + /* XXX I hate this function. Split it? */ + if (hdr->size < sizeof data) fatalx("bad MSG_COMMAND size"); buffer_read(c->in, &data, sizeof data); @@ -141,8 +143,8 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) } } else { if (client == NULL) { - server_msg_fn_command_error(&ctx, "%s: must " - "specify a client: %s", cmd->entry->name, client); + server_msg_fn_command_error(&ctx, + "%s: must specify a client: %s", cmd->entry->name); goto out; } for (i = 0; i < ARRAY_LENGTH(&clients); i++) { @@ -158,15 +160,15 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) } } - ctx.session = server_extract_session(&data, name, &cause); + ctx.session = NULL; if (cmd->entry->flags & CMD_NOSESSION) { - if (ctx.session != NULL) { + if (name != NULL) { server_msg_fn_command_error(&ctx, "%s: cannot specify a session", cmd->entry->name); goto out; - } else - xfree(cause); + } } else { + ctx.session = server_extract_session(&data, name, &cause); if (ctx.session == NULL) { server_msg_fn_command_error( &ctx, "%s: %s", cmd->entry->name, cause); -- cgit