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