[SSSD] [PATCH] PAM: Fix off-by-one-error in the SELinux session code

Jakub Hrozek jhrozek at redhat.com
Wed Jul 18 18:37:40 UTC 2012


This was causing unpredictable behaviour when writing the SELinux user
-- because the string wasn't NULL-terminated, the PAM module sometimes
wrote junk into the logins file.
-------------- next part --------------
>From 94e643a5edd8396c150ef31296499b8e632b8aa5 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 18 Jul 2012 20:35:45 +0200
Subject: [PATCH] PAM: Fix off-by-one-error in the SELinux session code

---
 src/responder/pam/pamsrv_cmd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index e66debe24397140462e334a4c70fd93801b09ca2..006edcd36988ebae808613031bc7bd51c76be960 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -494,7 +494,7 @@ static errno_t get_selinux_string(struct pam_auth_req *preq)
     }
 
     if (file_content) {
-        len = strlen(file_content);
+        len = strlen(file_content)+1;
         if (len > 0) {
             ret = pam_add_response(pd, SSS_PAM_SELINUX_MAP, len,
                                    (uint8_t *)file_content);
-- 
1.7.10.4



More information about the sssd-devel mailing list