You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by nk...@apache.org on 2020/02/09 13:55:11 UTC

[zookeeper] branch branch-3.5 updated: ZOOKEEPER-3719: Fix C Client compilation issues

This is an automated email from the ASF dual-hosted git repository.

nkalmar pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/branch-3.5 by this push:
     new 9c0773c  ZOOKEEPER-3719: Fix C Client compilation issues
9c0773c is described below

commit 9c0773cbac6958e1a47071c6ebded65f38b1517f
Author: Damien Diederen <dd...@crosstwine.com>
AuthorDate: Sun Feb 9 14:54:44 2020 +0100

    ZOOKEEPER-3719: Fix C Client compilation issues
    
    This series fixes the following:
    
      * Actually build the C code in `full-build` profile:
    
        Without this, the C client is configured by Maven, but not built.
        This helps avoiding compilation errors, but has other downsides.
    
      * Fix Windows compilation issue:
    
        The backport of ZOOKEEPER-1105 introduced a compilation error in
        one of the `WIN32` branches of the C client code.
    
        This happened because the "socket object" does not use the same
        representation on `branch-3.5` (as it does not include the SSL
        support introduced by ZOOKEEPER-2122).
    
      * Fix GCC 8.3 compilation issues:
    
        `Makefile.am` uses `-Werror`, and this causes the build to fail
        with GCC 8.3, which warns about a couple possible buffer overruns.
    
    Author: Damien Diederen <dd...@crosstwine.com>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>, Norbert Kalmar <nk...@apache.org>
    
    Closes #1249 from ztzg/ZOOKEEPER-3719-c-client-3.5.7-fixes
    
    (cherry picked from commit 89730f4adcda9c9b3bf19ccdaf4cc65b0a8fec1d)
    Signed-off-by: Norbert Kalmar <nk...@apache.org>
---
 zookeeper-client/zookeeper-client-c/pom.xml         | 21 ++++++++++++++++++---
 zookeeper-client/zookeeper-client-c/src/cli.c       |  3 ++-
 zookeeper-client/zookeeper-client-c/src/zookeeper.c |  4 ++--
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/zookeeper-client/zookeeper-client-c/pom.xml b/zookeeper-client/zookeeper-client-c/pom.xml
index 40e6bb0..1f56284 100755
--- a/zookeeper-client/zookeeper-client-c/pom.xml
+++ b/zookeeper-client/zookeeper-client-c/pom.xml
@@ -80,7 +80,7 @@
         <executions>
           <execution>
             <id>autoreconf</id>
-            <phase>test-compile</phase>
+            <phase>process-sources</phase>
             <goals>
               <goal>exec</goal>
             </goals>
@@ -97,7 +97,7 @@
           </execution>
           <execution>
             <id>configure</id>
-            <phase>test-compile</phase>
+            <phase>process-sources</phase>
             <goals>
               <goal>exec</goal>
             </goals>
@@ -114,6 +114,21 @@
               </arguments>
             </configuration>
           </execution>
+          <execution>
+            <id>build-c-client</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+            <configuration>
+              <workingDirectory>${project.build.directory}/c</workingDirectory>
+              <executable>make</executable>
+              <arguments>
+                <argument>clean</argument>
+                <argument>install</argument>
+              </arguments>
+            </configuration>
+          </execution>
           <!--execution> TODO: Why is this not working?!
             <id>test-cppunit</id>
             <phase>test</phase>
@@ -140,4 +155,4 @@
     </plugins>
   </build>
 
-</project>
\ No newline at end of file
+</project>
diff --git a/zookeeper-client/zookeeper-client-c/src/cli.c b/zookeeper-client/zookeeper-client-c/src/cli.c
index eca3b63..3494f83 100644
--- a/zookeeper-client/zookeeper-client-c/src/cli.c
+++ b/zookeeper-client/zookeeper-client-c/src/cli.c
@@ -747,7 +747,8 @@ int main(int argc, char **argv) {
                   sizeof(cmd));
           return 2;
         }
-        strncpy(cmd, argv[2]+4, sizeof(cmd));
+        strncpy(cmd, argv[2]+4, sizeof(cmd)-1);
+        cmd[sizeof(cmd)-1] = '\0';
         batchMode=1;
         fprintf(stderr,"Batch mode: %s\n",cmd);
       }else{
diff --git a/zookeeper-client/zookeeper-client-c/src/zookeeper.c b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
index 04cfae2..a43ebf2 100644
--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
@@ -3274,7 +3274,7 @@ int wait_for_session_to_be_closed(zhandle_t *zh, int timeout_ms)
     ret = poll(fd_s, 1, timeout_ms);
 #else
     FD_ZERO(&rfds);
-    FD_SET(zh->fd->sock , &rfds);
+    FD_SET(zh->fd , &rfds);
     ret = select((int)(zh->fd)+1, &rfds, NULL, NULL, &waittime);
 #endif
 
@@ -4557,7 +4557,7 @@ int zoo_add_auth(zhandle_t *zh,const char* scheme,const char* cert,
 
 static const char* format_endpoint_info(const struct sockaddr_storage* ep)
 {
-    static char buf[128] = { 0 };
+    static char buf[128+6] = { 0 };
     char addrstr[128] = { 0 };
     void *inaddr;
 #ifdef _WIN32