zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1755750 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/c/README src/c/src/cli.c
Date Wed, 10 Aug 2016 14:11:48 GMT
Author: fpj
Date: Wed Aug 10 14:11:48 2016
New Revision: 1755750

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

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/c/README
    zookeeper/branches/branch-3.4/src/c/src/cli.c

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1755750&r1=1755749&r2=1755750&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Wed Aug 10 14:11:48 2016
@@ -45,6 +45,8 @@ BUGFIXES:
   ZOOKEEPER-2498: Potential resource leak in C client when processing
   unexpected / out of order response (Michael Han via rgs)
 
+  Fix command handling in the C client shell (phunt via fpj)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-2240 Make the three-node minimum more explicit in 

Modified: zookeeper/branches/branch-3.4/src/c/README
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/README?rev=1755750&r1=1755749&r2=1755750&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/c/README (original)
+++ zookeeper/branches/branch-3.4/src/c/README Wed Aug 10 14:11:48 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/branches/branch-3.4/src/c/src/cli.c
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/cli.c?rev=1755750&r1=1755749&r2=1755750&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/c/src/cli.c (original)
+++ zookeeper/branches/branch-3.4/src/c/src/cli.c Wed Aug 10 14:11:48 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>
@@ -540,7 +548,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