zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] phunt commented on a change in pull request #846: ZOOKEEPER-3302 ZooKeeper C client does not compile on Fedora 29
Date Wed, 13 Mar 2019 04:41:44 GMT
phunt commented on a change in pull request #846: ZOOKEEPER-3302 ZooKeeper C client does not
compile on Fedora 29
URL: https://github.com/apache/zookeeper/pull/846#discussion_r264972610
 
 

 ##########
 File path: zookeeper-client/zookeeper-client-c/src/cli.c
 ##########
 @@ -678,15 +678,15 @@ int main(int argc, char **argv) {
     }
     if (argc > 2) {
       if(strncmp("cmd:",argv[2],4)==0){
-        size_t cmdlen = strlen(argv[2]);
+        size_t cmdlen = strlen(argv[2]) - 4;
         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));
+        memcpy(cmd, argv[2]+4, cmdlen + 1);
 
 Review comment:
   This looks broken to me given the conditional above. "if (cmdlen > sizeof(cmd))"

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message