[Pkg-sssd-devel] ding-libs: Changes to 'upstream'

Timo Aaltonen tjaalton at moszumanska.debian.org
Sat Dec 23 04:20:56 UTC 2017


 .git-commit-template          |    9 +
 Makefile.am                   |   27 ++-
 collection/collection.c       |    5 
 collection/collection_tools.c |    2 
 configure.ac                  |    5 
 contrib/ding-libs.spec.in     |    6 
 dhash/dhash.c                 |   31 ++-
 dhash/dhash.h                 |    4 
 dhash/dhash_ut_check.c        |  226 +++++++++++++++++++++++++++
 dhash/examples/dhash_test.c   |    3 
 ini/ini.d/merge.validator     |   16 -
 ini/ini_augment.c             |  120 ++++++--------
 ini/ini_augment_ut_check.c    |  343 ++++++++++++++++++++++++++++++++++++++++++
 ini/ini_configmod.c           |    3 
 ini/ini_configobj.c           |   71 +++++---
 ini/ini_configobj.h           |    9 -
 ini/ini_defines.h             |    5 
 ini/ini_fileobj.c             |    1 
 ini/ini_get_value.c           |    4 
 ini/ini_get_valueobj.c        |    1 
 ini/ini_parse.c               |   71 +++-----
 ini/ini_parse_ut_check.c      |  157 +++++++++++++++++++
 version.m4                    |    6 
 23 files changed, 946 insertions(+), 179 deletions(-)

New commits:
commit ee13e47d309a87d8631cef92df3a47c0c734741d
Author: Michal Židek <mzidek at redhat.com>
Date:   Thu Sep 7 11:58:34 2017 +0200

    Update versions before 0.6.1 release
    
    Reviewed-by: Lukas Slebodnik <lslebodn at redhat.com>

diff --git a/version.m4 b/version.m4
index 08814fe..6022c18 100644
--- a/version.m4
+++ b/version.m4
@@ -1,5 +1,5 @@
 # Primary version number
-m4_define([VERSION_NUMBER], [0.6.0])
+m4_define([VERSION_NUMBER], [0.6.1])
 
 # If the PRERELEASE_VERSION_NUMBER is set, we'll append
 # it to the release tag when creating an RPM or SRPM
@@ -11,8 +11,8 @@ m4_define([VERSION_NUMBER], [0.6.0])
 m4_define([PRERELEASE_VERSION_NUMBER], [])
 
 m4_define([PATH_UTILS_VERSION_NUMBER], [0.2.1])
-m4_define([DHASH_VERSION_NUMBER], [0.4.3])
+m4_define([DHASH_VERSION_NUMBER], [0.5.0])
 m4_define([COLLECTION_VERSION_NUMBER], [0.7.0])
 m4_define([REF_ARRAY_VERSION_NUMBER], [0.1.5])
 m4_define([BASICOBJECTS_VERSION_NUMBER], [0.1.1])
-m4_define([INI_CONFIG_VERSION_NUMBER], [1.3.0])
+m4_define([INI_CONFIG_VERSION_NUMBER], [1.3.1])

commit 403a6fefe7a06c1136e0f0e40391e5f2ec6a8981
Author: Michal Židek <mzidek at redhat.com>
Date:   Thu Sep 7 12:29:47 2017 +0200

    Bump version info
    
    Changes have been made to:
    - libdhash - added new key type for constant strings (added interface)
    - libcollection - just updated code (no interface changes)
    - libini_config - allowed new combination of parsing flags (no interface changes)
    
    Reviewed-by: Lukas Slebodnik <lslebodn at redhat.com>

diff --git a/Makefile.am b/Makefile.am
index 81e40e1..d032739 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -110,7 +110,7 @@ dist_include_HEADERS += dhash/dhash.h
 libdhash_la_SOURCES = dhash/dhash.c
 libdhash_la_DEPENDENCIES = dhash/libdhash.sym
 libdhash_la_LDFLAGS = \
-    -version-info 1:2:0 \
+    -version-info 2:0:1 \
     -Wl,--version-script=$(top_srcdir)/dhash/libdhash.sym
 
 check_PROGRAMS += dhash_test dhash_example
@@ -166,7 +166,7 @@ libcollection_la_SOURCES = \
     trace/trace.h
 libcollection_la_DEPENDENCIES = collection/libcollection.sym
 libcollection_la_LDFLAGS = \
-    -version-info 5:0:1 \
+    -version-info 5:1:1 \
     -Wl,--version-script=$(top_srcdir)/collection/libcollection.sym
 
 check_PROGRAMS += \
@@ -292,7 +292,7 @@ libini_config_la_LIBADD = \
     libref_array.la \
     libbasicobjects.la
 libini_config_la_LDFLAGS = \
