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

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

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 27, 2025, 15:44 UTC
Message-ID
<045c11dc1d51690eed4dc07da26dcace612f786c.1740671049.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1867.git.1740671049.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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 <johannes.schindelin@gmx.de>
---
 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
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 2 of 14 in “Hot fixes from Git for Windows v2.49.0-rc0”
  1. 0/2 Hot fixes from Git for Windows v2.49.0-rc0Johannes Schindelin via GitGitGadget, Feb 27, 2025
  2. 1/2 ident: stop assuming that `gw_gecos` is writableJohannes Schindelin via GitGitGadget, Feb 27, 2025
  3. Junio C HamanoFeb 27, 2025
  4. 2/2 meson: fix sortingJohannes Schindelin via GitGitGadget, Feb 27, 2025
  5. Patrick SteinhardtFeb 28, 2025
  6. 0/3 Hot fixes from Git for Windows v2.49.0-rc0Johannes Schindelin via GitGitGadget, Mar 6, 2025
  7. 1/3 ident: stop assuming that `gw_gecos` is writableJohannes Schindelin via GitGitGadget, Mar 6, 2025
  8. Patrick SteinhardtMar 6, 2025
  9. Johannes SchindelinMar 6, 2025
  10. Junio C HamanoMar 6, 2025
  11. Patrick SteinhardtMar 7, 2025
  12. Junio C HamanoMar 7, 2025
  13. 2/3 meson: fix sortingJohannes Schindelin via GitGitGadget, Mar 6, 2025
  14. 3/3 cmake: generalize the handling of the `CLAR_TEST_OBJS` listJohannes Schindelin via GitGitGadget, Mar 6, 2025

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.