From f1e6b9d168281196010c44af2eae4587c1d2d088 Mon Sep 17 00:00:00 2001 From: Harald Sitter Date: Wed, 21 Oct 2015 07:38:48 +0200 Subject: [PATCH 4/4] initialize socket size with correct value to quote man 2 accept: > The addrlen argument is a value-result argument: the caller must > initialize it to contain the size (in bytes) of the structure pointed > to by addr; on return it will contain the actual size of the peer > address. If addrlen is not correct we may get EINVAL on trying to connect to the environment socket which in turn results in a broken environment of the daemon when started through pam as it will inherit the DM environment. This doesn't have to happen, it does however reproducibly with nvidia-352 on Kubuntu 15.10. Why or how nvidia plays into this is not entirely clear, best bet is that it simply is a coincidence where nvidia would have something allocated in the memory beforehand and since the addrlen stack variable was not explicitly initialized to anything it would could potentially be negative (EINVAL condition) or wrong such that it meets an internal error check within accept(). CHANGELOG: Fixed KWallet configuration file warnings on login FIXED-IN: 5.16 BUG: 351805 REVIEW: 125717 --- src/runtime/kwalletd/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/kwalletd/main.cpp b/src/runtime/kwalletd/main.cpp index 39b5ae9..e790afe 100644 --- a/src/runtime/kwalletd/main.cpp +++ b/src/runtime/kwalletd/main.cpp @@ -82,8 +82,8 @@ static int waitForEnvironment() printf("kwalletd5: waitingForEnvironment on: %d\n", socketfd); int s2; - socklen_t t; struct sockaddr_un remote; + socklen_t t = sizeof(remote); if ((s2 = accept(socketfd, (struct sockaddr *)&remote, &t)) == -1) { fprintf(stdout, "kwalletd5: Couldn't accept incoming connection\n"); return -1; -- 2.5.0