# Still unsafe: write_sha1_from_fd()

2 messages from 2005-10-06 to 2005-10-06. Participants: Linus Torvalds, Junio C Hamano.
Thread: https://gitlist.dev/t/2036

## Linus Torvalds, 2005-10-06 22:26

Subject: Still unsafe: write_sha1_from_fd()
Message-ID: <Pine.LNX.4.64.0510061520400.31407@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0510061520400.31407%40g5.osdl.org

```

I was looking over the object writing functions, and noticed that 
"write_sha1_from_fd()" writes its object directly into the final object 
name, which means that if it is interrupted with ^C at an inopportune 
time, it will leave a corrupt object behind.

The only user is apparently ssh-fetch, but especially since the input-fd 
is a network connection, it looks like it is not at all unlikely that this 
case will trigger - all it takes is somebody impatient waiting for a large 
object.

Ugh,

		Linus

```

## Junio C Hamano, 2005-10-06 22:37

Subject: Re: Still unsafe: write_sha1_from_fd()
Message-ID: <7vvf0a5l1n.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvf0a5l1n.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0510061520400.31407@g5.osdl.org>

```
Linus Torvalds <torvalds@osdl.org> writes:

> The only user is apparently ssh-fetch, but especially since the input-fd 
> is a network connection, it looks like it is not at all unlikely that this 
> case will trigger - all it takes is somebody impatient waiting for a large 
> object.
>
> Ugh,

Ugh indeed.

I'd vote for renaming it to a less generic name, moving it out
of sha1_file.c -- make it static in ssh-fetch.c -- and slowly
deprecate the use of ssh-fetch/ssh-upload pair.

I do not see much point prefering it over the pack transfer
protocol anyway, if you already have ssh access to the box.

```
