zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1755857 - in /zookeeper/trunk: CHANGES.txt src/c/README src/c/src/cli.c
Date Wed, 10 Aug 2016 21:01:21 GMT
Author: fpj
Date: Wed Aug 10 21:01:21 2016
New Revision: 1755857

URL: http://svn.apache.org/viewvc?rev=1755857&view=rev
Log:
Fix command handling in the C client shell (phunt via fpj)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/c/README
    zookeeper/trunk/src/c/src/cli.c

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1755857&r1=1755856&r2=1755857&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Wed Aug 10 21:01:21 2016
@@ -347,6 +347,8 @@ BUGFIXES:
   ZOOKEEPER-2074: Incorrect exit codes for "./zkCli.sh cmd arg"
   (Abraham Fine via phunt)
 
+  Fix command handling in the C client shell (phunt via fpj)
+
 IMPROVEMENTS:
   ZOOKEEPER-2024 Major throughput improvement with mixed workloads (Kfir Lev-Ari via shralex)
 

Modified: zookeeper/trunk/src/c/README
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/README?rev=1755857&r1=1755856&r2=1755857&view=diff
==============================================================================
--- zookeeper/trunk/src/c/README (original)
+++ zookeeper/trunk/src/c/README Wed Aug 10 21:01:21 2016
@@ -72,7 +72,12 @@ tar downloaded from Apache please skip t
    other document formats please use "./configure --help"
 
 
-USING THE CLIENT
+EXAMPLE/SAMPLE C CLIENT SHELL
+
+NOTE: the ZooKeeper C client shell (cli_st and cli_mt) is meant as a
+example/sample of ZooKeeper C client API usage. It is not a full
+fledged client and not meant for production usage - see the Java
+client shell for a fully featured shell.
 
 You can test your client by running a zookeeper server (see
 instructions on the project wiki page on how to run it) and connecting

Modified: zookeeper/trunk/src/c/src/cli.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/cli.c?rev=1755857&r1=1755856&r2=1755857&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/cli.c (original)
+++ zookeeper/trunk/src/c/src/cli.c Wed Aug 10 21:01:21 2016
@@ -16,6 +16,14 @@
  * limitations under the License.
  */
 
+/**
+ * cli.c is a example/sample C client shell for ZooKeeper. It contains
+ * basic shell functionality which exercises some of the features of
+ * the ZooKeeper C client API. It is not a full fledged client and is
+ * not meant for production usage - see the Java client shell for a
+ * fully featured shell.
+ */
+
 #include <zookeeper.h>
 #include <proto.h>
 #include <stdlib.h>
@@ -679,7 +687,15 @@ int main(int argc, char **argv) {
     }
     if (argc > 2) {
       if(strncmp("cmd:",argv[2],4)==0){
-        strcpy(cmd,argv[2]+4);
+        size_t cmdlen = strlen(argv[2]);
+        if (cmdlen > sizeof(cmd)) {
+          fprintf(stderr,
+                  "Command length %zu exceeds max length of %zu\n",
+                  cmdlen,
+                  sizeof(cmd));
+          return 2;
+        }
+        strncpy(cmd, argv[2]+4, sizeof(cmd));
         batchMode=1;
         fprintf(stderr,"Batch mode: %s\n",cmd);
       }else{



Mime
View raw message