-    -version-info 7:0:2 \
+    -version-info 7:1:2 \
     -Wl,--version-script=$(top_srcdir)/ini/libini_config.sym
 
 dist_noinst_DATA += \
diff --git a/contrib/ding-libs.spec.in b/contrib/ding-libs.spec.in
index 3fc079c..0f9b877 100644
--- a/contrib/ding-libs.spec.in
+++ b/contrib/ding-libs.spec.in
@@ -131,7 +131,7 @@ time properties
 %defattr(-,root,root,-)
 %doc COPYING COPYING.LESSER
 %{_libdir}/libdhash.so.1
-%{_libdir}/libdhash.so.1.0.2
+%{_libdir}/libdhash.so.1.1.0
 
 %files -n libdhash-devel
 %defattr(-,root,root,-)
@@ -175,7 +175,7 @@ and serialization
 %doc COPYING
 %doc COPYING.LESSER
 %{_libdir}/libcollection.so.4
-%{_libdir}/libcollection.so.4.1.0
+%{_libdir}/libcollection.so.4.1.1
 
 %files -n libcollection-devel
 %defattr(-,root,root,-)
@@ -304,7 +304,7 @@ structure
 %doc COPYING
 %doc COPYING.LESSER
 %{_libdir}/libini_config.so.5
-%{_libdir}/libini_config.so.5.2.0
+%{_libdir}/libini_config.so.5.2.1
 
 %files -n libini_config-devel
 %defattr(-,root,root,-)

commit b73372021f343e6ef50acadea8786bfb297af75c
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 19:24:06 2017 +0200

    DHASH: Do not use c99 structure initialisation
    
    c99 allows to initialize a structure by specifying the structure
    element names e.g. point = { .x = 0, .y = 0};
    
    But it was used just in unit test and therefore it does not make a
    sense to increase requirements from c89 -> c99
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    merges: https://pagure.io/SSSD/ding-libs/pull-request/3180

diff --git a/dhash/dhash_ut_check.c b/dhash/dhash_ut_check.c
index 246e162..e724931 100644
--- a/dhash/dhash_ut_check.c
+++ b/dhash/dhash_ut_check.c
@@ -40,9 +40,16 @@ START_TEST(test_key_const_string)
     hash_table_t *htable;
     int ret;
     hash_value_t ret_val;
-    hash_value_t enter_val1 = {.type = HASH_VALUE_INT, .i = 1};
-    hash_value_t enter_val2 = {.type = HASH_VALUE_INT, .i = 2};
-    hash_key_t key = {.type = HASH_KEY_CONST_STRING, .c_str = "constant"};
+    hash_value_t enter_val1;
+    hash_value_t enter_val2;
+    hash_key_t key;
+
+    enter_val1.type = HASH_VALUE_INT;
+    enter_val1.i = 1;
+    enter_val2.type = HASH_VALUE_INT;
+    enter_val2.i = 2;
+    key.type = HASH_KEY_CONST_STRING;
+    key.c_str = "constant";
 
     ret = hash_create(HTABLE_SIZE, &htable, NULL, NULL);
     fail_unless(ret == 0);
@@ -87,11 +94,15 @@ START_TEST(test_key_string)
     hash_table_t *htable;
     int ret;
     hash_value_t ret_val;
-    hash_value_t enter_val1 = {.type = HASH_VALUE_INT, .i = 1};
-    hash_value_t enter_val2 = {.type = HASH_VALUE_INT, .i = 2};
+    hash_value_t enter_val1;
+    hash_value_t enter_val2;
     hash_key_t key;
     char str[] = "non_constant";
 
+    enter_val1.type = HASH_VALUE_INT;
+    enter_val1.i = 1;
+    enter_val2.type = HASH_VALUE_INT;
+    enter_val2.i = 2;
     key.type = HASH_KEY_STRING;
     key.str = str;
 
@@ -139,9 +150,16 @@ START_TEST(test_key_ulong)
     hash_table_t *htable;
     int ret;
     hash_value_t ret_val;
-    hash_value_t enter_val1 = {.type = HASH_VALUE_INT, .i = 1};
-    hash_value_t enter_val2 = {.type = HASH_VALUE_INT, .i = 2};
-    hash_key_t key = {.type = HASH_KEY_ULONG, .ul = 68ul};
+    hash_value_t enter_val1;
+    hash_value_t enter_val2;
+    hash_key_t key;
+
+    enter_val1.type = HASH_VALUE_INT;
+    enter_val1.i = 1;
+    enter_val2.type = HASH_VALUE_INT;
+    enter_val2.i = 2;
+    key.type = HASH_KEY_ULONG;
+    key.ul = 68ul;
 
     ret = hash_create(HTABLE_SIZE, &htable, NULL, NULL);
     fail_unless(ret == 0);

