1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
Description: Allow ssh-add to read from FIFOs
Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1869
Bug-Debian: http://bugs.debian.org/614897
Origin: other, https://bugzilla.mindrot.org/attachment.cgi?id=2002&action=diff
Forwarded: yes
Last-Update: 2011-03-18
Index: b/authfile.c
===================================================================
--- a/authfile.c
+++ b/authfile.c
@@ -317,7 +317,7 @@
static int
key_load_file(int fd, const char *filename, Buffer *blob)
{
- size_t len;
+ size_t len, readcount;
u_char *cp;
struct stat st;
@@ -337,11 +337,14 @@
return 0;
}
len = (size_t)st.st_size; /* truncated */
+ if (0 == len && S_ISFIFO(st.st_mode))
+ len = 8192; /* we will try reading up to 8KiB from a FIFO */
buffer_init(blob);
cp = buffer_append_space(blob, len);
- if (atomicio(read, fd, cp, len) != len) {
+ readcount = atomicio(read, fd, cp, len);
+ if (readcount != len && !(readcount > 0 && S_ISFIFO(st.st_mode))) {
debug("%s: read from key file %.200s%sfailed: %.100s", __func__,
filename == NULL ? "" : filename,
filename == NULL ? "" : " ",
|