summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRALOVICH, Kristof <tade60@freemail.hu>2014-08-11 18:37:30 +0200
committerRALOVICH, Kristof <tade60@freemail.hu>2014-08-11 18:37:30 +0200
commit55ccd71f73276006712f9247284aa825b49a0281 (patch)
tree5fe6e753de1d8b414583297c1cce0397da7f8bb1
parent472ca0ba0668533ebb729bca52b09786abcded1d (diff)
gant: fix two bugs
reported by coverity: - uninitialized r - leaking fd
-rw-r--r--src/gant/gant.c4
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;
}