commit 321e84768a75fb5bbbbec8922d50f1de59affe4c
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 17:45:49 2017 +0200

    COLLECTION: Fix misused comma
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/collection/collection_tools.c b/collection/collection_tools.c
index 7e60285..36282a0 100644
--- a/collection/collection_tools.c
+++ b/collection/collection_tools.c
@@ -647,7 +647,7 @@ int col_print_item(struct collection_item *handle, const char *name)
     else {
         if (buf_data.buffer != NULL) {
             if (buf_data.length > 0) buf_data.length--;
-            buf_data.buffer[buf_data.length] = '\0',
+            buf_data.buffer[buf_data.length] = '\0';
             printf("%s\n", buf_data.buffer);
             free(buf_data.buffer);
         }

commit c43a7f0005bd0a5e14a9ca33e10fe2b1413f9e74
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 17:44:56 2017 +0200

    INI: Fix doxygen comment for ini_errobj_create
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index 9d5b516..476ecec 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -2071,7 +2071,7 @@ struct ini_errobj;
  * hold error messages from generators. To add messages to
  * the structure use \ref ini_errobj_add_msg.
  *
- * @param[out] errobj         container for errors.
+ * @param[out] _errobj         container for errors.
  *
  * @return Zero on success, nonzero value in case of error.
  */

commit 64e54a72d7e997c6a8f12ac43ca3c0c27dabe93a
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 17:37:03 2017 +0200

    COLLECTION: Remove unused macros
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/collection/collection.c b/collection/collection.c
index 3d834eb..f7d089b 100644
--- a/collection/collection.c
+++ b/collection/collection.c
@@ -44,11 +44,6 @@
 #define EINTR_INTERNAL 10000
 
 
-/* Potential subject for management with libtools */
-#define DATE_FORMAT "%c"
-
-#define TIME_ARRAY_SIZE 100
-
 /* Magic numbers for hashing */
 #if SIZEOF_LONG == 8
     #define FNV1a_prime 1099511628211ul

commit b892f7220a692e64774c307c26156276d788087b
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 17:28:04 2017 +0200

    Do not define _GNU_SOURCE
    
    Let autotools to detect gnu features.
    
    Patch also prefer AC_USE_SYSTEM_EXTENSIONS to deprecated AC_GNU_SOURCE
    
    https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Obsolete-Macros.html#index-AC_005fGNU_005fSOURCE-1960
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/configure.ac b/configure.ac
index 048d3ad..1e8e0d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,10 @@ AC_INIT([ding-libs],
         [sssd-devel at lists.fedorahosted.org])
 AC_CONFIG_SRCDIR([README])
 AC_CONFIG_AUX_DIR([build])
-AC_GNU_SOURCE
+
+m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
+    [AC_USE_SYSTEM_EXTENSIONS],
+    [AC_GNU_SOURCE])
 AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
 AM_PROG_CC_C_O
 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
diff --git a/ini/ini_augment.c b/ini/ini_augment.c
index 11b0e3b..af5c0b6 100644
--- a/ini/ini_augment.c
+++ b/ini/ini_augment.c
@@ -21,7 +21,6 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE /* for vasprintf */
 #include "config.h"
 #include <errno.h>
 #include <stdarg.h>
diff --git a/ini/ini_configmod.c b/ini/ini_configmod.c
index 02a188f..da4175c 100644
--- a/ini/ini_configmod.c
+++ b/ini/ini_configmod.c
@@ -19,12 +19,11 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE /* for asprintf */
+#include "config.h"
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <inttypes.h>
-#include "config.h"
 #include "trace.h"
 #include "ref_array.h"
 #include "simplebuffer.h"
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 421d22b..d478d93 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -18,7 +18,6 @@
     You should have received a copy of the GNU Lesser General Public License
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
-#define _GNU_SOURCE /* for asprintf */
 #include "config.h"
 #include <errno.h>
 #include <sys/types.h>

