From 400eea2f884e8d000a25d6e223ace28f3f76b306 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Jan 21 2020 20:12:39 +0000
Subject: [PATCH 1/2] PROXY: Fix warning-format-overflow directive argument is null


  CC       src/providers/proxy/libsss_proxy_la-proxy_id.lo
In file included from src/util/util.h:47,
                 from src/providers/proxy/proxy.h:35,
                 from src/providers/proxy/proxy_id.c:30:
In function ‘delete_user’,
    inlined from ‘get_pw_uid’ at src/providers/proxy/proxy_id.c:383:15,
    inlined from ‘proxy_account_info’ at src/providers/proxy/proxy_id.c:1617:19,
    inlined from ‘proxy_account_info_handler_send’ at src/providers/proxy/proxy_id.c:1760:20:
src/util/debug.h:126:9: error: ‘%s’ directive argument is null
[-Werror=format-overflow=]
  126 |         sss_debug_fn(__FILE__, __LINE__, __FUNCTION__, \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  127 |                      __debug_macro_level, \
      |                      ~~~~~~~~~~~~~~~~~~~~~~
  128 |                      format, ##__VA_ARGS__); \
      |                      ~~~~~~~~~~~~~~~~~~~~~~
src/providers/proxy/proxy_id.c:215:5: note: in expansion of macro ‘DEBUG’
  215 |     DEBUG(SSSDBG_TRACE_FUNC,
      |     ^~~~~
src/providers/proxy/proxy_id.c: In function ‘proxy_account_info_handler_send’:
src/providers/proxy/proxy_id.c:216:17: note: format string is defined here
  216 |           "User %s does not exist (or is invalid) on remote server,"
      |                 ^~

---

diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index 91105ce..8239486 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -212,9 +212,16 @@ delete_user(struct sss_domain_info *domain,
 {
     int ret = EOK;
 
-    DEBUG(SSSDBG_TRACE_FUNC,
-          "User %s does not exist (or is invalid) on remote server,"
-           " deleting!\n", name);
+    if (name != NULL) {
+        DEBUG(SSSDBG_TRACE_FUNC,
+              "User %s does not exist (or is invalid) on remote server,"
+              " deleting!\n", name);
+    } else {
+        DEBUG(SSSDBG_TRACE_FUNC,
+              "User with UID %"SPRIuid" does not exist (or is invalid) "
+              "on remote server, deleting!\n", uid);
+    }
+
     ret = sysdb_delete_user(domain, name, uid);
     if (ret == ENOENT) {
         ret = EOK;

From 2084213ff4f3e97ab320fcc6538426be77bacf65 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Jan 21 2020 20:44:17 +0000
Subject: [PATCH 2/2] test_nss_srv: Suppress Conditional jump or move depends on uninitialised value


gcc10 reordered conditions in long "or" condition
```
if (size < 2 || _list == NULL || *_list == NULL) {
```

And _list(gr->gr_mem) could be uninitialized in size was lover than 2.
It is a simplified implementation of parsing packet in unit test due to
mocking. `gr->gr_mem` always points to some array in real code.

Therefore we could see following error

Splitting condition to two if blocks fixes warning as well but
initializing `gr->gr_mem` to `NULL` is simpler change

[ RUN      ] test_nss_getgrnam_no_members
==12857== Conditional jump or move depends on uninitialised value(s)
==12857==    at 0x41B6C5: order_string_array (test_nss_srv.c:599)
==12857==    by 0x41B6C5: assert_groups_equal (test_nss_srv.c:617)
==12857==    by 0x41B810: test_nss_getgrnam_no_members_check (test_nss_srv.c:1476)
==12857==    by 0x41CB3F: __wrap_sss_cmd_done (test_nss_srv.c:138)
==12857==    by 0x4270C4: nss_protocol_done (nss_protocol.c:69)
==12857==    by 0x423949: nss_getby_done (nss_cmd.c:571)
==12857==    by 0x4E08359: tevent_common_invoke_immediate_handler (in /usr/lib64/libtevent.so.0.10.1)
==12857==    by 0x4E0837D: tevent_common_loop_immediate (in /usr/lib64/libtevent.so.0.10.1)
==12857==    by 0x4E0E1BF: ??? (in /usr/lib64/libtevent.so.0.10.1)
==12857==    by 0x4E0C54A: ??? (in /usr/lib64/libtevent.so.0.10.1)
==12857==    by 0x4E075D7: _tevent_loop_once (in /usr/lib64/libtevent.so.0.10.1)
==12857==    by 0x42D45B: test_ev_loop (common_tev.c:82)
==12857==    by 0x41C442: test_nss_getgrnam_no_members (test_nss_srv.c:1503)
==12857==
[       OK ] test_nss_getgrnam_no_members

Merges: https://pagure.io/SSSD/sssd/pull-request/4141

---

diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
index 95c080c..69cfbc4 100644
--- a/src/tests/cmocka/test_nss_srv.c
+++ b/src/tests/cmocka/test_nss_srv.c
@@ -403,6 +403,8 @@ static int parse_group_packet(uint8_t *body, size_t blen, struct group *gr, uint
     gr->gr_passwd = (char *) body+rp;
     rp += strlen(gr->gr_passwd) + 1;
 
+    gr->gr_mem = NULL;
+
     if (*nmem > 0) {
         gr->gr_mem = talloc_zero_array(nss_test_ctx, char *, *nmem);
         if (gr->gr_mem == NULL) return ENOMEM;

