{"thread":{"id":"5952","subject":"[PATCH] Don't segfault if the given SHA1 name is longer than 40 characters","startedAt":"2006-10-19T01:34:41Z","lastAt":"2006-10-19T04:54:39Z","messageCount":3,"participants":["pclouds@gmail.com","Junio C Hamano","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"29195","messageId":"20061019013441.GB9379@localhost","threadId":"5952","inReplyTo":null,"subject":"[PATCH] Don't segfault if the given SHA1 name is longer than 40 characters","fromName":"","fromEmail":"pclouds@gmail.com","sentAt":"2006-10-19T01:34:41Z","receivedAt":"2006-10-19T01:34:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sha1_name.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 9b226e3..6ffee22 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -157,7 +157,7 @@ static int get_short_sha1(const char *na\n \tchar canonical[40];\n \tunsigned char res[20];\n \n-\tif (len < MINIMUM_ABBREV)\n+\tif (len < MINIMUM_ABBREV || len > 40)\n \t\treturn -1;\n \thashclr(res);\n \tmemset(canonical, 'x', 40);\n-- \n1.4.3.rc2.g0503-dirty\n"},{"id":"29201","messageId":"7vwt6xvt7q.fsf@assigned-by-dhcp.cox.net","threadId":"5952","inReplyTo":"20061019013441.GB9379@localhost","subject":"Re: [PATCH] Don't segfault if the given SHA1 name is longer than 40 characters","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-19T04:13:13Z","receivedAt":"2006-10-19T04:13:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"pclouds@gmail.com writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  sha1_name.c |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/sha1_name.c b/sha1_name.c\n> index 9b226e3..6ffee22 100644\n> --- a/sha1_name.c\n> +++ b/sha1_name.c\n> @@ -157,7 +157,7 @@ static int get_short_sha1(const char *na\n>  \tchar canonical[40];\n>  \tunsigned char res[20];\n>  \n> -\tif (len < MINIMUM_ABBREV)\n> +\tif (len < MINIMUM_ABBREV || len > 40)\n>  \t\treturn -1;\n>  \thashclr(res);\n>  \tmemset(canonical, 'x', 40);\n\nThanks.\n\nThe patch is correct, but it needs a better explanation in the\nproposed commit log message than just \"Don't segfault\".\n\nget_describe_name() can be fed a string foo-gXXX...XXX with a\nvery looooooooong hexstring.  It calls get_short_sha1() without\nchecking if XXX...XXX part is longer than 40-bytes (in which\ncase it cannot be a valid object name).\n\nget_sha1_1() has the same problem.  Given a hexstring longer\nthan 40-bytes, it calls the function with it because earlier\nones such as get_sha1_hex() would reject the input.\n"},{"id":"29203","messageId":"fcaeb9bf0610182154l55de75d1w4a99db608f7f6477@mail.gmail.com","threadId":"5952","inReplyTo":"7vwt6xvt7q.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Don't segfault if the given SHA1 name is longer than 40 characters","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2006-10-19T04:54:39Z","receivedAt":"2006-10-19T04:54:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 10/19/06, Junio C Hamano <junkio@cox.net> wrote:\n> The patch is correct, but it needs a better explanation in the\n> proposed commit log message than just \"Don't segfault\".\n\nWell, maybe because I got a segfault when I accidentally pasted an\nsha1 twice (blame my mouse). I hadn't looked closely enough to the\nbug. Anyway, you got the bug and obviously have a better explanation\nthan mine. Please fix it with a better explanation. I'll be more\nexplanatory next time. Thank you :-)\n\n> get_describe_name() can be fed a string foo-gXXX...XXX with a\n> very looooooooong hexstring.  It calls get_short_sha1() without\n> checking if XXX...XXX part is longer than 40-bytes (in which\n> case it cannot be a valid object name).\n>\n> get_sha1_1() has the same problem.  Given a hexstring longer\n> than 40-bytes, it calls the function with it because earlier\n> ones such as get_sha1_hex() would reject the input.\n-- \nDuy\n"}]}