Hello community,

here is the log from the commit of package nss_wrapper for openSUSE:Factory 
checked in at 2020-03-19 19:47:57
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nss_wrapper (Old)
 and      /work/SRC/openSUSE:Factory/.nss_wrapper.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "nss_wrapper"

Thu Mar 19 19:47:57 2020 rev:11 rq:786394 version:1.1.10

Changes:
--------
--- /work/SRC/openSUSE:Factory/nss_wrapper/nss_wrapper.changes  2020-02-21 
16:40:39.157828598 +0100
+++ /work/SRC/openSUSE:Factory/.nss_wrapper.new.3160/nss_wrapper.changes        
2020-03-19 19:50:39.088196307 +0100
@@ -1,0 +2,13 @@
+Thu Mar 19 09:53:19 UTC 2020 - Andreas Schneider <[email protected]>
+
+- Update to version 1.1.10
+  * Fixed crash bug in OpenLDAP libraries with gethostbyname_r()
+  * Code cleanup in gethostbyname(2)(_r) functions
+
+-------------------------------------------------------------------
+Mon Mar 16 16:14:14 UTC 2020 - Andreas Schneider <[email protected]>
+
+- Update to version 1.1.9
+  * Fixed log spam when loading modules
+
+-------------------------------------------------------------------

Old:
----
  nss_wrapper-1.1.8.tar.gz
  nss_wrapper-1.1.8.tar.gz.asc

New:
----
  nss_wrapper-1.1.10.tar.gz
  nss_wrapper-1.1.10.tar.gz.asc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ nss_wrapper.spec ++++++
--- /var/tmp/diff_new_pack.SyYpEi/_old  2020-03-19 19:50:40.012196841 +0100
+++ /var/tmp/diff_new_pack.SyYpEi/_new  2020-03-19 19:50:40.016196843 +0100
@@ -24,7 +24,7 @@
 ############################# NOTE ##################################
 
 Name:           nss_wrapper
-Version:        1.1.8
+Version:        1.1.10
 Release:        0
 
 Summary:        A wrapper for the user, group and hosts NSS API

++++++ nss_wrapper-1.1.8.tar.gz -> nss_wrapper-1.1.10.tar.gz ++++++
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/nss_nwrap.c.6CD8D6240BEF45A7.idx and 
new/nss_wrapper-1.1.10/.clangd/index/nss_nwrap.c.6CD8D6240BEF45A7.idx differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/nss_wrapper.c.496306141B70693D.idx and 
new/nss_wrapper-1.1.10/.clangd/index/nss_wrapper.c.496306141B70693D.idx differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_getaddrinfo.c.641BB471F444137A.idx and 
new/nss_wrapper-1.1.10/.clangd/index/test_getaddrinfo.c.641BB471F444137A.idx 
differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_gethostby_name_addr.c.C9C460E7372D7C61.idx
 and 
new/nss_wrapper-1.1.10/.clangd/index/test_gethostby_name_addr.c.C9C460E7372D7C61.idx
 differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_gethostent.c.FDE119456A174D8F.idx and 
new/nss_wrapper-1.1.10/.clangd/index/test_gethostent.c.FDE119456A174D8F.idx 
differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_getnameinfo.c.779E41D17A149E05.idx and 
new/nss_wrapper-1.1.10/.clangd/index/test_getnameinfo.c.779E41D17A149E05.idx 
differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_nwrap_disabled.c.59E63F9B2D58E517.idx 
and 
new/nss_wrapper-1.1.10/.clangd/index/test_nwrap_disabled.c.59E63F9B2D58E517.idx 
differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_nwrap_vector.c.6DA36926E43E358A.idx 
and 
new/nss_wrapper-1.1.10/.clangd/index/test_nwrap_vector.c.6DA36926E43E358A.idx 
differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/test_shadow.c.85DFA55943F2551B.idx and 
new/nss_wrapper-1.1.10/.clangd/index/test_shadow.c.85DFA55943F2551B.idx differ
Binary files 
old/nss_wrapper-1.1.8/.clangd/index/testsuite.c.AF64C06B860D31A7.idx and 
new/nss_wrapper-1.1.10/.clangd/index/testsuite.c.AF64C06B860D31A7.idx differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/CHANGELOG 
new/nss_wrapper-1.1.10/CHANGELOG
--- old/nss_wrapper-1.1.8/CHANGELOG     2020-02-17 10:42:43.000000000 +0100
+++ new/nss_wrapper-1.1.10/CHANGELOG    2020-03-19 10:07:54.000000000 +0100
@@ -1,6 +1,13 @@
 ChangeLog
 ==========
 
