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

[PATCH] daemon: Skip unknown "extra arg" information

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 4, 2009, 22:08 UTC
Message-ID
<20090604220824.GT3355@spearce.org>

If we don't recognize an extra arg supplied hidden behind the command, we should skip it and look at the next extra arg, in case we recognize the next one.

For example, we currently don't recognize the "user=" extra arg, but we should still be able to start this connection anyway:

 perl -e '
   $s="git-upload-pack /.git\0user=me\0host=localhost\0";
   printf "%4.4x%s",4+length $s,$s
 ' | ./git-daemon --inetd --base-path=`pwd` --export-all
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 This should go in maint.
 daemon.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/daemon.c b/daemon.c
index daa4c8e..a9a4f02 100644
--- a/daemon.c
+++ b/daemon.c
@@ -411,14 +411,13 @@ static char *xstrdup_tolower(const char *str)
 static void parse_extra_args(char *extra_args, int buflen)
 {
 	char *val;
-	int vallen;
 	char *end = extra_args + buflen;
 
 	while (extra_args < end && *extra_args) {
+		int arglen = strlen(extra_args);
 		saw_extended_args = 1;
 		if (strncasecmp("host=", extra_args, 5) == 0) {
 			val = extra_args + 5;
-			vallen = strlen(val) + 1;
 			if (*val) {
 				/* Split <host>:<port> at colon. */
 				char *host = val;
@@ -432,10 +431,10 @@ static void parse_extra_args(char *extra_args, int buflen)
 				free(hostname);
 				hostname = xstrdup_tolower(host);
 			}
-
-			/* On to the next one */
-			extra_args = val + vallen;
 		}
+
+		/* On to the next one */
+		extra_args += arglen + 1;
 	}
 
 	/*
-- 
1.6.3.1.333.g3ebba7
Next: Junio C Hamano
Message 1 of 7 in “daemon: Skip unknown "extra arg" information”
  1. daemon: Skip unknown "extra arg" informationShawn O. Pearce, Jun 4, 2009
  2. Junio C HamanoJun 5, 2009
  3. Shawn O. PearceJun 5, 2009
  4. Jakub NarebskiJun 5, 2009
  5. Sergey VlasovJun 5, 2009
  6. Johannes SixtJun 7, 2009
  7. Junio C HamanoJun 7, 2009

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.