commit 6002a75d2d24a69c46651db0bc723feb7d6aae2b
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 17:14:24 2017 +0200

    INI: Fix warning Walloc-size-larger-than
    
    ini/ini_get_value.c: In function ‘get_bin_config_value’:
    ini/ini_get_value.c:552:11: warning: argument 1 range
      [18446744072635809792, 18446744073709551615] exceeds maximum object size
       9223372036854775807 [-Walloc-size-larger-than=]
         value = malloc(len / 2);
         ~~~~~~^~~~~~~~~~~~~~~~~
    In file included from ini/ini_get_value.c:27:0:
    /usr/include/stdlib.h:424:14: note: in a call to allocation function ‘malloc’ declared here
     extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
                  ^~~~~~
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/ini/ini_get_value.c b/ini/ini_get_value.c
index 0afadd0..2441c14 100644
--- a/ini/ini_get_value.c
+++ b/ini/ini_get_value.c
@@ -501,12 +501,12 @@ const char *get_const_string_config_value(struct collection_item *item, int *err
 char *get_bin_config_value(struct collection_item *item,
                            int *length, int *error)
 {
-    int i;
+    unsigned i;
     char *value = NULL;
     const char *buff;
     int size = 0;
     unsigned char hex;
-    int len;
+    unsigned len;
     const char *str;
 
     TRACE_FLOW_STRING("get_bin_config_value", "Entry");

commit 7db68eb4d8b1955abfefd0676db9329aa6f5f372
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 17:09:06 2017 +0200

    DHASH: Suppress gcc7 warning
    
    Such comment is recognized by -Wimplicit-fallthrough=4
    
    dhash/dhash.c: In function ‘hash_iter_next’:
    dhash/dhash.c:748:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
                     state = HI_STATE_2;
                     ~~~~~~^~~~~~~~~~~~
    dhash/dhash.c:750:13: note: here
                 case HI_STATE_2:
                 ^~~~
    dhash/dhash.c:756:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
                     state = HI_STATE_3A;
                     ~~~~~~^~~~~~~~~~~~~
    dhash/dhash.c:758:13: note: here
                 case HI_STATE_3A:
                 ^~~~
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/dhash/dhash.c b/dhash/dhash.c
index 98439e8..6b4b51d 100644
--- a/dhash/dhash.c
+++ b/dhash/dhash.c
@@ -746,6 +746,7 @@ static hash_entry_t *hash_iter_next(struct hash_iter_context_t *iter_arg)
                 }
                 iter->j = 0;
                 state = HI_STATE_2;
+                /* FALLTHROUGH */
 
             case HI_STATE_2:
                 if (iter->j >= iter->table->segment_size) {
@@ -754,6 +755,7 @@ static hash_entry_t *hash_iter_next(struct hash_iter_context_t *iter_arg)
                 }
                 iter->p = iter->s[iter->j];
                 state = HI_STATE_3A;
+                /* FALLTHROUGH */
 
             case HI_STATE_3A:
                 if (iter->p == NULL) {

commit 7a95fde3853d260146a5706e53c4750777db281c
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 16:34:56 2017 +0200

    INI: Fix memory leaks in unit test test_ini_augment_empty_dir
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/ini/ini_augment_ut_check.c b/ini/ini_augment_ut_check.c
index 36a28ec..f7e3b66 100644
--- a/ini/ini_augment_ut_check.c
+++ b/ini/ini_augment_ut_check.c
@@ -308,6 +308,9 @@ START_TEST(test_ini_augment_empty_dir)
     val = ini_get_int32_config_value(vo, 1, 100, NULL);
     fail_unless(val == 1, "Expected attribute value not found.\n");
 
+    ini_free_attribute_list(attrs_list);
+    ini_free_section_list(section_list);
+    ini_config_destroy(result_cfg);
     ini_config_destroy(ini_cfg);
     ini_config_file_destroy(file_ctx);
     remove(empty_dir_path);

commit 5ef9d8106848e2d436a7ba6729bc281f3e1a15b2
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 16:20:13 2017 +0200

    INI: Fix usage of buiddir in ini_augment_ut_check
    
    The function getenv does not return dynamically allocated string.
    Therefore we cannot call free for value returned from this function.
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179
    
    ==26075== 1 errors in context 1 of 4:
    ==26075== Invalid free() / delete / delete[] / realloc()
    ==26075==    at 0x4C30D18: free (vg_replace_malloc.c:530)
    ==26075==    by 0x401E31: test_ini_augment_merge_sections (ini_augment_ut_check.c:224)
    ==26075==    by 0x505A9EB: ??? (in /usr/lib64/libcheck.so.0.0.0)
    ==26075==    by 0x505AEED: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0)
    ==26075==    by 0x401223: main (ini_augment_ut_check.c:337)
    ==26075==  Address 0x1fff0006c1 is on thread 1's stack

diff --git a/ini/ini_augment_ut_check.c b/ini/ini_augment_ut_check.c
index ee1162d..36a28ec 100644
--- a/ini/ini_augment_ut_check.c
+++ b/ini/ini_augment_ut_check.c
@@ -76,7 +76,7 @@ START_TEST(test_ini_augment_merge_sections)
         "key1 = augment\n"
         "key3 = exists\n";
 
-    char *builddir;
+    const char *builddir;
 
     uint32_t flags[3] = { INI_MS_DETECT , INI_MS_DETECT | INI_MS_PRESERVE,
                           INI_MS_DETECT | INI_MS_OVERWRITE };
@@ -91,7 +91,7 @@ START_TEST(test_ini_augment_merge_sections)
 
     builddir = getenv("builddir");
     if (builddir == NULL) {
-        builddir = strdup(".");
+        builddir = ".";
     }
 
     snprintf(base_path, PATH_MAX, "%s/tmp_augment_base.conf", builddir);
@@ -221,7 +221,6 @@ START_TEST(test_ini_augment_merge_sections)
 
     remove(base_path);
     remove(augment_path);
-    free(builddir);
 }
 END_TEST
 
