[lxc-devel] [lxcfs/master] pam_cgfs: make trim() safer

brauner on Github lxc-bot at linuxcontainers.org
Thu Mar 2 23:35:48 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 365 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170302/a4a80062/attachment.bin>
-------------- next part --------------
From fa00d59aa49de0809b200b8f5eb91d9059876d82 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 3 Mar 2017 00:35:07 +0100
Subject: [PATCH] pam_cgfs: make trim() safer

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 pam/pam_cgfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pam/pam_cgfs.c b/pam/pam_cgfs.c
index fd47d70..e5818f9 100644
--- a/pam/pam_cgfs.c
+++ b/pam/pam_cgfs.c
@@ -346,7 +346,7 @@ static void trim(char *s)
 {
 	size_t len = strlen(s);
 
-	while (s[len - 1] == '\n')
+	while ((len > 0) && s[len - 1] == '\n')
 		s[--len] = '\0';
 }
 


More information about the lxc-devel mailing list