+version 1.1.10 (released 2020-03-19)
+  * Fixed crash bug in OpenLDAP libraries with gethostbyname_r()
+  * Code cleanup in gethostbyname(2)(_r) functions
+
+version 1.1.9 (released 2020-03-16)
+  * Fixed log spam when loading modules
+
 version 1.1.8 (released 2020-02-17)
   * Fixed path to library in nss_wrapper.pc
   * Try different backends for gethostbyaddr nd gethostbyname
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/CMakeLists.txt 
new/nss_wrapper-1.1.10/CMakeLists.txt
--- old/nss_wrapper-1.1.8/CMakeLists.txt        2020-02-17 10:42:43.000000000 
+0100
+++ new/nss_wrapper-1.1.10/CMakeLists.txt       2020-03-19 10:05:40.000000000 
+0100
@@ -11,20 +11,23 @@
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(nss_wrapper VERSION 1.1.8 LANGUAGES C)
+project(nss_wrapper VERSION 1.1.10 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
 
-# SOVERSION scheme: CURRENT.AGE.REVISION
+# SOVERSION scheme: MAJOR.MINOR.PATCH
 #   If there was an incompatible interface change:
-#     Increment CURRENT. Set AGE and REVISION to 0
+#     Increment MAJOR. Set MINOR and PATCH to 0
 #   If there was a compatible interface change:
-#     Increment AGE. Set REVISION to 0
+#     Increment MINOR. Set PATCH to 0
 #   If the source code was changed, but there were no interface changes:
-#     Increment REVISION.
-set(LIBRARY_VERSION "0.2.7")
-set(LIBRARY_SOVERSION "0")
+#     Increment PATCH.
+set(LIBRARY_VERSION_MAJOR 0)
+set(LIBRARY_VERSION_MINOR 3)
+set(LIBRARY_VERSION_PATCH 0)
+set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
+set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 
 # add definitions
 include(DefineCMakeDefaults)
@@ -94,3 +97,12 @@
 )
 
 add_subdirectory(doc)
