Re: [PATCH/RFD] fix connection via git protocol

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Elijah Newren <newren@xxxxxxxxx> writes:

>> 5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
>> broke connections via git protocol because it removed the inclusion of
>> the default port macro. While some may consider this transport to be
>> deprecated, it still serves some purpose.
>
> In particular the problem is that
>
> 	const char *port = STR(DEFAULT_GIT_PORT);
>
> translates now to
>
> 	const char *port = "DEFAULT_GIT_PORT";
>
> instead of
>
> 	const char *port = "9418";

Wow, that is a bad one.  If people do want "DEFAULT_GIT_PORT", they
would never write STR(DEFAULT_GIT_PORT).  I wonder if we can have a
bit more clever STR() macro that catches this kind of mistake at the
compile time.

If this is worth fixing, the fix would probably be worth protecting
with a test or two, but the networking test with fixed port is not
something we can easily do without a sealed environment, so...

Thanks Michael for catching this.

> I've got a patch that does precisely this that I just submitted as
> part of my follow-on to the en/header-split-cache-h series.  I've included
> that patch below in case Junio wants to advance it faster than the rest of
> that series.

Yeah, burying it in a 24-patch series is a bit unfortunate.


> -- >8 --
> Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
>
> Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
> ---
>  cache.h    | 21 ---------------------
>  daemon.c   |  1 +
>  protocol.h | 21 +++++++++++++++++++++
>  3 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index 2f21704da9e..71e2fe74c4f 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -39,27 +39,6 @@
>  #define S_DIFFTREE_IFXMIN_NEQ	0x80000000
>  
>  
> -/*
> - * Intensive research over the course of many years has shown that
> - * port 9418 is totally unused by anything else. Or
> - *
> - *	Your search - "port 9418" - did not match any documents.
> - *
> - * as www.google.com puts it.
> - *
> - * This port has been properly assigned for git use by IANA:
> - * git (Assigned-9418) [I06-050728-0001].
> - *
> - *	git  9418/tcp   git pack transfer service
> - *	git  9418/udp   git pack transfer service
> - *
> - * with Linus Torvalds <torvalds@xxxxxxxx> as the point of
> - * contact. September 2005.
> - *
> - * See http://www.iana.org/assignments/port-numbers
> - */
> -#define DEFAULT_GIT_PORT 9418
> -
>  /*
>   * Basic data structures for the directory cache
>   */
> diff --git a/daemon.c b/daemon.c
> index db8a31a6ea2..75c3c064574 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -4,6 +4,7 @@
>  #include "config.h"
>  #include "environment.h"
>  #include "pkt-line.h"
> +#include "protocol.h"
>  #include "run-command.h"
>  #include "setup.h"
>  #include "strbuf.h"
> diff --git a/protocol.h b/protocol.h
> index cef1a4a01c7..de66bf80f84 100644
> --- a/protocol.h
> +++ b/protocol.h
> @@ -1,6 +1,27 @@
>  #ifndef PROTOCOL_H
>  #define PROTOCOL_H
>  
> +/*
> + * Intensive research over the course of many years has shown that
> + * port 9418 is totally unused by anything else. Or
> + *
> + *	Your search - "port 9418" - did not match any documents.
> + *
> + * as www.google.com puts it.
> + *
> + * This port has been properly assigned for git use by IANA:
> + * git (Assigned-9418) [I06-050728-0001].
> + *
> + *	git  9418/tcp   git pack transfer service
> + *	git  9418/udp   git pack transfer service
> + *
> + * with Linus Torvalds <torvalds@xxxxxxxx> as the point of
> + * contact. September 2005.
> + *
> + * See http://www.iana.org/assignments/port-numbers
> + */
> +#define DEFAULT_GIT_PORT 9418
> +
>  enum protocol_version {
>  	protocol_unknown_version = -1,
>  	protocol_v0 = 0,



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux