URL: https://github.com/SSSD/sssd/pull/732 Author: alexey-tikhonov Title: #732: Issue 3841 Action: opened
PR body: """ sss_client/common.c: fix Coverity issue Usage of strncpy(nssaddr.sun_path, socket_name, sizeof(nssaddr.sun_path)) 1) confuses Coverity due to 3rd argument being equal to sizeof(1st) 2) again zeroes previously zeroed buffer So replaced with strcpy() This should be safe due to existing check of sizes. Resolves: https://pagure.io/SSSD/sssd/issue/3841 """ To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/732/head:pr732 git checkout pr732
From 1830b07c8c3b103ccbfd30d9d1253319f8c961db Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov <atikh...@redhat.com> Date: Fri, 11 Jan 2019 17:28:22 +0100 Subject: [PATCH 1/2] sss_client/common.c: fix Coverity issue Usage of strncpy(nssaddr.sun_path, socket_name, sizeof(nssaddr.sun_path)) 1) confuses Coverity due to 3rd argument being equal to sizeof(1st) 2) again zeroes previously zeroed buffer So replaced with strcpy() This should be safe due to existing check of sizes. Resolves: https://pagure.io/SSSD/sssd/issue/3841 --- src/sss_client/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sss_client/common.c b/src/sss_client/common.c index 67a4607056..f330e17942 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -546,7 +546,7 @@ static int sss_cli_open_socket(int *errnop, const char *socket_name, int timeout memset(&nssaddr, 0, sizeof(struct sockaddr_un)); nssaddr.sun_family = AF_UNIX; - strncpy(nssaddr.sun_path, socket_name, sizeof(nssaddr.sun_path)); + strcpy(nssaddr.sun_path, socket_name); /* safe due to above check */ sd = socket(AF_UNIX, SOCK_STREAM, 0); if (sd == -1) { From a7eb5226fc6d6d4954549093ce31e074b6eb5b29 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov <atikh...@redhat.com> Date: Mon, 14 Jan 2019 11:07:09 +0100 Subject: [PATCH 2/2] sss_client/common.c: fix off-by-one error in sizes check `sizeof(nssaddr.sun_path)` being equal to `strlen(socket_name) + 1` should be fine, not error. --- src/sss_client/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sss_client/common.c b/src/sss_client/common.c index f330e17942..2788f773e1 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -539,7 +539,7 @@ static int sss_cli_open_socket(int *errnop, const char *socket_name, int timeout int ret; int sd; - if (sizeof(nssaddr.sun_path) <= strlen(socket_name) + 1) { + if (sizeof(nssaddr.sun_path) < strlen(socket_name) + 1) { *errnop = EINVAL; return -1; }
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org