diff options
author | RALOVICH, Kristof <tade60@freemail.hu> | 2014-08-11 18:37:30 +0200 |
---|---|---|
committer | RALOVICH, Kristof <tade60@freemail.hu> | 2014-08-11 18:37:30 +0200 |
commit | 55ccd71f73276006712f9247284aa825b49a0281 (patch) | |
tree | 5fe6e753de1d8b414583297c1cce0397da7f8bb1 /src | |
parent | 472ca0ba0668533ebb729bca52b09786abcded1d (diff) |
gant: fix two bugs
reported by coverity:
- uninitialized r
- leaking fd
Diffstat (limited to 'src')
-rw-r--r-- | src/gant/gant.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gant/gant.c b/src/gant/gant.c index 044f80c..73b04cb 100644 --- a/src/gant/gant.c +++ b/src/gant/gant.c @@ -194,11 +194,13 @@ uint randno(void) uint r; int fd = open("/dev/urandom", O_RDONLY); - if (fd > 0) + if (fd >= 0) { read(fd, &r, sizeof r); close(fd); } + else + r = rand(); return r; } |