summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-07-09 11:42:46 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-07-09 17:26:25 +0200
commitd528e4960bf233bc002f9676919ede196c91564c (patch)
tree7e499cb791e9f3ab953a5872a6f47e296b928124 /src
parentf28b09f887870c10c8c611beee3c17eaa9ef74f3 (diff)
downloadsssd-d528e4960bf233bc002f9676919ede196c91564c.tar.gz
sssd-d528e4960bf233bc002f9676919ede196c91564c.tar.xz
sssd-d528e4960bf233bc002f9676919ede196c91564c.zip
sdap-tests: Fix off by one.
Function sss_base64_decode does not return NUL terminated string and it causes valgrind warning in test "Invalid read of size 1" ==30954== Invalid read of size 1 ==30954== at 0x4A09FB8: strcmp (mc_replace_strmem.c:730) ==30954== by 0x4C2AAFA: _assert_string_equal (in /usr/lib64/libcmocka.so.0.2.1) ==30954== by 0x407DBA: test_parse_with_map (test_sdap.c:285) ==30954== by 0x4C2C817: _run_test (in /usr/lib64/libcmocka.so.0.2.1) ==30954== by 0x4C2CCF8: _run_tests (in /usr/lib64/libcmocka.so.0.2.1) ==30954== by 0x408A6F: main (test_sdap.c:583) ==30954== Address 0x6a8db34 is 0 bytes after a block of size 100 alloc'd ==30954== at 0x4A0645D: malloc (vg_replace_malloc.c:291) ==30954== by 0x35C8204980: _talloc_memdup (talloc.c:613) ==30954== by 0x5080A4B: sss_base64_decode (nss_base64.c:86) ==30954== by 0x407DA0: test_parse_with_map (test_sdap.c:282) ==30954== by 0x4C2C817: _run_test (in /usr/lib64/libcmocka.so.0.2.1) ==30954== by 0x4C2CCF8: _run_tests (in /usr/lib64/libcmocka.so.0.2.1) ==30954== by 0x408A6F: main (test_sdap.c:583) Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/tests/cmocka/test_sdap.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tests/cmocka/test_sdap.c b/src/tests/cmocka/test_sdap.c
index 33cefcc88..f61c38c5f 100644
--- a/src/tests/cmocka/test_sdap.c
+++ b/src/tests/cmocka/test_sdap.c
@@ -282,7 +282,8 @@ void test_parse_with_map(void **state)
decoded_key = sss_base64_decode(test_ctx,
(const char *)el->values[0].data,
&key_len);
- assert_string_equal(decoded_key, "1234");
+ assert_non_null(decoded_key);
+ assert_memory_equal(decoded_key, "1234", key_len);
/* The extra attribute must not be downloaded, it's not present in map */
assert_entry_has_no_attr(attrs, "extra");