Thread (10 messages) 10 messages, 3 authors, 2025-03-06
STALE483d
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 1/2] ident: stop assuming that `gw_gecos` is writable

From: Johannes Schindelin via GitGitGadget <hidden>
Date: 2025-02-27 15:44:13
Subsystem: the rest · Maintainer: Linus Torvalds

From: Johannes Schindelin <redacted>

In 590e081dea7c (ident: add NO_GECOS_IN_PWENT for systems without
pw_gecos in struct passwd, 2011-05-19), code was introduced to iterate
over the `gw_gecos` field; The loop variable is of type `char *`, which
assumes that `gw_gecos` is writable.

However, it is not necessarily writable (and it is a bad idea to have it
writable in the first place), so let's switch the loop variable type to
`const char *`.

Signed-off-by: Johannes Schindelin <redacted>
---
 ident.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ident.c b/ident.c
index caf41fb2a98..967895d8850 100644
--- a/ident.c
+++ b/ident.c
@@ -59,7 +59,7 @@ static struct passwd *xgetpwuid_self(int *is_bogus)
 
 static void copy_gecos(const struct passwd *w, struct strbuf *name)
 {
-	char *src;
+	const char *src;
 
 	/* Traditionally GECOS field had office phone numbers etc, separated
 	 * with commas.  Also & stands for capitalized form of the login name.
-- 
gitgitgadget
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help