{"thread":{"id":"5485","subject":"remote_get_heads: reference length limit","startedAt":"2006-09-05T12:18:50Z","lastAt":"2006-09-05T12:18:50Z","messageCount":1,"participants":["Andy Whitcroft"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"26358","messageId":"44FD6B2A.2040408@shadowen.org","threadId":"5485","inReplyTo":null,"subject":"remote_get_heads: reference length limit","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":"2006-09-05T12:18:50Z","receivedAt":"2006-09-05T12:18:50Z","isPatch":false,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"I've been having trouble with git push apparently resending the entire\ncommit trace for the branch each and every time I push.  Poking at the\nsource it seems this is due to a length limit on reference names as\npulled from the remote repository.\n\nWhen we are building the pack to send we are sent a list of remote\nheads.  get_remote_heads() reads these in, validates them and finally\nadds them to the remote_refs list.  Part of the validation is a simple\ncheck for size and form; check_ref().\n\nstatic int check_ref(const char *name, int len, unsigned int flags)\n{\n        if (!flags)\n                return 1;\n\n        if (len > 45 || memcmp(name, \"refs/\", 5))\n                return 0;\n[...]\n}\n\nWith the refs/heads/ prefix included this limits the head names to 34\ncharacters.  From what I can see there is no good reason for this limit\nto be so low.  I can see we don't want the remote end bloating us out of\ncontrol, but we are already limiting the lines which contain these\nreferences to 1000 bytes and making no attempt to limit the number of\nthem the remote server can send us.  There seems to be no limits imposed\non the name length other than MAX_PATHLEN.\n\nCan anyone see a reason to keep this (len > 45) check?\n\n-apw\n\n\nsend-pack: remove remote reference limit\n\nWhen build a pack for a push we query the remote copy for existant\nheads.  These are used to prune unnecessary objects from the pack.\nAs we receive the remote references in get_remote_heads() we validate\nthe reference names via check_ref() which includes a length check;\nrejecting those >45 characters in size.\n\nWe appear to be able to handle reference names upto MAXPATHLEN in\nsize.  Relax the limit out to that size.\n\nSigned-off-by: Andy Whitcroft <apw@shadowen.org>\n---\ndiff --git a/connect.c b/connect.c\nindex 4422a0d..0a51e78 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -17,7 +17,7 @@ static int check_ref(const char *name, i\n \tif (!flags)\n \t\treturn 1;\n \n-\tif (len > 45 || memcmp(name, \"refs/\", 5))\n+\tif (len > MAXPATHLEN || memcmp(name, \"refs/\", 5))\n \t\treturn 0;\n \n \t/* Skip the \"refs/\" part */\n"}]}