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:
[email protected]


With regards,
Apache Git Services

Reply via email to