Check-in [6ab9a334b8]
Overview
Comment:Explicitly ignore the return value of read() for random data
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6ab9a334b85e4a96751fe9c7772af1e511983d2b
User & Date: rkeene on 2014-06-20 04:45:34
Other Links: manifest | tags
Context
2014-07-23
07:53
Made wording slightly more clear check-in: f74837eecc user: rkeene tags: trunk
2014-06-20
04:45
Explicitly ignore the return value of read() for random data check-in: 6ab9a334b8 user: rkeene tags: trunk
2014-06-16
17:15
Added support for SIGHUP flushing all caches check-in: 20fd373453 user: rkeene tags: trunk
Changes

Modified filed.c from [3f7bad2ab6] to [9ca8af3757].

202
203
204
205
206
207
208

209
210
211
212
213
214
215

	return(0);
}

/* Initialize process */
static int filed_init(unsigned int cache_size) {
	static int called = 0;

	unsigned int random_value = 0;
	int cache_ret;
	int random_fd;

	if (called) {
		return(0);
	}







>







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
	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));

		close(random_fd);
	}

	random_value ^= getpid();
	random_value ^= getuid();
	random_value ^= time(NULL);

	srandom(random_value);

	return(0);



}

/* 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;







|











>
>
>







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_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;