+
+# Add 'make dist' target which makes sure to invoke cmake before
+add_custom_target(dist
+                  COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
+
+# Link combile database for clangd
+execute_process(COMMAND cmake -E create_symlink
+                "${CMAKE_BINARY_DIR}/compile_commands.json"
+                "${CMAKE_SOURCE_DIR}/compile_commands.json")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/ConfigureChecks.cmake 
new/nss_wrapper-1.1.10/ConfigureChecks.cmake
--- old/nss_wrapper-1.1.8/ConfigureChecks.cmake 2019-11-13 15:40:38.000000000 
+0100
+++ new/nss_wrapper-1.1.10/ConfigureChecks.cmake        2020-03-17 
20:05:20.000000000 +0100
@@ -77,6 +77,7 @@
 check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
 
 check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
+check_function_exists(gethostbyname2_r HAVE_GETHOSTBYNAME2_R)
 
 check_function_exists(getprogname HAVE_GETPROGNAME)
 check_function_exists(getexecname HAVE_GETEXECNAME)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/compile_commands.json 
new/nss_wrapper-1.1.10/compile_commands.json
--- old/nss_wrapper-1.1.8/compile_commands.json 1970-01-01 01:00:00.000000000 
+0100
+++ new/nss_wrapper-1.1.10/compile_commands.json        2020-03-19 
19:50:40.100196891 +0100
@@ -0,0 +1 @@
+symbolic link to 
/home/asn/workspace/projects/nss_wrapper/obj/compile_commands.json
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/config.h.cmake 
new/nss_wrapper-1.1.10/config.h.cmake
--- old/nss_wrapper-1.1.8/config.h.cmake        2019-11-13 15:40:38.000000000 
+0100
+++ new/nss_wrapper-1.1.10/config.h.cmake       2020-03-17 20:05:20.000000000 
+0100
@@ -59,6 +59,9 @@
 /* Define to 1 if you have the `gethostbyname2' function. */
 #cmakedefine HAVE_GETHOSTBYNAME2 1
 
+/* Define to 1 if you have the `gethostbyname2_r' function. */
+#cmakedefine HAVE_GETHOSTBYNAME2_R 1
+
 #cmakedefine HAVE_GETPROGNAME 1
 #cmakedefine HAVE_GETEXECNAME 1
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/src/nss_wrapper.c 
new/nss_wrapper-1.1.10/src/nss_wrapper.c
--- old/nss_wrapper-1.1.8/src/nss_wrapper.c     2020-02-17 10:42:35.000000000 
+0100
+++ new/nss_wrapper-1.1.10/src/nss_wrapper.c    2020-03-19 10:03:10.000000000 
+0100
@@ -352,6 +352,15 @@
 #ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
        struct hostent *(*_libc_gethostbyname2)(const char *name, int af);
 #endif
+#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
+       int (*_libc_gethostbyname2_r)(const char *name,
+                                     int af,
+                                     struct hostent *ret,
+                                     char *buf,
+                                     size_t buflen,
+                                     struct hostent **result,
+                                     int *h_errnop);
+#endif
        struct hostent *(*_libc_gethostbyaddr)(const void *addr, socklen_t len, 
int type);
 
        int (*_libc_getaddrinfo)(const char *node, const char *service,
@@ -512,8 +521,10 @@
                                                 socklen_t len, int type);
 static struct hostent *nwrap_files_gethostbyname(struct nwrap_backend *b,
                                                 const char *name);
+#ifdef HAVE_GETHOSTBYNAME2
 static struct hostent *nwrap_files_gethostbyname2(struct nwrap_backend *b,
                                                  const char *name, int af);
+#endif /* HAVE_GETHOSTBYNAME2 */
 static int nwrap_files_gethostbyname2_r(struct nwrap_backend *b,
                                        const char *name, int af,
                                        struct hostent *hedst,
@@ -589,7 +600,9 @@
        .nw_endgrent    = nwrap_files_endgrent,
        .nw_gethostbyaddr       = nwrap_files_gethostbyaddr,
        .nw_gethostbyname       = nwrap_files_gethostbyname,
+#ifdef HAVE_GETHOSTBYNAME2
        .nw_gethostbyname2      = nwrap_files_gethostbyname2,
+#endif /* HAVE_GETHOSTBYNAME2 */
        .nw_gethostbyname2_r    = nwrap_files_gethostbyname2_r,
 };
 
@@ -1372,6 +1385,27 @@
 }
 #endif
 
+#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
+static int libc_gethostbyname2_r(const char *name,
+                                int af,
+                                struct hostent *ret,
+                                char *buf,
+                                size_t buflen,
+                                struct hostent **result,
+                                int *h_errnop)
+{
+       nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname2_r);
+
+       return nwrap_main_global->libc->fns->_libc_gethostbyname2_r(name,
+                                                                   af,
+                                                                   ret,
+                                                                   buf,
+                                                                   buflen,
+                                                                   result,
+                                                                   h_errnop);
+}
+#endif
+
 static struct hostent *libc_gethostbyaddr(const void *addr,
                                          socklen_t len,
                                          int type)
