project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
savannah
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
0
ft_var_load_avar( TT_Face face ) { FT_Stream stream = FT_FACE_STREAM(face); FT_Memory memory = stream->memory; GX_Blend blend = face->blend; GX_AVarSegment segment; FT_Error error = TT_Err_Ok; FT_ULong version; FT_Long axisCount; FT_Int i, j; FT_ULong table_len; FT_UNUSED( error ); blend->avar_checked = TRUE; if ( (error = face->goto_table( face, TTAG_avar, stream, &table_len )) != 0 ) return; if ( FT_FRAME_ENTER( table_len ) ) return; version = FT_GET_LONG(); axisCount = FT_GET_LONG(); if ( version != 0x00010000L || axisCount != (FT_Long)blend->mmvar->num_axis ) goto Exit; if ( FT_NEW_ARRAY( blend->avar_segment, axisCount ) ) goto Exit; segment = &blend->avar_segment[0]; for ( i = 0; i < axisCount; ++i, ++segment ) { segment->pairCount = FT_GET_USHORT(); if ( FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) ) { /* Failure. Free everything we have done so far. We must do */ /* it right now since loading the `avar' table is optional. */ for ( j = i - 1; j >= 0; --j ) FT_FREE( blend->avar_segment[j].correspondence ); FT_FREE( blend->avar_segment ); blend->avar_segment = NULL; goto Exit; } for ( j = 0; j < segment->pairCount; ++j ) { segment->correspondence[j].fromCoord = FT_GET_SHORT() << 2; /* convert to Fixed */ segment->correspondence[j].toCoord = FT_GET_SHORT()<<2; /* convert to Fixed */ } } Exit: FT_FRAME_EXIT(); }
CWE-119
7,749
15,574
176972993586521751767325097947030289301
null
null
null
savannah
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
0
ft_var_load_gvar( TT_Face face ) { FT_Stream stream = FT_FACE_STREAM(face); FT_Memory memory = stream->memory; GX_Blend blend = face->blend; FT_Error error; FT_UInt i, j; FT_ULong table_len; FT_ULong gvar_start; FT_ULong offsetToData; GX_GVar_Head gvar_head; static const FT_Frame_Field gvar_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_GVar_Head FT_FRAME_START( 20 ), FT_FRAME_LONG ( version ), FT_FRAME_USHORT( axisCount ), FT_FRAME_USHORT( globalCoordCount ), FT_FRAME_ULONG ( offsetToCoord ), FT_FRAME_USHORT( glyphCount ), FT_FRAME_USHORT( flags ), FT_FRAME_ULONG ( offsetToData ), FT_FRAME_END }; if ( (error = face->goto_table( face, TTAG_gvar, stream, &table_len )) != 0 ) goto Exit; gvar_start = FT_STREAM_POS( ); if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) ) goto Exit; blend->tuplecount = gvar_head.globalCoordCount; blend->gv_glyphcnt = gvar_head.glyphCount; offsetToData = gvar_start + gvar_head.offsetToData; if ( gvar_head.version != (FT_Long)0x00010000L || gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis ) { error = TT_Err_Invalid_Table; goto Exit; } if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) ) goto Exit; if ( gvar_head.flags & 1 ) { /* long offsets (one more offset than glyphs, to mark size of last) */ if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) ) goto Exit; for ( i = 0; i <= blend->gv_glyphcnt; ++i ) blend->glyphoffsets[i] = offsetToData + FT_GET_LONG(); FT_FRAME_EXIT(); } else { /* short offsets (one more offset than glyphs, to mark size of last) */ if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) ) goto Exit; for ( i = 0; i <= blend->gv_glyphcnt; ++i ) blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2; /* XXX: Undocumented: `*2'! */ FT_FRAME_EXIT(); } if ( blend->tuplecount != 0 ) { if ( FT_NEW_ARRAY( blend->tuplecoords, gvar_head.axisCount * blend->tuplecount ) ) goto Exit; if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) || FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L ) ) goto Exit; for ( i = 0; i < blend->tuplecount; ++i ) for ( j = 0 ; j < (FT_UInt)gvar_head.axisCount; ++j ) blend->tuplecoords[i * gvar_head.axisCount + j] = FT_GET_SHORT() << 2; /* convert to FT_Fixed */ FT_FRAME_EXIT(); } Exit: return error; }
CWE-119
7,750
15,575
212533515305625439440641320344619305080
null
null
null
savannah
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
0
ft_var_readpackeddeltas( FT_Stream stream, FT_Offset delta_cnt ) { FT_Short *deltas = NULL; FT_UInt runcnt; FT_Offset i; FT_UInt j; FT_Memory memory = stream->memory; FT_Error error = TT_Err_Ok; FT_UNUSED( error ); if ( FT_NEW_ARRAY( deltas, delta_cnt ) ) return NULL; i = 0; while ( i < delta_cnt ) { runcnt = FT_GET_BYTE(); if ( runcnt & GX_DT_DELTAS_ARE_ZERO ) { /* runcnt zeroes get added */ for ( j = 0; j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt; ++j ) deltas[i++] = 0; } else if ( runcnt & GX_DT_DELTAS_ARE_WORDS ) { /* runcnt shorts from the stack */ for ( j = 0; j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt; ++j ) deltas[i++] = FT_GET_SHORT(); } else { /* runcnt signed bytes from the stack */ for ( j = 0; j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt; ++j ) deltas[i++] = FT_GET_CHAR(); } if ( j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) ) { /* Bad format */ FT_FREE( deltas ); return NULL; } } return deltas; }
CWE-119
7,751
15,576
234712086368934595949659730186083641738
null
null
null
savannah
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
0
tt_done_blend( FT_Memory memory, GX_Blend blend ) { if ( blend != NULL ) { FT_UInt i; FT_FREE( blend->normalizedcoords ); FT_FREE( blend->mmvar ); if ( blend->avar_segment != NULL ) { for ( i = 0; i < blend->num_axis; ++i ) FT_FREE( blend->avar_segment[i].correspondence ); FT_FREE( blend->avar_segment ); } FT_FREE( blend->tuplecoords ); FT_FREE( blend->glyphoffsets ); FT_FREE( blend ); } }
CWE-119
7,752
15,577
208443476197169057566947733525539792956
null
null
null
savannah
59eb9f8cfe7d1df379a2318316d1f04f80fba54a
0
tt_face_vary_cvt( TT_Face face, FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; FT_ULong table_start; FT_ULong table_len; FT_UInt tupleCount; FT_ULong offsetToData; FT_ULong here; FT_UInt i, j; FT_Fixed* tuple_coords = NULL; FT_Fixed* im_start_coords = NULL; FT_Fixed* im_end_coords = NULL; GX_Blend blend = face->blend; FT_UInt point_count; FT_UShort* localpoints; FT_Short* deltas; FT_TRACE2(( "CVAR " )); if ( blend == NULL ) { FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" )); error = TT_Err_Ok; goto Exit; } if ( face->cvt == NULL ) { FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" )); error = TT_Err_Ok; goto Exit; } error = face->goto_table( face, TTAG_cvar, stream, &table_len ); if ( error ) { FT_TRACE2(( "is missing\n" )); error = TT_Err_Ok; goto Exit; } if ( FT_FRAME_ENTER( table_len ) ) { error = TT_Err_Ok; goto Exit; } table_start = FT_Stream_FTell( stream ); if ( FT_GET_LONG() != 0x00010000L ) { FT_TRACE2(( "bad table version\n" )); error = TT_Err_Ok; goto FExit; } if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) || FT_NEW_ARRAY( im_start_coords, blend->num_axis ) || FT_NEW_ARRAY( im_end_coords, blend->num_axis ) ) goto FExit; tupleCount = FT_GET_USHORT(); offsetToData = table_start + FT_GET_USHORT(); /* The documentation implies there are flags packed into the */ /* tuplecount, but John Jenkins says that shared points don't apply */ /* to `cvar', and no other flags are defined. */ for ( i = 0; i < ( tupleCount & 0xFFF ); ++i ) { FT_UInt tupleDataSize; FT_UInt tupleIndex; FT_Fixed apply; tupleDataSize = FT_GET_USHORT(); tupleIndex = FT_GET_USHORT(); /* There is no provision here for a global tuple coordinate section, */ /* so John says. There are no tuple indices, just embedded tuples. */ if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD ) { for ( j = 0; j < blend->num_axis; ++j ) tuple_coords[j] = FT_GET_SHORT() << 2; /* convert from */ /* short frac to fixed */ } else { /* skip this tuple; it makes no sense */ if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) for ( j = 0; j < 2 * blend->num_axis; ++j ) (void)FT_GET_SHORT(); offsetToData += tupleDataSize; continue; } if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) { for ( j = 0; j < blend->num_axis; ++j ) im_start_coords[j] = FT_GET_SHORT() << 2; for ( j = 0; j < blend->num_axis; ++j ) im_end_coords[j] = FT_GET_SHORT() << 2; } apply = ft_var_apply_tuple( blend, (FT_UShort)tupleIndex, tuple_coords, im_start_coords, im_end_coords ); if ( /* tuple isn't active for our blend */ apply == 0 || /* global points not allowed, */ /* if they aren't local, makes no sense */ !( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) ) { offsetToData += tupleDataSize; continue; } here = FT_Stream_FTell( stream ); FT_Stream_SeekSet( stream, offsetToData ); localpoints = ft_var_readpackedpoints( stream, &point_count ); deltas = ft_var_readpackeddeltas( stream, point_count == 0 ? face->cvt_size : point_count ); if ( localpoints == NULL || deltas == NULL ) /* failure, ignore it */; else if ( localpoints == ALL_POINTS ) { /* this means that there are deltas for every entry in cvt */ for ( j = 0; j < face->cvt_size; ++j ) face->cvt[j] = (FT_Short)( face->cvt[j] + FT_MulFix( deltas[j], apply ) ); } else { for ( j = 0; j < point_count; ++j ) { int pindex = localpoints[j]; face->cvt[pindex] = (FT_Short)( face->cvt[pindex] + FT_MulFix( deltas[j], apply ) ); } } if ( localpoints != ALL_POINTS ) FT_FREE( localpoints ); FT_FREE( deltas ); offsetToData += tupleDataSize; FT_Stream_SeekSet( stream, here ); } FExit: FT_FRAME_EXIT(); Exit: FT_FREE( tuple_coords ); FT_FREE( im_start_coords ); FT_FREE( im_end_coords ); return error; }
CWE-119
7,753
15,578
12021061423789488026978047633267998967
null
null
null
ghostscript
39b1e54b2968620723bf32e96764c88797714879
0
append_text_move(pdf_text_state_t *pts, double dw) { int count = pts->buffer.count_moves; int pos = pts->buffer.count_chars; double rounded; if (count > 0 && pts->buffer.moves[count - 1].index == pos) { /* Merge adjacent moves. */ dw += pts->buffer.moves[--count].amount; } /* Round dw if it's very close to an integer. */ rounded = floor(dw + 0.5); if (fabs(dw - rounded) < 0.001) dw = rounded; if (dw < -MAX_USER_COORD) { /* Acrobat reader 4.0c, 5.0 can't handle big offsets. Adobe Reader 6 can. */ return -1; } if (dw != 0) { if (count == MAX_TEXT_BUFFER_MOVES) return -1; pts->buffer.moves[count].index = pos; pts->buffer.moves[count].amount = dw; ++count; } pts->buffer.count_moves = count; return 0; }
CWE-119
7,754
15,579
309698345664930670889264920993211952326
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void __h2_deinit(void) { pool_destroy(pool_head_h2s); pool_destroy(pool_head_h2c); }
CWE-119
7,755
15,580
71333567995758947929089157676741818894
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void __h2_init(void) { alpn_register_mux(&alpn_mux_h2); cfg_register_keywords(&cfg_kws); hap_register_post_deinit(__h2_deinit); pool_head_h2c = create_pool("h2c", sizeof(struct h2c), MEM_F_SHARED); pool_head_h2s = create_pool("h2s", sizeof(struct h2s), MEM_F_SHARED); }
CWE-119
7,756
15,581
236227510973136664282110513794400324977
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_buf_available(void *target) { struct h2c *h2c = target; if ((h2c->flags & H2_CF_DEM_DALLOC) && b_alloc_margin(&h2c->dbuf, 0)) { h2c->flags &= ~H2_CF_DEM_DALLOC; if (h2_recv_allowed(h2c)) conn_xprt_want_recv(h2c->conn); return 1; } if ((h2c->flags & H2_CF_MUX_MALLOC) && b_alloc_margin(&h2c->mbuf, 0)) { h2c->flags &= ~H2_CF_MUX_MALLOC; if (!(h2c->flags & H2_CF_MUX_BLOCK_ANY)) conn_xprt_want_send(h2c->conn); if (h2c->flags & H2_CF_DEM_MROOM) { h2c->flags &= ~H2_CF_DEM_MROOM; if (h2_recv_allowed(h2c)) conn_xprt_want_recv(h2c->conn); } return 1; } return 0; }
CWE-119
7,758
15,582
151751785725708512882817683457432728222
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_detach(struct conn_stream *cs) { struct h2s *h2s = cs->ctx; struct h2c *h2c; cs->ctx = NULL; if (!h2s) return; h2c = h2s->h2c; h2s->cs = NULL; /* this stream may be blocked waiting for some data to leave (possibly * an ES or RST frame), so orphan it in this case. */ if (!(cs->conn->flags & CO_FL_ERROR) && (h2s->flags & (H2_SF_BLK_MBUSY | H2_SF_BLK_MROOM | H2_SF_BLK_MFCTL))) return; if ((h2c->flags & H2_CF_DEM_BLOCK_ANY && h2s->id == h2c->dsi) || (h2c->flags & H2_CF_MUX_BLOCK_ANY && h2s->id == h2c->msi)) { /* unblock the connection if it was blocked on this * stream. */ h2c->flags &= ~H2_CF_DEM_BLOCK_ANY; h2c->flags &= ~H2_CF_MUX_BLOCK_ANY; conn_xprt_want_recv(cs->conn); conn_xprt_want_send(cs->conn); } h2s_destroy(h2s); /* We don't want to close right now unless we're removing the * last stream, and either the connection is in error, or it * reached the ID already specified in a GOAWAY frame received * or sent (as seen by last_sid >= 0). */ if (eb_is_empty(&h2c->streams_by_id) && /* don't close if streams exist */ ((h2c->conn->flags & CO_FL_ERROR) || /* errors close immediately */ (h2c->flags & H2_CF_GOAWAY_FAILED) || (!h2c->mbuf->o && /* mux buffer empty, also process clean events below */ (conn_xprt_read0_pending(h2c->conn) || (h2c->last_sid >= 0 && h2c->max_id >= h2c->last_sid))))) { /* no more stream will come, kill it now */ h2_release(h2c->conn); } else if (h2c->task) { if (eb_is_empty(&h2c->streams_by_id) || h2c->mbuf->o) { h2c->task->expire = tick_add(now_ms, h2c->last_sid < 0 ? h2c->timeout : h2c->shut_timeout); task_queue(h2c->task); } else h2c->task->expire = TICK_ETERNITY; } }
CWE-119
7,759
15,583
128989728916700945610326751425724071493
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_frt_transfer_data(struct h2s *h2s, struct buffer *buf, int count) { struct h2c *h2c = h2s->h2c; int block1, block2; unsigned int flen = h2c->dfl; h2s->cs->flags &= ~CS_FL_RCV_MORE; h2c->flags &= ~H2_CF_DEM_SFULL; /* The padlen is the first byte before data, and the padding appears * after data. padlen+data+padding are included in flen. */ if (h2c->dff & H2_F_DATA_PADDED) { if (h2c->dbuf->i < 1) return 0; h2c->dpl = *(uint8_t *)bi_ptr(h2c->dbuf); if (h2c->dpl >= h2c->dfl) { /* RFC7540#6.1 : pad length = length of frame payload or greater */ h2c_error(h2c, H2_ERR_PROTOCOL_ERROR); return 0; } /* skip the padlen byte */ bi_del(h2c->dbuf, 1); h2c->dfl--; h2c->rcvd_c++; h2c->rcvd_s++; h2c->dff &= ~H2_F_DATA_PADDED; } flen = h2c->dfl - h2c->dpl; if (!flen) goto end_transfer; if (flen > h2c->dbuf->i) { flen = h2c->dbuf->i; if (!flen) return 0; } /* does it fit in output buffer or should we wait ? */ if (flen > count) { flen = count; if (!flen) { h2c->flags |= H2_CF_DEM_SFULL; h2s->cs->flags |= CS_FL_RCV_MORE; return 0; } } /* Block1 is the length of the first block before the buffer wraps, * block2 is the optional second block to reach the end of the frame. */ block1 = bi_contig_data(h2c->dbuf); if (block1 > flen) block1 = flen; block2 = flen - block1; if (block1) bi_putblk(buf, b_ptr(h2c->dbuf, 0), block1); if (block2) bi_putblk(buf, b_ptr(h2c->dbuf, block1), block2); /* now mark the input data as consumed (will be deleted from the buffer * by the caller when seeing FRAME_A after sending the window update). */ bi_del(h2c->dbuf, flen); h2c->dfl -= flen; h2c->rcvd_c += flen; h2c->rcvd_s += flen; // warning, this can also affect the closed streams! if (h2c->dfl > h2c->dpl) { /* more data available, transfer stalled on stream full */ h2c->flags |= H2_CF_DEM_SFULL; h2s->cs->flags |= CS_FL_RCV_MORE; return flen; } end_transfer: /* here we're done with the frame, all the payload (except padding) was * transferred. */ h2c->rcvd_c += h2c->dpl; h2c->rcvd_s += h2c->dpl; h2c->dpl = 0; h2c->st0 = H2_CS_FRAME_A; // send the corresponding window update /* don't send it before returning data! * FIXME: should we instead try to send it much later, after the * response ? This would require that we keep a copy of it in h2s. */ if (h2c->dff & H2_F_DATA_END_STREAM) { h2s->cs->flags |= CS_FL_EOS; h2s->flags |= H2_SF_ES_RCVD; } return flen; }
CWE-119
7,761
15,584
337212494394096334796956908250077982036
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline struct buffer *h2_get_buf(struct h2c *h2c, struct buffer **bptr) { struct buffer *buf = NULL; if (likely(LIST_ISEMPTY(&h2c->buf_wait.list)) && unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) { h2c->buf_wait.target = h2c; h2c->buf_wait.wakeup_cb = h2_buf_available; HA_SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock); LIST_ADDQ(&buffer_wq, &h2c->buf_wait.list); HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock); __conn_xprt_stop_recv(h2c->conn); } return buf; }
CWE-119
7,762
15,585
257511545027476691143213399658260051978
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused uint32_t h2_get_n32(const struct buffer *b, int o) { return readv_n32(b_ptr(b, o), b_end(b) - b_ptr(b, o), b->data); }
CWE-119
7,765
15,586
62844930446244770032658528436219357004
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused uint64_t h2_get_n64(const struct buffer *b, int o) { return readv_n64(b_ptr(b, o), b_end(b) - b_ptr(b, o), b->data); }
CWE-119
7,766
15,587
116428694020869648375560374709855868990
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_init(struct connection *conn) { if (conn->mux_ctx) { /* we don't support outgoing connections for now */ return -1; } return h2c_frt_init(conn); }
CWE-119
7,767
15,588
5517686850874099546355263673633217123
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_parse_header_table_size(char **args, int section_type, struct proxy *curpx, struct proxy *defpx, const char *file, int line, char **err) { if (too_many_args(1, args, err, NULL)) return -1; h2_settings_header_table_size = atoi(args[1]); if (h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) { memprintf(err, "'%s' expects a numeric value between 4096 and 65536.", args[0]); return -1; } return 0; }
CWE-119
7,768
15,589
98227586260593415578647185229080426950
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_parse_initial_window_size(char **args, int section_type, struct proxy *curpx, struct proxy *defpx, const char *file, int line, char **err) { if (too_many_args(1, args, err, NULL)) return -1; h2_settings_initial_window_size = atoi(args[1]); if (h2_settings_initial_window_size < 0) { memprintf(err, "'%s' expects a positive numeric value.", args[0]); return -1; } return 0; }
CWE-119
7,769
15,590
323355058541305893806294570907787739766
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_parse_max_concurrent_streams(char **args, int section_type, struct proxy *curpx, struct proxy *defpx, const char *file, int line, char **err) { if (too_many_args(1, args, err, NULL)) return -1; h2_settings_max_concurrent_streams = atoi(args[1]); if (h2_settings_max_concurrent_streams < 0) { memprintf(err, "'%s' expects a positive numeric value.", args[0]); return -1; } return 0; }
CWE-119
7,770
15,591
269629674629943918646835609897830468961
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static __maybe_unused int h2_peek_frame_hdr(const struct buffer *b, struct h2_fh *h) { uint64_t w; if (b->i < 9) return 0; w = readv_n64(b_ptr(b,1), b_end(b) - b_ptr(b,1), b->data); h->len = *b->p << 16; h->sid = w & 0x7FFFFFFF; /* RFC7540#4.1: R bit must be ignored */ h->ff = w >> 32; h->ft = w >> 40; h->len += w >> 48; return 1; }
CWE-119
7,771
15,592
301394280374455202375280173923798413221
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_process_mux(struct h2c *h2c) { struct h2s *h2s, *h2s_back; /* start by sending possibly pending window updates */ if (h2c->rcvd_c > 0 && !(h2c->flags & (H2_CF_MUX_MFULL | H2_CF_MUX_MALLOC)) && h2c_send_conn_wu(h2c) < 0) goto fail; /* First we always process the flow control list because the streams * waiting there were already elected for immediate emission but were * blocked just on this. */ list_for_each_entry_safe(h2s, h2s_back, &h2c->fctl_list, list) { if (h2c->mws <= 0 || h2c->flags & H2_CF_MUX_BLOCK_ANY || h2c->st0 >= H2_CS_ERROR) break; /* In theory it's possible that h2s->cs == NULL here : * - client sends crap that causes a parse error * - RST_STREAM is produced and CS_FL_ERROR at the same time * - RST_STREAM cannot be emitted because mux is busy/full * - stream gets notified, detaches and quits * - mux buffer gets ready and wakes pending streams up * - bam! */ h2s->flags &= ~H2_SF_BLK_ANY; if (h2s->cs) { h2s->cs->data_cb->send(h2s->cs); h2s->cs->data_cb->wake(h2s->cs); } else { h2s_send_rst_stream(h2c, h2s); } /* depending on callee's blocking reasons, we may queue in send * list or completely dequeue. */ if ((h2s->flags & H2_SF_BLK_MFCTL) == 0) { if (h2s->flags & H2_SF_BLK_ANY) { LIST_DEL(&h2s->list); LIST_ADDQ(&h2c->send_list, &h2s->list); } else { LIST_DEL(&h2s->list); LIST_INIT(&h2s->list); if (h2s->cs) h2s->cs->flags &= ~CS_FL_DATA_WR_ENA; else { /* just sent the last frame for this orphaned stream */ h2s_destroy(h2s); } } } } list_for_each_entry_safe(h2s, h2s_back, &h2c->send_list, list) { if (h2c->st0 >= H2_CS_ERROR || h2c->flags & H2_CF_MUX_BLOCK_ANY) break; /* In theory it's possible that h2s->cs == NULL here : * - client sends crap that causes a parse error * - RST_STREAM is produced and CS_FL_ERROR at the same time * - RST_STREAM cannot be emitted because mux is busy/full * - stream gets notified, detaches and quits * - mux buffer gets ready and wakes pending streams up * - bam! */ h2s->flags &= ~H2_SF_BLK_ANY; if (h2s->cs) { h2s->cs->data_cb->send(h2s->cs); h2s->cs->data_cb->wake(h2s->cs); } else { h2s_send_rst_stream(h2c, h2s); } /* depending on callee's blocking reasons, we may queue in fctl * list or completely dequeue. */ if (h2s->flags & H2_SF_BLK_MFCTL) { /* stream hit the connection's flow control */ LIST_DEL(&h2s->list); LIST_ADDQ(&h2c->fctl_list, &h2s->list); } else if (!(h2s->flags & H2_SF_BLK_ANY)) { LIST_DEL(&h2s->list); LIST_INIT(&h2s->list); if (h2s->cs) h2s->cs->flags &= ~CS_FL_DATA_WR_ENA; else { /* just sent the last frame for this orphaned stream */ h2s_destroy(h2s); } } } fail: if (unlikely(h2c->st0 >= H2_CS_ERROR)) { if (h2c->st0 == H2_CS_ERROR) { if (h2c->max_id >= 0) { h2c_send_goaway_error(h2c, NULL); if (h2c->flags & H2_CF_MUX_BLOCK_ANY) return 0; } h2c->st0 = H2_CS_ERROR2; // sent (or failed hard) ! } return 1; } return (h2c->mws <= 0 || LIST_ISEMPTY(&h2c->fctl_list)) && LIST_ISEMPTY(&h2c->send_list); }
CWE-119
7,772
15,593
227692449274959441210978836268483730422
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, int count) { struct h2s *h2s = cs->ctx; struct h2c *h2c = h2s->h2c; int ret = 0; if (h2c->st0 != H2_CS_FRAME_P) return 0; // no pre-parsed frame yet if (h2c->dsi != h2s->id) return 0; // not for us if (!h2c->dbuf->size) return 0; // empty buffer switch (h2c->dft) { case H2_FT_HEADERS: ret = h2_frt_decode_headers(h2s, buf, count); break; case H2_FT_DATA: ret = h2_frt_transfer_data(h2s, buf, count); break; default: ret = 0; } return ret; }
CWE-119
7,773
15,594
116021702836138925070129263137973997068
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_recv(struct connection *conn) { struct h2c *h2c = conn->mux_ctx; struct buffer *buf; int max; if (!h2_recv_allowed(h2c)) return; buf = h2_get_buf(h2c, &h2c->dbuf); if (!buf) { h2c->flags |= H2_CF_DEM_DALLOC; return; } /* note: buf->o == 0 */ max = buf->size - buf->i; if (max) conn->xprt->rcv_buf(conn, buf, max); if (!buf->i) { h2_release_buf(h2c, &h2c->dbuf); return; } if (buf->i == buf->size) h2c->flags |= H2_CF_DEM_DFULL; return; }
CWE-119
7,774
15,595
186148895390861663627547407941099588480
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline int h2_recv_allowed(const struct h2c *h2c) { if (h2c->dbuf->i == 0 && (h2c->st0 >= H2_CS_ERROR || h2c->conn->flags & CO_FL_ERROR || conn_xprt_read0_pending(h2c->conn))) return 0; if (!(h2c->flags & H2_CF_DEM_DALLOC) && !(h2c->flags & H2_CF_DEM_BLOCK_ANY)) return 1; return 0; }
CWE-119
7,775
15,596
72605635119539676208828961798424723284
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_release(struct connection *conn) { struct h2c *h2c = conn->mux_ctx; LIST_DEL(&conn->list); if (h2c) { hpack_dht_free(h2c->ddht); HA_SPIN_LOCK(BUF_WQ_LOCK, &buffer_wq_lock); LIST_DEL(&h2c->buf_wait.list); HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock); h2_release_buf(h2c, &h2c->dbuf); h2_release_buf(h2c, &h2c->mbuf); if (h2c->task) { h2c->task->context = NULL; task_wakeup(h2c->task, TASK_WOKEN_OTHER); h2c->task = NULL; } pool_free(pool_head_h2c, h2c); } conn->mux = NULL; conn->mux_ctx = NULL; conn_stop_tracking(conn); conn_full_close(conn); if (conn->destroy_cb) conn->destroy_cb(conn); conn_free(conn); }
CWE-119
7,776
15,597
122611300324965391759012563464974058676
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline void h2_release_buf(struct h2c *h2c, struct buffer **bptr) { if ((*bptr)->size) { b_free(bptr); offer_buffers(h2c->buf_wait.target, tasks_run_queue + applets_active_queue); } }
CWE-119
7,777
15,598
35537115755985564879177888228146537579
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_send(struct connection *conn) { struct h2c *h2c = conn->mux_ctx; int done; if (conn->flags & CO_FL_ERROR) return; if (conn->flags & (CO_FL_HANDSHAKE|CO_FL_WAIT_L4_CONN|CO_FL_WAIT_L6_CONN)) { /* a handshake was requested */ return; } /* This loop is quite simple : it tries to fill as much as it can from * pending streams into the existing buffer until it's reportedly full * or the end of send requests is reached. Then it tries to send this * buffer's contents out, marks it not full if at least one byte could * be sent, and tries again. * * The snd_buf() function normally takes a "flags" argument which may * be made of a combination of CO_SFL_MSG_MORE to indicate that more * data immediately comes and CO_SFL_STREAMER to indicate that the * connection is streaming lots of data (used to increase TLS record * size at the expense of latency). The former can be sent any time * there's a buffer full flag, as it indicates at least one stream * attempted to send and failed so there are pending data. An * alternative would be to set it as long as there's an active stream * but that would be problematic for ACKs until we have an absolute * guarantee that all waiters have at least one byte to send. The * latter should possibly not be set for now. */ done = 0; while (!done) { unsigned int flags = 0; /* fill as much as we can into the current buffer */ while (((h2c->flags & (H2_CF_MUX_MFULL|H2_CF_MUX_MALLOC)) == 0) && !done) done = h2_process_mux(h2c); if (conn->flags & CO_FL_ERROR) break; if (h2c->flags & (H2_CF_MUX_MFULL | H2_CF_DEM_MBUSY | H2_CF_DEM_MROOM)) flags |= CO_SFL_MSG_MORE; if (h2c->mbuf->o && conn->xprt->snd_buf(conn, h2c->mbuf, flags) <= 0) break; /* wrote at least one byte, the buffer is not full anymore */ h2c->flags &= ~(H2_CF_MUX_MFULL | H2_CF_DEM_MROOM); } if (conn->flags & CO_FL_SOCK_WR_SH) { /* output closed, nothing to send, clear the buffer to release it */ h2c->mbuf->o = 0; } }
CWE-119
7,778
15,599
235234553558552278807963071454339652898
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_send_empty_data_es(struct h2s *h2s) { struct h2c *h2c = h2s->h2c; struct buffer *res; char str[9]; int ret; if (h2s->st == H2_SS_HLOC || h2s->st == H2_SS_ERROR || h2s->st == H2_SS_CLOSED) return 1; 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: 0x000000, type: 0(DATA), flags: ES=1 */ memcpy(str, "\x00\x00\x00\x00\x01", 5); write_n32(str + 5, h2s->id); ret = bo_istput(res, ist2(str, 9)); if (likely(ret > 0)) { h2s->flags |= H2_SF_ES_SENT; } else 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; } return ret; }
CWE-119
7,779
15,600
111137664603309651950724343954065395386
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused void h2_set_frame_size(void *frame, uint32_t len) { uint8_t *out = frame; *out = len >> 16; write_n16(out + 1, len); }
CWE-119
7,780
15,601
132003103376394401240026381317540753847
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_show_fd(struct chunk *msg, struct connection *conn) { struct h2c *h2c = conn->mux_ctx; struct h2s *h2s; struct eb32_node *node; int fctl_cnt = 0; int send_cnt = 0; int tree_cnt = 0; int orph_cnt = 0; if (!h2c) return; list_for_each_entry(h2s, &h2c->fctl_list, list) fctl_cnt++; list_for_each_entry(h2s, &h2c->send_list, list) send_cnt++; node = eb32_first(&h2c->streams_by_id); while (node) { h2s = container_of(node, struct h2s, by_id); tree_cnt++; if (!h2s->cs) orph_cnt++; node = eb32_next(node); } chunk_appendf(msg, " st0=%d flg=0x%08x fctl_cnt=%d send_cnt=%d tree_cnt=%d orph_cnt=%d", h2c->st0, h2c->flags, fctl_cnt, send_cnt, tree_cnt, orph_cnt); }
CWE-119
7,781
15,602
249910222513496487967856525207110155793
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode) { struct h2s *h2s = cs->ctx; if (!mode) return; if (h2s->st == H2_SS_HLOC || h2s->st == H2_SS_ERROR || h2s->st == H2_SS_CLOSED) return; /* if no outgoing data was seen on this stream, it means it was * closed with a "tcp-request content" rule that is normally * used to kill the connection ASAP (eg: limit abuse). In this * case we send a goaway to close the connection. */ if (!(h2s->flags & H2_SF_RST_SENT) && h2s_send_rst_stream(h2s->h2c, h2s) <= 0) goto add_to_list; if (!(h2s->flags & H2_SF_OUTGOING_DATA) && !(h2s->h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED)) && h2c_send_goaway_error(h2s->h2c, h2s) <= 0) goto add_to_list; if (h2s->h2c->mbuf->o && !(cs->conn->flags & CO_FL_XPRT_WR_ENA)) conn_xprt_want_send(cs->conn); h2s_close(h2s); add_to_list: if (LIST_ISEMPTY(&h2s->list)) { if (h2s->flags & H2_SF_BLK_MFCTL) LIST_ADDQ(&h2s->h2c->fctl_list, &h2s->list); else if (h2s->flags & (H2_SF_BLK_MBUSY|H2_SF_BLK_MROOM)) LIST_ADDQ(&h2s->h2c->send_list, &h2s->list); } }
CWE-119
7,782
15,603
184460882756776312192777249802065359971
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode) { struct h2s *h2s = cs->ctx; if (h2s->st == H2_SS_HLOC || h2s->st == H2_SS_ERROR || h2s->st == H2_SS_CLOSED) return; if (h2s->flags & H2_SF_HEADERS_SENT) { /* we can cleanly close using an empty data frame only after headers */ if (!(h2s->flags & (H2_SF_ES_SENT|H2_SF_RST_SENT)) && h2_send_empty_data_es(h2s) <= 0) goto add_to_list; if (h2s->st == H2_SS_HREM) h2s_close(h2s); else h2s->st = H2_SS_HLOC; } else { /* if no outgoing data was seen on this stream, it means it was * closed with a "tcp-request content" rule that is normally * used to kill the connection ASAP (eg: limit abuse). In this * case we send a goaway to close the connection. */ if (!(h2s->flags & H2_SF_RST_SENT) && h2s_send_rst_stream(h2s->h2c, h2s) <= 0) goto add_to_list; if (!(h2s->flags & H2_SF_OUTGOING_DATA) && !(h2s->h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED)) && h2c_send_goaway_error(h2s->h2c, h2s) <= 0) goto add_to_list; h2s_close(h2s); } if (h2s->h2c->mbuf->o && !(cs->conn->flags & CO_FL_XPRT_WR_ENA)) conn_xprt_want_send(cs->conn); add_to_list: if (LIST_ISEMPTY(&h2s->list)) { if (h2s->flags & H2_SF_BLK_MFCTL) LIST_ADDQ(&h2s->h2c->fctl_list, &h2s->list); else if (h2s->flags & (H2_SF_BLK_MBUSY|H2_SF_BLK_MROOM)) LIST_ADDQ(&h2s->h2c->send_list, &h2s->list); } }
CWE-119
7,783
15,604
172695112764824274046453629669306074540
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused void h2_skip_frame_hdr(struct buffer *b) { bi_del(b, 9); }
CWE-119
7,784
15,605
211789348989532481476065292798783651873
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_snd_buf(struct conn_stream *cs, struct buffer *buf, int flags) { struct h2s *h2s = cs->ctx; int total = 0; if (!(h2s->flags & H2_SF_OUTGOING_DATA) && buf->o) h2s->flags |= H2_SF_OUTGOING_DATA; while (h2s->res.state < HTTP_MSG_DONE && buf->o) { if (h2s->res.state < HTTP_MSG_BODY) { total += h2s_frt_make_resp_headers(h2s, buf); if (h2s->st >= H2_SS_ERROR) break; if (h2s->flags & H2_SF_BLK_ANY) break; } else if (h2s->res.state < HTTP_MSG_TRAILERS) { total += h2s_frt_make_resp_data(h2s, buf); if (h2s->st >= H2_SS_ERROR) break; if (h2s->flags & H2_SF_BLK_ANY) break; } else if (h2s->res.state == HTTP_MSG_TRAILERS) { /* consume the trailers if any (we don't forward them for now) */ int count = h1_measure_trailers(buf); if (unlikely(count <= 0)) { if (count < 0) h2s_error(h2s, H2_ERR_INTERNAL_ERROR); break; } total += count; bo_del(buf, count); bo_del(buf, buf->o); h2s->res.state = HTTP_MSG_DONE; break; } else { cs->flags |= CS_FL_ERROR; break; } } /* RST are sent similarly to frame acks */ if (h2s->st == H2_SS_ERROR || h2s->flags & H2_SF_RST_RCVD) { cs->flags |= CS_FL_ERROR; if (h2s_send_rst_stream(h2s->h2c, h2s) > 0) h2s_close(h2s); } if (h2s->flags & H2_SF_BLK_SFCTL) { /* stream flow control, quit the list */ LIST_DEL(&h2s->list); LIST_INIT(&h2s->list); } else if (LIST_ISEMPTY(&h2s->list)) { if (h2s->flags & H2_SF_BLK_MFCTL) LIST_ADDQ(&h2s->h2c->fctl_list, &h2s->list); else if (h2s->flags & (H2_SF_BLK_MBUSY|H2_SF_BLK_MROOM)) LIST_ADDQ(&h2s->h2c->send_list, &h2s->list); } return total; }
CWE-119
7,785
15,606
24143983146075972373640407200439244843
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static struct task *h2_timeout_task(struct task *t) { struct h2c *h2c = t->context; int expired = tick_is_expired(t->expire, now_ms); if (!expired && h2c) return t; task_delete(t); task_free(t); if (!h2c) { /* resources were already deleted */ return NULL; } h2c->task = NULL; h2c_error(h2c, H2_ERR_NO_ERROR); h2_wake_some_streams(h2c, 0, 0); if (h2c->mbuf->o) { /* don't even try to send a GOAWAY, the buffer is stuck */ h2c->flags |= H2_CF_GOAWAY_FAILED; } /* try to send but no need to insist */ h2c->last_sid = h2c->max_id; if (h2c_send_goaway_error(h2c, NULL) <= 0) h2c->flags |= H2_CF_GOAWAY_FAILED; if (h2c->mbuf->o && !(h2c->flags & H2_CF_GOAWAY_FAILED) && conn_xprt_ready(h2c->conn)) h2c->conn->xprt->snd_buf(h2c->conn, h2c->mbuf, 0); /* either we can release everything now or it will be done later once * the last stream closes. */ if (eb_is_empty(&h2c->streams_by_id)) h2_release(h2c->conn); return NULL; }
CWE-119
7,786
15,607
218403721116115110301615617266354800761
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_update_poll(struct conn_stream *cs) { struct h2s *h2s = cs->ctx; if (!h2s) return; /* we may unblock a blocked read */ if (cs->flags & CS_FL_DATA_RD_ENA) { /* the stream indicates it's willing to read */ h2s->h2c->flags &= ~H2_CF_DEM_SFULL; if (h2s->h2c->dsi == h2s->id) { conn_xprt_want_recv(cs->conn); conn_xprt_want_send(cs->conn); } } /* Note: the stream and stream-int code doesn't allow us to perform a * synchronous send() here unfortunately, because this code is called * as si_update() from the process_stream() context. This means that * we have to queue the current cs and defer its processing after the * connection's cs list is processed anyway. */ if (cs->flags & CS_FL_DATA_WR_ENA) { if (LIST_ISEMPTY(&h2s->list)) { if (LIST_ISEMPTY(&h2s->h2c->send_list) && !h2s->h2c->mbuf->o && // not yet subscribed !(cs->conn->flags & CO_FL_SOCK_WR_SH)) conn_xprt_want_send(cs->conn); LIST_ADDQ(&h2s->h2c->send_list, &h2s->list); } } else if (!LIST_ISEMPTY(&h2s->list)) { LIST_DEL(&h2s->list); LIST_INIT(&h2s->list); h2s->flags &= ~(H2_SF_BLK_MBUSY | H2_SF_BLK_MROOM | H2_SF_BLK_MFCTL); } /* this can happen from within si_chk_snd() */ if (h2s->h2c->mbuf->o && !(cs->conn->flags & CO_FL_XPRT_WR_ENA)) conn_xprt_want_send(cs->conn); }
CWE-119
7,787
15,608
147124141727436707803313525434035894224
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2_wake(struct connection *conn) { struct h2c *h2c = conn->mux_ctx; struct session *sess = conn->owner; if (h2c->dbuf->i && !(h2c->flags & H2_CF_DEM_BLOCK_ANY)) { h2_process_demux(h2c); if (h2c->st0 >= H2_CS_ERROR || conn->flags & CO_FL_ERROR) h2c->dbuf->i = 0; if (h2c->dbuf->i != h2c->dbuf->size) h2c->flags &= ~H2_CF_DEM_DFULL; } if (sess && unlikely(sess->fe->state == PR_STSTOPPED)) { /* frontend is stopping, reload likely in progress, let's try * to announce a graceful shutdown if not yet done. We don't * care if it fails, it will be tried again later. */ if (!(h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED))) { if (h2c->last_sid < 0) h2c->last_sid = (1U << 31) - 1; h2c_send_goaway_error(h2c, NULL); } } /* * If we received early data, and the handshake is done, wake * any stream that was waiting for it. */ if (!(h2c->flags & H2_CF_WAIT_FOR_HS) && (conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_HANDSHAKE | CO_FL_EARLY_DATA)) == CO_FL_EARLY_DATA) { struct eb32_node *node; struct h2s *h2s; h2c->flags |= H2_CF_WAIT_FOR_HS; node = eb32_lookup_ge(&h2c->streams_by_id, 1); while (node) { h2s = container_of(node, struct h2s, by_id); if (h2s->cs->flags & CS_FL_WAIT_FOR_HS) h2s->cs->data_cb->wake(h2s->cs); node = eb32_next(node); } } if (conn->flags & CO_FL_ERROR || conn_xprt_read0_pending(conn) || h2c->st0 == H2_CS_ERROR2 || h2c->flags & H2_CF_GOAWAY_FAILED || (eb_is_empty(&h2c->streams_by_id) && h2c->last_sid >= 0 && h2c->max_id >= h2c->last_sid)) { h2_wake_some_streams(h2c, 0, 0); if (eb_is_empty(&h2c->streams_by_id)) { /* no more stream, kill the connection now */ h2_release(conn); return -1; } else { /* some streams still there, we need to signal them all and * wait for their departure. */ __conn_xprt_stop_recv(conn); __conn_xprt_stop_send(conn); return 0; } } if (!h2c->dbuf->i) h2_release_buf(h2c, &h2c->dbuf); /* stop being notified of incoming data if we can't process them */ if (!h2_recv_allowed(h2c)) { __conn_xprt_stop_recv(conn); } else { __conn_xprt_want_recv(conn); } /* adjust output polling */ if (!(conn->flags & CO_FL_SOCK_WR_SH) && (h2c->st0 == H2_CS_ERROR || h2c->mbuf->o || (h2c->mws > 0 && !LIST_ISEMPTY(&h2c->fctl_list)) || (!(h2c->flags & H2_CF_MUX_BLOCK_ANY) && !LIST_ISEMPTY(&h2c->send_list)))) { __conn_xprt_want_send(conn); } else { h2_release_buf(h2c, &h2c->mbuf); __conn_xprt_stop_send(conn); } if (h2c->task) { if (eb_is_empty(&h2c->streams_by_id) || h2c->mbuf->o) { h2c->task->expire = tick_add(now_ms, h2c->last_sid < 0 ? h2c->timeout : h2c->shut_timeout); task_queue(h2c->task); } else h2c->task->expire = TICK_ETERNITY; } return 0; }
CWE-119
7,788
15,609
54292309611214149469904012818882494505
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2_wake_some_streams(struct h2c *h2c, int last, uint32_t flags) { struct eb32_node *node; struct h2s *h2s; if (h2c->st0 >= H2_CS_ERROR || h2c->conn->flags & CO_FL_ERROR) flags |= CS_FL_ERROR; if (conn_xprt_read0_pending(h2c->conn)) flags |= CS_FL_EOS; node = eb32_lookup_ge(&h2c->streams_by_id, last + 1); while (node) { h2s = container_of(node, struct h2s, by_id); if (h2s->id <= last) break; node = eb32_next(node); if (!h2s->cs) { /* this stream was already orphaned */ h2s_destroy(h2s); continue; } h2s->cs->flags |= flags; /* recv is used to force to detect CS_FL_EOS that wake() * doesn't handle in the stream int code. */ h2s->cs->data_cb->recv(h2s->cs); h2s->cs->data_cb->wake(h2s->cs); if (flags & CS_FL_ERROR && h2s->st < H2_SS_ERROR) h2s->st = H2_SS_ERROR; else if (flags & CS_FL_EOS && h2s->st == H2_SS_OPEN) h2s->st = H2_SS_HREM; else if (flags & CS_FL_EOS && h2s->st == H2_SS_HLOC) h2s_close(h2s); } }
CWE-119
7,789
15,610
33598846060004711176661012488082310678
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_ack_settings(struct h2c *h2c) { struct buffer *res; char str[9]; int ret = -1; if (h2c_mux_busy(h2c, NULL)) { h2c->flags |= H2_CF_DEM_MBUSY; return 0; } res = h2_get_buf(h2c, &h2c->mbuf); if (!res) { h2c->flags |= H2_CF_MUX_MALLOC; h2c->flags |= H2_CF_DEM_MROOM; return 0; } memcpy(str, "\x00\x00\x00" /* length : 0 (no data) */ "\x04" "\x01" /* type : 4, flags : ACK */ "\x00\x00\x00\x00" /* stream ID */, 9); ret = bo_istput(res, ist2(str, 9)); if (unlikely(ret <= 0)) { if (!ret) { h2c->flags |= H2_CF_MUX_MFULL; h2c->flags |= H2_CF_DEM_MROOM; return 0; } else { h2c_error(h2c, H2_ERR_INTERNAL_ERROR); return 0; } } return ret; }
CWE-119
7,790
15,611
304033050333638090481497017736076567306
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused void h2c_error(struct h2c *h2c, enum h2_err err) { h2c->errcode = err; h2c->st0 = H2_CS_ERROR; }
CWE-119
7,791
15,612
203601683362566603456581041941294877021
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s) { int error; if (!h2c->dfl) { error = H2_ERR_PROTOCOL_ERROR; // empty headers frame! goto strm_err; } if (!h2c->dbuf->size) return 0; // empty buffer if (h2c->dbuf->i < h2c->dfl && h2c->dbuf->i < h2c->dbuf->size) return 0; // incomplete frame /* now either the frame is complete or the buffer is complete */ if (h2s->st != H2_SS_IDLE) { /* FIXME: stream already exists, this is only allowed for * trailers (not supported for now). */ error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } else if (h2c->dsi <= h2c->max_id || !(h2c->dsi & 1)) { /* RFC7540#5.1.1 stream id > prev ones, and must be odd here */ error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } h2s = h2c_stream_new(h2c, h2c->dsi); if (!h2s) { error = H2_ERR_INTERNAL_ERROR; goto conn_err; } h2s->st = H2_SS_OPEN; if (h2c->dff & H2_F_HEADERS_END_STREAM) { h2s->st = H2_SS_HREM; h2s->flags |= H2_SF_ES_RCVD; } /* call the upper layers to process the frame, then let the upper layer * notify the stream about any change. */ h2s->cs->data_cb->recv(h2s->cs); if (h2s->cs->data_cb->wake(h2s->cs) < 0) { /* FIXME: cs has already been destroyed, but we have to kill h2s. */ error = H2_ERR_INTERNAL_ERROR; goto conn_err; } if (h2c->st0 >= H2_CS_ERROR) return 0; if (h2s->st >= H2_SS_ERROR) { /* stream error : send RST_STREAM */ h2c->st0 = H2_CS_FRAME_E; } else { /* update the max stream ID if the request is being processed */ if (h2s->id > h2c->max_id) h2c->max_id = h2s->id; } return 1; conn_err: h2c_error(h2c, error); return 0; strm_err: if (h2s) { h2s_error(h2s, error); h2c->st0 = H2_CS_FRAME_E; } else h2c_error(h2c, error); return 0; }
CWE-119
7,793
15,613
183725007302530520098440206105359457198
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_frt_init(struct connection *conn) { struct h2c *h2c; struct task *t = NULL; struct session *sess = conn->owner; h2c = pool_alloc(pool_head_h2c); if (!h2c) goto fail; h2c->shut_timeout = h2c->timeout = sess->fe->timeout.client; if (tick_isset(sess->fe->timeout.clientfin)) h2c->shut_timeout = sess->fe->timeout.clientfin; h2c->task = NULL; if (tick_isset(h2c->timeout)) { t = task_new(tid_bit); if (!t) goto fail; h2c->task = t; t->process = h2_timeout_task; t->context = h2c; t->expire = tick_add(now_ms, h2c->timeout); } h2c->ddht = hpack_dht_alloc(h2_settings_header_table_size); if (!h2c->ddht) goto fail; /* Initialise the context. */ h2c->st0 = H2_CS_PREFACE; h2c->conn = conn; h2c->max_id = -1; h2c->errcode = H2_ERR_NO_ERROR; h2c->flags = H2_CF_NONE; h2c->rcvd_c = 0; h2c->rcvd_s = 0; h2c->nb_streams = 0; h2c->dbuf = &buf_empty; h2c->dsi = -1; h2c->msi = -1; h2c->last_sid = -1; h2c->mbuf = &buf_empty; h2c->miw = 65535; /* mux initial window size */ h2c->mws = 65535; /* mux window size */ h2c->mfs = 16384; /* initial max frame size */ h2c->streams_by_id = EB_ROOT_UNIQUE; LIST_INIT(&h2c->send_list); LIST_INIT(&h2c->fctl_list); LIST_INIT(&h2c->buf_wait.list); conn->mux_ctx = h2c; if (t) task_queue(t); conn_xprt_want_recv(conn); /* mux->wake will be called soon to complete the operation */ return 0; fail: if (t) task_free(t); pool_free(pool_head_h2c, h2c); return -1; }
CWE-119
7,794
15,614
297771289495637832154054840029475336225
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_frt_recv_preface(struct h2c *h2c) { int ret1; int ret2; ret1 = b_isteq(h2c->dbuf, 0, h2c->dbuf->i, ist(H2_CONN_PREFACE)); if (unlikely(ret1 <= 0)) { if (ret1 < 0 || conn_xprt_read0_pending(h2c->conn)) h2c_error(h2c, H2_ERR_PROTOCOL_ERROR); return 0; } ret2 = h2c_snd_settings(h2c); if (ret2 > 0) bi_del(h2c->dbuf, ret1); return ret2; }
CWE-119
7,795
15,615
316476265047878673657972607491587214021
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_handle_goaway(struct h2c *h2c) { int error; int last; if (h2c->dsi != 0) { error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } if (h2c->dfl < 8) { error = H2_ERR_FRAME_SIZE_ERROR; goto conn_err; } /* process full frame only */ if (h2c->dbuf->i < h2c->dfl) return 0; last = h2_get_n32(h2c->dbuf, 0); h2c->errcode = h2_get_n32(h2c->dbuf, 4); h2_wake_some_streams(h2c, last, CS_FL_ERROR); if (h2c->last_sid < 0) h2c->last_sid = last; return 1; conn_err: h2c_error(h2c, error); return 0; }
CWE-119
7,796
15,616
227786989108810493799184266465329537984
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_handle_ping(struct h2c *h2c) { /* frame length must be exactly 8 */ if (h2c->dfl != 8) { h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR); return 0; } /* schedule a response */ if (!(h2c->dff & H2_F_PING_ACK)) h2c->st0 = H2_CS_FRAME_A; return 1; }
CWE-119
7,797
15,617
45473568088657818429156791251272580274
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_handle_priority(struct h2c *h2c) { int error; if (h2c->dsi == 0) { error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } if (h2c->dfl != 5) { error = H2_ERR_FRAME_SIZE_ERROR; goto conn_err; } /* process full frame only */ if (h2c->dbuf->i < h2c->dfl) return 0; if (h2_get_n32(h2c->dbuf, 0) == h2c->dsi) { /* 7540#5.3 : can't depend on itself */ error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } return 1; conn_err: h2c_error(h2c, error); return 0; }
CWE-119
7,798
15,618
124980732968823520034155978245713081275
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_handle_rst_stream(struct h2c *h2c, struct h2s *h2s) { int error; if (h2c->dsi == 0) { error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } if (h2c->dfl != 4) { error = H2_ERR_FRAME_SIZE_ERROR; goto conn_err; } /* process full frame only */ if (h2c->dbuf->i < h2c->dfl) return 0; /* late RST, already handled */ if (h2s->st == H2_SS_CLOSED) return 1; h2s->errcode = h2_get_n32(h2c->dbuf, 0); h2s_close(h2s); if (h2s->cs) { h2s->cs->flags |= CS_FL_EOS | CS_FL_ERROR; /* recv is used to force to detect CS_FL_EOS that wake() * doesn't handle in the stream-int code. */ h2s->cs->data_cb->recv(h2s->cs); h2s->cs->data_cb->wake(h2s->cs); } h2s->flags |= H2_SF_RST_RCVD; return 1; conn_err: h2c_error(h2c, error); return 0; }
CWE-119
7,799
15,619
335733371803684035784414310346670526649
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_handle_settings(struct h2c *h2c) { unsigned int offset; int error; if (h2c->dff & H2_F_SETTINGS_ACK) { if (h2c->dfl) { error = H2_ERR_FRAME_SIZE_ERROR; goto fail; } return 1; } if (h2c->dsi != 0) { error = H2_ERR_PROTOCOL_ERROR; goto fail; } if (h2c->dfl % 6) { error = H2_ERR_FRAME_SIZE_ERROR; goto fail; } /* that's the limit we can process */ if (h2c->dfl > global.tune.bufsize) { error = H2_ERR_FRAME_SIZE_ERROR; goto fail; } /* process full frame only */ if (h2c->dbuf->i < h2c->dfl) return 0; /* parse the frame */ for (offset = 0; offset < h2c->dfl; offset += 6) { uint16_t type = h2_get_n16(h2c->dbuf, offset); int32_t arg = h2_get_n32(h2c->dbuf, offset + 2); switch (type) { case H2_SETTINGS_INITIAL_WINDOW_SIZE: /* we need to update all existing streams with the * difference from the previous iws. */ if (arg < 0) { // RFC7540#6.5.2 error = H2_ERR_FLOW_CONTROL_ERROR; goto fail; } h2c_update_all_ws(h2c, arg - h2c->miw); h2c->miw = arg; break; case H2_SETTINGS_MAX_FRAME_SIZE: if (arg < 16384 || arg > 16777215) { // RFC7540#6.5.2 error = H2_ERR_PROTOCOL_ERROR; goto fail; } h2c->mfs = arg; break; case H2_SETTINGS_ENABLE_PUSH: if (arg < 0 || arg > 1) { // RFC7540#6.5.2 error = H2_ERR_PROTOCOL_ERROR; goto fail; } break; } } /* need to ACK this frame now */ h2c->st0 = H2_CS_FRAME_A; return 1; fail: h2c_error(h2c, error); return 0; }
CWE-119
7,800
15,620
94077180253996341479716633584745299201
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_handle_window_update(struct h2c *h2c, struct h2s *h2s) { int32_t inc; int error; if (h2c->dfl != 4) { error = H2_ERR_FRAME_SIZE_ERROR; goto conn_err; } /* process full frame only */ if (h2c->dbuf->i < h2c->dfl) return 0; inc = h2_get_n32(h2c->dbuf, 0); if (h2c->dsi != 0) { /* stream window update */ /* it's not an error to receive WU on a closed stream */ if (h2s->st == H2_SS_CLOSED) return 1; if (!inc) { error = H2_ERR_PROTOCOL_ERROR; goto strm_err; } if (h2s->mws >= 0 && h2s->mws + inc < 0) { error = H2_ERR_FLOW_CONTROL_ERROR; goto strm_err; } h2s->mws += inc; if (h2s->mws > 0 && (h2s->flags & H2_SF_BLK_SFCTL)) { h2s->flags &= ~H2_SF_BLK_SFCTL; if (h2s->cs && LIST_ISEMPTY(&h2s->list) && (h2s->cs->flags & CS_FL_DATA_WR_ENA)) { /* This stream wanted to send but could not due to its * own flow control. We can put it back into the send * list now, it will be handled upon next send() call. */ LIST_ADDQ(&h2c->send_list, &h2s->list); } } } else { /* connection window update */ if (!inc) { error = H2_ERR_PROTOCOL_ERROR; goto conn_err; } if (h2c->mws >= 0 && h2c->mws + inc < 0) { error = H2_ERR_FLOW_CONTROL_ERROR; goto conn_err; } h2c->mws += inc; } return 1; conn_err: h2c_error(h2c, error); return 0; strm_err: if (h2s) { h2s_error(h2s, error); h2c->st0 = H2_CS_FRAME_E; } else h2c_error(h2c, error); return 0; }
CWE-119
7,801
15,621
83533277217729863970647670153777285565
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused int h2c_mux_busy(const struct h2c *h2c, const struct h2s *h2s) { if (h2c->msi < 0) return 0; if (h2c->msi == h2s_id(h2s)) return 0; return 1; }
CWE-119
7,802
15,622
145438288167778593512379644099493720057
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_send_conn_wu(struct h2c *h2c) { int ret = 1; if (h2c->rcvd_c <= 0) return 1; /* send WU for the connection */ ret = h2c_send_window_update(h2c, 0, h2c->rcvd_c); if (ret > 0) h2c->rcvd_c = 0; return ret; }
CWE-119
7,803
15,623
233836926441601719039013827052020359101
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_send_goaway_error(struct h2c *h2c, struct h2s *h2s) { struct buffer *res; char str[17]; int ret; if (h2c->flags & H2_CF_GOAWAY_FAILED) return 1; // claim that it worked if (h2c_mux_busy(h2c, h2s)) { if (h2s) h2s->flags |= H2_SF_BLK_MBUSY; else h2c->flags |= H2_CF_DEM_MBUSY; return 0; } res = h2_get_buf(h2c, &h2c->mbuf); if (!res) { h2c->flags |= H2_CF_MUX_MALLOC; if (h2s) h2s->flags |= H2_SF_BLK_MROOM; else h2c->flags |= H2_CF_DEM_MROOM; return 0; } /* len: 8, type: 7, flags: none, sid: 0 */ memcpy(str, "\x00\x00\x08\x07\x00\x00\x00\x00\x00", 9); if (h2c->last_sid < 0) h2c->last_sid = h2c->max_id; write_n32(str + 9, h2c->last_sid); write_n32(str + 13, h2c->errcode); ret = bo_istput(res, ist2(str, 17)); if (unlikely(ret <= 0)) { if (!ret) { h2c->flags |= H2_CF_MUX_MFULL; if (h2s) h2s->flags |= H2_SF_BLK_MROOM; else h2c->flags |= H2_CF_DEM_MROOM; return 0; } else { /* we cannot report this error using GOAWAY, so we mark * it and claim a success. */ h2c_error(h2c, H2_ERR_INTERNAL_ERROR); h2c->flags |= H2_CF_GOAWAY_FAILED; return 1; } } h2c->flags |= H2_CF_GOAWAY_SENT; return ret; }
CWE-119
7,804
15,624
58067800477289220536123595689132134296
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_send_rst_stream(struct h2c *h2c, struct h2s *h2s) { struct buffer *res; char str[13]; int ret; /* 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)) { h2c->flags |= H2_CF_DEM_MBUSY; return 0; } res = h2_get_buf(h2c, &h2c->mbuf); if (!res) { h2c->flags |= H2_CF_MUX_MALLOC; h2c->flags |= H2_CF_DEM_MROOM; return 0; } /* len: 4, type: 3, flags: none */ memcpy(str, "\x00\x00\x04\x03\x00", 5); write_n32(str + 5, h2c->dsi); write_n32(str + 9, (h2s->st > H2_SS_IDLE && h2s->st < H2_SS_CLOSED) ? h2s->errcode : H2_ERR_STREAM_CLOSED); ret = bo_istput(res, ist2(str, 13)); if (unlikely(ret <= 0)) { if (!ret) { h2c->flags |= H2_CF_MUX_MFULL; h2c->flags |= H2_CF_DEM_MROOM; return 0; } else { h2c_error(h2c, H2_ERR_INTERNAL_ERROR); return 0; } } ignore: if (h2s->st > H2_SS_IDLE && h2s->st < H2_SS_CLOSED) { h2s->flags |= H2_SF_RST_SENT; h2s_close(h2s); } return ret; }
CWE-119
7,805
15,625
148921302119248597432167059190386981396
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_send_strm_wu(struct h2c *h2c) { int ret = 1; if (h2c->rcvd_s <= 0) return 1; /* send WU for the stream */ ret = h2c_send_window_update(h2c, h2c->dsi, h2c->rcvd_s); if (ret > 0) h2c->rcvd_s = 0; return ret; }
CWE-119
7,806
15,626
56702160115297767546657892767483853062
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_send_window_update(struct h2c *h2c, int sid, uint32_t increment) { struct buffer *res; char str[13]; int ret = -1; if (h2c_mux_busy(h2c, NULL)) { h2c->flags |= H2_CF_DEM_MBUSY; return 0; } res = h2_get_buf(h2c, &h2c->mbuf); if (!res) { h2c->flags |= H2_CF_MUX_MALLOC; h2c->flags |= H2_CF_DEM_MROOM; return 0; } /* length: 4, type: 8, flags: none */ memcpy(str, "\x00\x00\x04\x08\x00", 5); write_n32(str + 5, sid); write_n32(str + 9, increment); ret = bo_istput(res, ist2(str, 13)); if (unlikely(ret <= 0)) { if (!ret) { h2c->flags |= H2_CF_MUX_MFULL; h2c->flags |= H2_CF_DEM_MROOM; return 0; } else { h2c_error(h2c, H2_ERR_INTERNAL_ERROR); return 0; } } return ret; }
CWE-119
7,807
15,627
77298780433646418246257513558861712827
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static int h2c_snd_settings(struct h2c *h2c) { struct buffer *res; char buf_data[100]; // enough for 15 settings struct chunk buf; int ret; if (h2c_mux_busy(h2c, NULL)) { h2c->flags |= H2_CF_DEM_MBUSY; return 0; } res = h2_get_buf(h2c, &h2c->mbuf); if (!res) { h2c->flags |= H2_CF_MUX_MALLOC; h2c->flags |= H2_CF_DEM_MROOM; return 0; } chunk_init(&buf, buf_data, sizeof(buf_data)); chunk_memcpy(&buf, "\x00\x00\x00" /* length : 0 for now */ "\x04\x00" /* type : 4 (settings), flags : 0 */ "\x00\x00\x00\x00", /* stream ID : 0 */ 9); if (h2_settings_header_table_size != 4096) { char str[6] = "\x00\x01"; /* header_table_size */ write_n32(str + 2, h2_settings_header_table_size); chunk_memcat(&buf, str, 6); } if (h2_settings_initial_window_size != 65535) { char str[6] = "\x00\x04"; /* initial_window_size */ write_n32(str + 2, h2_settings_initial_window_size); chunk_memcat(&buf, str, 6); } if (h2_settings_max_concurrent_streams != 0) { char str[6] = "\x00\x03"; /* max_concurrent_streams */ /* Note: 0 means "unlimited" for haproxy's config but not for * the protocol, so never send this value! */ write_n32(str + 2, h2_settings_max_concurrent_streams); chunk_memcat(&buf, str, 6); } if (global.tune.bufsize != 16384) { char str[6] = "\x00\x05"; /* max_frame_size */ /* note: similarly we could also emit MAX_HEADER_LIST_SIZE to * match bufsize - rewrite size, but at the moment it seems * that clients don't take care of it. */ write_n32(str + 2, global.tune.bufsize); chunk_memcat(&buf, str, 6); } h2_set_frame_size(buf.str, buf.len - 9); ret = bo_istput(res, ist2(buf.str, buf.len)); if (unlikely(ret <= 0)) { if (!ret) { h2c->flags |= H2_CF_MUX_MFULL; h2c->flags |= H2_CF_DEM_MROOM; return 0; } else { h2c_error(h2c, H2_ERR_INTERNAL_ERROR); return 0; } } return ret; }
CWE-119
7,808
15,628
165810537543462263560183500150807371673
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
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); }
CWE-119
7,809
15,629
205059829113258784511141742862697395701
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
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; }
CWE-119
7,810
15,630
283096964928970214332285673684509560979
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
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); } }
CWE-119
7,811
15,631
10061724003387065276907980703891136513
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static void h2s_destroy(struct h2s *h2s) { h2s_close(h2s); LIST_DEL(&h2s->list); LIST_INIT(&h2s->list); eb32_delete(&h2s->by_id); pool_free(pool_head_h2s, h2s); }
CWE-119
7,812
15,632
299855142798153425035076125258214825059
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused void h2s_error(struct h2s *h2s, enum h2_err err) { if (h2s->st > H2_SS_IDLE && h2s->st < H2_SS_ERROR) { h2s->errcode = err; h2s->st = H2_SS_ERROR; if (h2s->cs) h2s->cs->flags |= CS_FL_ERROR; } }
CWE-119
7,813
15,633
281814418518019232041841407872763372614
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
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; }
CWE-119
7,814
15,634
239237708247358917430814586702212314218
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
0
static inline __maybe_unused int h2s_id(const struct h2s *h2s) { return h2s ? h2s->id : 0; }
CWE-119
7,816
15,635
109731608238059279685212423240678732021
null
null
null
haproxy
3f0e1ec70173593f4c2b3681b26c04a4ed5fc588
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; }
CWE-119
7,817
15,636
124894346211042872694237720488924781088
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
FoFiType1::FoFiType1(char *fileA, int lenA, GBool freeFileDataA): FoFiBase(fileA, lenA, freeFileDataA) { name = NULL; encoding = NULL; parsed = gFalse; }
CWE-20
8,059
15,704
6736204617007836013789287912976866533
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
char **FoFiType1::getEncoding() { if (!parsed) { parse(); } return encoding; }
CWE-20
8,060
15,705
24012806537636732686978352147906529284
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
char *FoFiType1::getName() { if (!parsed) { parse(); } return name; }
CWE-20
8,061
15,706
67189862414955415923611497695119392529
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
FoFiType1 *FoFiType1::load(char *fileName) { char *fileA; int lenA; if (!(fileA = FoFiBase::readFile(fileName, &lenA))) { return NULL; } return new FoFiType1(fileA, lenA, gTrue); }
CWE-20
8,062
15,707
148794890680604668112088449430473175697
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
FoFiType1 *FoFiType1::make(char *fileA, int lenA) { return new FoFiType1(fileA, lenA, gFalse); }
CWE-20
8,063
15,708
337235921933309394798468216407618223581
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
void FoFiType1::writeEncoded(char **newEncoding, FoFiOutputFunc outputFunc, void *outputStream) { char buf[512]; char *line, *line2, *p; int i; for (line = (char *)file; line && strncmp(line, "/Encoding", 9); line = getNextLine(line)) ; if (!line) { (*outputFunc)(outputStream, (char *)file, len); return; } (*outputFunc)(outputStream, (char *)file, line - (char *)file); (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); (*outputFunc)(outputStream, "0 1 255 {1 index exch /.notdef put} for\n", 40); for (i = 0; i < 256; ++i) { if (newEncoding[i]) { sprintf(buf, "dup %d /%s put\n", i, newEncoding[i]); (*outputFunc)(outputStream, buf, strlen(buf)); } } (*outputFunc)(outputStream, "readonly def\n", 13); if (!strncmp(line, "/Encoding StandardEncoding def", 30)) { line = getNextLine(line); } else { p = line + 10; line = NULL; for (; p < (char *)file + len; ++p) { if ((*p == ' ' || *p == '\t' || *p == '\x0a' || *p == '\x0d' || *p == '\x0c' || *p == '\0') && p + 4 <= (char *)file + len && !strncmp(p + 1, "def", 3)) { line = p + 4; break; } } } if (line) { for (line2 = line, i = 0; i < 20 && line2 && strncmp(line2, "/Encoding", 9); line2 = getNextLine(line2), ++i) ; if (i < 20 && line2) { (*outputFunc)(outputStream, line, line2 - line); if (!strncmp(line2, "/Encoding StandardEncoding def", 30)) { line = getNextLine(line2); } else { p = line2 + 10; line = NULL; for (; p < (char *)file + len; ++p) { if ((*p == ' ' || *p == '\t' || *p == '\x0a' || *p == '\x0d' || *p == '\x0c' || *p == '\0') && p + 4 <= (char *)file + len && !strncmp(p + 1, "def", 3)) { line = p + 4; break; } } } } if (line) { (*outputFunc)(outputStream, line, ((char *)file + len) - line); } } }
CWE-20
8,064
15,709
255154393531655252205571655295199444504
null
null
null
poppler
39d140bfc0b8239bdd96d6a55842034ae5c05473
0
FoFiType1::~FoFiType1() { int i; if (name) { gfree(name); } if (encoding && encoding != fofiType1StandardEncoding) { for (i = 0; i < 256; ++i) { gfree(encoding[i]); } gfree(encoding); } }
CWE-20
8,065
15,710
26623994837503579816646095269544830714
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
XvImageFormatValues * XvMCListSubpictureTypes ( Display * dpy, XvPortID port, int surface_type_id, int *count_return ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcListSubpictureTypesReply rep; xvmcListSubpictureTypesReq *req; XvImageFormatValues *ret = NULL; *count_return = 0; XvMCCheckExtension (dpy, info, NULL); LockDisplay (dpy); XvMCGetReq (ListSubpictureTypes, req); req->port = port; req->surface_type_id = surface_type_id; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return NULL; } if(rep.num > 0) { if (rep.num < (INT_MAX / sizeof(XvImageFormatValues))) ret = Xmalloc(rep.num * sizeof(XvImageFormatValues)); if(ret) { xvImageFormatInfo Info; int i; *count_return = rep.num; for(i = 0; i < rep.num; i++) { _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo); ret[i].id = Info.id; ret[i].type = Info.type; ret[i].byte_order = Info.byte_order; memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); ret[i].bits_per_pixel = Info.bpp; ret[i].format = Info.format; ret[i].num_planes = Info.num_planes; ret[i].depth = Info.depth; ret[i].red_mask = Info.red_mask; ret[i].green_mask = Info.green_mask; ret[i].blue_mask = Info.blue_mask; ret[i].y_sample_bits = Info.y_sample_bits; ret[i].u_sample_bits = Info.u_sample_bits; ret[i].v_sample_bits = Info.v_sample_bits; ret[i].horz_y_period = Info.horz_y_period; ret[i].horz_u_period = Info.horz_u_period; ret[i].horz_v_period = Info.horz_v_period; ret[i].vert_y_period = Info.vert_y_period; ret[i].vert_u_period = Info.vert_u_period; ret[i].vert_v_period = Info.vert_v_period; memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32); ret[i].scanline_order = Info.scanline_order; } } else _XEatDataWords(dpy, rep.length); } UnlockDisplay (dpy); SyncHandle (); return ret; }
CWE-119
8,249
15,815
216992624040034109413032290179600818348
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
Bool XvMCQueryExtension (Display *dpy, int *event_basep, int *error_basep) { XExtDisplayInfo *info = xvmc_find_display(dpy); if (XextHasExtension(info)) { *event_basep = info->codes->first_event; *error_basep = info->codes->first_error; return True; } else { return False; } }
CWE-119
8,251
15,816
153880099005140543321577779091089577091
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
Status XvMCQueryVersion (Display *dpy, int *major, int *minor) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcQueryVersionReply rep; xvmcQueryVersionReq *req; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (QueryVersion, req); if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return BadImplementation; } *major = rep.major; *minor = rep.minor; UnlockDisplay (dpy); SyncHandle (); return Success; }
CWE-119
8,252
15,817
305269877438411866114449715088311119169
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
Status _xvmc_create_surface ( Display *dpy, XvMCContext *context, XvMCSurface *surface, int *priv_count, CARD32 **priv_data ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcCreateSurfaceReply rep; xvmcCreateSurfaceReq *req; *priv_count = 0; *priv_data = NULL; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (CreateSurface, req); surface->surface_id = XAllocID(dpy); surface->context_id = context->context_id; surface->surface_type_id = context->surface_type_id; surface->width = context->width; surface->height = context->height; req->surface_id = surface->surface_id; req->context_id = surface->context_id; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return BadImplementation; } if(rep.length) { if (rep.length < (INT_MAX >> 2)) *priv_data = Xmalloc(rep.length << 2); if(*priv_data) { _XRead(dpy, (char*)(*priv_data), rep.length << 2); *priv_count = rep.length; } else _XEatDataWords(dpy, rep.length); } UnlockDisplay (dpy); SyncHandle (); return Success; }
CWE-119
8,254
15,818
107359597066355267415274763986437908229
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
Status _xvmc_destroy_context ( Display *dpy, XvMCContext *context ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcDestroyContextReq *req; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (DestroyContext, req); req->context_id = context->context_id; UnlockDisplay (dpy); SyncHandle (); return Success; }
CWE-119
8,255
15,819
267704829254253655636642949426030211385
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
Status _xvmc_destroy_subpicture( Display *dpy, XvMCSubpicture *subpicture ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcDestroySubpictureReq *req; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (DestroySubpicture, req); req->subpicture_id = subpicture->subpicture_id; UnlockDisplay (dpy); SyncHandle (); return Success; }
CWE-119
8,256
15,820
169762052857276226273614350928119123045
null
null
null
libXvMC
2cd95e7da8367cccdcdd5c9b160012d1dec5cbdb
0
Status _xvmc_destroy_surface ( Display *dpy, XvMCSurface *surface ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcDestroySurfaceReq *req; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (DestroySurface, req); req->surface_id = surface->surface_id; UnlockDisplay (dpy); SyncHandle (); return Success; }
CWE-119
8,257
15,821
13273521524113849026470989133185392832
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesCopyRegion (Display *dpy, XserverRegion dst, XserverRegion src) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesCopyRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesCopyRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesCopyRegion; req->source = src; req->destination = dst; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,302
15,861
13892634865764537225290336390305954068
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesCreateRegionFromGC (Display *dpy, GC gc) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesCreateRegionFromGCReq *req; XserverRegion region; XFixesCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (XFixesCreateRegionFromGC, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesCreateRegionFromGC; region = req->region = XAllocID (dpy); req->gc = gc->gid; UnlockDisplay (dpy); SyncHandle(); return region; }
CWE-190
8,304
15,862
31783117689851148474213217728235107258
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesCreateRegionFromWindow (Display *dpy, Window window, int kind) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesCreateRegionFromWindowReq *req; XserverRegion region; XFixesCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (XFixesCreateRegionFromWindow, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesCreateRegionFromWindow; region = req->region = XAllocID (dpy); req->window = window; req->kind = kind; UnlockDisplay (dpy); SyncHandle(); return region; }
CWE-190
8,306
15,863
177886446197506632176536690411429489600
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesDestroyRegion (Display *dpy, XserverRegion region) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesDestroyRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesDestroyRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesDestroyRegion; req->region = region; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,307
15,864
196347015747526291729003113942710795606
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesExpandRegion (Display *dpy, XserverRegion dst, XserverRegion src, unsigned left, unsigned right, unsigned top, unsigned bottom) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesExpandRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesExpandRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesExpandRegion; req->source = src; req->destination = dst; req->left = left; req->right = right; req->top = top; req->bottom = bottom; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,308
15,865
309041834665320569805225378599141039756
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesFetchRegion (Display *dpy, XserverRegion region, int *nrectanglesRet) { XRectangle bounds; return XFixesFetchRegionAndBounds (dpy, region, nrectanglesRet, &bounds); }
CWE-190
8,309
15,866
98160681550546344344762805614235945316
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesIntersectRegion (Display *dpy, XserverRegion dst, XserverRegion src1, XserverRegion src2) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesIntersectRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesIntersectRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesIntersectRegion; req->source1 = src1; req->source2 = src2; req->destination = dst; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,310
15,867
114887857755095259409423326387873342627
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesInvertRegion (Display *dpy, XserverRegion dst, XRectangle *rect, XserverRegion src) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesInvertRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesInvertRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesInvertRegion; req->x = rect->x; req->y = rect->y; req->width = rect->width; req->height = rect->height; req->source = src; req->destination = dst; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,311
15,868
270859050793095443232692384622486225238
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesRegionExtents (Display *dpy, XserverRegion dst, XserverRegion src) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesRegionExtentsReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesRegionExtents, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesRegionExtents; req->source = src; req->destination = dst; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,312
15,869
85591156536234612299084405396112079040
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesSetGCClipRegion (Display *dpy, GC gc, int clip_x_origin, int clip_y_origin, XserverRegion region) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesSetGCClipRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesSetGCClipRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesSetGCClipRegion; req->gc = gc->gid; req->region = region; req->xOrigin = clip_x_origin; req->yOrigin = clip_y_origin; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,313
15,870
261018473665253117332179213312666170664
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesSetPictureClipRegion (Display *dpy, XID picture, int clip_x_origin, int clip_y_origin, XserverRegion region) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesSetPictureClipRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesSetPictureClipRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesSetPictureClipRegion; req->picture = picture; req->region = region; req->xOrigin = clip_x_origin; req->yOrigin = clip_y_origin; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,314
15,871
201487713006068237154889845081037865780
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesSetRegion (Display *dpy, XserverRegion region, XRectangle *rectangles, int nrectangles) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesSetRegionReq *req; long len; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesSetRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesSetRegion; req->region = region; len = ((long) nrectangles) << 1; SetReqLen (req, len, len); len <<= 2; Data16 (dpy, (short *) rectangles, len); UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,315
15,872
339077707758550689662394070477237521463
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesSetWindowShapeRegion (Display *dpy, Window win, int shape_kind, int x_off, int y_off, XserverRegion region) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesSetWindowShapeRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesSetWindowShapeRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesSetWindowShapeRegion; req->dest = win; req->destKind = shape_kind; req->xOff = x_off; req->yOff = y_off; req->region = region; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,316
15,873
18045614235480717849538283312630616681
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesSubtractRegion (Display *dpy, XserverRegion dst, XserverRegion src1, XserverRegion src2) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesSubtractRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesSubtractRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesSubtractRegion; req->source1 = src1; req->source2 = src2; req->destination = dst; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,317
15,874
209323103350878862794810954587988850603
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesTranslateRegion (Display *dpy, XserverRegion region, int dx, int dy) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesTranslateRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesTranslateRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesTranslateRegion; req->region = region; req->dx = dx; req->dy = dy; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,318
15,875
280797979824254473742655041786113953371
null
null
null
libXfixes
61c1039ee23a2d1de712843bed3480654d7ef42e
0
XFixesUnionRegion (Display *dpy, XserverRegion dst, XserverRegion src1, XserverRegion src2) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesUnionRegionReq *req; XFixesSimpleCheckExtension (dpy, info); LockDisplay (dpy); GetReq (XFixesUnionRegion, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesUnionRegion; req->source1 = src1; req->source2 = src2; req->destination = dst; UnlockDisplay (dpy); SyncHandle(); }
CWE-190
8,319
15,876
277153794366354418081086598644711398193
null
null
null
libav
136f55207521f0b03194ef5b55ba70f1635d6aee
0
static void gmc_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture) { uint8_t *ptr; int linesize, uvlinesize; const int a = s->sprite_warping_accuracy; int ox, oy; linesize = s->linesize; uvlinesize = s->uvlinesize; ptr = ref_picture[0]; ox = s->sprite_offset[0][0] + s->sprite_delta[0][0] * s->mb_x * 16 + s->sprite_delta[0][1] * s->mb_y * 16; oy = s->sprite_offset[0][1] + s->sprite_delta[1][0] * s->mb_x * 16 + s->sprite_delta[1][1] * s->mb_y * 16; s->mdsp.gmc(dest_y, ptr, linesize, 16, ox, oy, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, s->h_edge_pos, s->v_edge_pos); s->mdsp.gmc(dest_y + 8, ptr, linesize, 16, ox + s->sprite_delta[0][0] * 8, oy + s->sprite_delta[1][0] * 8, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, s->h_edge_pos, s->v_edge_pos); if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 + s->sprite_delta[0][1] * s->mb_y * 8; oy = s->sprite_offset[1][1] + s->sprite_delta[1][0] * s->mb_x * 8 + s->sprite_delta[1][1] * s->mb_y * 8; ptr = ref_picture[1]; s->mdsp.gmc(dest_cb, ptr, uvlinesize, 8, ox, oy, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, s->h_edge_pos >> 1, s->v_edge_pos >> 1); ptr = ref_picture[2]; s->mdsp.gmc(dest_cr, ptr, uvlinesize, 8, ox, oy, s->sprite_delta[0][0], s->sprite_delta[0][1], s->sprite_delta[1][0], s->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, s->h_edge_pos >> 1, s->v_edge_pos >> 1); }
CWE-476
8,351
15,877
223540679498198063472703797081349938728
null
null
null
tartarus
4ff22863d895cb7ebfced4cf923a012a614adaa8
0
static int alloc_channel_id(Ssh ssh) { const unsigned CHANNEL_NUMBER_OFFSET = 256; unsigned low, high, mid; int tsize; struct ssh_channel *c; /* * First-fit allocation of channel numbers: always pick the * lowest unused one. To do this, binary-search using the * counted B-tree to find the largest channel ID which is in a * contiguous sequence from the beginning. (Precisely * everything in that sequence must have ID equal to its tree * index plus CHANNEL_NUMBER_OFFSET.) */ tsize = count234(ssh->channels); low = -1; high = tsize; while (high - low > 1) { mid = (high + low) / 2; c = index234(ssh->channels, mid); if (c->localid == mid + CHANNEL_NUMBER_OFFSET) low = mid; /* this one is fine */ else high = mid; /* this one is past it */ } /* * Now low points to either -1, or the tree index of the * largest ID in the initial sequence. */ { unsigned i = low + 1 + CHANNEL_NUMBER_OFFSET; assert(NULL == find234(ssh->channels, &i, ssh_channelfind)); } return low + 1 + CHANNEL_NUMBER_OFFSET; }
CWE-119
8,503
15,878
320624061170069302561574530426442499632
null
null
null
tartarus
4ff22863d895cb7ebfced4cf923a012a614adaa8
0
void bndebug(char *string, Bignum b) { unsigned char *p; int i, len; p = ssh2_mpint_fmt(b, &len); debug(("%s", string)); for (i = 0; i < len; i++) debug((" %02x", p[i])); debug(("\n")); sfree(p); }
CWE-119
8,504
15,879
169209189690852735458657785557303178719
null
null
null
tartarus
4ff22863d895cb7ebfced4cf923a012a614adaa8
0
static void bomb_out(Ssh ssh, char *text) { ssh_do_close(ssh, FALSE); logevent(text); connection_fatal(ssh->frontend, "%s", text); sfree(text); }
CWE-119
8,505
15,880
280453803270323613364690658747329900163
null
null
null
tartarus
4ff22863d895cb7ebfced4cf923a012a614adaa8
0
static void c_write(Ssh ssh, const char *buf, int len) { if (flags & FLAG_STDERR) c_write_stderr(1, buf, len); else from_backend(ssh->frontend, 1, buf, len); }
CWE-119
8,506
15,881
72507288605396065105015912513804720171
null
null
null
tartarus
4ff22863d895cb7ebfced4cf923a012a614adaa8
0
static void c_write_stderr(int trusted, const char *buf, int len) { int i; for (i = 0; i < len; i++) if (buf[i] != '\r' && (trusted || buf[i] == '\n' || (buf[i] & 0x60))) fputc(buf[i], stderr); }
CWE-119
8,507
15,882
80022425628195657693577932294801932957
null
null
null
tartarus
4ff22863d895cb7ebfced4cf923a012a614adaa8
0
static void c_write_str(Ssh ssh, const char *buf) { c_write(ssh, buf, strlen(buf)); }
CWE-119
8,508
15,883
124753490329853718390520725599364428193
null
null
null