idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
6,200
|
static inline struct h2s *h2c_st_by_id(struct h2c *h2c, int id)
{
struct eb32_node *node;
if (id > h2c->max_id)
return (struct h2s *)h2_idle_stream;
node = eb32_lookup(&h2c->streams_by_id, id);
if (!node)
return (struct h2s *)h2_closed_stream;
return container_of(node, struct h2s, by_id);
}
|
Exec Code Overflow
| 0
|
static inline struct h2s *h2c_st_by_id(struct h2c *h2c, int id)
{
struct eb32_node *node;
if (id > h2c->max_id)
return (struct h2s *)h2_idle_stream;
node = eb32_lookup(&h2c->streams_by_id, id);
if (!node)
return (struct h2s *)h2_closed_stream;
return container_of(node, struct h2s, by_id);
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,201
|
static struct h2s *h2c_stream_new(struct h2c *h2c, int id)
{
struct conn_stream *cs;
struct h2s *h2s;
h2s = pool_alloc(pool_head_h2s);
if (!h2s)
goto out;
h2s->h2c = h2c;
h2s->mws = h2c->miw;
h2s->flags = H2_SF_NONE;
h2s->errcode = H2_ERR_NO_ERROR;
h2s->st = H2_SS_IDLE;
h1m_init(&h2s->req);
h1m_init(&h2s->res);
h2s->by_id.key = h2s->id = id;
h2c->max_id = id;
LIST_INIT(&h2s->list);
eb32_insert(&h2c->streams_by_id, &h2s->by_id);
h2c->nb_streams++;
if (h2c->nb_streams > h2_settings_max_concurrent_streams)
goto out_close;
cs = cs_new(h2c->conn);
if (!cs)
goto out_close;
h2s->cs = cs;
cs->ctx = h2s;
if (stream_create_from_cs(cs) < 0)
goto out_free_cs;
/* OK done, the stream lives its own life now */
return h2s;
out_free_cs:
cs_free(cs);
out_close:
h2s_destroy(h2s);
h2s = NULL;
out:
return h2s;
}
|
Exec Code Overflow
| 0
|
static struct h2s *h2c_stream_new(struct h2c *h2c, int id)
{
struct conn_stream *cs;
struct h2s *h2s;
h2s = pool_alloc(pool_head_h2s);
if (!h2s)
goto out;
h2s->h2c = h2c;
h2s->mws = h2c->miw;
h2s->flags = H2_SF_NONE;
h2s->errcode = H2_ERR_NO_ERROR;
h2s->st = H2_SS_IDLE;
h1m_init(&h2s->req);
h1m_init(&h2s->res);
h2s->by_id.key = h2s->id = id;
h2c->max_id = id;
LIST_INIT(&h2s->list);
eb32_insert(&h2c->streams_by_id, &h2s->by_id);
h2c->nb_streams++;
if (h2c->nb_streams > h2_settings_max_concurrent_streams)
goto out_close;
cs = cs_new(h2c->conn);
if (!cs)
goto out_close;
h2s->cs = cs;
cs->ctx = h2s;
if (stream_create_from_cs(cs) < 0)
goto out_free_cs;
/* OK done, the stream lives its own life now */
return h2s;
out_free_cs:
cs_free(cs);
out_close:
h2s_destroy(h2s);
h2s = NULL;
out:
return h2s;
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,202
|
static void h2c_update_all_ws(struct h2c *h2c, int diff)
{
struct h2s *h2s;
struct eb32_node *node;
if (!diff)
return;
node = eb32_first(&h2c->streams_by_id);
while (node) {
h2s = container_of(node, struct h2s, by_id);
h2s->mws += diff;
node = eb32_next(node);
}
}
|
Exec Code Overflow
| 0
|
static void h2c_update_all_ws(struct h2c *h2c, int diff)
{
struct h2s *h2s;
struct eb32_node *node;
if (!diff)
return;
node = eb32_first(&h2c->streams_by_id);
while (node) {
h2s = container_of(node, struct h2s, by_id);
h2s->mws += diff;
node = eb32_next(node);
}
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,203
|
static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf)
{
struct h2c *h2c = h2s->h2c;
struct h1m *h1m = &h2s->res;
struct chunk outbuf;
int ret = 0;
int total = 0;
int es_now = 0;
int size = 0;
char *blk1, *blk2;
int len1, len2;
if (h2c_mux_busy(h2c, h2s)) {
h2s->flags |= H2_SF_BLK_MBUSY;
goto end;
}
if (!h2_get_buf(h2c, &h2c->mbuf)) {
h2c->flags |= H2_CF_MUX_MALLOC;
h2s->flags |= H2_SF_BLK_MROOM;
goto end;
}
new_frame:
if (!buf->o)
goto end;
chunk_reset(&outbuf);
while (1) {
outbuf.str = bo_end(h2c->mbuf);
outbuf.size = bo_contig_space(h2c->mbuf);
outbuf.len = 0;
if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
break;
realign_again:
buffer_slow_realign(h2c->mbuf);
}
if (outbuf.size < 9) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
goto end;
}
/* len: 0x000000 (fill later), type: 0(DATA), flags: none=0 */
memcpy(outbuf.str, "\x00\x00\x00\x00\x00", 5);
write_n32(outbuf.str + 5, h2s->id); // 4 bytes
outbuf.len = 9;
switch (h1m->flags & (H1_MF_CLEN|H1_MF_CHNK)) {
case 0: /* no content length, read till SHUTW */
size = buf->o;
h1m->curr_len = size;
break;
case H1_MF_CLEN: /* content-length: read only h2m->body_len */
size = buf->o;
if ((long long)size > h1m->curr_len)
size = h1m->curr_len;
break;
default: /* te:chunked : parse chunks */
if (h1m->state == HTTP_MSG_CHUNK_CRLF) {
ret = h1_skip_chunk_crlf(buf, -buf->o, 0);
if (!ret)
goto end;
if (ret < 0) {
/* FIXME: bad contents. how to proceed here when we're in H2 ? */
h1m->err_pos = ret;
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
goto end;
}
bo_del(buf, ret);
total += ret;
h1m->state = HTTP_MSG_CHUNK_SIZE;
}
if (h1m->state == HTTP_MSG_CHUNK_SIZE) {
unsigned int chunk;
ret = h1_parse_chunk_size(buf, -buf->o, 0, &chunk);
if (!ret)
goto end;
if (ret < 0) {
/* FIXME: bad contents. how to proceed here when we're in H2 ? */
h1m->err_pos = ret;
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
goto end;
}
size = chunk;
h1m->curr_len = chunk;
h1m->body_len += chunk;
bo_del(buf, ret);
total += ret;
h1m->state = size ? HTTP_MSG_DATA : HTTP_MSG_TRAILERS;
if (!size)
goto send_empty;
}
/* in MSG_DATA state, continue below */
size = h1m->curr_len;
break;
}
/* we have in <size> the exact number of bytes we need to copy from
* the H1 buffer. We need to check this against the connection's and
* the stream's send windows, and to ensure that this fits in the max
* frame size and in the buffer's available space minus 9 bytes (for
* the frame header). The connection's flow control is applied last so
* that we can use a separate list of streams which are immediately
* unblocked on window opening. Note: we don't implement padding.
*/
if (size > buf->o)
size = buf->o;
if (size > h2s->mws)
size = h2s->mws;
if (size <= 0) {
h2s->flags |= H2_SF_BLK_SFCTL;
goto end;
}
if (h2c->mfs && size > h2c->mfs)
size = h2c->mfs;
if (size + 9 > outbuf.size) {
/* we have an opportunity for enlarging the too small
* available space, let's try.
*/
if (buffer_space_wraps(h2c->mbuf))
goto realign_again;
size = outbuf.size - 9;
}
if (size <= 0) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
goto end;
}
if (size > h2c->mws)
size = h2c->mws;
if (size <= 0) {
h2s->flags |= H2_SF_BLK_MFCTL;
goto end;
}
/* copy whatever we can */
blk1 = blk2 = NULL; // silence a maybe-uninitialized warning
ret = bo_getblk_nc(buf, &blk1, &len1, &blk2, &len2);
if (ret == 1)
len2 = 0;
if (!ret || len1 + len2 < size) {
/* FIXME: must normally never happen */
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
goto end;
}
/* limit len1/len2 to size */
if (len1 + len2 > size) {
int sub = len1 + len2 - size;
if (len2 > sub)
len2 -= sub;
else {
sub -= len2;
len2 = 0;
len1 -= sub;
}
}
/* now let's copy this this into the output buffer */
memcpy(outbuf.str + 9, blk1, len1);
if (len2)
memcpy(outbuf.str + 9 + len1, blk2, len2);
send_empty:
/* we may need to add END_STREAM */
/* FIXME: we should also detect shutdown(w) below, but how ? Maybe we
* could rely on the MSG_MORE flag as a hint for this ?
*/
if (((h1m->flags & H1_MF_CLEN) && !(h1m->curr_len - size)) ||
!h1m->curr_len || h1m->state >= HTTP_MSG_DONE)
es_now = 1;
/* update the frame's size */
h2_set_frame_size(outbuf.str, size);
if (es_now)
outbuf.str[4] |= H2_F_DATA_END_STREAM;
/* commit the H2 response */
h2c->mbuf->o += size + 9;
h2c->mbuf->p = b_ptr(h2c->mbuf, size + 9);
/* consume incoming H1 response */
if (size > 0) {
bo_del(buf, size);
total += size;
h1m->curr_len -= size;
h2s->mws -= size;
h2c->mws -= size;
if (size && !h1m->curr_len && (h1m->flags & H1_MF_CHNK)) {
h1m->state = HTTP_MSG_CHUNK_CRLF;
goto new_frame;
}
}
if (es_now) {
if (h2s->st == H2_SS_OPEN)
h2s->st = H2_SS_HLOC;
else
h2s_close(h2s);
if (!(h1m->flags & H1_MF_CHNK)) {
bo_del(buf, buf->o);
h1m->state = HTTP_MSG_DONE;
}
h2s->flags |= H2_SF_ES_SENT;
}
end:
trace("[%d] sent simple H2 DATA response (sid=%d) = %d bytes out (%d in, st=%s, ep=%u, es=%s, h2cws=%d h2sws=%d) buf->o=%d", h2c->st0, h2s->id, size+9, total, h1_msg_state_str(h1m->state), h1m->err_pos, h1_msg_state_str(h1m->err_state), h2c->mws, h2s->mws, buf->o);
return total;
}
|
Exec Code Overflow
| 0
|
static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf)
{
struct h2c *h2c = h2s->h2c;
struct h1m *h1m = &h2s->res;
struct chunk outbuf;
int ret = 0;
int total = 0;
int es_now = 0;
int size = 0;
char *blk1, *blk2;
int len1, len2;
if (h2c_mux_busy(h2c, h2s)) {
h2s->flags |= H2_SF_BLK_MBUSY;
goto end;
}
if (!h2_get_buf(h2c, &h2c->mbuf)) {
h2c->flags |= H2_CF_MUX_MALLOC;
h2s->flags |= H2_SF_BLK_MROOM;
goto end;
}
new_frame:
if (!buf->o)
goto end;
chunk_reset(&outbuf);
while (1) {
outbuf.str = bo_end(h2c->mbuf);
outbuf.size = bo_contig_space(h2c->mbuf);
outbuf.len = 0;
if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
break;
realign_again:
buffer_slow_realign(h2c->mbuf);
}
if (outbuf.size < 9) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
goto end;
}
/* len: 0x000000 (fill later), type: 0(DATA), flags: none=0 */
memcpy(outbuf.str, "\x00\x00\x00\x00\x00", 5);
write_n32(outbuf.str + 5, h2s->id); // 4 bytes
outbuf.len = 9;
switch (h1m->flags & (H1_MF_CLEN|H1_MF_CHNK)) {
case 0: /* no content length, read till SHUTW */
size = buf->o;
h1m->curr_len = size;
break;
case H1_MF_CLEN: /* content-length: read only h2m->body_len */
size = buf->o;
if ((long long)size > h1m->curr_len)
size = h1m->curr_len;
break;
default: /* te:chunked : parse chunks */
if (h1m->state == HTTP_MSG_CHUNK_CRLF) {
ret = h1_skip_chunk_crlf(buf, -buf->o, 0);
if (!ret)
goto end;
if (ret < 0) {
/* FIXME: bad contents. how to proceed here when we're in H2 ? */
h1m->err_pos = ret;
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
goto end;
}
bo_del(buf, ret);
total += ret;
h1m->state = HTTP_MSG_CHUNK_SIZE;
}
if (h1m->state == HTTP_MSG_CHUNK_SIZE) {
unsigned int chunk;
ret = h1_parse_chunk_size(buf, -buf->o, 0, &chunk);
if (!ret)
goto end;
if (ret < 0) {
/* FIXME: bad contents. how to proceed here when we're in H2 ? */
h1m->err_pos = ret;
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
goto end;
}
size = chunk;
h1m->curr_len = chunk;
h1m->body_len += chunk;
bo_del(buf, ret);
total += ret;
h1m->state = size ? HTTP_MSG_DATA : HTTP_MSG_TRAILERS;
if (!size)
goto send_empty;
}
/* in MSG_DATA state, continue below */
size = h1m->curr_len;
break;
}
/* we have in <size> the exact number of bytes we need to copy from
* the H1 buffer. We need to check this against the connection's and
* the stream's send windows, and to ensure that this fits in the max
* frame size and in the buffer's available space minus 9 bytes (for
* the frame header). The connection's flow control is applied last so
* that we can use a separate list of streams which are immediately
* unblocked on window opening. Note: we don't implement padding.
*/
if (size > buf->o)
size = buf->o;
if (size > h2s->mws)
size = h2s->mws;
if (size <= 0) {
h2s->flags |= H2_SF_BLK_SFCTL;
goto end;
}
if (h2c->mfs && size > h2c->mfs)
size = h2c->mfs;
if (size + 9 > outbuf.size) {
/* we have an opportunity for enlarging the too small
* available space, let's try.
*/
if (buffer_space_wraps(h2c->mbuf))
goto realign_again;
size = outbuf.size - 9;
}
if (size <= 0) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
goto end;
}
if (size > h2c->mws)
size = h2c->mws;
if (size <= 0) {
h2s->flags |= H2_SF_BLK_MFCTL;
goto end;
}
/* copy whatever we can */
blk1 = blk2 = NULL; // silence a maybe-uninitialized warning
ret = bo_getblk_nc(buf, &blk1, &len1, &blk2, &len2);
if (ret == 1)
len2 = 0;
if (!ret || len1 + len2 < size) {
/* FIXME: must normally never happen */
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
goto end;
}
/* limit len1/len2 to size */
if (len1 + len2 > size) {
int sub = len1 + len2 - size;
if (len2 > sub)
len2 -= sub;
else {
sub -= len2;
len2 = 0;
len1 -= sub;
}
}
/* now let's copy this this into the output buffer */
memcpy(outbuf.str + 9, blk1, len1);
if (len2)
memcpy(outbuf.str + 9 + len1, blk2, len2);
send_empty:
/* we may need to add END_STREAM */
/* FIXME: we should also detect shutdown(w) below, but how ? Maybe we
* could rely on the MSG_MORE flag as a hint for this ?
*/
if (((h1m->flags & H1_MF_CLEN) && !(h1m->curr_len - size)) ||
!h1m->curr_len || h1m->state >= HTTP_MSG_DONE)
es_now = 1;
/* update the frame's size */
h2_set_frame_size(outbuf.str, size);
if (es_now)
outbuf.str[4] |= H2_F_DATA_END_STREAM;
/* commit the H2 response */
h2c->mbuf->o += size + 9;
h2c->mbuf->p = b_ptr(h2c->mbuf, size + 9);
/* consume incoming H1 response */
if (size > 0) {
bo_del(buf, size);
total += size;
h1m->curr_len -= size;
h2s->mws -= size;
h2c->mws -= size;
if (size && !h1m->curr_len && (h1m->flags & H1_MF_CHNK)) {
h1m->state = HTTP_MSG_CHUNK_CRLF;
goto new_frame;
}
}
if (es_now) {
if (h2s->st == H2_SS_OPEN)
h2s->st = H2_SS_HLOC;
else
h2s_close(h2s);
if (!(h1m->flags & H1_MF_CHNK)) {
bo_del(buf, buf->o);
h1m->state = HTTP_MSG_DONE;
}
h2s->flags |= H2_SF_ES_SENT;
}
end:
trace("[%d] sent simple H2 DATA response (sid=%d) = %d bytes out (%d in, st=%s, ep=%u, es=%s, h2cws=%d h2sws=%d) buf->o=%d", h2c->st0, h2s->id, size+9, total, h1_msg_state_str(h1m->state), h1m->err_pos, h1_msg_state_str(h1m->err_state), h2c->mws, h2s->mws, buf->o);
return total;
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,204
|
static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf)
{
struct http_hdr list[MAX_HTTP_HDR];
struct h2c *h2c = h2s->h2c;
struct h1m *h1m = &h2s->res;
struct chunk outbuf;
int es_now = 0;
int ret = 0;
int hdr;
if (h2c_mux_busy(h2c, h2s)) {
h2s->flags |= H2_SF_BLK_MBUSY;
return 0;
}
if (!h2_get_buf(h2c, &h2c->mbuf)) {
h2c->flags |= H2_CF_MUX_MALLOC;
h2s->flags |= H2_SF_BLK_MROOM;
return 0;
}
/* First, try to parse the H1 response and index it into <list>.
* NOTE! Since it comes from haproxy, we *know* that a response header
* block does not wrap and we can safely read it this way without
* having to realign the buffer.
*/
ret = h1_headers_to_hdr_list(bo_ptr(buf), bo_ptr(buf) + buf->o,
list, sizeof(list)/sizeof(list[0]), h1m);
if (ret <= 0) {
/* incomplete or invalid response, this is abnormal coming from
* haproxy and may only result in a bad errorfile or bad Lua code
* so that won't be fixed, raise an error now.
*
* FIXME: we should instead add the ability to only return a
* 502 bad gateway. But in theory this is not supposed to
* happen.
*/
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
ret = 0;
goto end;
}
chunk_reset(&outbuf);
while (1) {
outbuf.str = bo_end(h2c->mbuf);
outbuf.size = bo_contig_space(h2c->mbuf);
outbuf.len = 0;
if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
break;
realign_again:
buffer_slow_realign(h2c->mbuf);
}
if (outbuf.size < 9) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
ret = 0;
goto end;
}
/* len: 0x000000 (fill later), type: 1(HEADERS), flags: ENDH=4 */
memcpy(outbuf.str, "\x00\x00\x00\x01\x04", 5);
write_n32(outbuf.str + 5, h2s->id); // 4 bytes
outbuf.len = 9;
/* encode status, which necessarily is the first one */
if (outbuf.len < outbuf.size && h1m->status == 200)
outbuf.str[outbuf.len++] = 0x88; // indexed field : idx[08]=(":status", "200")
else if (outbuf.len < outbuf.size && h1m->status == 304)
outbuf.str[outbuf.len++] = 0x8b; // indexed field : idx[11]=(":status", "304")
else if (unlikely(list[0].v.len != 3)) {
/* this is an unparsable response */
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
ret = 0;
goto end;
}
else if (unlikely(outbuf.len + 2 + 3 <= outbuf.size)) {
/* basic encoding of the status code */
outbuf.str[outbuf.len++] = 0x48; // indexed name -- name=":status" (idx 8)
outbuf.str[outbuf.len++] = 0x03; // 3 bytes status
outbuf.str[outbuf.len++] = list[0].v.ptr[0];
outbuf.str[outbuf.len++] = list[0].v.ptr[1];
outbuf.str[outbuf.len++] = list[0].v.ptr[2];
}
else {
if (buffer_space_wraps(h2c->mbuf))
goto realign_again;
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
ret = 0;
goto end;
}
/* encode all headers, stop at empty name */
for (hdr = 1; hdr < sizeof(list)/sizeof(list[0]); hdr++) {
/* these ones do not exist in H2 and must be dropped. */
if (isteq(list[hdr].n, ist("connection")) ||
isteq(list[hdr].n, ist("proxy-connection")) ||
isteq(list[hdr].n, ist("keep-alive")) ||
isteq(list[hdr].n, ist("upgrade")) ||
isteq(list[hdr].n, ist("transfer-encoding")))
continue;
if (isteq(list[hdr].n, ist("")))
break; // end
if (!hpack_encode_header(&outbuf, list[hdr].n, list[hdr].v)) {
/* output full */
if (buffer_space_wraps(h2c->mbuf))
goto realign_again;
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
ret = 0;
goto end;
}
}
/* we may need to add END_STREAM */
if (((h1m->flags & H1_MF_CLEN) && !h1m->body_len) || h2s->cs->flags & CS_FL_SHW)
es_now = 1;
/* update the frame's size */
h2_set_frame_size(outbuf.str, outbuf.len - 9);
if (es_now)
outbuf.str[4] |= H2_F_HEADERS_END_STREAM;
/* consume incoming H1 response */
bo_del(buf, ret);
/* commit the H2 response */
h2c->mbuf->o += outbuf.len;
h2c->mbuf->p = b_ptr(h2c->mbuf, outbuf.len);
h2s->flags |= H2_SF_HEADERS_SENT;
/* for now we don't implemented CONTINUATION, so we wait for a
* body or directly end in TRL2.
*/
if (es_now) {
bo_del(buf, buf->o);
h1m->state = HTTP_MSG_DONE;
h2s->flags |= H2_SF_ES_SENT;
if (h2s->st == H2_SS_OPEN)
h2s->st = H2_SS_HLOC;
else
h2s_close(h2s);
}
else if (h1m->status >= 100 && h1m->status < 200) {
/* we'll let the caller check if it has more headers to send */
h1m->state = HTTP_MSG_RPBEFORE;
h1m->status = 0;
h1m->flags = 0;
goto end;
}
else
h1m->state = (h1m->flags & H1_MF_CHNK) ? HTTP_MSG_CHUNK_SIZE : HTTP_MSG_BODY;
end:
return ret;
}
|
Exec Code Overflow
| 0
|
static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf)
{
struct http_hdr list[MAX_HTTP_HDR];
struct h2c *h2c = h2s->h2c;
struct h1m *h1m = &h2s->res;
struct chunk outbuf;
int es_now = 0;
int ret = 0;
int hdr;
if (h2c_mux_busy(h2c, h2s)) {
h2s->flags |= H2_SF_BLK_MBUSY;
return 0;
}
if (!h2_get_buf(h2c, &h2c->mbuf)) {
h2c->flags |= H2_CF_MUX_MALLOC;
h2s->flags |= H2_SF_BLK_MROOM;
return 0;
}
/* First, try to parse the H1 response and index it into <list>.
* NOTE! Since it comes from haproxy, we *know* that a response header
* block does not wrap and we can safely read it this way without
* having to realign the buffer.
*/
ret = h1_headers_to_hdr_list(bo_ptr(buf), bo_ptr(buf) + buf->o,
list, sizeof(list)/sizeof(list[0]), h1m);
if (ret <= 0) {
/* incomplete or invalid response, this is abnormal coming from
* haproxy and may only result in a bad errorfile or bad Lua code
* so that won't be fixed, raise an error now.
*
* FIXME: we should instead add the ability to only return a
* 502 bad gateway. But in theory this is not supposed to
* happen.
*/
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
ret = 0;
goto end;
}
chunk_reset(&outbuf);
while (1) {
outbuf.str = bo_end(h2c->mbuf);
outbuf.size = bo_contig_space(h2c->mbuf);
outbuf.len = 0;
if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf))
break;
realign_again:
buffer_slow_realign(h2c->mbuf);
}
if (outbuf.size < 9) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
ret = 0;
goto end;
}
/* len: 0x000000 (fill later), type: 1(HEADERS), flags: ENDH=4 */
memcpy(outbuf.str, "\x00\x00\x00\x01\x04", 5);
write_n32(outbuf.str + 5, h2s->id); // 4 bytes
outbuf.len = 9;
/* encode status, which necessarily is the first one */
if (outbuf.len < outbuf.size && h1m->status == 200)
outbuf.str[outbuf.len++] = 0x88; // indexed field : idx[08]=(":status", "200")
else if (outbuf.len < outbuf.size && h1m->status == 304)
outbuf.str[outbuf.len++] = 0x8b; // indexed field : idx[11]=(":status", "304")
else if (unlikely(list[0].v.len != 3)) {
/* this is an unparsable response */
h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
ret = 0;
goto end;
}
else if (unlikely(outbuf.len + 2 + 3 <= outbuf.size)) {
/* basic encoding of the status code */
outbuf.str[outbuf.len++] = 0x48; // indexed name -- name=":status" (idx 8)
outbuf.str[outbuf.len++] = 0x03; // 3 bytes status
outbuf.str[outbuf.len++] = list[0].v.ptr[0];
outbuf.str[outbuf.len++] = list[0].v.ptr[1];
outbuf.str[outbuf.len++] = list[0].v.ptr[2];
}
else {
if (buffer_space_wraps(h2c->mbuf))
goto realign_again;
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
ret = 0;
goto end;
}
/* encode all headers, stop at empty name */
for (hdr = 1; hdr < sizeof(list)/sizeof(list[0]); hdr++) {
/* these ones do not exist in H2 and must be dropped. */
if (isteq(list[hdr].n, ist("connection")) ||
isteq(list[hdr].n, ist("proxy-connection")) ||
isteq(list[hdr].n, ist("keep-alive")) ||
isteq(list[hdr].n, ist("upgrade")) ||
isteq(list[hdr].n, ist("transfer-encoding")))
continue;
if (isteq(list[hdr].n, ist("")))
break; // end
if (!hpack_encode_header(&outbuf, list[hdr].n, list[hdr].v)) {
/* output full */
if (buffer_space_wraps(h2c->mbuf))
goto realign_again;
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
ret = 0;
goto end;
}
}
/* we may need to add END_STREAM */
if (((h1m->flags & H1_MF_CLEN) && !h1m->body_len) || h2s->cs->flags & CS_FL_SHW)
es_now = 1;
/* update the frame's size */
h2_set_frame_size(outbuf.str, outbuf.len - 9);
if (es_now)
outbuf.str[4] |= H2_F_HEADERS_END_STREAM;
/* consume incoming H1 response */
bo_del(buf, ret);
/* commit the H2 response */
h2c->mbuf->o += outbuf.len;
h2c->mbuf->p = b_ptr(h2c->mbuf, outbuf.len);
h2s->flags |= H2_SF_HEADERS_SENT;
/* for now we don't implemented CONTINUATION, so we wait for a
* body or directly end in TRL2.
*/
if (es_now) {
bo_del(buf, buf->o);
h1m->state = HTTP_MSG_DONE;
h2s->flags |= H2_SF_ES_SENT;
if (h2s->st == H2_SS_OPEN)
h2s->st = H2_SS_HLOC;
else
h2s_close(h2s);
}
else if (h1m->status >= 100 && h1m->status < 200) {
/* we'll let the caller check if it has more headers to send */
h1m->state = HTTP_MSG_RPBEFORE;
h1m->status = 0;
h1m->flags = 0;
goto end;
}
else
h1m->state = (h1m->flags & H1_MF_CHNK) ? HTTP_MSG_CHUNK_SIZE : HTTP_MSG_BODY;
end:
return ret;
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,205
|
static inline __maybe_unused int h2s_id(const struct h2s *h2s)
{
return h2s ? h2s->id : 0;
}
|
Exec Code Overflow
| 0
|
static inline __maybe_unused int h2s_id(const struct h2s *h2s)
{
return h2s ? h2s->id : 0;
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,206
|
static int h2s_send_rst_stream(struct h2c *h2c, struct h2s *h2s)
{
struct buffer *res;
char str[13];
int ret;
if (!h2s || h2s->st == H2_SS_CLOSED)
return 1;
/* RFC7540#5.4.2: To avoid looping, an endpoint MUST NOT send a
* RST_STREAM in response to a RST_STREAM frame.
*/
if (h2c->dft == H2_FT_RST_STREAM) {
ret = 1;
goto ignore;
}
if (h2c_mux_busy(h2c, h2s)) {
h2s->flags |= H2_SF_BLK_MBUSY;
return 0;
}
res = h2_get_buf(h2c, &h2c->mbuf);
if (!res) {
h2c->flags |= H2_CF_MUX_MALLOC;
h2s->flags |= H2_SF_BLK_MROOM;
return 0;
}
/* len: 4, type: 3, flags: none */
memcpy(str, "\x00\x00\x04\x03\x00", 5);
write_n32(str + 5, h2s->id);
write_n32(str + 9, h2s->errcode);
ret = bo_istput(res, ist2(str, 13));
if (unlikely(ret <= 0)) {
if (!ret) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
return 0;
}
else {
h2c_error(h2c, H2_ERR_INTERNAL_ERROR);
return 0;
}
}
ignore:
h2s->flags |= H2_SF_RST_SENT;
h2s_close(h2s);
return ret;
}
|
Exec Code Overflow
| 0
|
static int h2s_send_rst_stream(struct h2c *h2c, struct h2s *h2s)
{
struct buffer *res;
char str[13];
int ret;
if (!h2s || h2s->st == H2_SS_CLOSED)
return 1;
/* RFC7540#5.4.2: To avoid looping, an endpoint MUST NOT send a
* RST_STREAM in response to a RST_STREAM frame.
*/
if (h2c->dft == H2_FT_RST_STREAM) {
ret = 1;
goto ignore;
}
if (h2c_mux_busy(h2c, h2s)) {
h2s->flags |= H2_SF_BLK_MBUSY;
return 0;
}
res = h2_get_buf(h2c, &h2c->mbuf);
if (!res) {
h2c->flags |= H2_CF_MUX_MALLOC;
h2s->flags |= H2_SF_BLK_MROOM;
return 0;
}
/* len: 4, type: 3, flags: none */
memcpy(str, "\x00\x00\x04\x03\x00", 5);
write_n32(str + 5, h2s->id);
write_n32(str + 9, h2s->errcode);
ret = bo_istput(res, ist2(str, 13));
if (unlikely(ret <= 0)) {
if (!ret) {
h2c->flags |= H2_CF_MUX_MFULL;
h2s->flags |= H2_SF_BLK_MROOM;
return 0;
}
else {
h2c_error(h2c, H2_ERR_INTERNAL_ERROR);
return 0;
}
}
ignore:
h2s->flags |= H2_SF_RST_SENT;
h2s_close(h2s);
return ret;
}
|
@@ -1735,7 +1735,7 @@ static void h2_process_demux(struct h2c *h2c)
goto fail;
}
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
/* RFC7540#3.5: a GOAWAY frame MAY be omitted */
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR2;
@@ -1765,7 +1765,7 @@ static void h2_process_demux(struct h2c *h2c)
if (!h2_peek_frame_hdr(h2c->dbuf, &hdr))
break;
- if ((int)hdr.len < 0 || (int)hdr.len > h2c->mfs) {
+ if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) {
h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR);
h2c->st0 = H2_CS_ERROR;
break;
|
CWE-119
| null | null |
6,207
|
Current_Ratio( EXEC_OP )
{
if ( !CUR.tt_metrics.ratio )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
else
CUR.tt_metrics.ratio = CUR.tt_metrics.y_ratio;
}
else
#endif
{
if ( CUR.GS.projVector.y == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
else if ( CUR.GS.projVector.x == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.y_ratio;
else
{
FT_Long x, y;
x = TT_MULDIV( CUR.GS.projVector.x,
CUR.tt_metrics.x_ratio, 0x4000 );
y = TT_MULDIV( CUR.GS.projVector.y,
CUR.tt_metrics.y_ratio, 0x4000 );
CUR.tt_metrics.ratio = TT_VecLen( x, y );
}
}
}
return CUR.tt_metrics.ratio;
}
|
DoS Exec Code Overflow
| 0
|
Current_Ratio( EXEC_OP )
{
if ( !CUR.tt_metrics.ratio )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
else
CUR.tt_metrics.ratio = CUR.tt_metrics.y_ratio;
}
else
#endif
{
if ( CUR.GS.projVector.y == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
else if ( CUR.GS.projVector.x == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.y_ratio;
else
{
FT_Long x, y;
x = TT_MULDIV( CUR.GS.projVector.x,
CUR.tt_metrics.x_ratio, 0x4000 );
y = TT_MULDIV( CUR.GS.projVector.y,
CUR.tt_metrics.y_ratio, 0x4000 );
CUR.tt_metrics.ratio = TT_VecLen( x, y );
}
}
}
return CUR.tt_metrics.ratio;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,208
|
Init_Context( TT_ExecContext exec,
FT_Memory memory )
{
FT_Error error;
FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec ));
exec->memory = memory;
exec->callSize = 32;
if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) )
goto Fail_Memory;
/* all values in the context are set to 0 already, but this is */
/* here as a remainder */
exec->maxPoints = 0;
exec->maxContours = 0;
exec->stackSize = 0;
exec->glyphSize = 0;
exec->stack = NULL;
exec->glyphIns = NULL;
exec->face = NULL;
exec->size = NULL;
return TT_Err_Ok;
Fail_Memory:
FT_ERROR(( "Init_Context: not enough memory for 0x%08lx\n",
(FT_Long)exec ));
TT_Done_Context( exec );
return error;
}
|
DoS Exec Code Overflow
| 0
|
Init_Context( TT_ExecContext exec,
FT_Memory memory )
{
FT_Error error;
FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec ));
exec->memory = memory;
exec->callSize = 32;
if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) )
goto Fail_Memory;
/* all values in the context are set to 0 already, but this is */
/* here as a remainder */
exec->maxPoints = 0;
exec->maxContours = 0;
exec->stackSize = 0;
exec->glyphSize = 0;
exec->stack = NULL;
exec->glyphIns = NULL;
exec->face = NULL;
exec->size = NULL;
return TT_Err_Ok;
Fail_Memory:
FT_ERROR(( "Init_Context: not enough memory for 0x%08lx\n",
(FT_Long)exec ));
TT_Done_Context( exec );
return error;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,209
|
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range )
{
FT_ASSERT( range >= 1 && range <= 3 );
exec->codeRangeTable[range - 1].base = NULL;
exec->codeRangeTable[range - 1].size = 0;
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range )
{
FT_ASSERT( range >= 1 && range <= 3 );
exec->codeRangeTable[range - 1].base = NULL;
exec->codeRangeTable[range - 1].size = 0;
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,210
|
TT_Done_Context( TT_ExecContext exec )
{
FT_Memory memory = exec->memory;
/* points zone */
exec->maxPoints = 0;
exec->maxContours = 0;
/* free stack */
FT_FREE( exec->stack );
exec->stackSize = 0;
/* free call stack */
FT_FREE( exec->callStack );
exec->callSize = 0;
exec->callTop = 0;
/* free glyph code range */
FT_FREE( exec->glyphIns );
exec->glyphSize = 0;
exec->size = NULL;
exec->face = NULL;
FT_FREE( exec );
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
TT_Done_Context( TT_ExecContext exec )
{
FT_Memory memory = exec->memory;
/* points zone */
exec->maxPoints = 0;
exec->maxContours = 0;
/* free stack */
FT_FREE( exec->stack );
exec->stackSize = 0;
/* free call stack */
FT_FREE( exec->callStack );
exec->callSize = 0;
exec->callTop = 0;
/* free glyph code range */
FT_FREE( exec->glyphIns );
exec->glyphSize = 0;
exec->size = NULL;
exec->face = NULL;
FT_FREE( exec );
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,211
|
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP )
{
TT_CodeRange* coderange;
FT_ASSERT( range >= 1 && range <= 3 );
coderange = &exec->codeRangeTable[range - 1];
FT_ASSERT( coderange->base != NULL );
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for IP <= Size instead of IP < Size. */
/* */
FT_ASSERT( (FT_ULong)IP <= coderange->size );
exec->code = coderange->base;
exec->codeSize = coderange->size;
exec->IP = IP;
exec->curRange = range;
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP )
{
TT_CodeRange* coderange;
FT_ASSERT( range >= 1 && range <= 3 );
coderange = &exec->codeRangeTable[range - 1];
FT_ASSERT( coderange->base != NULL );
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for IP <= Size instead of IP < Size. */
/* */
FT_ASSERT( (FT_ULong)IP <= coderange->size );
exec->code = coderange->base;
exec->codeSize = coderange->size;
exec->IP = IP;
exec->curRange = range;
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,212
|
TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size )
{
FT_Int i;
FT_ULong tmp;
TT_MaxProfile* maxp;
FT_Error error;
exec->face = face;
maxp = &face->max_profile;
exec->size = size;
if ( size )
{
exec->numFDefs = size->num_function_defs;
exec->maxFDefs = size->max_function_defs;
exec->numIDefs = size->num_instruction_defs;
exec->maxIDefs = size->max_instruction_defs;
exec->FDefs = size->function_defs;
exec->IDefs = size->instruction_defs;
exec->tt_metrics = size->ttmetrics;
exec->metrics = size->metrics;
exec->maxFunc = size->max_func;
exec->maxIns = size->max_ins;
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
exec->codeRangeTable[i] = size->codeRangeTable[i];
/* set graphics state */
exec->GS = size->GS;
exec->cvtSize = size->cvt_size;
exec->cvt = size->cvt;
exec->storeSize = size->storage_size;
exec->storage = size->storage;
exec->twilight = size->twilight;
}
/* XXX: We reserve a little more elements on the stack to deal safely */
/* with broken fonts like arialbs, courbs, timesbs, etc. */
tmp = exec->stackSize;
error = Update_Max( exec->memory,
&tmp,
sizeof ( FT_F26Dot6 ),
(void*)&exec->stack,
maxp->maxStackElements + 32 );
exec->stackSize = (FT_UInt)tmp;
if ( error )
return error;
tmp = exec->glyphSize;
error = Update_Max( exec->memory,
&tmp,
sizeof ( FT_Byte ),
(void*)&exec->glyphIns,
maxp->maxSizeOfInstructions );
exec->glyphSize = (FT_UShort)tmp;
if ( error )
return error;
exec->pts.n_points = 0;
exec->pts.n_contours = 0;
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->zp0 = exec->pts;
exec->instruction_trap = FALSE;
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size )
{
FT_Int i;
FT_ULong tmp;
TT_MaxProfile* maxp;
FT_Error error;
exec->face = face;
maxp = &face->max_profile;
exec->size = size;
if ( size )
{
exec->numFDefs = size->num_function_defs;
exec->maxFDefs = size->max_function_defs;
exec->numIDefs = size->num_instruction_defs;
exec->maxIDefs = size->max_instruction_defs;
exec->FDefs = size->function_defs;
exec->IDefs = size->instruction_defs;
exec->tt_metrics = size->ttmetrics;
exec->metrics = size->metrics;
exec->maxFunc = size->max_func;
exec->maxIns = size->max_ins;
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
exec->codeRangeTable[i] = size->codeRangeTable[i];
/* set graphics state */
exec->GS = size->GS;
exec->cvtSize = size->cvt_size;
exec->cvt = size->cvt;
exec->storeSize = size->storage_size;
exec->storage = size->storage;
exec->twilight = size->twilight;
}
/* XXX: We reserve a little more elements on the stack to deal safely */
/* with broken fonts like arialbs, courbs, timesbs, etc. */
tmp = exec->stackSize;
error = Update_Max( exec->memory,
&tmp,
sizeof ( FT_F26Dot6 ),
(void*)&exec->stack,
maxp->maxStackElements + 32 );
exec->stackSize = (FT_UInt)tmp;
if ( error )
return error;
tmp = exec->glyphSize;
error = Update_Max( exec->memory,
&tmp,
sizeof ( FT_Byte ),
(void*)&exec->glyphIns,
maxp->maxSizeOfInstructions );
exec->glyphSize = (FT_UShort)tmp;
if ( error )
return error;
exec->pts.n_points = 0;
exec->pts.n_contours = 0;
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->zp0 = exec->pts;
exec->instruction_trap = FALSE;
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,213
|
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
FT_Int32 sign;
FT_UInt32 ah, al, mid, lo, hi;
sign = a ^ b;
if ( a < 0 )
a = -a;
if ( b < 0 )
b = -b;
ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
al = (FT_UInt32)( a & 0xFFFFU );
lo = al * b;
mid = ah * b;
hi = mid >> 16;
mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
lo += mid;
if ( lo < mid )
hi += 1;
mid = ( lo >> 14 ) | ( hi << 18 );
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
}
|
DoS Exec Code Overflow
| 0
|
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
FT_Int32 sign;
FT_UInt32 ah, al, mid, lo, hi;
sign = a ^ b;
if ( a < 0 )
a = -a;
if ( b < 0 )
b = -b;
ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
al = (FT_UInt32)( a & 0xFFFFU );
lo = al * b;
mid = ah * b;
hi = mid >> 16;
mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
lo += mid;
if ( lo < mid )
hi += 1;
mid = ( lo >> 14 ) | ( hi << 18 );
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,214
|
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
FT_Int32 m, s, hi;
FT_UInt32 l, lo;
/* compute ax*bx as 64-bit value */
l = (FT_UInt32)( ( a & 0xFFFFU ) * b );
m = ( a >> 16 ) * b;
lo = l + (FT_UInt32)( m << 16 );
hi = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo < l );
/* divide the result by 2^14 with rounding */
s = hi >> 31;
l = lo + (FT_UInt32)s;
hi += s + ( l < lo );
lo = l;
l = lo + 0x2000U;
hi += l < lo;
return ( hi << 18 ) | ( l >> 14 );
}
|
DoS Exec Code Overflow
| 0
|
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
FT_Int32 m, s, hi;
FT_UInt32 l, lo;
/* compute ax*bx as 64-bit value */
l = (FT_UInt32)( ( a & 0xFFFFU ) * b );
m = ( a >> 16 ) * b;
lo = l + (FT_UInt32)( m << 16 );
hi = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo < l );
/* divide the result by 2^14 with rounding */
s = hi >> 31;
l = lo + (FT_UInt32)s;
hi += s + ( l < lo );
lo = l;
l = lo + 0x2000U;
hi += l < lo;
return ( hi << 18 ) | ( l >> 14 );
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,215
|
TT_New_Context( TT_Driver driver )
{
TT_ExecContext exec;
FT_Memory memory;
memory = driver->root.root.memory;
exec = driver->context;
if ( !driver->context )
{
FT_Error error;
/* allocate object */
if ( FT_NEW( exec ) )
goto Fail;
/* initialize it; in case of error this deallocates `exec' too */
error = Init_Context( exec, memory );
if ( error )
goto Fail;
/* store it into the driver */
driver->context = exec;
}
return driver->context;
Fail:
return NULL;
}
|
DoS Exec Code Overflow
| 0
|
TT_New_Context( TT_Driver driver )
{
TT_ExecContext exec;
FT_Memory memory;
memory = driver->root.root.memory;
exec = driver->context;
if ( !driver->context )
{
FT_Error error;
/* allocate object */
if ( FT_NEW( exec ) )
goto Fail;
/* initialize it; in case of error this deallocates `exec' too */
error = Init_Context( exec, memory );
if ( error )
goto Fail;
/* store it into the driver */
driver->context = exec;
}
return driver->context;
Fail:
return NULL;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,216
|
TT_Run_Context( TT_ExecContext exec,
FT_Bool debug )
{
FT_Error error;
if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) )
!= TT_Err_Ok )
return error;
exec->zp0 = exec->pts;
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->GS.gep0 = 1;
exec->GS.gep1 = 1;
exec->GS.gep2 = 1;
exec->GS.projVector.x = 0x4000;
exec->GS.projVector.y = 0x0000;
exec->GS.freeVector = exec->GS.projVector;
exec->GS.dualVector = exec->GS.projVector;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
exec->GS.both_x_axis = TRUE;
#endif
exec->GS.round_state = 1;
exec->GS.loop = 1;
/* some glyphs leave something on the stack. so we clean it */
/* before a new execution. */
exec->top = 0;
exec->callTop = 0;
#if 1
FT_UNUSED( debug );
return exec->face->interpreter( exec );
#else
if ( !debug )
return TT_RunIns( exec );
else
return TT_Err_Ok;
#endif
}
|
DoS Exec Code Overflow
| 0
|
TT_Run_Context( TT_ExecContext exec,
FT_Bool debug )
{
FT_Error error;
if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) )
!= TT_Err_Ok )
return error;
exec->zp0 = exec->pts;
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->GS.gep0 = 1;
exec->GS.gep1 = 1;
exec->GS.gep2 = 1;
exec->GS.projVector.x = 0x4000;
exec->GS.projVector.y = 0x0000;
exec->GS.freeVector = exec->GS.projVector;
exec->GS.dualVector = exec->GS.projVector;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
exec->GS.both_x_axis = TRUE;
#endif
exec->GS.round_state = 1;
exec->GS.loop = 1;
/* some glyphs leave something on the stack. so we clean it */
/* before a new execution. */
exec->top = 0;
exec->callTop = 0;
#if 1
FT_UNUSED( debug );
return exec->face->interpreter( exec );
#else
if ( !debug )
return TT_RunIns( exec );
else
return TT_Err_Ok;
#endif
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,217
|
TT_Save_Context( TT_ExecContext exec,
TT_Size size )
{
FT_Int i;
/* XXXX: Will probably disappear soon with all the code range */
/* management, which is now rather obsolete. */
/* */
size->num_function_defs = exec->numFDefs;
size->num_instruction_defs = exec->numIDefs;
size->max_func = exec->maxFunc;
size->max_ins = exec->maxIns;
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
size->codeRangeTable[i] = exec->codeRangeTable[i];
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
TT_Save_Context( TT_ExecContext exec,
TT_Size size )
{
FT_Int i;
/* XXXX: Will probably disappear soon with all the code range */
/* management, which is now rather obsolete. */
/* */
size->num_function_defs = exec->numFDefs;
size->num_instruction_defs = exec->numIDefs;
size->max_func = exec->maxFunc;
size->max_ins = exec->maxIns;
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
size->codeRangeTable[i] = exec->codeRangeTable[i];
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,218
|
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
FT_Long length )
{
FT_ASSERT( range >= 1 && range <= 3 );
exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
exec->codeRangeTable[range - 1].size = length;
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
FT_Long length )
{
FT_ASSERT( range >= 1 && range <= 3 );
exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
exec->codeRangeTable[range - 1].size = length;
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,219
|
TT_VecLen( FT_F26Dot6 X,
FT_F26Dot6 Y )
{
FT_Vector v;
v.x = X;
v.y = Y;
return FT_Vector_Length( &v );
}
|
DoS Exec Code Overflow
| 0
|
TT_VecLen( FT_F26Dot6 X,
FT_F26Dot6 Y )
{
FT_Vector v;
v.x = X;
v.y = Y;
return FT_Vector_Length( &v );
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,220
|
Update_Max( FT_Memory memory,
FT_ULong* size,
FT_Long multiplier,
void* _pbuff,
FT_ULong new_max )
{
FT_Error error;
void** pbuff = (void**)_pbuff;
if ( *size < new_max )
{
if ( FT_REALLOC( *pbuff, *size * multiplier, new_max * multiplier ) )
return error;
*size = new_max;
}
return TT_Err_Ok;
}
|
DoS Exec Code Overflow
| 0
|
Update_Max( FT_Memory memory,
FT_ULong* size,
FT_Long multiplier,
void* _pbuff,
FT_ULong new_max )
{
FT_Error error;
void** pbuff = (void**)_pbuff;
if ( *size < new_max )
{
if ( FT_REALLOC( *pbuff, *size * multiplier, new_max * multiplier ) )
return error;
*size = new_max;
}
return TT_Err_Ok;
}
|
@@ -5795,7 +5795,16 @@
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
+ {
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
+
+ if ( BOUNDS( last_point, CUR.zp2.n_points ) )
+ {
+ if ( CUR.pedantic_hinting )
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+ }
else
last_point = 0;
|
CWE-119
| null | null |
6,221
|
static void XBZRLE_cache_lock(void)
{
if (migrate_use_xbzrle())
qemu_mutex_lock(&XBZRLE.lock);
}
|
Exec Code
| 0
|
static void XBZRLE_cache_lock(void)
{
if (migrate_use_xbzrle())
qemu_mutex_lock(&XBZRLE.lock);
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,222
|
static void XBZRLE_cache_unlock(void)
{
if (migrate_use_xbzrle())
qemu_mutex_unlock(&XBZRLE.lock);
}
|
Exec Code
| 0
|
static void XBZRLE_cache_unlock(void)
{
if (migrate_use_xbzrle())
qemu_mutex_unlock(&XBZRLE.lock);
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,223
|
static void acct_clear(void)
{
memset(&acct_info, 0, sizeof(acct_info));
}
|
Exec Code
| 0
|
static void acct_clear(void)
{
memset(&acct_info, 0, sizeof(acct_info));
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,224
|
void acct_update_position(QEMUFile *f, size_t size, bool zero)
{
uint64_t pages = size / TARGET_PAGE_SIZE;
if (zero) {
acct_info.dup_pages += pages;
} else {
acct_info.norm_pages += pages;
bytes_transferred += size;
qemu_update_position(f, size);
}
}
|
Exec Code
| 0
|
void acct_update_position(QEMUFile *f, size_t size, bool zero)
{
uint64_t pages = size / TARGET_PAGE_SIZE;
if (zero) {
acct_info.dup_pages += pages;
} else {
acct_info.norm_pages += pages;
bytes_transferred += size;
qemu_update_position(f, size);
}
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,225
|
void cpudef_init(void)
{
#if defined(cpudef_setup)
cpudef_setup(); /* parse cpu definitions in target config file */
#endif
}
|
Exec Code
| 0
|
void cpudef_init(void)
{
#if defined(cpudef_setup)
cpudef_setup(); /* parse cpu definitions in target config file */
#endif
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,226
|
void do_acpitable_option(const QemuOpts *opts)
{
#ifdef TARGET_I386
Error *err = NULL;
acpi_table_add(opts, &err);
if (err) {
error_report("Wrong acpi table provided: %s",
error_get_pretty(err));
error_free(err);
exit(1);
}
#endif
}
|
Exec Code
| 0
|
void do_acpitable_option(const QemuOpts *opts)
{
#ifdef TARGET_I386
Error *err = NULL;
acpi_table_add(opts, &err);
if (err) {
error_report("Wrong acpi table provided: %s",
error_get_pretty(err));
error_free(err);
exit(1);
}
#endif
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,227
|
void do_smbios_option(QemuOpts *opts)
{
#ifdef TARGET_I386
smbios_entry_add(opts);
#endif
}
|
Exec Code
| 0
|
void do_smbios_option(QemuOpts *opts)
{
#ifdef TARGET_I386
smbios_entry_add(opts);
#endif
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,228
|
uint64_t dup_mig_bytes_transferred(void)
{
return acct_info.dup_pages * TARGET_PAGE_SIZE;
}
|
Exec Code
| 0
|
uint64_t dup_mig_bytes_transferred(void)
{
return acct_info.dup_pages * TARGET_PAGE_SIZE;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,229
|
uint64_t dup_mig_pages_transferred(void)
{
return acct_info.dup_pages;
}
|
Exec Code
| 0
|
uint64_t dup_mig_pages_transferred(void)
{
return acct_info.dup_pages;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,230
|
void free_xbzrle_decoded_buf(void)
{
g_free(xbzrle_decoded_buf);
xbzrle_decoded_buf = NULL;
}
|
Exec Code
| 0
|
void free_xbzrle_decoded_buf(void)
{
g_free(xbzrle_decoded_buf);
xbzrle_decoded_buf = NULL;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,231
|
static inline bool is_zero_range(uint8_t *p, uint64_t size)
{
return buffer_find_nonzero_offset(p, size) == size;
}
|
Exec Code
| 0
|
static inline bool is_zero_range(uint8_t *p, uint64_t size)
{
return buffer_find_nonzero_offset(p, size) == size;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,232
|
void isa_register_soundhw(const char *name, const char *descr,
int (*init_isa)(ISABus *bus))
{
assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
soundhw[soundhw_count].name = name;
soundhw[soundhw_count].descr = descr;
soundhw[soundhw_count].isa = 1;
soundhw[soundhw_count].init.init_isa = init_isa;
soundhw_count++;
}
|
Exec Code
| 0
|
void isa_register_soundhw(const char *name, const char *descr,
int (*init_isa)(ISABus *bus))
{
assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
soundhw[soundhw_count].name = name;
soundhw[soundhw_count].descr = descr;
soundhw[soundhw_count].isa = 1;
soundhw[soundhw_count].init.init_isa = init_isa;
soundhw_count++;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,233
|
int kvm_available(void)
{
#ifdef CONFIG_KVM
return 1;
#else
return 0;
#endif
}
|
Exec Code
| 0
|
int kvm_available(void)
{
#ifdef CONFIG_KVM
return 1;
#else
return 0;
#endif
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,234
|
static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
{
unsigned int xh_len;
int xh_flags;
if (!xbzrle_decoded_buf) {
xbzrle_decoded_buf = g_malloc(TARGET_PAGE_SIZE);
}
/* extract RLE header */
xh_flags = qemu_get_byte(f);
xh_len = qemu_get_be16(f);
if (xh_flags != ENCODING_FLAG_XBZRLE) {
error_report("Failed to load XBZRLE page - wrong compression!");
return -1;
}
if (xh_len > TARGET_PAGE_SIZE) {
error_report("Failed to load XBZRLE page - len overflow!");
return -1;
}
/* load data and decode */
qemu_get_buffer(f, xbzrle_decoded_buf, xh_len);
/* decode RLE */
if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
TARGET_PAGE_SIZE) == -1) {
error_report("Failed to load XBZRLE page - decode error!");
return -1;
}
return 0;
}
|
Exec Code
| 0
|
static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
{
unsigned int xh_len;
int xh_flags;
if (!xbzrle_decoded_buf) {
xbzrle_decoded_buf = g_malloc(TARGET_PAGE_SIZE);
}
/* extract RLE header */
xh_flags = qemu_get_byte(f);
xh_len = qemu_get_be16(f);
if (xh_flags != ENCODING_FLAG_XBZRLE) {
error_report("Failed to load XBZRLE page - wrong compression!");
return -1;
}
if (xh_len > TARGET_PAGE_SIZE) {
error_report("Failed to load XBZRLE page - len overflow!");
return -1;
}
/* load data and decode */
qemu_get_buffer(f, xbzrle_decoded_buf, xh_len);
/* decode RLE */
if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
TARGET_PAGE_SIZE) == -1) {
error_report("Failed to load XBZRLE page - decode error!");
return -1;
}
return 0;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,235
|
static void mig_throttle_guest_down(void)
{
CPUState *cpu;
qemu_mutex_lock_iothread();
CPU_FOREACH(cpu) {
async_run_on_cpu(cpu, mig_sleep_cpu, NULL);
}
qemu_mutex_unlock_iothread();
}
|
Exec Code
| 0
|
static void mig_throttle_guest_down(void)
{
CPUState *cpu;
qemu_mutex_lock_iothread();
CPU_FOREACH(cpu) {
async_run_on_cpu(cpu, mig_sleep_cpu, NULL);
}
qemu_mutex_unlock_iothread();
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,236
|
ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr,
ram_addr_t start)
{
unsigned long base = mr->ram_addr >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t mr_size = TARGET_PAGE_ALIGN(memory_region_size(mr));
unsigned long size = base + (mr_size >> TARGET_PAGE_BITS);
unsigned long next;
if (ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(migration_bitmap, size, nr);
}
if (next < size) {
clear_bit(next, migration_bitmap);
migration_dirty_pages--;
}
return (next - base) << TARGET_PAGE_BITS;
}
|
Exec Code
| 0
|
ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr,
ram_addr_t start)
{
unsigned long base = mr->ram_addr >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t mr_size = TARGET_PAGE_ALIGN(memory_region_size(mr));
unsigned long size = base + (mr_size >> TARGET_PAGE_BITS);
unsigned long next;
if (ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(migration_bitmap, size, nr);
}
if (next < size) {
clear_bit(next, migration_bitmap);
migration_dirty_pages--;
}
return (next - base) << TARGET_PAGE_BITS;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,237
|
static inline bool migration_bitmap_set_dirty(ram_addr_t addr)
{
bool ret;
int nr = addr >> TARGET_PAGE_BITS;
ret = test_and_set_bit(nr, migration_bitmap);
if (!ret) {
migration_dirty_pages++;
}
return ret;
}
|
Exec Code
| 0
|
static inline bool migration_bitmap_set_dirty(ram_addr_t addr)
{
bool ret;
int nr = addr >> TARGET_PAGE_BITS;
ret = test_and_set_bit(nr, migration_bitmap);
if (!ret) {
migration_dirty_pages++;
}
return ret;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,238
|
static void migration_bitmap_sync(void)
{
RAMBlock *block;
uint64_t num_dirty_pages_init = migration_dirty_pages;
MigrationState *s = migrate_get_current();
static int64_t start_time;
static int64_t bytes_xfer_prev;
static int64_t num_dirty_pages_period;
int64_t end_time;
int64_t bytes_xfer_now;
static uint64_t xbzrle_cache_miss_prev;
static uint64_t iterations_prev;
bitmap_sync_count++;
if (!bytes_xfer_prev) {
bytes_xfer_prev = ram_bytes_transferred();
}
if (!start_time) {
start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
}
trace_migration_bitmap_sync_start();
address_space_sync_dirty_bitmap(&address_space_memory);
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
migration_bitmap_sync_range(block->mr->ram_addr, block->length);
}
trace_migration_bitmap_sync_end(migration_dirty_pages
- num_dirty_pages_init);
num_dirty_pages_period += migration_dirty_pages - num_dirty_pages_init;
end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
/* more than 1 second = 1000 millisecons */
if (end_time > start_time + 1000) {
if (migrate_auto_converge()) {
/* The following detection logic can be refined later. For now:
Check to see if the dirtied bytes is 50% more than the approx.
amount of bytes that just got transferred since the last time we
were in this routine. If that happens >N times (for now N==4)
we turn on the throttle down logic */
bytes_xfer_now = ram_bytes_transferred();
if (s->dirty_pages_rate &&
(num_dirty_pages_period * TARGET_PAGE_SIZE >
(bytes_xfer_now - bytes_xfer_prev)/2) &&
(dirty_rate_high_cnt++ > 4)) {
trace_migration_throttle();
mig_throttle_on = true;
dirty_rate_high_cnt = 0;
}
bytes_xfer_prev = bytes_xfer_now;
} else {
mig_throttle_on = false;
}
if (migrate_use_xbzrle()) {
if (iterations_prev != 0) {
acct_info.xbzrle_cache_miss_rate =
(double)(acct_info.xbzrle_cache_miss -
xbzrle_cache_miss_prev) /
(acct_info.iterations - iterations_prev);
}
iterations_prev = acct_info.iterations;
xbzrle_cache_miss_prev = acct_info.xbzrle_cache_miss;
}
s->dirty_pages_rate = num_dirty_pages_period * 1000
/ (end_time - start_time);
s->dirty_bytes_rate = s->dirty_pages_rate * TARGET_PAGE_SIZE;
start_time = end_time;
num_dirty_pages_period = 0;
s->dirty_sync_count = bitmap_sync_count;
}
}
|
Exec Code
| 0
|
static void migration_bitmap_sync(void)
{
RAMBlock *block;
uint64_t num_dirty_pages_init = migration_dirty_pages;
MigrationState *s = migrate_get_current();
static int64_t start_time;
static int64_t bytes_xfer_prev;
static int64_t num_dirty_pages_period;
int64_t end_time;
int64_t bytes_xfer_now;
static uint64_t xbzrle_cache_miss_prev;
static uint64_t iterations_prev;
bitmap_sync_count++;
if (!bytes_xfer_prev) {
bytes_xfer_prev = ram_bytes_transferred();
}
if (!start_time) {
start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
}
trace_migration_bitmap_sync_start();
address_space_sync_dirty_bitmap(&address_space_memory);
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
migration_bitmap_sync_range(block->mr->ram_addr, block->length);
}
trace_migration_bitmap_sync_end(migration_dirty_pages
- num_dirty_pages_init);
num_dirty_pages_period += migration_dirty_pages - num_dirty_pages_init;
end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
/* more than 1 second = 1000 millisecons */
if (end_time > start_time + 1000) {
if (migrate_auto_converge()) {
/* The following detection logic can be refined later. For now:
Check to see if the dirtied bytes is 50% more than the approx.
amount of bytes that just got transferred since the last time we
were in this routine. If that happens >N times (for now N==4)
we turn on the throttle down logic */
bytes_xfer_now = ram_bytes_transferred();
if (s->dirty_pages_rate &&
(num_dirty_pages_period * TARGET_PAGE_SIZE >
(bytes_xfer_now - bytes_xfer_prev)/2) &&
(dirty_rate_high_cnt++ > 4)) {
trace_migration_throttle();
mig_throttle_on = true;
dirty_rate_high_cnt = 0;
}
bytes_xfer_prev = bytes_xfer_now;
} else {
mig_throttle_on = false;
}
if (migrate_use_xbzrle()) {
if (iterations_prev != 0) {
acct_info.xbzrle_cache_miss_rate =
(double)(acct_info.xbzrle_cache_miss -
xbzrle_cache_miss_prev) /
(acct_info.iterations - iterations_prev);
}
iterations_prev = acct_info.iterations;
xbzrle_cache_miss_prev = acct_info.xbzrle_cache_miss;
}
s->dirty_pages_rate = num_dirty_pages_period * 1000
/ (end_time - start_time);
s->dirty_bytes_rate = s->dirty_pages_rate * TARGET_PAGE_SIZE;
start_time = end_time;
num_dirty_pages_period = 0;
s->dirty_sync_count = bitmap_sync_count;
}
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,239
|
static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
{
ram_addr_t addr;
unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
/* start address is aligned at the start of a word? */
if (((page * BITS_PER_LONG) << TARGET_PAGE_BITS) == start) {
int k;
int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS);
unsigned long *src = ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION];
for (k = page; k < page + nr; k++) {
if (src[k]) {
unsigned long new_dirty;
new_dirty = ~migration_bitmap[k];
migration_bitmap[k] |= src[k];
new_dirty &= src[k];
migration_dirty_pages += ctpopl(new_dirty);
src[k] = 0;
}
}
} else {
for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) {
if (cpu_physical_memory_get_dirty(start + addr,
TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION)) {
cpu_physical_memory_reset_dirty(start + addr,
TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION);
migration_bitmap_set_dirty(start + addr);
}
}
}
}
|
Exec Code
| 0
|
static void migration_bitmap_sync_range(ram_addr_t start, ram_addr_t length)
{
ram_addr_t addr;
unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
/* start address is aligned at the start of a word? */
if (((page * BITS_PER_LONG) << TARGET_PAGE_BITS) == start) {
int k;
int nr = BITS_TO_LONGS(length >> TARGET_PAGE_BITS);
unsigned long *src = ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION];
for (k = page; k < page + nr; k++) {
if (src[k]) {
unsigned long new_dirty;
new_dirty = ~migration_bitmap[k];
migration_bitmap[k] |= src[k];
new_dirty &= src[k];
migration_dirty_pages += ctpopl(new_dirty);
src[k] = 0;
}
}
} else {
for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) {
if (cpu_physical_memory_get_dirty(start + addr,
TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION)) {
cpu_physical_memory_reset_dirty(start + addr,
TARGET_PAGE_SIZE,
DIRTY_MEMORY_MIGRATION);
migration_bitmap_set_dirty(start + addr);
}
}
}
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,240
|
static void migration_end(void)
{
if (migration_bitmap) {
memory_global_dirty_log_stop();
g_free(migration_bitmap);
migration_bitmap = NULL;
}
XBZRLE_cache_lock();
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
XBZRLE.cache = NULL;
XBZRLE.encoded_buf = NULL;
XBZRLE.current_buf = NULL;
}
XBZRLE_cache_unlock();
}
|
Exec Code
| 0
|
static void migration_end(void)
{
if (migration_bitmap) {
memory_global_dirty_log_stop();
g_free(migration_bitmap);
migration_bitmap = NULL;
}
XBZRLE_cache_lock();
if (XBZRLE.cache) {
cache_fini(XBZRLE.cache);
g_free(XBZRLE.encoded_buf);
g_free(XBZRLE.current_buf);
XBZRLE.cache = NULL;
XBZRLE.encoded_buf = NULL;
XBZRLE.current_buf = NULL;
}
XBZRLE_cache_unlock();
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,241
|
uint64_t norm_mig_bytes_transferred(void)
{
return acct_info.norm_pages * TARGET_PAGE_SIZE;
}
|
Exec Code
| 0
|
uint64_t norm_mig_bytes_transferred(void)
{
return acct_info.norm_pages * TARGET_PAGE_SIZE;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,242
|
uint64_t norm_mig_pages_transferred(void)
{
return acct_info.norm_pages;
}
|
Exec Code
| 0
|
uint64_t norm_mig_pages_transferred(void)
{
return acct_info.norm_pages;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,243
|
int qemu_read_default_config_files(bool userconfig)
{
int ret;
struct defconfig_file *f;
for (f = default_config_files; f->filename; f++) {
if (!userconfig && f->userconfig) {
continue;
}
ret = qemu_read_config_file(f->filename);
if (ret < 0 && ret != -ENOENT) {
return ret;
}
}
return 0;
}
|
Exec Code
| 0
|
int qemu_read_default_config_files(bool userconfig)
{
int ret;
struct defconfig_file *f;
for (f = default_config_files; f->filename; f++) {
if (!userconfig && f->userconfig) {
continue;
}
ret = qemu_read_config_file(f->filename);
if (ret < 0 && ret != -ENOENT) {
return ret;
}
}
return 0;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,244
|
int qemu_uuid_parse(const char *str, uint8_t *uuid)
{
int ret;
if (strlen(str) != 36) {
return -1;
}
ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
&uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
&uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14],
&uuid[15]);
if (ret != 16) {
return -1;
}
return 0;
}
|
Exec Code
| 0
|
int qemu_uuid_parse(const char *str, uint8_t *uuid)
{
int ret;
if (strlen(str) != 36) {
return -1;
}
ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
&uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
&uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14],
&uuid[15]);
if (ret != 16) {
return -1;
}
return 0;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,245
|
TargetInfo *qmp_query_target(Error **errp)
{
TargetInfo *info = g_malloc0(sizeof(*info));
info->arch = g_strdup(TARGET_NAME);
return info;
}
|
Exec Code
| 0
|
TargetInfo *qmp_query_target(Error **errp)
{
TargetInfo *info = g_malloc0(sizeof(*info));
info->arch = g_strdup(TARGET_NAME);
return info;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,246
|
uint64_t ram_bytes_remaining(void)
{
return ram_save_remaining() * TARGET_PAGE_SIZE;
}
|
Exec Code
| 0
|
uint64_t ram_bytes_remaining(void)
{
return ram_save_remaining() * TARGET_PAGE_SIZE;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,247
|
uint64_t ram_bytes_total(void)
{
RAMBlock *block;
uint64_t total = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next)
total += block->length;
return total;
}
|
Exec Code
| 0
|
uint64_t ram_bytes_total(void)
{
RAMBlock *block;
uint64_t total = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next)
total += block->length;
return total;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,248
|
uint64_t ram_bytes_transferred(void)
{
return bytes_transferred;
}
|
Exec Code
| 0
|
uint64_t ram_bytes_transferred(void)
{
return bytes_transferred;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,249
|
static int ram_find_and_save_block(QEMUFile *f, bool last_stage)
{
RAMBlock *block = last_seen_block;
ram_addr_t offset = last_offset;
bool complete_round = false;
int bytes_sent = 0;
MemoryRegion *mr;
if (!block)
block = QTAILQ_FIRST(&ram_list.blocks);
while (true) {
mr = block->mr;
offset = migration_bitmap_find_and_reset_dirty(mr, offset);
if (complete_round && block == last_seen_block &&
offset >= last_offset) {
break;
}
if (offset >= block->length) {
offset = 0;
block = QTAILQ_NEXT(block, next);
if (!block) {
block = QTAILQ_FIRST(&ram_list.blocks);
complete_round = true;
ram_bulk_stage = false;
}
} else {
bytes_sent = ram_save_page(f, block, offset, last_stage);
/* if page is unmodified, continue to the next */
if (bytes_sent > 0) {
last_sent_block = block;
break;
}
}
}
last_seen_block = block;
last_offset = offset;
return bytes_sent;
}
|
Exec Code
| 0
|
static int ram_find_and_save_block(QEMUFile *f, bool last_stage)
{
RAMBlock *block = last_seen_block;
ram_addr_t offset = last_offset;
bool complete_round = false;
int bytes_sent = 0;
MemoryRegion *mr;
if (!block)
block = QTAILQ_FIRST(&ram_list.blocks);
while (true) {
mr = block->mr;
offset = migration_bitmap_find_and_reset_dirty(mr, offset);
if (complete_round && block == last_seen_block &&
offset >= last_offset) {
break;
}
if (offset >= block->length) {
offset = 0;
block = QTAILQ_NEXT(block, next);
if (!block) {
block = QTAILQ_FIRST(&ram_list.blocks);
complete_round = true;
ram_bulk_stage = false;
}
} else {
bytes_sent = ram_save_page(f, block, offset, last_stage);
/* if page is unmodified, continue to the next */
if (bytes_sent > 0) {
last_sent_block = block;
break;
}
}
}
last_seen_block = block;
last_offset = offset;
return bytes_sent;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,250
|
void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
{
if (ch != 0 || !is_zero_range(host, size)) {
memset(host, ch, size);
}
}
|
Exec Code
| 0
|
void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
{
if (ch != 0 || !is_zero_range(host, size)) {
memset(host, ch, size);
}
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,251
|
static int ram_load(QEMUFile *f, void *opaque, int version_id)
{
int flags = 0, ret = 0;
static uint64_t seq_iter;
seq_iter++;
if (version_id != 4) {
ret = -EINVAL;
}
while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) {
ram_addr_t addr, total_ram_bytes;
void *host;
uint8_t ch;
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
addr &= TARGET_PAGE_MASK;
switch (flags & ~RAM_SAVE_FLAG_CONTINUE) {
case RAM_SAVE_FLAG_MEM_SIZE:
/* Synchronize RAM block list */
total_ram_bytes = addr;
while (!ret && total_ram_bytes) {
RAMBlock *block;
uint8_t len;
char id[256];
ram_addr_t length;
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)id, len);
id[len] = 0;
length = qemu_get_be64(f);
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id))) {
if (block->length != length) {
error_report("Length mismatch: %s: 0x" RAM_ADDR_FMT
" in != 0x" RAM_ADDR_FMT, id, length,
block->length);
ret = -EINVAL;
}
break;
}
}
if (!block) {
error_report("Unknown ramblock \"%s\", cannot "
"accept migration", id);
ret = -EINVAL;
}
total_ram_bytes -= length;
}
break;
case RAM_SAVE_FLAG_COMPRESS:
host = host_from_stream_offset(f, addr, flags);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
ch = qemu_get_byte(f);
ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
break;
case RAM_SAVE_FLAG_PAGE:
host = host_from_stream_offset(f, addr, flags);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
break;
case RAM_SAVE_FLAG_XBZRLE:
host = host_from_stream_offset(f, addr, flags);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
if (load_xbzrle(f, addr, host) < 0) {
error_report("Failed to decompress XBZRLE page at "
RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
break;
case RAM_SAVE_FLAG_EOS:
/* normal exit */
break;
default:
if (flags & RAM_SAVE_FLAG_HOOK) {
ram_control_load_hook(f, flags);
} else {
error_report("Unknown combination of migration flags: %#x",
flags);
ret = -EINVAL;
}
}
if (!ret) {
ret = qemu_file_get_error(f);
}
}
DPRINTF("Completed load of VM with exit code %d seq iteration "
"%" PRIu64 "\n", ret, seq_iter);
return ret;
}
|
Exec Code
| 0
|
static int ram_load(QEMUFile *f, void *opaque, int version_id)
{
int flags = 0, ret = 0;
static uint64_t seq_iter;
seq_iter++;
if (version_id != 4) {
ret = -EINVAL;
}
while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) {
ram_addr_t addr, total_ram_bytes;
void *host;
uint8_t ch;
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
addr &= TARGET_PAGE_MASK;
switch (flags & ~RAM_SAVE_FLAG_CONTINUE) {
case RAM_SAVE_FLAG_MEM_SIZE:
/* Synchronize RAM block list */
total_ram_bytes = addr;
while (!ret && total_ram_bytes) {
RAMBlock *block;
uint8_t len;
char id[256];
ram_addr_t length;
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)id, len);
id[len] = 0;
length = qemu_get_be64(f);
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id))) {
if (block->length != length) {
error_report("Length mismatch: %s: 0x" RAM_ADDR_FMT
" in != 0x" RAM_ADDR_FMT, id, length,
block->length);
ret = -EINVAL;
}
break;
}
}
if (!block) {
error_report("Unknown ramblock \"%s\", cannot "
"accept migration", id);
ret = -EINVAL;
}
total_ram_bytes -= length;
}
break;
case RAM_SAVE_FLAG_COMPRESS:
host = host_from_stream_offset(f, addr, flags);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
ch = qemu_get_byte(f);
ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
break;
case RAM_SAVE_FLAG_PAGE:
host = host_from_stream_offset(f, addr, flags);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
break;
case RAM_SAVE_FLAG_XBZRLE:
host = host_from_stream_offset(f, addr, flags);
if (!host) {
error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
if (load_xbzrle(f, addr, host) < 0) {
error_report("Failed to decompress XBZRLE page at "
RAM_ADDR_FMT, addr);
ret = -EINVAL;
break;
}
break;
case RAM_SAVE_FLAG_EOS:
/* normal exit */
break;
default:
if (flags & RAM_SAVE_FLAG_HOOK) {
ram_control_load_hook(f, flags);
} else {
error_report("Unknown combination of migration flags: %#x",
flags);
ret = -EINVAL;
}
}
if (!ret) {
ret = qemu_file_get_error(f);
}
}
DPRINTF("Completed load of VM with exit code %d seq iteration "
"%" PRIu64 "\n", ret, seq_iter);
return ret;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,252
|
void ram_mig_init(void)
{
qemu_mutex_init(&XBZRLE.lock);
register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL);
}
|
Exec Code
| 0
|
void ram_mig_init(void)
{
qemu_mutex_init(&XBZRLE.lock);
register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL);
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,253
|
static int ram_save_iterate(QEMUFile *f, void *opaque)
{
int ret;
int i;
int64_t t0;
int total_sent = 0;
qemu_mutex_lock_ramlist();
if (ram_list.version != last_version) {
reset_ram_globals();
}
ram_control_before_iterate(f, RAM_CONTROL_ROUND);
t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
i = 0;
while ((ret = qemu_file_rate_limit(f)) == 0) {
int bytes_sent;
bytes_sent = ram_find_and_save_block(f, false);
/* no more blocks to sent */
if (bytes_sent == 0) {
break;
}
total_sent += bytes_sent;
acct_info.iterations++;
check_guest_throttling();
/* we want to check in the 1st loop, just in case it was the 1st time
and we had to sync the dirty bitmap.
qemu_get_clock_ns() is a bit expensive, so we only check each some
iterations
*/
if ((i & 63) == 0) {
uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;
if (t1 > MAX_WAIT) {
DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n",
t1, i);
break;
}
}
i++;
}
qemu_mutex_unlock_ramlist();
/*
* Must occur before EOS (or any QEMUFile operation)
* because of RDMA protocol.
*/
ram_control_after_iterate(f, RAM_CONTROL_ROUND);
bytes_transferred += total_sent;
/*
* Do not count these 8 bytes into total_sent, so that we can
* return 0 if no page had been dirtied.
*/
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
bytes_transferred += 8;
ret = qemu_file_get_error(f);
if (ret < 0) {
return ret;
}
return total_sent;
}
|
Exec Code
| 0
|
static int ram_save_iterate(QEMUFile *f, void *opaque)
{
int ret;
int i;
int64_t t0;
int total_sent = 0;
qemu_mutex_lock_ramlist();
if (ram_list.version != last_version) {
reset_ram_globals();
}
ram_control_before_iterate(f, RAM_CONTROL_ROUND);
t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
i = 0;
while ((ret = qemu_file_rate_limit(f)) == 0) {
int bytes_sent;
bytes_sent = ram_find_and_save_block(f, false);
/* no more blocks to sent */
if (bytes_sent == 0) {
break;
}
total_sent += bytes_sent;
acct_info.iterations++;
check_guest_throttling();
/* we want to check in the 1st loop, just in case it was the 1st time
and we had to sync the dirty bitmap.
qemu_get_clock_ns() is a bit expensive, so we only check each some
iterations
*/
if ((i & 63) == 0) {
uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;
if (t1 > MAX_WAIT) {
DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n",
t1, i);
break;
}
}
i++;
}
qemu_mutex_unlock_ramlist();
/*
* Must occur before EOS (or any QEMUFile operation)
* because of RDMA protocol.
*/
ram_control_after_iterate(f, RAM_CONTROL_ROUND);
bytes_transferred += total_sent;
/*
* Do not count these 8 bytes into total_sent, so that we can
* return 0 if no page had been dirtied.
*/
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
bytes_transferred += 8;
ret = qemu_file_get_error(f);
if (ret < 0) {
return ret;
}
return total_sent;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,254
|
static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,
bool last_stage)
{
int bytes_sent;
int cont;
ram_addr_t current_addr;
MemoryRegion *mr = block->mr;
uint8_t *p;
int ret;
bool send_async = true;
cont = (block == last_sent_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
p = memory_region_get_ram_ptr(mr) + offset;
/* In doubt sent page as normal */
bytes_sent = -1;
ret = ram_control_save_page(f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_sent);
XBZRLE_cache_lock();
current_addr = block->offset + offset;
if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret != RAM_SAVE_CONTROL_DELAYED) {
if (bytes_sent > 0) {
acct_info.norm_pages++;
} else if (bytes_sent == 0) {
acct_info.dup_pages++;
}
}
} else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
acct_info.dup_pages++;
bytes_sent = save_block_hdr(f, block, offset, cont,
RAM_SAVE_FLAG_COMPRESS);
qemu_put_byte(f, 0);
bytes_sent++;
/* Must let xbzrle know, otherwise a previous (now 0'd) cached
* page would be stale
*/
xbzrle_cache_zero_page(current_addr);
} else if (!ram_bulk_stage && migrate_use_xbzrle()) {
bytes_sent = save_xbzrle_page(f, &p, current_addr, block,
offset, cont, last_stage);
if (!last_stage) {
/* Can't send this cached data async, since the cache page
* might get updated before it gets to the wire
*/
send_async = false;
}
}
/* XBZRLE overflow or normal page */
if (bytes_sent == -1) {
bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE);
if (send_async) {
qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE);
} else {
qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
}
bytes_sent += TARGET_PAGE_SIZE;
acct_info.norm_pages++;
}
XBZRLE_cache_unlock();
return bytes_sent;
}
|
Exec Code
| 0
|
static int ram_save_page(QEMUFile *f, RAMBlock* block, ram_addr_t offset,
bool last_stage)
{
int bytes_sent;
int cont;
ram_addr_t current_addr;
MemoryRegion *mr = block->mr;
uint8_t *p;
int ret;
bool send_async = true;
cont = (block == last_sent_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
p = memory_region_get_ram_ptr(mr) + offset;
/* In doubt sent page as normal */
bytes_sent = -1;
ret = ram_control_save_page(f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_sent);
XBZRLE_cache_lock();
current_addr = block->offset + offset;
if (ret != RAM_SAVE_CONTROL_NOT_SUPP) {
if (ret != RAM_SAVE_CONTROL_DELAYED) {
if (bytes_sent > 0) {
acct_info.norm_pages++;
} else if (bytes_sent == 0) {
acct_info.dup_pages++;
}
}
} else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
acct_info.dup_pages++;
bytes_sent = save_block_hdr(f, block, offset, cont,
RAM_SAVE_FLAG_COMPRESS);
qemu_put_byte(f, 0);
bytes_sent++;
/* Must let xbzrle know, otherwise a previous (now 0'd) cached
* page would be stale
*/
xbzrle_cache_zero_page(current_addr);
} else if (!ram_bulk_stage && migrate_use_xbzrle()) {
bytes_sent = save_xbzrle_page(f, &p, current_addr, block,
offset, cont, last_stage);
if (!last_stage) {
/* Can't send this cached data async, since the cache page
* might get updated before it gets to the wire
*/
send_async = false;
}
}
/* XBZRLE overflow or normal page */
if (bytes_sent == -1) {
bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE);
if (send_async) {
qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE);
} else {
qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
}
bytes_sent += TARGET_PAGE_SIZE;
acct_info.norm_pages++;
}
XBZRLE_cache_unlock();
return bytes_sent;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,255
|
static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
{
uint64_t remaining_size;
remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE;
if (remaining_size < max_size) {
qemu_mutex_lock_iothread();
migration_bitmap_sync();
qemu_mutex_unlock_iothread();
remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE;
}
return remaining_size;
}
|
Exec Code
| 0
|
static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
{
uint64_t remaining_size;
remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE;
if (remaining_size < max_size) {
qemu_mutex_lock_iothread();
migration_bitmap_sync();
qemu_mutex_unlock_iothread();
remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE;
}
return remaining_size;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,256
|
static ram_addr_t ram_save_remaining(void)
{
return migration_dirty_pages;
}
|
Exec Code
| 0
|
static ram_addr_t ram_save_remaining(void)
{
return migration_dirty_pages;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,257
|
static int ram_save_setup(QEMUFile *f, void *opaque)
{
RAMBlock *block;
int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */
mig_throttle_on = false;
dirty_rate_high_cnt = 0;
bitmap_sync_count = 0;
if (migrate_use_xbzrle()) {
XBZRLE_cache_lock();
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
TARGET_PAGE_SIZE,
TARGET_PAGE_SIZE);
if (!XBZRLE.cache) {
XBZRLE_cache_unlock();
error_report("Error creating cache");
return -1;
}
XBZRLE_cache_unlock();
/* We prefer not to abort if there is no memory */
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
if (!XBZRLE.encoded_buf) {
error_report("Error allocating encoded_buf");
return -1;
}
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
if (!XBZRLE.current_buf) {
error_report("Error allocating current_buf");
g_free(XBZRLE.encoded_buf);
XBZRLE.encoded_buf = NULL;
return -1;
}
acct_clear();
}
qemu_mutex_lock_iothread();
qemu_mutex_lock_ramlist();
bytes_transferred = 0;
reset_ram_globals();
ram_bitmap_pages = last_ram_offset() >> TARGET_PAGE_BITS;
migration_bitmap = bitmap_new(ram_bitmap_pages);
bitmap_set(migration_bitmap, 0, ram_bitmap_pages);
/*
* Count the total number of pages used by ram blocks not including any
* gaps due to alignment or unplugs.
*/
migration_dirty_pages = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
uint64_t block_pages;
block_pages = block->length >> TARGET_PAGE_BITS;
migration_dirty_pages += block_pages;
}
memory_global_dirty_log_start();
migration_bitmap_sync();
qemu_mutex_unlock_iothread();
qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
qemu_put_byte(f, strlen(block->idstr));
qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
qemu_put_be64(f, block->length);
}
qemu_mutex_unlock_ramlist();
ram_control_before_iterate(f, RAM_CONTROL_SETUP);
ram_control_after_iterate(f, RAM_CONTROL_SETUP);
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
return 0;
}
|
Exec Code
| 0
|
static int ram_save_setup(QEMUFile *f, void *opaque)
{
RAMBlock *block;
int64_t ram_bitmap_pages; /* Size of bitmap in pages, including gaps */
mig_throttle_on = false;
dirty_rate_high_cnt = 0;
bitmap_sync_count = 0;
if (migrate_use_xbzrle()) {
XBZRLE_cache_lock();
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() /
TARGET_PAGE_SIZE,
TARGET_PAGE_SIZE);
if (!XBZRLE.cache) {
XBZRLE_cache_unlock();
error_report("Error creating cache");
return -1;
}
XBZRLE_cache_unlock();
/* We prefer not to abort if there is no memory */
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
if (!XBZRLE.encoded_buf) {
error_report("Error allocating encoded_buf");
return -1;
}
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
if (!XBZRLE.current_buf) {
error_report("Error allocating current_buf");
g_free(XBZRLE.encoded_buf);
XBZRLE.encoded_buf = NULL;
return -1;
}
acct_clear();
}
qemu_mutex_lock_iothread();
qemu_mutex_lock_ramlist();
bytes_transferred = 0;
reset_ram_globals();
ram_bitmap_pages = last_ram_offset() >> TARGET_PAGE_BITS;
migration_bitmap = bitmap_new(ram_bitmap_pages);
bitmap_set(migration_bitmap, 0, ram_bitmap_pages);
/*
* Count the total number of pages used by ram blocks not including any
* gaps due to alignment or unplugs.
*/
migration_dirty_pages = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
uint64_t block_pages;
block_pages = block->length >> TARGET_PAGE_BITS;
migration_dirty_pages += block_pages;
}
memory_global_dirty_log_start();
migration_bitmap_sync();
qemu_mutex_unlock_iothread();
qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
qemu_put_byte(f, strlen(block->idstr));
qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
qemu_put_be64(f, block->length);
}
qemu_mutex_unlock_ramlist();
ram_control_before_iterate(f, RAM_CONTROL_SETUP);
ram_control_after_iterate(f, RAM_CONTROL_SETUP);
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
return 0;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,258
|
static void reset_ram_globals(void)
{
last_seen_block = NULL;
last_sent_block = NULL;
last_offset = 0;
last_version = ram_list.version;
ram_bulk_stage = true;
}
|
Exec Code
| 0
|
static void reset_ram_globals(void)
{
last_seen_block = NULL;
last_sent_block = NULL;
last_offset = 0;
last_version = ram_list.version;
ram_bulk_stage = true;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,259
|
static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
ram_addr_t current_addr, RAMBlock *block,
ram_addr_t offset, int cont, bool last_stage)
{
int encoded_len = 0, bytes_sent = -1;
uint8_t *prev_cached_page;
if (!cache_is_cached(XBZRLE.cache, current_addr)) {
acct_info.xbzrle_cache_miss++;
if (!last_stage) {
if (cache_insert(XBZRLE.cache, current_addr, *current_data) == -1) {
return -1;
} else {
/* update *current_data when the page has been
inserted into cache */
*current_data = get_cached_data(XBZRLE.cache, current_addr);
}
}
return -1;
}
prev_cached_page = get_cached_data(XBZRLE.cache, current_addr);
/* save current buffer into memory */
memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
/* XBZRLE encoding (if there is no overflow) */
encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
TARGET_PAGE_SIZE);
if (encoded_len == 0) {
DPRINTF("Skipping unmodified page\n");
return 0;
} else if (encoded_len == -1) {
DPRINTF("Overflow\n");
acct_info.xbzrle_overflows++;
/* update data in the cache */
if (!last_stage) {
memcpy(prev_cached_page, *current_data, TARGET_PAGE_SIZE);
*current_data = prev_cached_page;
}
return -1;
}
/* we need to update the data in the cache, in order to get the same data */
if (!last_stage) {
memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE);
}
/* Send XBZRLE based compressed page */
bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE);
qemu_put_byte(f, ENCODING_FLAG_XBZRLE);
qemu_put_be16(f, encoded_len);
qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len);
bytes_sent += encoded_len + 1 + 2;
acct_info.xbzrle_pages++;
acct_info.xbzrle_bytes += bytes_sent;
return bytes_sent;
}
|
Exec Code
| 0
|
static int save_xbzrle_page(QEMUFile *f, uint8_t **current_data,
ram_addr_t current_addr, RAMBlock *block,
ram_addr_t offset, int cont, bool last_stage)
{
int encoded_len = 0, bytes_sent = -1;
uint8_t *prev_cached_page;
if (!cache_is_cached(XBZRLE.cache, current_addr)) {
acct_info.xbzrle_cache_miss++;
if (!last_stage) {
if (cache_insert(XBZRLE.cache, current_addr, *current_data) == -1) {
return -1;
} else {
/* update *current_data when the page has been
inserted into cache */
*current_data = get_cached_data(XBZRLE.cache, current_addr);
}
}
return -1;
}
prev_cached_page = get_cached_data(XBZRLE.cache, current_addr);
/* save current buffer into memory */
memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
/* XBZRLE encoding (if there is no overflow) */
encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
TARGET_PAGE_SIZE);
if (encoded_len == 0) {
DPRINTF("Skipping unmodified page\n");
return 0;
} else if (encoded_len == -1) {
DPRINTF("Overflow\n");
acct_info.xbzrle_overflows++;
/* update data in the cache */
if (!last_stage) {
memcpy(prev_cached_page, *current_data, TARGET_PAGE_SIZE);
*current_data = prev_cached_page;
}
return -1;
}
/* we need to update the data in the cache, in order to get the same data */
if (!last_stage) {
memcpy(prev_cached_page, XBZRLE.current_buf, TARGET_PAGE_SIZE);
}
/* Send XBZRLE based compressed page */
bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE);
qemu_put_byte(f, ENCODING_FLAG_XBZRLE);
qemu_put_be16(f, encoded_len);
qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len);
bytes_sent += encoded_len + 1 + 2;
acct_info.xbzrle_pages++;
acct_info.xbzrle_bytes += bytes_sent;
return bytes_sent;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,260
|
void select_soundhw(const char *optarg)
{
struct soundhw *c;
if (is_help_option(optarg)) {
show_valid_cards:
if (soundhw_count) {
printf("Valid sound card names (comma separated):\n");
for (c = soundhw; c->name; ++c) {
printf ("%-11s %s\n", c->name, c->descr);
}
printf("\n-soundhw all will enable all of the above\n");
} else {
printf("Machine has no user-selectable audio hardware "
"(it may or may not have always-present audio hardware).\n");
}
exit(!is_help_option(optarg));
}
else {
size_t l;
const char *p;
char *e;
int bad_card = 0;
if (!strcmp(optarg, "all")) {
for (c = soundhw; c->name; ++c) {
c->enabled = 1;
}
return;
}
p = optarg;
while (*p) {
e = strchr(p, ',');
l = !e ? strlen(p) : (size_t) (e - p);
for (c = soundhw; c->name; ++c) {
if (!strncmp(c->name, p, l) && !c->name[l]) {
c->enabled = 1;
break;
}
}
if (!c->name) {
if (l > 80) {
error_report("Unknown sound card name (too big to show)");
}
else {
error_report("Unknown sound card name `%.*s'",
(int) l, p);
}
bad_card = 1;
}
p += l + (e != NULL);
}
if (bad_card) {
goto show_valid_cards;
}
}
}
|
Exec Code
| 0
|
void select_soundhw(const char *optarg)
{
struct soundhw *c;
if (is_help_option(optarg)) {
show_valid_cards:
if (soundhw_count) {
printf("Valid sound card names (comma separated):\n");
for (c = soundhw; c->name; ++c) {
printf ("%-11s %s\n", c->name, c->descr);
}
printf("\n-soundhw all will enable all of the above\n");
} else {
printf("Machine has no user-selectable audio hardware "
"(it may or may not have always-present audio hardware).\n");
}
exit(!is_help_option(optarg));
}
else {
size_t l;
const char *p;
char *e;
int bad_card = 0;
if (!strcmp(optarg, "all")) {
for (c = soundhw; c->name; ++c) {
c->enabled = 1;
}
return;
}
p = optarg;
while (*p) {
e = strchr(p, ',');
l = !e ? strlen(p) : (size_t) (e - p);
for (c = soundhw; c->name; ++c) {
if (!strncmp(c->name, p, l) && !c->name[l]) {
c->enabled = 1;
break;
}
}
if (!c->name) {
if (l > 80) {
error_report("Unknown sound card name (too big to show)");
}
else {
error_report("Unknown sound card name `%.*s'",
(int) l, p);
}
bad_card = 1;
}
p += l + (e != NULL);
}
if (bad_card) {
goto show_valid_cards;
}
}
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,261
|
uint64_t skipped_mig_bytes_transferred(void)
{
return acct_info.skipped_pages * TARGET_PAGE_SIZE;
}
|
Exec Code
| 0
|
uint64_t skipped_mig_bytes_transferred(void)
{
return acct_info.skipped_pages * TARGET_PAGE_SIZE;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,262
|
uint64_t skipped_mig_pages_transferred(void)
{
return acct_info.skipped_pages;
}
|
Exec Code
| 0
|
uint64_t skipped_mig_pages_transferred(void)
{
return acct_info.skipped_pages;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,263
|
uint64_t xbzrle_mig_bytes_transferred(void)
{
return acct_info.xbzrle_bytes;
}
|
Exec Code
| 0
|
uint64_t xbzrle_mig_bytes_transferred(void)
{
return acct_info.xbzrle_bytes;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,264
|
double xbzrle_mig_cache_miss_rate(void)
{
return acct_info.xbzrle_cache_miss_rate;
}
|
Exec Code
| 0
|
double xbzrle_mig_cache_miss_rate(void)
{
return acct_info.xbzrle_cache_miss_rate;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,265
|
uint64_t xbzrle_mig_pages_cache_miss(void)
{
return acct_info.xbzrle_cache_miss;
}
|
Exec Code
| 0
|
uint64_t xbzrle_mig_pages_cache_miss(void)
{
return acct_info.xbzrle_cache_miss;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,266
|
uint64_t xbzrle_mig_pages_overflow(void)
{
return acct_info.xbzrle_overflows;
}
|
Exec Code
| 0
|
uint64_t xbzrle_mig_pages_overflow(void)
{
return acct_info.xbzrle_overflows;
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,267
|
int xen_available(void)
{
#ifdef CONFIG_XEN
return 1;
#else
return 0;
#endif
}
|
Exec Code
| 0
|
int xen_available(void)
{
#ifdef CONFIG_XEN
return 1;
#else
return 0;
#endif
}
|
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
uint8_t len;
if (flags & RAM_SAVE_FLAG_CONTINUE) {
- if (!block) {
+ if (!block || block->length <= offset) {
error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1019,8 +1019,9 @@ static inline void *host_from_stream_offset(QEMUFile *f,
id[len] = 0;
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
- if (!strncmp(id, block->idstr, sizeof(id)))
+ if (!strncmp(id, block->idstr, sizeof(id)) && block->length > offset) {
return memory_region_get_ram_ptr(block->mr) + offset;
+ }
}
error_report("Can't find block %s!", id);
|
CWE-20
| null | null |
6,268
|
static int addfunction(JF, js_Function *value)
{
if (F->funlen >= F->funcap) {
F->funcap = F->funcap ? F->funcap * 2 : 16;
F->funtab = js_realloc(J, F->funtab, F->funcap * sizeof *F->funtab);
}
F->funtab[F->funlen] = value;
return F->funlen++;
}
|
DoS
| 0
|
static int addfunction(JF, js_Function *value)
{
if (F->funlen >= F->funcap) {
F->funcap = F->funcap ? F->funcap * 2 : 16;
F->funtab = js_realloc(J, F->funtab, F->funcap * sizeof *F->funtab);
}
F->funtab[F->funlen] = value;
return F->funlen++;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,269
|
static void addjump(JF, enum js_AstType type, js_Ast *target, int inst)
{
js_JumpList *jump = js_malloc(J, sizeof *jump);
jump->type = type;
jump->inst = inst;
jump->next = target->jumps;
target->jumps = jump;
}
|
DoS
| 0
|
static void addjump(JF, enum js_AstType type, js_Ast *target, int inst)
{
js_JumpList *jump = js_malloc(J, sizeof *jump);
jump->type = type;
jump->inst = inst;
jump->next = target->jumps;
target->jumps = jump;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,270
|
static void addlocal(JF, js_Ast *ident, int reuse)
{
const char *name = ident->string;
if (J->strict) {
if (!strcmp(name, "arguments"))
jsC_error(J, ident, "redefining 'arguments' is not allowed in strict mode");
if (!strcmp(name, "eval"))
jsC_error(J, ident, "redefining 'eval' is not allowed in strict mode");
}
if (reuse || J->strict) {
int i;
for (i = 0; i < F->varlen; ++i) {
if (!strcmp(F->vartab[i], name)) {
if (reuse)
return;
if (J->strict)
jsC_error(J, ident, "duplicate formal parameter '%s'", name);
}
}
}
if (F->varlen >= F->varcap) {
F->varcap = F->varcap ? F->varcap * 2 : 16;
F->vartab = js_realloc(J, F->vartab, F->varcap * sizeof *F->vartab);
}
F->vartab[F->varlen++] = name;
}
|
DoS
| 0
|
static void addlocal(JF, js_Ast *ident, int reuse)
{
const char *name = ident->string;
if (J->strict) {
if (!strcmp(name, "arguments"))
jsC_error(J, ident, "redefining 'arguments' is not allowed in strict mode");
if (!strcmp(name, "eval"))
jsC_error(J, ident, "redefining 'eval' is not allowed in strict mode");
}
if (reuse || J->strict) {
int i;
for (i = 0; i < F->varlen; ++i) {
if (!strcmp(F->vartab[i], name)) {
if (reuse)
return;
if (J->strict)
jsC_error(J, ident, "duplicate formal parameter '%s'", name);
}
}
}
if (F->varlen >= F->varcap) {
F->varcap = F->varcap ? F->varcap * 2 : 16;
F->vartab = js_realloc(J, F->vartab, F->varcap * sizeof *F->vartab);
}
F->vartab[F->varlen++] = name;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,271
|
static int addnumber(JF, double value)
{
int i;
for (i = 0; i < F->numlen; ++i)
if (F->numtab[i] == value)
return i;
if (F->numlen >= F->numcap) {
F->numcap = F->numcap ? F->numcap * 2 : 16;
F->numtab = js_realloc(J, F->numtab, F->numcap * sizeof *F->numtab);
}
F->numtab[F->numlen] = value;
return F->numlen++;
}
|
DoS
| 0
|
static int addnumber(JF, double value)
{
int i;
for (i = 0; i < F->numlen; ++i)
if (F->numtab[i] == value)
return i;
if (F->numlen >= F->numcap) {
F->numcap = F->numcap ? F->numcap * 2 : 16;
F->numtab = js_realloc(J, F->numtab, F->numcap * sizeof *F->numtab);
}
F->numtab[F->numlen] = value;
return F->numlen++;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,272
|
static int addstring(JF, const char *value)
{
int i;
for (i = 0; i < F->strlen; ++i)
if (!strcmp(F->strtab[i], value))
return i;
if (F->strlen >= F->strcap) {
F->strcap = F->strcap ? F->strcap * 2 : 16;
F->strtab = js_realloc(J, F->strtab, F->strcap * sizeof *F->strtab);
}
F->strtab[F->strlen] = value;
return F->strlen++;
}
|
DoS
| 0
|
static int addstring(JF, const char *value)
{
int i;
for (i = 0; i < F->strlen; ++i)
if (!strcmp(F->strtab[i], value))
return i;
if (F->strlen >= F->strcap) {
F->strcap = F->strcap ? F->strcap * 2 : 16;
F->strtab = js_realloc(J, F->strtab, F->strcap * sizeof *F->strtab);
}
F->strtab[F->strlen] = value;
return F->strlen++;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,273
|
static void analyze(JF, js_Ast *node)
{
if (isfun(node->type)) {
F->lightweight = 0;
return; /* don't scan inner functions */
}
if (node->type == STM_WITH) {
F->lightweight = 0;
}
if (node->type == STM_TRY && node->c) {
F->lightweight = 0;
}
if (node->type == EXP_IDENTIFIER) {
if (!strcmp(node->string, "arguments")) {
F->lightweight = 0;
F->arguments = 1;
} else if (!strcmp(node->string, "eval")) {
/* eval may only be used as a direct function call */
if (!node->parent || node->parent->type != EXP_CALL || node->parent->a != node)
js_evalerror(J, "%s:%d: invalid use of 'eval'", J->filename, node->line);
F->lightweight = 0;
}
}
if (node->a) analyze(J, F, node->a);
if (node->b) analyze(J, F, node->b);
if (node->c) analyze(J, F, node->c);
if (node->d) analyze(J, F, node->d);
}
|
DoS
| 0
|
static void analyze(JF, js_Ast *node)
{
if (isfun(node->type)) {
F->lightweight = 0;
return; /* don't scan inner functions */
}
if (node->type == STM_WITH) {
F->lightweight = 0;
}
if (node->type == STM_TRY && node->c) {
F->lightweight = 0;
}
if (node->type == EXP_IDENTIFIER) {
if (!strcmp(node->string, "arguments")) {
F->lightweight = 0;
F->arguments = 1;
} else if (!strcmp(node->string, "eval")) {
/* eval may only be used as a direct function call */
if (!node->parent || node->parent->type != EXP_CALL || node->parent->a != node)
js_evalerror(J, "%s:%d: invalid use of 'eval'", J->filename, node->line);
F->lightweight = 0;
}
}
if (node->a) analyze(J, F, node->a);
if (node->b) analyze(J, F, node->b);
if (node->c) analyze(J, F, node->c);
if (node->d) analyze(J, F, node->d);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,274
|
static js_Ast *breaktarget(JF, js_Ast *node, const char *label)
{
while (node) {
if (isfun(node->type))
break;
if (!label) {
if (isloop(node->type) || node->type == STM_SWITCH)
return node;
} else {
if (matchlabel(node->parent, label))
return node;
}
node = node->parent;
}
return NULL;
}
|
DoS
| 0
|
static js_Ast *breaktarget(JF, js_Ast *node, const char *label)
{
while (node) {
if (isfun(node->type))
break;
if (!label) {
if (isloop(node->type) || node->type == STM_SWITCH)
return node;
} else {
if (matchlabel(node->parent, label))
return node;
}
node = node->parent;
}
return NULL;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,275
|
static void cassign(JF, js_Ast *exp)
{
js_Ast *lhs = exp->a;
js_Ast *rhs = exp->b;
switch (lhs->type) {
case EXP_IDENTIFIER:
cexp(J, F, rhs);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
cexp(J, F, rhs);
emit(J, F, OP_SETPROP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
cexp(J, F, rhs);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
|
DoS
| 0
|
static void cassign(JF, js_Ast *exp)
{
js_Ast *lhs = exp->a;
js_Ast *rhs = exp->b;
switch (lhs->type) {
case EXP_IDENTIFIER:
cexp(J, F, rhs);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
cexp(J, F, rhs);
emit(J, F, OP_SETPROP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
cexp(J, F, rhs);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,276
|
static void cassignforin(JF, js_Ast *stm)
{
js_Ast *lhs = stm->a;
if (stm->type == STM_FOR_IN_VAR) {
if (lhs->b)
jsC_error(J, lhs->b, "more than one loop variable in for-in statement");
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs->a->a); /* list(var-init(ident)) */
emit(J, F, OP_POP);
return;
}
switch (lhs->type) {
case EXP_IDENTIFIER:
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
emit(J, F, OP_POP);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
emit(J, F, OP_ROT3);
emit(J, F, OP_SETPROP);
emit(J, F, OP_POP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
emit(J, F, OP_ROT2);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
emit(J, F, OP_POP);
break;
default:
jsC_error(J, lhs, "invalid l-value in for-in loop assignment");
}
}
|
DoS
| 0
|
static void cassignforin(JF, js_Ast *stm)
{
js_Ast *lhs = stm->a;
if (stm->type == STM_FOR_IN_VAR) {
if (lhs->b)
jsC_error(J, lhs->b, "more than one loop variable in for-in statement");
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs->a->a); /* list(var-init(ident)) */
emit(J, F, OP_POP);
return;
}
switch (lhs->type) {
case EXP_IDENTIFIER:
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
emit(J, F, OP_POP);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
emit(J, F, OP_ROT3);
emit(J, F, OP_SETPROP);
emit(J, F, OP_POP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
emit(J, F, OP_ROT2);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
emit(J, F, OP_POP);
break;
default:
jsC_error(J, lhs, "invalid l-value in for-in loop assignment");
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,277
|
static void cassignop(JF, js_Ast *exp, int opcode)
{
js_Ast *lhs = exp->a;
js_Ast *rhs = exp->b;
cassignop1(J, F, lhs);
cexp(J, F, rhs);
emit(J, F, opcode);
cassignop2(J, F, lhs, 0);
}
|
DoS
| 0
|
static void cassignop(JF, js_Ast *exp, int opcode)
{
js_Ast *lhs = exp->a;
js_Ast *rhs = exp->b;
cassignop1(J, F, lhs);
cexp(J, F, rhs);
emit(J, F, opcode);
cassignop2(J, F, lhs, 0);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,278
|
static void cassignop1(JF, js_Ast *lhs)
{
switch (lhs->type) {
case EXP_IDENTIFIER:
emitlocal(J, F, OP_GETLOCAL, OP_GETVAR, lhs);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
emit(J, F, OP_DUP2);
emit(J, F, OP_GETPROP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
emit(J, F, OP_DUP);
emitstring(J, F, OP_GETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
|
DoS
| 0
|
static void cassignop1(JF, js_Ast *lhs)
{
switch (lhs->type) {
case EXP_IDENTIFIER:
emitlocal(J, F, OP_GETLOCAL, OP_GETVAR, lhs);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
emit(J, F, OP_DUP2);
emit(J, F, OP_GETPROP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
emit(J, F, OP_DUP);
emitstring(J, F, OP_GETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,279
|
static void cassignop2(JF, js_Ast *lhs, int postfix)
{
switch (lhs->type) {
case EXP_IDENTIFIER:
if (postfix) emit(J, F, OP_ROT2);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
break;
case EXP_INDEX:
if (postfix) emit(J, F, OP_ROT4);
emit(J, F, OP_SETPROP);
break;
case EXP_MEMBER:
if (postfix) emit(J, F, OP_ROT3);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
|
DoS
| 0
|
static void cassignop2(JF, js_Ast *lhs, int postfix)
{
switch (lhs->type) {
case EXP_IDENTIFIER:
if (postfix) emit(J, F, OP_ROT2);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
break;
case EXP_INDEX:
if (postfix) emit(J, F, OP_ROT4);
emit(J, F, OP_SETPROP);
break;
case EXP_MEMBER:
if (postfix) emit(J, F, OP_ROT3);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,280
|
static void cdelete(JF, js_Ast *exp)
{
switch (exp->type) {
case EXP_IDENTIFIER:
if (J->strict)
jsC_error(J, exp, "delete on an unqualified name is not allowed in strict mode");
emitlocal(J, F, OP_DELLOCAL, OP_DELVAR, exp);
break;
case EXP_INDEX:
cexp(J, F, exp->a);
cexp(J, F, exp->b);
emit(J, F, OP_DELPROP);
break;
case EXP_MEMBER:
cexp(J, F, exp->a);
emitstring(J, F, OP_DELPROP_S, exp->b->string);
break;
default:
jsC_error(J, exp, "invalid l-value in delete expression");
}
}
|
DoS
| 0
|
static void cdelete(JF, js_Ast *exp)
{
switch (exp->type) {
case EXP_IDENTIFIER:
if (J->strict)
jsC_error(J, exp, "delete on an unqualified name is not allowed in strict mode");
emitlocal(J, F, OP_DELLOCAL, OP_DELVAR, exp);
break;
case EXP_INDEX:
cexp(J, F, exp->a);
cexp(J, F, exp->b);
emit(J, F, OP_DELPROP);
break;
case EXP_MEMBER:
cexp(J, F, exp->a);
emitstring(J, F, OP_DELPROP_S, exp->b->string);
break;
default:
jsC_error(J, exp, "invalid l-value in delete expression");
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,281
|
static void cexit(JF, enum js_AstType T, js_Ast *node, js_Ast *target)
{
js_Ast *prev;
do {
prev = node, node = node->parent;
switch (node->type) {
default: /* impossible */ break;
case STM_WITH:
emit(J, F, OP_ENDWITH);
break;
case STM_FOR_IN:
case STM_FOR_IN_VAR:
/* pop the iterator if leaving the loop */
if (F->script) {
if (T == STM_RETURN || T == STM_BREAK || (T == STM_CONTINUE && target != node)) {
/* pop the iterator, save the return or exp value */
emit(J, F, OP_ROT2);
emit(J, F, OP_POP);
}
if (T == STM_CONTINUE)
emit(J, F, OP_ROT2); /* put the iterator back on top */
} else {
if (T == STM_RETURN) {
/* pop the iterator, save the return value */
emit(J, F, OP_ROT2);
emit(J, F, OP_POP);
}
if (T == STM_BREAK || (T == STM_CONTINUE && target != node))
emit(J, F, OP_POP); /* pop the iterator */
}
break;
case STM_TRY:
/* came from try block */
if (prev == node->a) {
emit(J, F, OP_ENDTRY);
if (node->d) cstm(J, F, node->d); /* finally */
}
/* came from catch block */
if (prev == node->c) {
/* ... with finally */
if (node->d) {
emit(J, F, OP_ENDCATCH);
emit(J, F, OP_ENDTRY);
cstm(J, F, node->d); /* finally */
} else {
emit(J, F, OP_ENDCATCH);
}
}
break;
}
} while (node != target);
}
|
DoS
| 0
|
static void cexit(JF, enum js_AstType T, js_Ast *node, js_Ast *target)
{
js_Ast *prev;
do {
prev = node, node = node->parent;
switch (node->type) {
default: /* impossible */ break;
case STM_WITH:
emit(J, F, OP_ENDWITH);
break;
case STM_FOR_IN:
case STM_FOR_IN_VAR:
/* pop the iterator if leaving the loop */
if (F->script) {
if (T == STM_RETURN || T == STM_BREAK || (T == STM_CONTINUE && target != node)) {
/* pop the iterator, save the return or exp value */
emit(J, F, OP_ROT2);
emit(J, F, OP_POP);
}
if (T == STM_CONTINUE)
emit(J, F, OP_ROT2); /* put the iterator back on top */
} else {
if (T == STM_RETURN) {
/* pop the iterator, save the return value */
emit(J, F, OP_ROT2);
emit(J, F, OP_POP);
}
if (T == STM_BREAK || (T == STM_CONTINUE && target != node))
emit(J, F, OP_POP); /* pop the iterator */
}
break;
case STM_TRY:
/* came from try block */
if (prev == node->a) {
emit(J, F, OP_ENDTRY);
if (node->d) cstm(J, F, node->d); /* finally */
}
/* came from catch block */
if (prev == node->c) {
/* ... with finally */
if (node->d) {
emit(J, F, OP_ENDCATCH);
emit(J, F, OP_ENDTRY);
cstm(J, F, node->d); /* finally */
} else {
emit(J, F, OP_ENDCATCH);
}
}
break;
}
} while (node != target);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,282
|
static void cfunbody(JF, js_Ast *name, js_Ast *params, js_Ast *body)
{
F->lightweight = 1;
F->arguments = 0;
if (F->script)
F->lightweight = 0;
if (body)
analyze(J, F, body);
cparams(J, F, params);
if (name) {
emit(J, F, OP_CURRENT);
if (F->lightweight) {
addlocal(J, F, name, 0);
emit(J, F, OP_INITLOCAL);
emitraw(J, F, findlocal(J, F, name->string));
} else {
emitstring(J, F, OP_INITVAR, name->string);
}
}
if (body) {
cvardecs(J, F, body);
cfundecs(J, F, body);
}
if (F->script) {
emit(J, F, OP_UNDEF);
cstmlist(J, F, body);
emit(J, F, OP_RETURN);
} else {
cstmlist(J, F, body);
emit(J, F, OP_UNDEF);
emit(J, F, OP_RETURN);
}
}
|
DoS
| 0
|
static void cfunbody(JF, js_Ast *name, js_Ast *params, js_Ast *body)
{
F->lightweight = 1;
F->arguments = 0;
if (F->script)
F->lightweight = 0;
if (body)
analyze(J, F, body);
cparams(J, F, params);
if (name) {
emit(J, F, OP_CURRENT);
if (F->lightweight) {
addlocal(J, F, name, 0);
emit(J, F, OP_INITLOCAL);
emitraw(J, F, findlocal(J, F, name->string));
} else {
emitstring(J, F, OP_INITVAR, name->string);
}
}
if (body) {
cvardecs(J, F, body);
cfundecs(J, F, body);
}
if (F->script) {
emit(J, F, OP_UNDEF);
cstmlist(J, F, body);
emit(J, F, OP_RETURN);
} else {
cstmlist(J, F, body);
emit(J, F, OP_UNDEF);
emit(J, F, OP_RETURN);
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,283
|
static void cfundecs(JF, js_Ast *list)
{
while (list) {
js_Ast *stm = list->a;
if (stm->type == AST_FUNDEC) {
emitfunction(J, F, newfun(J, stm->a, stm->b, stm->c, 0));
emitstring(J, F, OP_INITVAR, stm->a->string);
}
list = list->b;
}
}
|
DoS
| 0
|
static void cfundecs(JF, js_Ast *list)
{
while (list) {
js_Ast *stm = list->a;
if (stm->type == AST_FUNDEC) {
emitfunction(J, F, newfun(J, stm->a, stm->b, stm->c, 0));
emitstring(J, F, OP_INITVAR, stm->a->string);
}
list = list->b;
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,284
|
static void checkdup(JF, js_Ast *list, js_Ast *end)
{
char nbuf[32], sbuf[32];
const char *needle, *straw;
if (end->a->type == EXP_NUMBER)
needle = jsV_numbertostring(J, nbuf, end->a->number);
else
needle = end->a->string;
while (list->a != end) {
if (list->a->type == end->type) {
js_Ast *prop = list->a->a;
if (prop->type == EXP_NUMBER)
straw = jsV_numbertostring(J, sbuf, prop->number);
else
straw = prop->string;
if (!strcmp(needle, straw))
jsC_error(J, list, "duplicate property '%s' in object literal", needle);
}
list = list->b;
}
}
|
DoS
| 0
|
static void checkdup(JF, js_Ast *list, js_Ast *end)
{
char nbuf[32], sbuf[32];
const char *needle, *straw;
if (end->a->type == EXP_NUMBER)
needle = jsV_numbertostring(J, nbuf, end->a->number);
else
needle = end->a->string;
while (list->a != end) {
if (list->a->type == end->type) {
js_Ast *prop = list->a->a;
if (prop->type == EXP_NUMBER)
straw = jsV_numbertostring(J, sbuf, prop->number);
else
straw = prop->string;
if (!strcmp(needle, straw))
jsC_error(J, list, "duplicate property '%s' in object literal", needle);
}
list = list->b;
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,285
|
static void cobject(JF, js_Ast *list)
{
js_Ast *head = list;
while (list) {
js_Ast *kv = list->a;
js_Ast *prop = kv->a;
if (prop->type == AST_IDENTIFIER || prop->type == EXP_STRING)
emitstring(J, F, OP_STRING, prop->string);
else if (prop->type == EXP_NUMBER)
emitnumber(J, F, prop->number);
else
jsC_error(J, prop, "invalid property name in object initializer");
if (J->strict)
checkdup(J, F, head, kv);
switch (kv->type) {
default: /* impossible */ break;
case EXP_PROP_VAL:
cexp(J, F, kv->b);
emit(J, F, OP_INITPROP);
break;
case EXP_PROP_GET:
emitfunction(J, F, newfun(J, NULL, kv->b, kv->c, 0));
emit(J, F, OP_INITGETTER);
break;
case EXP_PROP_SET:
emitfunction(J, F, newfun(J, NULL, kv->b, kv->c, 0));
emit(J, F, OP_INITSETTER);
break;
}
list = list->b;
}
}
|
DoS
| 0
|
static void cobject(JF, js_Ast *list)
{
js_Ast *head = list;
while (list) {
js_Ast *kv = list->a;
js_Ast *prop = kv->a;
if (prop->type == AST_IDENTIFIER || prop->type == EXP_STRING)
emitstring(J, F, OP_STRING, prop->string);
else if (prop->type == EXP_NUMBER)
emitnumber(J, F, prop->number);
else
jsC_error(J, prop, "invalid property name in object initializer");
if (J->strict)
checkdup(J, F, head, kv);
switch (kv->type) {
default: /* impossible */ break;
case EXP_PROP_VAL:
cexp(J, F, kv->b);
emit(J, F, OP_INITPROP);
break;
case EXP_PROP_GET:
emitfunction(J, F, newfun(J, NULL, kv->b, kv->c, 0));
emit(J, F, OP_INITGETTER);
break;
case EXP_PROP_SET:
emitfunction(J, F, newfun(J, NULL, kv->b, kv->c, 0));
emit(J, F, OP_INITSETTER);
break;
}
list = list->b;
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,286
|
static js_Ast *continuetarget(JF, js_Ast *node, const char *label)
{
while (node) {
if (isfun(node->type))
break;
if (isloop(node->type)) {
if (!label)
return node;
else if (matchlabel(node->parent, label))
return node;
}
node = node->parent;
}
return NULL;
}
|
DoS
| 0
|
static js_Ast *continuetarget(JF, js_Ast *node, const char *label)
{
while (node) {
if (isfun(node->type))
break;
if (isloop(node->type)) {
if (!label)
return node;
else if (matchlabel(node->parent, label))
return node;
}
node = node->parent;
}
return NULL;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,287
|
static void cstmlist(JF, js_Ast *list)
{
while (list) {
cstm(J, F, list->a);
list = list->b;
}
}
|
DoS
| 0
|
static void cstmlist(JF, js_Ast *list)
{
while (list) {
cstm(J, F, list->a);
list = list->b;
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,288
|
static void cswitch(JF, js_Ast *ref, js_Ast *head)
{
js_Ast *node, *clause, *def = NULL;
int end;
cexp(J, F, ref);
/* emit an if-else chain of tests for the case clause expressions */
for (node = head; node; node = node->b) {
clause = node->a;
if (clause->type == STM_DEFAULT) {
if (def)
jsC_error(J, clause, "more than one default label in switch");
def = clause;
} else {
cexp(J, F, clause->a);
clause->casejump = emitjump(J, F, OP_JCASE);
}
}
emit(J, F, OP_POP);
if (def) {
def->casejump = emitjump(J, F, OP_JUMP);
end = 0;
} else {
end = emitjump(J, F, OP_JUMP);
}
/* emit the casue clause bodies */
for (node = head; node; node = node->b) {
clause = node->a;
label(J, F, clause->casejump);
if (clause->type == STM_DEFAULT)
cstmlist(J, F, clause->a);
else
cstmlist(J, F, clause->b);
}
if (end)
label(J, F, end);
}
|
DoS
| 0
|
static void cswitch(JF, js_Ast *ref, js_Ast *head)
{
js_Ast *node, *clause, *def = NULL;
int end;
cexp(J, F, ref);
/* emit an if-else chain of tests for the case clause expressions */
for (node = head; node; node = node->b) {
clause = node->a;
if (clause->type == STM_DEFAULT) {
if (def)
jsC_error(J, clause, "more than one default label in switch");
def = clause;
} else {
cexp(J, F, clause->a);
clause->casejump = emitjump(J, F, OP_JCASE);
}
}
emit(J, F, OP_POP);
if (def) {
def->casejump = emitjump(J, F, OP_JUMP);
end = 0;
} else {
end = emitjump(J, F, OP_JUMP);
}
/* emit the casue clause bodies */
for (node = head; node; node = node->b) {
clause = node->a;
label(J, F, clause->casejump);
if (clause->type == STM_DEFAULT)
cstmlist(J, F, clause->a);
else
cstmlist(J, F, clause->b);
}
if (end)
label(J, F, end);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,289
|
static void ctrycatch(JF, js_Ast *trystm, js_Ast *catchvar, js_Ast *catchstm)
{
int L1, L2;
L1 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the try block */
if (J->strict) {
if (!strcmp(catchvar->string, "arguments"))
jsC_error(J, catchvar, "redefining 'arguments' is not allowed in strict mode");
if (!strcmp(catchvar->string, "eval"))
jsC_error(J, catchvar, "redefining 'eval' is not allowed in strict mode");
}
emitstring(J, F, OP_CATCH, catchvar->string);
cstm(J, F, catchstm);
emit(J, F, OP_ENDCATCH);
L2 = emitjump(J, F, OP_JUMP); /* skip past the try block */
}
label(J, F, L1);
cstm(J, F, trystm);
emit(J, F, OP_ENDTRY);
label(J, F, L2);
}
|
DoS
| 0
|
static void ctrycatch(JF, js_Ast *trystm, js_Ast *catchvar, js_Ast *catchstm)
{
int L1, L2;
L1 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the try block */
if (J->strict) {
if (!strcmp(catchvar->string, "arguments"))
jsC_error(J, catchvar, "redefining 'arguments' is not allowed in strict mode");
if (!strcmp(catchvar->string, "eval"))
jsC_error(J, catchvar, "redefining 'eval' is not allowed in strict mode");
}
emitstring(J, F, OP_CATCH, catchvar->string);
cstm(J, F, catchstm);
emit(J, F, OP_ENDCATCH);
L2 = emitjump(J, F, OP_JUMP); /* skip past the try block */
}
label(J, F, L1);
cstm(J, F, trystm);
emit(J, F, OP_ENDTRY);
label(J, F, L2);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,290
|
static void ctrycatchfinally(JF, js_Ast *trystm, js_Ast *catchvar, js_Ast *catchstm, js_Ast *finallystm)
{
int L1, L2, L3;
L1 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the try block */
L2 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the catch block */
cstm(J, F, finallystm); /* inline finally block */
emit(J, F, OP_THROW); /* rethrow exception */
}
label(J, F, L2);
if (J->strict) {
if (!strcmp(catchvar->string, "arguments"))
jsC_error(J, catchvar, "redefining 'arguments' is not allowed in strict mode");
if (!strcmp(catchvar->string, "eval"))
jsC_error(J, catchvar, "redefining 'eval' is not allowed in strict mode");
}
emitstring(J, F, OP_CATCH, catchvar->string);
cstm(J, F, catchstm);
emit(J, F, OP_ENDCATCH);
L3 = emitjump(J, F, OP_JUMP); /* skip past the try block to the finally block */
}
label(J, F, L1);
cstm(J, F, trystm);
emit(J, F, OP_ENDTRY);
label(J, F, L3);
cstm(J, F, finallystm);
}
|
DoS
| 0
|
static void ctrycatchfinally(JF, js_Ast *trystm, js_Ast *catchvar, js_Ast *catchstm, js_Ast *finallystm)
{
int L1, L2, L3;
L1 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the try block */
L2 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the catch block */
cstm(J, F, finallystm); /* inline finally block */
emit(J, F, OP_THROW); /* rethrow exception */
}
label(J, F, L2);
if (J->strict) {
if (!strcmp(catchvar->string, "arguments"))
jsC_error(J, catchvar, "redefining 'arguments' is not allowed in strict mode");
if (!strcmp(catchvar->string, "eval"))
jsC_error(J, catchvar, "redefining 'eval' is not allowed in strict mode");
}
emitstring(J, F, OP_CATCH, catchvar->string);
cstm(J, F, catchstm);
emit(J, F, OP_ENDCATCH);
L3 = emitjump(J, F, OP_JUMP); /* skip past the try block to the finally block */
}
label(J, F, L1);
cstm(J, F, trystm);
emit(J, F, OP_ENDTRY);
label(J, F, L3);
cstm(J, F, finallystm);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,291
|
static void ctryfinally(JF, js_Ast *trystm, js_Ast *finallystm)
{
int L1;
L1 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the try block */
cstm(J, F, finallystm); /* inline finally block */
emit(J, F, OP_THROW); /* rethrow exception */
}
label(J, F, L1);
cstm(J, F, trystm);
emit(J, F, OP_ENDTRY);
cstm(J, F, finallystm);
}
|
DoS
| 0
|
static void ctryfinally(JF, js_Ast *trystm, js_Ast *finallystm)
{
int L1;
L1 = emitjump(J, F, OP_TRY);
{
/* if we get here, we have caught an exception in the try block */
cstm(J, F, finallystm); /* inline finally block */
emit(J, F, OP_THROW); /* rethrow exception */
}
label(J, F, L1);
cstm(J, F, trystm);
emit(J, F, OP_ENDTRY);
cstm(J, F, finallystm);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,292
|
static void ctypeof(JF, js_Ast *exp)
{
if (exp->type == EXP_IDENTIFIER)
emitlocal(J, F, OP_GETLOCAL, OP_HASVAR, exp);
else
cexp(J, F, exp);
emit(J, F, OP_TYPEOF);
}
|
DoS
| 0
|
static void ctypeof(JF, js_Ast *exp)
{
if (exp->type == EXP_IDENTIFIER)
emitlocal(J, F, OP_GETLOCAL, OP_HASVAR, exp);
else
cexp(J, F, exp);
emit(J, F, OP_TYPEOF);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,293
|
static void cunary(JF, js_Ast *exp, int opcode)
{
cexp(J, F, exp->a);
emit(J, F, opcode);
}
|
DoS
| 0
|
static void cunary(JF, js_Ast *exp, int opcode)
{
cexp(J, F, exp->a);
emit(J, F, opcode);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,294
|
static void cvardecs(JF, js_Ast *node)
{
if (isfun(node->type))
return; /* stop at inner functions */
if (node->type == EXP_VAR) {
if (F->lightweight)
addlocal(J, F, node->a, 1);
else
emitstring(J, F, OP_DEFVAR, node->a->string);
}
if (node->a) cvardecs(J, F, node->a);
if (node->b) cvardecs(J, F, node->b);
if (node->c) cvardecs(J, F, node->c);
if (node->d) cvardecs(J, F, node->d);
}
|
DoS
| 0
|
static void cvardecs(JF, js_Ast *node)
{
if (isfun(node->type))
return; /* stop at inner functions */
if (node->type == EXP_VAR) {
if (F->lightweight)
addlocal(J, F, node->a, 1);
else
emitstring(J, F, OP_DEFVAR, node->a->string);
}
if (node->a) cvardecs(J, F, node->a);
if (node->b) cvardecs(J, F, node->b);
if (node->c) cvardecs(J, F, node->c);
if (node->d) cvardecs(J, F, node->d);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,295
|
static void cvarinit(JF, js_Ast *list)
{
while (list) {
js_Ast *var = list->a;
if (var->b) {
cexp(J, F, var->b);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, var->a);
emit(J, F, OP_POP);
}
list = list->b;
}
}
|
DoS
| 0
|
static void cvarinit(JF, js_Ast *list)
{
while (list) {
js_Ast *var = list->a;
if (var->b) {
cexp(J, F, var->b);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, var->a);
emit(J, F, OP_POP);
}
list = list->b;
}
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,296
|
static void emit(JF, int value)
{
emitraw(J, F, value);
}
|
DoS
| 0
|
static void emit(JF, int value)
{
emitraw(J, F, value);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,297
|
static void emitfunction(JF, js_Function *fun)
{
emit(J, F, OP_CLOSURE);
emitraw(J, F, addfunction(J, F, fun));
}
|
DoS
| 0
|
static void emitfunction(JF, js_Function *fun)
{
emit(J, F, OP_CLOSURE);
emitraw(J, F, addfunction(J, F, fun));
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,298
|
static int emitjump(JF, int opcode)
{
int inst = F->codelen + 1;
emit(J, F, opcode);
emitraw(J, F, 0);
return inst;
}
|
DoS
| 0
|
static int emitjump(JF, int opcode)
{
int inst = F->codelen + 1;
emit(J, F, opcode);
emitraw(J, F, 0);
return inst;
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
6,299
|
static void emitjumpto(JF, int opcode, int dest)
{
emit(J, F, opcode);
if (dest != (js_Instruction)dest)
js_syntaxerror(J, "jump address integer overflow");
emitraw(J, F, dest);
}
|
DoS
| 0
|
static void emitjumpto(JF, int opcode, int dest)
{
emit(J, F, opcode);
if (dest != (js_Instruction)dest)
js_syntaxerror(J, "jump address integer overflow");
emitraw(J, F, dest);
}
|
@@ -1102,11 +1102,11 @@ static void cstm(JF, js_Ast *stm)
case STM_BREAK:
if (stm->a) {
- target = breaktarget(J, F, stm, stm->a->string);
+ target = breaktarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "break label '%s' not found", stm->a->string);
} else {
- target = breaktarget(J, F, stm, NULL);
+ target = breaktarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "unlabelled break must be inside loop or switch");
}
@@ -1116,11 +1116,11 @@ static void cstm(JF, js_Ast *stm)
case STM_CONTINUE:
if (stm->a) {
- target = continuetarget(J, F, stm, stm->a->string);
+ target = continuetarget(J, F, stm->parent, stm->a->string);
if (!target)
jsC_error(J, stm, "continue label '%s' not found", stm->a->string);
} else {
- target = continuetarget(J, F, stm, NULL);
+ target = continuetarget(J, F, stm->parent, NULL);
if (!target)
jsC_error(J, stm, "continue must be inside loop");
}
@@ -1133,7 +1133,7 @@ static void cstm(JF, js_Ast *stm)
cexp(J, F, stm->a);
else
emit(J, F, OP_UNDEF);
- target = returntarget(J, F, stm);
+ target = returntarget(J, F, stm->parent);
if (!target)
jsC_error(J, stm, "return not in function");
cexit(J, F, STM_RETURN, stm, target);
|
CWE-476
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.