@@ -1471,22 +1505,24 @@
 static void *nwrap_load_module_fn(struct nwrap_backend *b,
                                  const char *fn_name)
 {
-       void *res;
-       char *s;
+       void *res = NULL;
+       char *s = NULL;
+       int rc;
 
-       if (!b->so_handle) {
+       if (b->so_handle == NULL) {
                NWRAP_LOG(NWRAP_LOG_ERROR, "No handle");
                return NULL;
        }
 
-       if (asprintf(&s, "_nss_%s_%s", b->name, fn_name) == -1) {
+       rc = asprintf(&s, "_nss_%s_%s", b->name, fn_name);
+       if (rc == -1) {
                NWRAP_LOG(NWRAP_LOG_ERROR, "Out of memory");
                return NULL;
        }
 
        res = dlsym(b->so_handle, s);
-       if (!res) {
-               NWRAP_LOG(NWRAP_LOG_ERROR,
+       if (res == NULL) {
+               NWRAP_LOG(NWRAP_LOG_WARN,
                          "Cannot find function %s in %s",
                          s, b->so_path);
        }
@@ -3585,6 +3621,12 @@
        bool he_found = false;
        bool ok;
 
+       /*
+        * We need to make sure we have zeroed return pointer for consumers
+        * which don't check return values, e.g. OpenLDAP.
+        */
+       ZERO_STRUCTP(result);
+
        ok = nwrap_files_cache_reload(nwrap_he_global.cache);
        if (!ok) {
                NWRAP_LOG(NWRAP_LOG_ERROR, "error loading hosts file");
@@ -3675,7 +3717,7 @@
                                        char *buf, size_t buflen,
                                        struct hostent **hedstp)
 {
-       struct nwrap_vector *addr_list = malloc(sizeof(struct nwrap_vector));
+       struct nwrap_vector *addr_list = NULL;
        union {
                char *ptr;
                char **list;
@@ -3685,6 +3727,14 @@
        (void) b; /* unused */
        (void) af; /* unused */
 
+       if (name == NULL || hedst == NULL || buf == NULL || buflen == 0) {
+               errno = EINVAL;
+               return -1;
+       }
+       *hedstp = NULL;
+       buf[0] = '\0';
+
+       addr_list = calloc(1, sizeof(struct nwrap_vector));
        if (addr_list == NULL) {
                NWRAP_LOG(NWRAP_LOG_ERROR,
                          "Unable to allocate memory for address list");
@@ -3692,20 +3742,17 @@
                return -1;
        }
 
-       ZERO_STRUCTP(addr_list);
-
-       rc = nwrap_files_internal_gethostbyname(name, AF_UNSPEC, hedst,
+       rc = nwrap_files_internal_gethostbyname(name, af, hedst,
                                                addr_list);
        if (rc == -1) {
-               if (addr_list->items != NULL) {
-                       free(addr_list->items);
-               }
+               SAFE_FREE(addr_list->items);
                SAFE_FREE(addr_list);
                errno = ENOENT;
                return -1;
        }
 
-       if (buflen < (addr_list->count * sizeof(void *))) {
+       /* +1 i for ending NULL pointer */
+       if (buflen < ((addr_list->count + 1) * sizeof(void *))) {
                SAFE_FREE(addr_list->items);
                SAFE_FREE(addr_list);
                return ERANGE;
@@ -3716,8 +3763,8 @@
         * +1 is for ending NULL pointer. */
        memcpy(buf, addr_list->items, (addr_list->count + 1) * sizeof(void *));
 
-       free(addr_list->items);
-       free(addr_list);
+       SAFE_FREE(addr_list->items);
+       SAFE_FREE(addr_list);
 
        g.ptr = buf;
        hedst->h_addr_list = g.list;
@@ -3740,6 +3787,8 @@
                                                 buf, buflen, result);
                if (rc == 0) {
                        return 0;
+               } else if (rc == ERANGE) {
+                       return ERANGE;
                }
        }
        *h_errnop = h_errno;
@@ -3779,6 +3828,8 @@
                                                 buf, buflen, result);
                if (rc == 0) {
                        return 0;
+               } else if (rc == ERANGE) {
+                       return ERANGE;
                }
        }
        *h_errnop = h_errno;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nss_wrapper-1.1.8/tests/test_gethostby_name_addr.c 
new/nss_wrapper-1.1.10/tests/test_gethostby_name_addr.c
--- old/nss_wrapper-1.1.8/tests/test_gethostby_name_addr.c      2017-03-27 
16:24:48.000000000 +0200
+++ new/nss_wrapper-1.1.10/tests/test_gethostby_name_addr.c     2020-03-19 
10:03:10.000000000 +0100
@@ -247,6 +247,128 @@
 
        assert_string_equal(ip, "127.0.0.11");
 }
+
+static void test_nwrap_gethostbyname_r_null(void **state)
+{
+       char buf[2];
+       struct hostent hb, *he;
+       int herr = 0;
+       int rc;
+
+       (void) state; /* unused */
+
+       buf[0] = 'A';
+       buf[1] = '\0';
+
+       /* Check that the returned buffer is zeroed */
+       rc = gethostbyname_r("wurst",
+                            &hb,
+                            buf, sizeof(buf),
+                            &he,
+                            &herr);
+       assert_int_equal(rc, ENOENT);
+       assert_null(he);
+       assert_null(hb.h_name);
+       assert_null(hb.h_addr_list);
+       assert_string_equal(buf, "");
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYNAME2_R
+static void test_nwrap_gethostbyname2_r_v4(void **state)
+{
+       char *buf = NULL;
+       size_t buflen = 2;
+       char ip[INET_ADDRSTRLEN];
+       struct hostent hb, *he;
+       const char *a;
+       int herr = 0;
+       int rc;
+
+       (void) state; /* unused */
+
+       for (rc = ERANGE, buflen = 2; rc == ERANGE; buflen *= 2) {
+               if (buf != NULL) {
+                       free(buf);
+               }
+               buf = calloc(1, buflen);
+               assert_non_null(buf);
+
+               rc = gethostbyname2_r("magrathea.galaxy.site", AF_INET,
+                                     &hb,
+                                     buf, buflen,
+                                     &he,
+                                     &herr);
+       }
+
+       assert_int_equal(rc, 0);
+       assert_int_equal(herr, 0);
+       assert_non_null(he);
+       assert_non_null(he->h_name);
+       assert_non_null(he->h_addr_list);
+
+       assert_string_equal(he->h_name, "magrathea.galaxy.site");
+       assert_int_equal(he->h_addrtype, AF_INET);
+
+       assert_non_null(he->h_addr_list[0]);
+       a = inet_ntop(AF_INET, he->h_addr_list[0], ip, sizeof(ip));
+       assert_non_null(a);
+       assert_string_equal(a, "127.0.0.11");
+
+       assert_non_null(he->h_addr_list[1]);
+       a = inet_ntop(AF_INET, he->h_addr_list[1], ip, sizeof(ip));
+       assert_non_null(a);
+       assert_string_equal(a, "127.0.0.12");
+
+       assert_null(he->h_addr_list[2]);
+
+       free(buf);
+}
+
+static void test_nwrap_gethostbyname2_r_v6(void **state)
+{
+       char *buf = NULL;
+       size_t buflen = 2;
+       char ip[INET6_ADDRSTRLEN];
+       struct hostent hb, *he;
+       const char *a;
+       int herr = 0;
+       int rc;
+
+       (void) state; /* unused */
+
+       for (rc = ERANGE, buflen = 2; rc == ERANGE; buflen *= 2) {
+               if (buf != NULL) {
+                       free(buf);
+               }
+               buf = calloc(1, buflen);
+               assert_non_null(buf);
+
+               rc = gethostbyname2_r("magrathea.galaxy.site", AF_INET6,
+                                     &hb,
+                                     buf, buflen,
+                                     &he,
+                                     &herr);
+       }
+
+       assert_int_equal(rc, 0);
+       assert_int_equal(herr, 0);
+       assert_non_null(he);
+       assert_non_null(he->h_name);
+       assert_non_null(he->h_addr_list);
+
+       assert_string_equal(he->h_name, "magrathea.galaxy.site");
+       assert_int_equal(he->h_addrtype, AF_INET6);
+
+       assert_non_null(he->h_addr_list[0]);
+       a = inet_ntop(AF_INET6, he->h_addr_list[0], ip, sizeof(ip));
+       assert_non_null(a);
+       assert_string_equal(a, "::29a");
+
+       assert_null(he->h_addr_list[1]);
+
+       free(buf);
+}
 #endif
 
 #ifdef HAVE_GETHOSTBYADDR_R
@@ -293,6 +415,11 @@
                cmocka_unit_test(test_nwrap_gethostbyaddr),
 #ifdef HAVE_GETHOSTBYNAME_R
                cmocka_unit_test(test_nwrap_gethostbyname_r),
+               cmocka_unit_test(test_nwrap_gethostbyname_r_null),
+#endif
+#ifdef HAVE_GETHOSTBYNAME2_R
+               cmocka_unit_test(test_nwrap_gethostbyname2_r_v4),
+               cmocka_unit_test(test_nwrap_gethostbyname2_r_v6),
 #endif
 #ifdef HAVE_GETHOSTBYADDR_R
                cmocka_unit_test(test_nwrap_gethostbyaddr_r),



Reply via email to