From: John Wolfe Date: Tue, 18 Aug 2020 14:14:11 +0000 (-0700) Subject: Define "Unknown Command" Macro to replace hard coded strings in rpc files X-Git-Tag: stable-11.2.0~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07b065dbceadc6968f9b145dcef13a9fdfde1587;p=thirdparty%2Fopen-vm-tools.git Define "Unknown Command" Macro to replace hard coded strings in rpc files This changeset finds all instances of the hardcoded string "Unknown Command" in a few rpc files and replaces it with a macro defined in a shared header file. --- diff --git a/open-vm-tools/lib/include/vmware/guestrpc/tclodefs.h b/open-vm-tools/lib/include/vmware/guestrpc/tclodefs.h index 716e38195..3a7e17038 100644 --- a/open-vm-tools/lib/include/vmware/guestrpc/tclodefs.h +++ b/open-vm-tools/lib/include/vmware/guestrpc/tclodefs.h @@ -50,6 +50,9 @@ /** Reply from host when the command is not recognized. */ #define RPCI_UNKNOWN_COMMAND "Unknown command" +/** Reply from the guest when the command is not recognized. */ +#define GUEST_RPC_UNKNOWN_COMMAND "Unknown Command" + #define GUESTRPC_TCLO_VSOCK_LISTEN_PORT 975 #define GUESTRPC_RPCI_VSOCK_LISTEN_PORT 976 diff --git a/open-vm-tools/lib/rpcChannel/rpcChannel.c b/open-vm-tools/lib/rpcChannel/rpcChannel.c index 236ed8635..ba61a1e20 100644 --- a/open-vm-tools/lib/rpcChannel/rpcChannel.c +++ b/open-vm-tools/lib/rpcChannel/rpcChannel.c @@ -32,6 +32,7 @@ #include "vmxrpc.h" #include "xdrutil.h" #include "rpcin.h" +#include "vmware/guestrpc/tclodefs.h" #endif #include "str.h" @@ -431,7 +432,7 @@ RpcChannel_Dispatch(RpcInData *data) if (rpc == NULL) { Debug(LGPFX "Unknown Command '%s': Handler not registered.\n", name); - status = RPCIN_SETRETVALS(data, "Unknown Command", FALSE); + status = RPCIN_SETRETVALS(data, GUEST_RPC_UNKNOWN_COMMAND, FALSE); goto exit; } diff --git a/open-vm-tools/lib/rpcIn/rpcin.c b/open-vm-tools/lib/rpcIn/rpcin.c index 094cd228c..8b1fe759d 100644 --- a/open-vm-tools/lib/rpcIn/rpcin.c +++ b/open-vm-tools/lib/rpcIn/rpcin.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2020 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -61,7 +61,6 @@ # include "asyncsocket.h" # include "vmci_defs.h" #include "dataMap.h" -#include "vmware/guestrpc/tclodefs.h" #if defined(__linux__) #include #else @@ -74,6 +73,7 @@ # include "vmware/tools/utils.h" #endif +#include "vmware/guestrpc/tclodefs.h" #include "vmware.h" #include "message.h" #include "rpcin.h" @@ -1342,7 +1342,7 @@ RpcInExecRpc(RpcIn *in, // IN } else { Debug("RpcIn: Unknown Command '%s': No matching callback\n", cmd); status = FALSE; - result = "Unknown Command"; + result = GUEST_RPC_UNKNOWN_COMMAND; resultLen = strlen(result); } free(cmd);