@@ -238,7 +237,7 @@ START_TEST(test_ini_augment_empty_dir)
     struct ini_cfgobj *result_cfg = NULL;
     int size;
     char empty_dir_path[PATH_MAX] = {0};
-    char *builddir;
+    const char *builddir;
     int32_t val;
     char base_cfg[] =
         "[section_one]\n"
@@ -246,7 +245,7 @@ START_TEST(test_ini_augment_empty_dir)
 
     builddir = getenv("builddir");
     if (builddir == NULL) {
-        builddir = strdup(".");
+        builddir = ".";
     }
 
     ret = snprintf(empty_dir_path, PATH_MAX, "%s/tmp_empty_dir", builddir);

commit 522866dd20d6f9ec210ce73d78e7fb939d145ba8
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Mon Sep 4 16:12:54 2017 +0200

    BUILD: Fix linking of ini_augment_ut_check
    
    libref_array was used in the unit test but it was mot linked with
    libref_array
      CCLD     ini_augment_ut_check
    /usr/bin/ld: ini/ini_augment_ut_check-ini_augment_ut_check.o:
        undefined reference to symbol 'ref_array_destroy@@REF_ARRAY_0.1.1'
    .libs/libref_array.so.1: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:1287: ini_augment_ut_check] Error 1
    
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3179

diff --git a/Makefile.am b/Makefile.am
index 63ff6fe..81e40e1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -367,7 +367,8 @@ ini_configmod_ut_LDADD = libini_config.la libcollection.la \
 
 ini_augment_ut_check_SOURCES = ini/ini_augment_ut_check.c
 ini_augment_ut_check_CFLAGS = $(AM_CFLAGS) $(CHECK_CFLAGS)
-ini_augment_ut_check_LDADD = libini_config.la $(CHECK_LIBS)
+ini_augment_ut_check_LDADD = libini_config.la $(CHECK_LIBS) \
+                             libref_array.la
 
 ini_configmod_ut_check_SOURCES = ini/ini_configmod_ut_check.c
 ini_configmod_ut_check_CFLAGS = $(AM_CFLAGS) $(CHECK_CFLAGS)

commit 3d10336f7f23faff1de1ee575e819582b9a36d46
Author: Michal Židek <mzidek at redhat.com>
Date:   Wed Aug 30 17:18:15 2017 +0200

    INI: Add test for long values
    
    Resolves:
    https://pagure.io/SSSD/ding-libs/issue/3177
    
    Reviewed-by: Jakub Hrozek <jhrozek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3178

diff --git a/ini/ini_parse_ut_check.c b/ini/ini_parse_ut_check.c
index f5a671e..d72157b 100644
--- a/ini/ini_parse_ut_check.c
+++ b/ini/ini_parse_ut_check.c
@@ -235,6 +235,52 @@ START_TEST(test_ini_parse_section_key_conflict)
 }
 END_TEST
 
