From 1c55675135b389363c0fecf43f20c512ffbed1a7 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 30 Mar 2011 14:41:14 +0000 Subject: remove race by using fstat instead --- xxxterm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xxxterm.c b/xxxterm.c index 0918f56..cb4445f 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -2756,17 +2756,16 @@ ca_cmd(struct tab *t, struct karg *args) gnutls_x509_crt_t *c = NULL; char *certs_buf = NULL, *s; - /* yeah yeah stat race */ - if (stat(ssl_ca_file, &sb)) { - show_oops(t, "no CA file: %s", ssl_ca_file); - goto done; - } - if ((f = fopen(ssl_ca_file, "r")) == NULL) { show_oops(t, "Can't open CA file: %s", strerror(errno)); return (1); } + if (fstat(fileno(f), &sb) == -1) { + show_oops(t, "Can't stat CA file: %s", strerror(errno)); + goto done; + } + certs_buf = g_malloc(sb.st_size + 1); if (fread(certs_buf, 1, sb.st_size, f) != sb.st_size) { show_oops(t, "Can't read CA file: %s", strerror(errno)); -- cgit 1.4.1-2-gfad0 r> summary refs log tree commit diff stats
path: root/query.go
blob: 63e203c1fbff5301f67feea842174ac5b365c9fb (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114