1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

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