+/* Maybe we should test even bigger values? */
+#define VALUE_LEN 10000
+/* The +100 is space for section name and key name. */
+#define CFGBUF_LEN (VALUE_LEN + 100)
+START_TEST(test_ini_long_value)
+{
+    int ret;
+    struct ini_cfgobj *ini_cfg;
+    struct ini_cfgfile *file_ctx;
+    struct value_obj *vo;
+    char big_val_cfg[CFGBUF_LEN] = {0};
+    char value[VALUE_LEN] = {0};
+    char *value_got;
+
+    /* The value is just a lot of As ending with '\0'*/
+    memset(value, 'A', VALUE_LEN - 1);
+
+    /* Create config file */
+    ret = snprintf(big_val_cfg, CFGBUF_LEN, "[section]\nkey=%s", value);
+
+    ret = ini_config_file_from_mem(big_val_cfg, strlen(big_val_cfg),
+                                   &file_ctx);
+    fail_unless(ret == EOK, "Failed to load config. Error %d.\n", ret);
+
+    ret = ini_config_create(&ini_cfg);
+    fail_unless(ret == EOK, "Failed to create config. Error %d.\n", ret);
+    ret = ini_config_parse(file_ctx, INI_STOP_ON_ERROR, INI_MV1S_ALLOW, 0,
+                           ini_cfg);
+    fail_if(ret != 0, "Failed to parse config. Error %d.\n", ret);
+
+    ret = ini_get_config_valueobj("section", "key", ini_cfg,
+                                  INI_GET_FIRST_VALUE, &vo);
+    fail_unless(ret == EOK, "ini_get_config_valueobj returned %d\n: %s", ret,
+                strerror(ret));
+
+    value_got = ini_get_string_config_value(vo, &ret);
+    fail_unless(ret == EOK, "ini_get_int_config_value returned %d\n: %s", ret,
+                strerror(ret));
+
+    fail_unless(strcmp(value, value_got) == 0, "Expected and found values differ!\n");
+    free(value_got);
+    ini_config_destroy(ini_cfg);
+    ini_config_file_destroy(file_ctx);
+}
+END_TEST
+
 static Suite *ini_parse_suite(void)
 {
     Suite *s = suite_create("ini_parse_suite");
@@ -242,6 +288,7 @@ static Suite *ini_parse_suite(void)
     TCase *tc_parse = tcase_create("ini_parse");
     tcase_add_test(tc_parse, test_ini_parse_non_kvp);
     tcase_add_test(tc_parse, test_ini_parse_section_key_conflict);
+    tcase_add_test(tc_parse, test_ini_long_value);
 
     suite_add_tcase(s, tc_parse);
 

commit 7099295e99467fdf66f3e6da86c8e8b972960219
Author: Michal Židek <mzidek at redhat.com>
Date:   Wed Aug 30 15:27:23 2017 +0200

    INI: Allow longer values then PATH_MAX
    
    The older API used fgets to read the values and the
    size of buffer to hold the line was fixed. With the
    new API we use getline to get the whole line and this
    does not require pre-allocated buffer. The check
    for lenght was not necessary here.
    
    Resolves:
    https://pagure.io/SSSD/ding-libs/issue/3177
    
    Reviewed-by: Jakub Hrozek <jhrozek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3178

diff --git a/ini/ini_parse.c b/ini/ini_parse.c
index 55891ec..8d50725 100644
--- a/ini/ini_parse.c
+++ b/ini/ini_parse.c
@@ -338,31 +338,22 @@ static int parser_read(struct parser_obj *po)
             free(buffer);
         }
         else {
-            /* Check length */
-            if (len >= BUFFER_SIZE) {
-                TRACE_ERROR_STRING("Too long", "");
-                action = PARSE_ERROR;
-                po->last_error = ERR_LONGDATA;
-                free(buffer);
+            /* Trim end line */
+            i = len - 1;
+            while ((i >= 0) &&
+                   ((buffer[i] == '\r') ||
+                    (buffer[i] == '\n'))) {
+                TRACE_INFO_NUMBER("Offset:", i);
+                TRACE_INFO_NUMBER("Code:", buffer[i]);
+                buffer[i] = '\0';
+                i--;
             }
-            else {
-                /* Trim end line */
-                i = len - 1;
-                while ((i >= 0) &&
-                       ((buffer[i] == '\r') ||
-                        (buffer[i] == '\n'))) {
-                    TRACE_INFO_NUMBER("Offset:", i);
-                    TRACE_INFO_NUMBER("Code:", buffer[i]);
-                    buffer[i] = '\0';
-                    i--;
-                }
 
-                po->last_read = buffer;
-                po->last_read_len = i + 1;
-                action = PARSE_INSPECT;
-                TRACE_INFO_STRING("Line:", po->last_read);
-                TRACE_INFO_NUMBER("Linelen:", po->last_read_len);
-            }
+            po->last_read = buffer;
+            po->last_read_len = i + 1;
+            action = PARSE_INSPECT;
+            TRACE_INFO_STRING("Line:", po->last_read);
+            TRACE_INFO_NUMBER("Linelen:", po->last_read_len);
         }
     }
 

commit 8ad8417d859997f849cf68a166259c2667214fa9
Author: Michal Židek <mzidek at redhat.com>
Date:   Tue Aug 29 18:44:53 2017 +0200

    INI: do not use readdir_r
    
    readdir_r has some limitations and was deprecated in favor of readdir.
    See man 3 readdir (not to confuse with man 2 readdir).
    
    Resolves:
    https://pagure.io/SSSD/ding-libs/issue/3175
    
    Merges: https://pagure.io/SSSD/ding-libs/pull-request/3176
    
    Reviewed-by: Jakub Hrozek <jhrozek at redhat.com>

