threads / patch / 27375

patchcopy_gecos: fix not adding nlen to len when processing "&"

Subject: [PATCH] copy_gecos: fix not adding nlen to len when processing "&"

## tl;dr

2 messages between May 16, 2011 and May 18, 2011. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Rafael Gieschke· May 16, 2011, 20:08 UTC · lore

nlen has to be added to len when inserting (capitalized) pw_name as substitution for "&" in pw_gecos. Otherwise, pw_gecos will be truncated and data might be written beyond name+sz.

Signed-off-by: Rafael Gieschke <rafael@gieschke.de>
---
 ident.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to ident.c +1 −0
diff --git a/ident.c b/ident.c
index 1c4adb0..8e56b5e 100644
--- a/ident.c
+++ b/ident.c
@@ -34,6 +34,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
 			*dst++ = toupper(*w->pw_name);
 			memcpy(dst, w->pw_name + 1, nlen - 1);
 			dst += nlen - 1;
+			len += nlen;
 		}
 	}
 	if (len < sz)
-- 
1.7.4

← back to recent threads