coverity 83669 remove random from fraggle

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2014-11-30 13:55:40 +08:00
parent cbd98ed1e4
commit 453a9b34fd

View file

@ -67,6 +67,7 @@ callback_fraggle(struct libwebsocket_context *context,
unsigned long sum;
unsigned char *p = (unsigned char *)in;
unsigned char *bp = &buf[LWS_SEND_BUFFER_PRE_PADDING];
int ran;
switch (reason) {
@ -135,8 +136,8 @@ callback_fraggle(struct libwebsocket_context *context,
switch (psf->state) {
case FRAGSTATE_START_MESSAGE:
psf->packets_left = (random() % 1024) + 1;
libwebsockets_get_random(context, &ran, sizeof(ran));
psf->packets_left = (ran % 1024) + 1;
fprintf(stderr, "Spamming %d random fragments\n",
psf->packets_left);
psf->sum = 0;
@ -154,7 +155,8 @@ callback_fraggle(struct libwebsocket_context *context,
* code for rx spill because the rx buffer is full
*/
chunk = (random() % 8000) + 1;
libwebsockets_get_random(context, &ran, sizeof(ran));
chunk = (ran % 8000) + 1;
psf->total_message += chunk;
libwebsockets_get_random(context, bp, chunk);