]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Define "Unknown Command" Macro to replace hard coded strings in rpc files
authorJohn Wolfe <jwolfe@vmware.com>
Tue, 18 Aug 2020 14:14:11 +0000 (07:14 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Tue, 18 Aug 2020 14:14:11 +0000 (07:14 -0700)
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.

open-vm-tools/lib/include/vmware/guestrpc/tclodefs.h
open-vm-tools/lib/rpcChannel/rpcChannel.c
open-vm-tools/lib/rpcIn/rpcin.c

index 716e38195fe859adbfe29536de4f2f0282a022fb..3a7e1703886c16bb3e520056f8334abb36800db4 100644 (file)
@@ -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
 
index 236ed8635ab74b605c5163e44375dbf092af5fed..ba61a1e206bc26db13170329fc385268400b2c37 100644 (file)
@@ -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;
    }
 
index 094cd228c887d8e52a235deb78cb5cd6506c0ea0..8b1fe759d5c0f205630138a664610349247c3f1f 100644 (file)
@@ -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 <arpa/inet.h>
 #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);