aboutsummaryrefslogtreecommitdiffstats
path: root/src/p2p/p2p_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p/p2p_utils.c')
-rw-r--r--src/p2p/p2p_utils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index df540ef5..23acce76 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -450,7 +450,8 @@ void p2p_channels_dump(struct p2p_data *p2p, const char *title,
static u8 p2p_channel_pick_random(const u8 *channels, unsigned int num_channels)
{
unsigned int r;
- os_get_random((u8 *) &r, sizeof(r));
+ if (os_get_random((u8 *) &r, sizeof(r)) < 0)
+ r = 0;
r %= num_channels;
return channels[r];
}