git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Rafael Gieschke <rafael@gieschke.de>
Date
May 16, 2011, 20:08 UTC
Message-ID
<F0632D34-AA49-48B6-B54E-208B14F3FA90@gieschke.de>

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(-)
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
Next: Junio C Hamano
Message 1 of 2 in “copy_gecos: fix not adding nlen to len when processing "&"”
  1. copy_gecos: fix not adding nlen to len when processing "&"Rafael Gieschke, May 16, 2011
  2. Junio C HamanoMay 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.