202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
+
|
return(0);
}
/* Initialize process */
static int filed_init(unsigned int cache_size) {
static int called = 0;
ssize_t read_ret = 0;
unsigned int random_value = 0;
int cache_ret;
int random_fd;
if (called) {
return(0);
}
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
-
+
+
+
+
|
if (cache_ret != 0) {
return(cache_ret);
}
/* Initialize random number generator */
random_fd = open("/dev/urandom", O_RDONLY);
if (random_fd >= 0) {
read(random_fd, &random_value, sizeof(random_value));
read_ret = read(random_fd, &random_value, sizeof(random_value));
close(random_fd);
}
random_value ^= getpid();
random_value ^= getuid();
random_value ^= time(NULL);
srandom(random_value);
return(0);
/* NOTREACH: Read may fail or succeed, we don't actually care */
read_ret = read_ret;
}
/* Listen on a particular address/port */
static int filed_listen(const char *address, unsigned int port) {
struct sockaddr_in6 addr_v6;
struct sockaddr_in addr_v4;
struct sockaddr *addr;
|