[PATCH] make nsswitch and libwbclient thread safe / Coverity findings
Ralph Wuerthner
ralphw at de.ibm.com
Fri Nov 9 10:42:15 UTC 2018
Hi!
Volker pointed me to two Coverity findings in stress-nss-libwbclient.c.
Please see attached patchset to address these findings.
On 31.10.18 19:50, Jeremy Allison via samba-technical wrote:
> On Wed, Oct 31, 2018 at 07:46:26PM +0100, Andreas Schneider via samba-technical wrote:
>> On Monday, 29 October 2018 18:29:21 CET Jeremy Allison wrote:
>>> On Mon, Oct 29, 2018 at 05:28:37PM +0100, Volker Lendecke via samba-
>> technical wrote:
>>>> On Mon, Oct 29, 2018 at 09:20:57AM -0700, Jeremy Allison wrote:
>>>>> Ping for Ralph and Volker.
>>>>>
>>>>> I'd love to get this into master if you both are
>>>>> happy with it !
>>>>
>>>> Ralph has found that the nss_wrapper needs some fixes. Attached find
>>>> my patchset with my Reviewed-By: (really just finished). We can't put
>>>> that into Samba, because the nss_wrapper piece needs to wait for the
>>>> nss_wrapper team to get to the point where they have enough patches to
>>>> justify a release. Then we need a patch to upgrade the in-tree
>>>> nss_wrapper copy, and *then* we can start thinking about putting this
>>>> into Samba. We will start working on that process asap.
>>>
>>> Ah, the perils of depending on third-party :-).
>>>
>>> Pinging Andreas.... !
>>
>> A new nss_wrapper version is in autobuild. I guess you need to rebase that
>> patchset once it lands in master and then push it.
>
> Will do, thanks !
>
--
Regards
Ralph
-------------- next part --------------
From d204f1013650bfd74fa7bbdcf3fe501586db8fce Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Fri, 9 Nov 2018 08:58:31 +0100
Subject: [PATCH 1/2] nsswitch: Fix CID 1441072 Error handling issues
(CHECKED_RETURN)
Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
---
nsswitch/stress-nss-libwbclient.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/nsswitch/stress-nss-libwbclient.c b/nsswitch/stress-nss-libwbclient.c
index cf85ff3..740ad0e 100644
--- a/nsswitch/stress-nss-libwbclient.c
+++ b/nsswitch/stress-nss-libwbclient.c
@@ -118,7 +118,13 @@ int main(int argc, char *argv[])
state.username = argv[1];
state.timeout = time(NULL) + RUNTIME;
- pthread_mutex_init(&state.lock, NULL);
+ rc = pthread_mutex_init(&state.lock, NULL);
+ if (rc != 0) {
+ fprintf(stderr,
+ "pthread_mutex_init failed: %s\n",
+ strerror(rc));
+ exit(1);
+ }
state.fail = false;
state.nss_loop_count = 0;
state.wbc_loop_count = 0;
--
2.7.4
From 2c140c1876f53ed51ddfbd453df640879c344927 Mon Sep 17 00:00:00 2001
From: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
Date: Fri, 9 Nov 2018 09:01:29 +0100
Subject: [PATCH 2/2] nsswitch: Fix CID 1441070 Error handling issues
(CHECKED_RETURN)
Signed-off-by: Ralph Wuerthner <ralph.wuerthner at de.ibm.com>
---
nsswitch/stress-nss-libwbclient.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/nsswitch/stress-nss-libwbclient.c b/nsswitch/stress-nss-libwbclient.c
index 740ad0e..df1d85c 100644
--- a/nsswitch/stress-nss-libwbclient.c
+++ b/nsswitch/stress-nss-libwbclient.c
@@ -149,7 +149,14 @@ int main(int argc, char *argv[])
/* wait for query threads to terminate */
for (n = 0; n < 2; n++) {
- pthread_join(threads[n], NULL);
+ rc = pthread_join(threads[n], NULL);
+ if (rc != 0) {
+ fprintf(stderr,
+ "joining query thread %i failed: %s\n",
+ n,
+ strerror(rc));
+ exit(1);
+ }
}
fprintf(state.fail ? stderr: stdout,
--
2.7.4
More information about the samba-technical
mailing list