diff --git a/ini/ini_augment.c b/ini/ini_augment.c
index b92f030..11b0e3b 100644
--- a/ini/ini_augment.c
+++ b/ini/ini_augment.c
@@ -363,14 +363,11 @@ static int ini_aug_construct_list(char *dirname ,
 
     int error = EOK;
     DIR *dir = NULL;
-    struct dirent *entry = NULL;
     struct dirent *entryp = NULL;
     char *snipname = NULL;
     char fullname[PATH_MAX + 1] = {0};
     struct ref_array *ra_regex = NULL;
     bool match = false;
-    int len = 0;
-    int name_max;
 
     TRACE_FLOW_ENTRY();
 
@@ -399,55 +396,42 @@ static int ini_aug_construct_list(char *dirname ,
         return EOK;
     }
 
-    /* Allocate memory for entry (as said in man pages)*/
-    name_max = pathconf(dirname, _PC_NAME_MAX);
-    if (name_max == -1)          /* Limit not defined, or error */
-        name_max = 1024;         /* Take a guess */
-    len = offsetof(struct dirent, d_name) + name_max + 1;
-    entry = malloc(len);
-    if (entry == NULL) {
-        TRACE_ERROR_NUMBER("Failed to allocate memory.", ENOMEM);
-        ref_array_destroy(ra_regex);
-        closedir(dir);
-        return ENOMEM;
-    }
-
     /* Loop through the directory */
     while (true)
     {
-        error = readdir_r(dir, entry, &entryp);
-        if (error) {
+        errno = 0;
+        entryp = readdir(dir);
+        if (entryp == NULL && errno != 0) {
+            error = errno;
             TRACE_ERROR_NUMBER("Failed to read directory.", error);
             ref_array_destroy(ra_regex);
             closedir(dir);
-            free(entry);
             return error;
         }
 
         /* Stop looping if we reached the end */
         if (entryp == NULL) break;
 
-        TRACE_INFO_STRING("Processing", entry->d_name);
+        TRACE_INFO_STRING("Processing", entryp->d_name);
 
         /* Always skip current and parent dirs */
-        if ((strncmp(entry->d_name,
+        if ((strncmp(entryp->d_name,
                      INI_CURRENT_DIR,
                      sizeof(INI_CURRENT_DIR)) == 0) ||
-            (strncmp(entry->d_name,
+            (strncmp(entryp->d_name,
                      INI_PARENT_DIR,
                      sizeof(INI_PARENT_DIR)) == 0)) continue;
 
-        error = path_concat(fullname, PATH_MAX, dirname, entry->d_name);
+        error = path_concat(fullname, PATH_MAX, dirname, entryp->d_name);
         if (error != EOK) {
             TRACE_ERROR_NUMBER("path_concat failed.", error);
             ref_array_destroy(ra_regex);
             closedir(dir);
-            free(entry);
             return error;
         }
 
         /* Match names */
-        match = ini_aug_match_name(entry->d_name, ra_regex);
+        match = ini_aug_match_name(entryp->d_name, ra_regex);
         if (match) {
             if(ini_check_file_perm(fullname, check_perm, ra_err)) {
 
@@ -458,7 +442,6 @@ static int ini_aug_construct_list(char *dirname ,
                     TRACE_ERROR_NUMBER("Failed to dup string.", ENOMEM);
                     ref_array_destroy(ra_regex);
                     closedir(dir);
-                    free(entry);
                     return ENOMEM;
                 }
 
@@ -469,7 +452,6 @@ static int ini_aug_construct_list(char *dirname ,
                                        ENOMEM);
                     ref_array_destroy(ra_regex);
                     closedir(dir);
-                    free(entry);
                     return ENOMEM;
                 }
             }
@@ -482,7 +464,6 @@ static int ini_aug_construct_list(char *dirname ,
         }
     }
 
-    free(entry);
     closedir(dir);
     ref_array_destroy(ra_regex);
 

commit d4088fadf6c397f37359b4b0822365fc82dcb75b
Author: Michal Židek <mzidek at redhat.com>
Date:   Thu Aug 24 13:35:12 2017 +0200

    INI: Unit test for augmentation with empty dir
    
    Merging a configuration with snippets from empty directory should result
    in the same configuration.
    
    Resolves:
    https://pagure.io/SSSD/ding-libs/issue/2776
    
    Meges: https://pagure.io/SSSD/ding-libs/pull-request/3174
    
    Reviewed-by: Alexander Scheel <ascheel at redhat.com>

diff --git a/ini/ini_augment_ut_check.c b/ini/ini_augment_ut_check.c
index be475a3..ee1162d 100644
--- a/ini/ini_augment_ut_check.c
+++ b/ini/ini_augment_ut_check.c
@@ -225,12 +225,103 @@ START_TEST(test_ini_augment_merge_sections)
 }
 END_TEST
 
+START_TEST(test_ini_augment_empty_dir)
+{
+    int ret;
+    struct ini_cfgobj *ini_cfg;
+    struct ini_cfgfile *file_ctx;
+    struct value_obj *vo;
+    const char *patterns[] = { ".*", NULL };
+    const char *sections[] = { ".*", NULL };
+    char **section_list;
+    char **attrs_list;
+    struct ini_cfgobj *result_cfg = NULL;
+    int size;
+    char empty_dir_path[PATH_MAX] = {0};
+    char *builddir;
+    int32_t val;
+    char base_cfg[] =
+        "[section_one]\n"
+        "one = 1\n";
+
+    builddir = getenv("builddir");
+    if (builddir == NULL) {
+        builddir = strdup(".");
+    }
+
+    ret = snprintf(empty_dir_path, PATH_MAX, "%s/tmp_empty_dir", builddir);
+    fail_if(ret > PATH_MAX || ret < 0, "snprintf failed\n");
+
+    ret = ini_config_file_from_mem(base_cfg, strlen(base_cfg),
+                                   &file_ctx);
+    fail_unless(ret == EOK, "Failed to load config. Error %d.\n", ret);
+
+    ret = ini_config_create(&ini_cfg);
+    fail_unless(ret == EOK, "Failed to create config. Error %d.\n", ret);
+    ret = ini_config_parse(file_ctx, INI_STOP_ON_ERROR, INI_MV1S_ALLOW, 0,
+                           ini_cfg);
+    fail_unless(ret == EOK, "Failed to parse configuration. Error %d.\n", ret);
+
+    /* Create an empty directory */
+    ret = mkdir(empty_dir_path, 0700);
+    if (ret == -1) {
+        ret = errno;
+        fail_if(ret != EEXIST,
+                "Failed to create empty directory. Error %d.\n", errno);
+    }
+
+    ret = ini_config_augment(ini_cfg,
+                             empty_dir_path,
+                             patterns,
+                             sections,
+                             NULL,
+                             INI_STOP_ON_ANY,
+                             INI_MV1S_OVERWRITE,
+                             INI_PARSE_NOWRAP,
+                             INI_MV2S_OVERWRITE,
+                             &result_cfg,
+                             NULL,
+                             NULL);
+
+    fail_unless(ret == EOK);
+
+    /* If the snippet directory is empty, result_cfg should be the original
+     * ini_cfg and not NULL */
+    fail_if(result_cfg == NULL);
+
+    /* Now check if the content of result_cfg is what we expected */
+    section_list = ini_get_section_list(result_cfg, &size, NULL);
+    fail_unless(size == 1);
+    fail_unless(strcmp(section_list[0], "section_one") == 0);
+
+    attrs_list = ini_get_attribute_list(result_cfg, section_list[0],
+                                        &size, NULL);
+    fail_unless(size == 1);
+    fail_unless(strcmp(attrs_list[0], "one") == 0);
+
+    ret = ini_get_config_valueobj(section_list[0],
+                                  attrs_list[0],
+                                  result_cfg,
+                                  INI_GET_FIRST_VALUE,
+                                  &vo);
+    fail_unless(ret == 0);
+
+    val = ini_get_int32_config_value(vo, 1, 100, NULL);
+    fail_unless(val == 1, "Expected attribute value not found.\n");
+
+    ini_config_destroy(ini_cfg);
+    ini_config_file_destroy(file_ctx);
+    remove(empty_dir_path);
+}
+END_TEST
+
 static Suite *ini_augment_suite(void)
 {
     Suite *s = suite_create("ini_augment_suite");
 
     TCase *tc_augment = tcase_create("ini_augment");
     tcase_add_test(tc_augment, test_ini_augment_merge_sections);
+    tcase_add_test(tc_augment, test_ini_augment_empty_dir);
 
     suite_add_tcase(s, tc_augment);
 

commit e322192d1711677e78b197915b1a12537a0e510b
Author: Alexander Scheel <ascheel at redhat.com>
Date:   Wed Jul 26 13:35:45 2017 -0400

    INI: Test INI_MS_DETECT non-exclusive behavior
    
    This adds test cases for the non-exclusive behavior of INI_MS_DETECT.
    
    Signed-off-by: Alexander Scheel <ascheel at redhat.com>
    Reviewed-by: Michal Židek <mzidek at redhat.com>
    
    Merges: https://pagure.io/SSSD/ding-libs/issue/3167

diff --git a/Makefile.am b/Makefile.am
index ca9710e..63ff6fe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,11 +70,13 @@ libpath_utils_la_LDFLAGS = \
 
 if HAVE_CHECK
     check_PROGRAMS += path_utils_ut \
+                      ini_augment_ut_check \



More information about the Pkg-sssd-devel mailing list