{"thread":{"id":"2036","subject":"Still unsafe: write_sha1_from_fd()","startedAt":"2005-10-06T22:26:52Z","lastAt":"2005-10-06T22:37:40Z","messageCount":2,"participants":["Linus Torvalds","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"9779","messageId":"Pine.LNX.4.64.0510061520400.31407@g5.osdl.org","threadId":"2036","inReplyTo":null,"subject":"Still unsafe: write_sha1_from_fd()","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-10-06T22:26:52Z","receivedAt":"2005-10-06T22:26:52Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nI was looking over the object writing functions, and noticed that \n\"write_sha1_from_fd()\" writes its object directly into the final object \nname, which means that if it is interrupted with ^C at an inopportune \ntime, it will leave a corrupt object behind.\n\nThe only user is apparently ssh-fetch, but especially since the input-fd \nis a network connection, it looks like it is not at all unlikely that this \ncase will trigger - all it takes is somebody impatient waiting for a large \nobject.\n\nUgh,\n\n\t\tLinus\n"},{"id":"9780","messageId":"7vvf0a5l1n.fsf@assigned-by-dhcp.cox.net","threadId":"2036","inReplyTo":"Pine.LNX.4.64.0510061520400.31407@g5.osdl.org","subject":"Re: Still unsafe: write_sha1_from_fd()","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-06T22:37:40Z","receivedAt":"2005-10-06T22:37:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> The only user is apparently ssh-fetch, but especially since the input-fd \n> is a network connection, it looks like it is not at all unlikely that this \n> case will trigger - all it takes is somebody impatient waiting for a large \n> object.\n>\n> Ugh,\n\nUgh indeed.\n\nI'd vote for renaming it to a less generic name, moving it out\nof sha1_file.c -- make it static in ssh-fetch.c -- and slowly\ndeprecate the use of ssh-fetch/ssh-upload pair.\n\nI do not see much point prefering it over the pack transfer\nprotocol anyway, if you already have ssh access to the box.\n"}]}