Use ws_open/ws_read to avoid prohibited APIs.

Close file handle after usage.

svn path=/trunk/; revision=37769
This commit is contained in:
Stig Bjørlykke 2011-06-23 13:51:26 +00:00
parent 7da7f34750
commit 30c6c1fb9d
1 changed files with 4 additions and 2 deletions

View File

@ -49,6 +49,7 @@
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
#include "wiretap/wtap.h" #include "wiretap/wtap.h"
#include "wsutil/file_util.h"
#ifdef _WIN32 #ifdef _WIN32
#include <wsutil/unicode-utils.h> #include <wsutil/unicode-utils.h>
@ -705,7 +706,7 @@ seed(void)
* *
* XXX - Use CryptGenRandom on Windows? * XXX - Use CryptGenRandom on Windows?
*/ */
fd = open(RANDOM_DEV, O_RDONLY); fd = ws_open(RANDOM_DEV, O_RDONLY);
if (fd == -1) { if (fd == -1) {
if (errno != ENOENT) { if (errno != ENOENT) {
fprintf(stderr, fprintf(stderr,
@ -716,7 +717,7 @@ seed(void)
goto fallback; goto fallback;
} }
ret = read(fd, &randomness, sizeof randomness); ret = ws_read(fd, &randomness, sizeof randomness);
if (ret == -1) { if (ret == -1) {
fprintf(stderr, fprintf(stderr,
"randpkt: Could not read from " RANDOM_DEV ": %s\n", "randpkt: Could not read from " RANDOM_DEV ": %s\n",
@ -730,6 +731,7 @@ seed(void)
exit(2); exit(2);
} }
srand(randomness); srand(randomness);
ws_close(fd);
return; return;
fallback: fallback: