func
stringlengths
0
484k
target
int64
0
1
cwe
listlengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
GF_Err dmax_dump(GF_Box *a, FILE * trace) { GF_DMAXBox *p; p = (GF_DMAXBox *)a; gf_isom_box_dump_start(a, "MaxPacketDurationBox", trace); fprintf(trace, "MaximumDuration=\"%d\">\n", p->maxDur); gf_isom_box_dump_done("MaxPacketDurationBox", a, trace); return GF_OK; }
0
[ "CWE-125" ]
gpac
bceb03fd2be95097a7b409ea59914f332fb6bc86
4,477,443,920,661,742,000,000,000,000,000,000,000
9
fixed 2 possible heap overflows (inc. #1088)
static void handle_nttrans(connection_struct *conn, struct trans_state *state, struct smb_request *req) { if (get_Protocol() >= PROTOCOL_NT1) { req->flags2 |= 0x40; /* IS_LONG_NAME */ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_flg2,req->flags2); } SMB_PERFCOUNT_SET_SUBOP(&req->pcd, state->call); /* Now we must call the relevant NT_TRANS function */ switch(state->call) { case NT_TRANSACT_CREATE: { START_PROFILE(NT_transact_create); call_nt_transact_create( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_create); break; } case NT_TRANSACT_IOCTL: { START_PROFILE(NT_transact_ioctl); call_nt_transact_ioctl( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_ioctl); break; } case NT_TRANSACT_SET_SECURITY_DESC: { START_PROFILE(NT_transact_set_security_desc); call_nt_transact_set_security_desc( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_set_security_desc); break; } case NT_TRANSACT_NOTIFY_CHANGE: { START_PROFILE(NT_transact_notify_change); call_nt_transact_notify_change( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return, state->max_param_return); END_PROFILE(NT_transact_notify_change); break; } case NT_TRANSACT_RENAME: { START_PROFILE(NT_transact_rename); call_nt_transact_rename( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_rename); break; } case NT_TRANSACT_QUERY_SECURITY_DESC: { START_PROFILE(NT_transact_query_security_desc); call_nt_transact_query_security_desc( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_query_security_desc); break; } #ifdef HAVE_SYS_QUOTAS case NT_TRANSACT_GET_USER_QUOTA: { START_PROFILE(NT_transact_get_user_quota); call_nt_transact_get_user_quota( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_get_user_quota); break; } case NT_TRANSACT_SET_USER_QUOTA: { START_PROFILE(NT_transact_set_user_quota); call_nt_transact_set_user_quota( conn, req, &state->setup, state->setup_count, &state->param, state->total_param, &state->data, state->total_data, state->max_data_return); END_PROFILE(NT_transact_set_user_quota); break; } #endif /* HAVE_SYS_QUOTAS */ default: /* Error in request */ DEBUG(0,("handle_nttrans: Unknown request %d in " "nttrans call\n", state->call)); reply_nterror(req, NT_STATUS_INVALID_LEVEL); return; } return; }
0
[ "CWE-189" ]
samba
b4bfcdf921aeee05c4608d7b48618fdfb1f134dc
86,294,844,921,768,350,000,000,000,000,000,000,000
130
Fix bug #10010 - Missing integer wrap protection in EA list reading can cause server to loop with DOS. Ensure we never wrap whilst adding client provided input. Signed-off-by: Jeremy Allison <[email protected]>
static int cbs_av1_read_leb128(CodedBitstreamContext *ctx, GetBitContext *gbc, const char *name, uint64_t *write_to) { uint64_t value; int position, err, i; if (ctx->trace_enable) position = get_bits_count(gbc); value = 0; for (i = 0; i < 8; i++) { int subscript[2] = { 1, i }; uint32_t byte; err = ff_cbs_read_unsigned(ctx, gbc, 8, "leb128_byte[i]", subscript, &byte, 0x00, 0xff); if (err < 0) return err; value |= (uint64_t)(byte & 0x7f) << (i * 7); if (!(byte & 0x80)) break; } if (ctx->trace_enable) ff_cbs_trace_syntax_element(ctx, position, name, NULL, "", value); *write_to = value; return 0; }
0
[ "CWE-20", "CWE-129" ]
FFmpeg
b97a4b658814b2de8b9f2a3bce491c002d34de31
250,397,302,278,337,000,000,000,000,000,000,000,000
29
cbs_av1: Fix reading of overlong uvlc codes The specification allows 2^32-1 to be encoded as any number of zeroes greater than 31, followed by a one. This previously failed because the trace code would overflow the array containing the string representation of the bits if there were more than 63 zeroes. Fix that by splitting the trace output into batches, and at the same time move it out of the default path. (While this seems likely to be a specification error, libaom does support it so we probably should as well.) From a test case by keval shah <[email protected]>. Reviewed-by: Michael Niedermayer <[email protected]>
static uint dump_routines_for_db(char *db) { char query_buff[QUERY_LENGTH]; const char *routine_type[]= {"FUNCTION", "PROCEDURE"}; char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3]; char *routine_name; int i; FILE *sql_file= md_result_file; MYSQL_RES *routine_res, *routine_list_res; MYSQL_ROW row, routine_list_row; char db_cl_name[MY_CS_NAME_SIZE]; int db_cl_altered= FALSE; DBUG_ENTER("dump_routines_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db)); /* nice comments */ print_comment(sql_file, 0, "\n--\n-- Dumping routines for database '%s'\n--\n", fix_for_comment(db)); /* not using "mysql_query_with_error_report" because we may have not enough privileges to lock mysql.proc. */ if (lock_tables) mysql_query(mysql, "LOCK TABLES mysql.proc READ"); /* Get database collation. */ if (fetch_db_collation(db, db_cl_name, sizeof (db_cl_name))) DBUG_RETURN(1); if (switch_character_set_results(mysql, "binary")) DBUG_RETURN(1); if (opt_xml) fputs("\t<routines>\n", sql_file); /* 0, retrieve and dump functions, 1, procedures */ for (i= 0; i <= 1; i++) { my_snprintf(query_buff, sizeof(query_buff), "SHOW %s STATUS WHERE Db = '%s'", routine_type[i], db_name_buff); if (mysql_query_with_error_report(mysql, &routine_list_res, query_buff)) DBUG_RETURN(1); if (mysql_num_rows(routine_list_res)) { while ((routine_list_row= mysql_fetch_row(routine_list_res))) { routine_name= quote_name(routine_list_row[1], name_buff, 0); DBUG_PRINT("info", ("retrieving CREATE %s for %s", routine_type[i], name_buff)); my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE %s %s", routine_type[i], routine_name); if (mysql_query_with_error_report(mysql, &routine_res, query_buff)) DBUG_RETURN(1); while ((row= mysql_fetch_row(routine_res))) { /* if the user has EXECUTE privilege he see routine names, but NOT the routine body of other routines that are not the creator of! */ DBUG_PRINT("info",("length of body for %s row[2] '%s' is %zu", routine_name, row[2] ? row[2] : "(null)", row[2] ? strlen(row[2]) : 0)); if (row[2] == NULL) { print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n", query_buff); print_comment(sql_file, 1, "-- does %s have permissions on mysql.proc?\n\n", current_user); maybe_die(EX_MYSQLERR,"%s has insufficent privileges to %s!", current_user, query_buff); } else if (strlen(row[2])) { if (opt_xml) { if (i) /* Procedures. */ print_xml_row(sql_file, "routine", routine_res, &row, "Create Procedure"); else /* Functions. */ print_xml_row(sql_file, "routine", routine_res, &row, "Create Function"); continue; } if (opt_drop) fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n", routine_type[i], routine_name); if (mysql_num_fields(routine_res) >= 6) { if (switch_db_collation(sql_file, db, ";", db_cl_name, row[5], &db_cl_altered)) { DBUG_RETURN(1); } switch_cs_variables(sql_file, ";", row[3], /* character_set_client */ row[3], /* character_set_results */ row[4]); /* collation_connection */ } else { /* mysqldump is being run against the server, that does not provide character set information in SHOW CREATE statements. NOTE: the dump may be incorrect, since character set information is required in order to restore stored procedure/function properly. */ fprintf(sql_file, "--\n" "-- WARNING: old server version. " "The following dump may be incomplete.\n" "--\n"); } switch_sql_mode(sql_file, ";", row[1]); fprintf(sql_file, "DELIMITER ;;\n" "%s ;;\n" "DELIMITER ;\n", (const char *) row[2]); restore_sql_mode(sql_file, ";"); if (mysql_num_fields(routine_res) >= 6) { restore_cs_variables(sql_file, ";"); if (db_cl_altered) { if (restore_db_collation(sql_file, db, ";", db_cl_name)) DBUG_RETURN(1); } } } } /* end of routine printing */ mysql_free_result(routine_res); } /* end of list of routines */ } mysql_free_result(routine_list_res); } /* end of for i (0 .. 1) */ if (opt_xml) { fputs("\t</routines>\n", sql_file); check_io(sql_file); } if (switch_character_set_results(mysql, default_charset)) DBUG_RETURN(1); if (lock_tables) (void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"); DBUG_RETURN(0); }
0
[]
server
5a43a31ee81bc181eeb5ef2bf0704befa6e0594d
26,008,446,072,967,945,000,000,000,000,000,000,000
176
mysqldump: comments and identifiers with new lines don't let identifiers with new lines to break a comment
int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb) { int error = 0; struct cxio_rdev *rdev; rdev = (struct cxio_rdev *)tdev->ulp; if (cxio_fatal_error(rdev)) { kfree_skb(skb); return -EIO; } error = cxgb3_ofld_send(tdev, skb); if (error < 0) kfree_skb(skb); return error; }
1
[ "CWE-703" ]
linux
67f1aee6f45059fd6b0f5b0ecb2c97ad0451f6b3
145,310,064,754,123,730,000,000,000,000,000,000,000
15
iw_cxgb3: Fix incorrectly returning error on success The cxgb3_*_send() functions return NET_XMIT_ values, which are positive integers values. So don't treat positive return values as an error. Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
DropoutDescriptor CreateDropoutDescriptor() { cudnnDropoutDescriptor_t result; CHECK_CUDNN_OK(cudnnCreateDropoutDescriptor(&result)); return DropoutDescriptor(result); }
0
[ "CWE-20" ]
tensorflow
14755416e364f17fb1870882fa778c7fec7f16e3
34,186,937,647,163,146,000,000,000,000,000,000,000
5
Prevent CHECK-fail in LSTM/GRU with zero-length input. PiperOrigin-RevId: 346239181 Change-Id: I5f233dbc076aab7bb4e31ba24f5abd4eaf99ea4f
//! Fill sequentially all pixel values with specified values \newinstance. CImg<T> get_fill(const T& val0, const T& val1, const T& val2, const T& val3) const { return CImg<T>(_width,_height,_depth,_spectrum).fill(val0,val1,val2,val3);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
285,336,893,292,194,600,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
int test_gf2m_mod_sqr(BIO *bp,BN_CTX *ctx) { BIGNUM *a,*b[2],*c,*d; int i, j, ret = 0; int p0[] = {163,7,6,3,0,-1}; int p1[] = {193,15,0,-1}; a=BN_new(); b[0]=BN_new(); b[1]=BN_new(); c=BN_new(); d=BN_new(); BN_GF2m_arr2poly(p0, b[0]); BN_GF2m_arr2poly(p1, b[1]); for (i=0; i<num0; i++) { BN_bntest_rand(a, 1024, 0, 0); for (j=0; j < 2; j++) { BN_GF2m_mod_sqr(c, a, b[j], ctx); BN_copy(d, a); BN_GF2m_mod_mul(d, a, d, b[j], ctx); #if 0 /* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic */ if (bp != NULL) { if (!results) { BN_print(bp,a); BIO_puts(bp," ^ 2 % "); BN_print(bp,b[j]); BIO_puts(bp, " = "); BN_print(bp,c); BIO_puts(bp,"; a * a = "); BN_print(bp,d); BIO_puts(bp,"\n"); } } #endif BN_GF2m_add(d, c, d); /* Test that a*a = a^2. */ if(!BN_is_zero(d)) { fprintf(stderr,"GF(2^m) modular squaring test failed!\n"); goto err; } } } ret = 1; err: BN_free(a); BN_free(b[0]); BN_free(b[1]); BN_free(c); BN_free(d); return ret; }
0
[ "CWE-310" ]
openssl
a7a44ba55cb4f884c6bc9ceac90072dea38e66d0
180,319,954,257,110,950,000,000,000,000,000,000,000
58
Fix for CVE-2014-3570 (with minor bn_asm.c revamp). Reviewed-by: Emilia Kasper <[email protected]>
halfpage(int flag, linenr_T Prenum) { long scrolled = 0; int i; int n; int room; if (Prenum) curwin->w_p_scr = (Prenum > curwin->w_height) ? curwin->w_height : Prenum; n = (curwin->w_p_scr <= curwin->w_height) ? curwin->w_p_scr : curwin->w_height; update_topline(); validate_botline(); room = curwin->w_empty_rows; #ifdef FEAT_DIFF room += curwin->w_filler_rows; #endif if (flag) { /* * scroll the text up */ while (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count) { #ifdef FEAT_DIFF if (curwin->w_topfill > 0) { i = 1; --n; --curwin->w_topfill; } else #endif { i = PLINES_NOFILL(curwin->w_topline); n -= i; if (n < 0 && scrolled > 0) break; #ifdef FEAT_FOLDING (void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline); #endif ++curwin->w_topline; #ifdef FEAT_DIFF curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline); #endif if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { ++curwin->w_cursor.lnum; curwin->w_valid &= ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL); } } curwin->w_valid &= ~(VALID_CROW|VALID_WROW); scrolled += i; /* * Correct w_botline for changed w_topline. * Won't work when there are filler lines. */ #ifdef FEAT_DIFF if (curwin->w_p_diff) curwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP); else #endif { room += i; do { i = plines(curwin->w_botline); if (i > room) break; #ifdef FEAT_FOLDING (void)hasFolding(curwin->w_botline, NULL, &curwin->w_botline); #endif ++curwin->w_botline; room -= i; } while (curwin->w_botline <= curbuf->b_ml.ml_line_count); } } /* * When hit bottom of the file: move cursor down. */ if (n > 0) { # ifdef FEAT_FOLDING if (hasAnyFolding(curwin)) { while (--n >= 0 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { (void)hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum); ++curwin->w_cursor.lnum; } } else # endif curwin->w_cursor.lnum += n; check_cursor_lnum(); } } else { /* * scroll the text down */ while (n > 0 && curwin->w_topline > 1) { #ifdef FEAT_DIFF if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)) { i = 1; --n; ++curwin->w_topfill; } else #endif { i = PLINES_NOFILL(curwin->w_topline - 1); n -= i; if (n < 0 && scrolled > 0) break; --curwin->w_topline; #ifdef FEAT_FOLDING (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); #endif #ifdef FEAT_DIFF curwin->w_topfill = 0; #endif } curwin->w_valid &= ~(VALID_CROW|VALID_WROW| VALID_BOTLINE|VALID_BOTLINE_AP); scrolled += i; if (curwin->w_cursor.lnum > 1) { --curwin->w_cursor.lnum; curwin->w_valid &= ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL); } } /* * When hit top of the file: move cursor up. */ if (n > 0) { if (curwin->w_cursor.lnum <= (linenr_T)n) curwin->w_cursor.lnum = 1; else # ifdef FEAT_FOLDING if (hasAnyFolding(curwin)) { while (--n >= 0 && curwin->w_cursor.lnum > 1) { --curwin->w_cursor.lnum; (void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL); } } else # endif curwin->w_cursor.lnum -= n; } } # ifdef FEAT_FOLDING // Move cursor to first line of closed fold. foldAdjustCursor(); # endif #ifdef FEAT_DIFF check_topfill(curwin, !flag); #endif cursor_correct(); beginline(BL_SOL | BL_FIX); redraw_later(VALID); }
0
[ "CWE-122" ]
vim
777e7c21b7627be80961848ac560cb0a9978ff43
60,061,165,113,433,210,000,000,000,000,000,000,000
179
patch 8.2.3564: invalid memory access when scrolling without valid screen Problem: Invalid memory access when scrolling without a valid screen. Solution: Do not set VALID_BOTLINE in w_valid.
plperlu_validator(PG_FUNCTION_ARGS) { return plperl_validator(fcinfo); }
1
[ "CWE-264" ]
postgres
537cbd35c893e67a63c59bc636c3e888bd228bc7
318,726,637,511,280,950,000,000,000,000,000,000,000
4
Prevent privilege escalation in explicit calls to PL validators. The primary role of PL validators is to be called implicitly during CREATE FUNCTION, but they are also normal functions that a user can call explicitly. Add a permissions check to each validator to ensure that a user cannot use explicit validator calls to achieve things he could not otherwise achieve. Back-patch to 8.4 (all supported versions). Non-core procedural language extensions ought to make the same two-line change to their own validators. Andres Freund, reviewed by Tom Lane and Noah Misch. Security: CVE-2014-0061
serialize_uep( bufinfo_T *bi, u_entry_T *uep) { int i; size_t len; undo_write_bytes(bi, (long_u)uep->ue_top, 4); undo_write_bytes(bi, (long_u)uep->ue_bot, 4); undo_write_bytes(bi, (long_u)uep->ue_lcount, 4); undo_write_bytes(bi, (long_u)uep->ue_size, 4); for (i = 0; i < uep->ue_size; ++i) { len = STRLEN(uep->ue_array[i]); if (undo_write_bytes(bi, (long_u)len, 4) == FAIL) return FAIL; if (len > 0 && fwrite_crypt(bi, uep->ue_array[i], len) == FAIL) return FAIL; } return OK; }
0
[ "CWE-190" ]
vim
3eb1637b1bba19519885dd6d377bd5596e91d22c
31,814,924,593,228,670,000,000,000,000,000,000,000
21
patch 8.0.0377: possible overflow when reading corrupted undo file Problem: Possible overflow when reading corrupted undo file. Solution: Check if allocated size is not too big. (King)
static int thread_sync(UNUSED void *arg) { virgl_gl_context gl_context = vrend_state.sync_context; struct vrend_fence *fence, *stor; pipe_mutex_lock(vrend_state.fence_mutex); vrend_clicbs->make_current(gl_context); while (!vrend_state.stop_sync_thread) { if (LIST_IS_EMPTY(&vrend_state.fence_wait_list) && pipe_condvar_wait(vrend_state.fence_cond, vrend_state.fence_mutex) != 0) { vrend_printf( "error while waiting on condition\n"); break; } LIST_FOR_EACH_ENTRY_SAFE(fence, stor, &vrend_state.fence_wait_list, fences) { if (vrend_state.stop_sync_thread) break; list_del(&fence->fences); pipe_mutex_unlock(vrend_state.fence_mutex); wait_sync(fence); pipe_mutex_lock(vrend_state.fence_mutex); } } vrend_clicbs->make_current(0); vrend_clicbs->destroy_gl_context(vrend_state.sync_context); pipe_mutex_unlock(vrend_state.fence_mutex); return 0; }
0
[ "CWE-787" ]
virglrenderer
cbc8d8b75be360236cada63784046688aeb6d921
36,816,208,529,983,953,000,000,000,000,000,000,000
31
vrend: check transfer bounds for negative values too and report error Closes #138 Signed-off-by: Gert Wollny <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
status_icon_stop (GsdXrandrManager *manager) { struct GsdXrandrManagerPrivate *priv = manager->priv; if (priv->status_icon) { g_signal_handlers_disconnect_by_func ( priv->status_icon, G_CALLBACK (status_icon_activate_cb), manager); g_signal_handlers_disconnect_by_func ( priv->status_icon, G_CALLBACK (status_icon_popup_menu_cb), manager); g_object_unref (priv->status_icon); priv->status_icon = NULL; } }
0
[]
gnome-settings-daemon
be513b3c7d80d0b7013d79ce46d7eeca929705cc
116,416,391,939,779,380,000,000,000,000,000,000,000
14
Implement autoconfiguration of the outputs This is similar in spirit to 'xrandr --auto', but we disfavor selecting clone modes. Instead, we lay out the outputs left-to-right. Signed-off-by: Federico Mena Quintero <[email protected]>
static inline void destroy_timer_on_stack(struct timer_list *timer) { }
0
[ "CWE-200" ]
tip
dfb4357da6ddbdf57d583ba64361c9d792b0e0b1
204,912,218,150,564,930,000,000,000,000,000,000,000
1
time: Remove CONFIG_TIMER_STATS Currently CONFIG_TIMER_STATS exposes process information across namespaces: kernel/time/timer_list.c print_timer(): SEQ_printf(m, ", %s/%d", tmp, timer->start_pid); /proc/timer_list: #11: <0000000000000000>, hrtimer_wakeup, S:01, do_nanosleep, cron/2570 Given that the tracer can give the same information, this patch entirely removes CONFIG_TIMER_STATS. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Kees Cook <[email protected]> Acked-by: John Stultz <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: [email protected] Cc: Lai Jiangshan <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Xing Gao <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Jessica Frazelle <[email protected]> Cc: [email protected] Cc: Nicolas Iooss <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Michal Marek <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Andrew Morton <[email protected]> Cc: [email protected] Cc: Arjan van de Ven <[email protected]> Link: http://lkml.kernel.org/r/20170208192659.GA32582@beast Signed-off-by: Thomas Gleixner <[email protected]>
void WebContents::ExitFullscreenModeForTab(content::WebContents* source) { CommonWebContentsDelegate::ExitFullscreenModeForTab(source); Emit("leave-html-full-screen"); }
0
[ "CWE-284", "CWE-693" ]
electron
18613925610ba319da7f497b6deed85ad712c59b
204,052,287,782,352,360,000,000,000,000,000,000,000
4
refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25108) * refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25065) * refactor: wire will-navigate up to a navigation throttle instead of OpenURL * spec: add test for x-site _top navigation * chore: old code be old
rb_str_count(argc, argv, str) int argc; VALUE *argv; VALUE str; { char table[256]; char *s, *send; int init = 1; int i; if (argc < 1) { rb_raise(rb_eArgError, "wrong number of arguments"); } for (i=0; i<argc; i++) { VALUE s = argv[i]; StringValue(s); tr_setup_table(s, table, init); init = 0; } s = RSTRING(str)->ptr; if (!s || RSTRING(str)->len == 0) return INT2FIX(0); send = s + RSTRING(str)->len; i = 0; while (s < send) { if (table[*s++ & 0xff]) { i++; } } return INT2NUM(i); }
0
[ "CWE-20" ]
ruby
e926ef5233cc9f1035d3d51068abe9df8b5429da
322,961,669,628,075,140,000,000,000,000,000,000,000
32
* random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export. * string.c (rb_str_tmp_new), intern.h: New function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
int ssl3_send_certificate_request(SSL *s) { unsigned char *p, *d; int i, j, nl, off, n; STACK_OF(X509_NAME) *sk = NULL; X509_NAME *name; BUF_MEM *buf; if (s->state == SSL3_ST_SW_CERT_REQ_A) { buf = s->init_buf; d = p = (unsigned char *)&(buf->data[4]); /* get the list of acceptable cert types */ p++; n = ssl3_get_req_cert_type(s, p); d[0] = n; p += n; n++; off = n; p += 2; n += 2; sk = SSL_get_client_CA_list(s); nl = 0; if (sk != NULL) { for (i = 0; i < sk_X509_NAME_num(sk); i++) { name = sk_X509_NAME_value(sk, i); j = i2d_X509_NAME(name, NULL); if (!BUF_MEM_grow_clean(buf, 4 + n + j + 2)) { SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, ERR_R_BUF_LIB); goto err; } p = (unsigned char *)&(buf->data[4 + n]); if (!(s->options & SSL_OP_NETSCAPE_CA_DN_BUG)) { s2n(j, p); i2d_X509_NAME(name, &p); n += 2 + j; nl += 2 + j; } else { d = p; i2d_X509_NAME(name, &p); j -= 2; s2n(j, d); j += 2; n += j; nl += j; } } } /* else no CA names */ p = (unsigned char *)&(buf->data[4 + off]); s2n(nl, p); d = (unsigned char *)buf->data; *(d++) = SSL3_MT_CERTIFICATE_REQUEST; l2n3(n, d); /* * we should now have things packed up, so lets send it off */ s->init_num = n + 4; s->init_off = 0; #ifdef NETSCAPE_HANG_BUG if (!BUF_MEM_grow_clean(buf, s->init_num + 4)) { SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, ERR_R_BUF_LIB); goto err; } p = (unsigned char *)s->init_buf->data + s->init_num; /* do the header */ *(p++) = SSL3_MT_SERVER_DONE; *(p++) = 0; *(p++) = 0; *(p++) = 0; s->init_num += 4; #endif s->state = SSL3_ST_SW_CERT_REQ_B; } /* SSL3_ST_SW_CERT_REQ_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); err: return (-1); }
0
[]
openssl
1392c238657ec745af6a40def03d67d4ce02a082
10,073,073,550,453,408,000,000,000,000,000,000,000
89
Fix PSK handling. The PSK identity hint should be stored in the SSL_SESSION structure and not in the parent context (which will overwrite values used by other SSL structures with the same SSL_CTX). Use BUF_strndup when copying identity as it may not be null terminated. Reviewed-by: Tim Hudson <[email protected]> (cherry picked from commit 3c66a669dfc7b3792f7af0758ea26fe8502ce70c)
PackLinuxElf32::PackLinuxElf32help1(InputFile *f) { e_type = get_te16(&ehdri.e_type); e_phnum = get_te16(&ehdri.e_phnum); e_shnum = get_te16(&ehdri.e_shnum); unsigned const e_phentsize = get_te16(&ehdri.e_phentsize); if (ehdri.e_ident[Elf32_Ehdr::EI_CLASS]!=Elf32_Ehdr::ELFCLASS32 || sizeof(Elf32_Phdr) != e_phentsize || (Elf32_Ehdr::ELFDATA2MSB == ehdri.e_ident[Elf32_Ehdr::EI_DATA] && &N_BELE_RTP::be_policy != bele) || (Elf32_Ehdr::ELFDATA2LSB == ehdri.e_ident[Elf32_Ehdr::EI_DATA] && &N_BELE_RTP::le_policy != bele)) { e_phoff = 0; e_shoff = 0; sz_phdrs = 0; return; } if (0==e_phnum) throwCantUnpack("0==e_phnum"); e_phoff = get_te32(&ehdri.e_phoff); unsigned const last_Phdr = e_phoff + e_phnum * sizeof(Elf32_Phdr); if (last_Phdr < e_phoff || (unsigned long)file_size < last_Phdr) { throwCantUnpack("bad e_phoff"); } e_shoff = get_te32(&ehdri.e_shoff); unsigned const last_Shdr = e_shoff + e_shnum * sizeof(Elf32_Shdr); if (last_Shdr < e_shoff || (unsigned long)file_size < last_Shdr) { if (opt->cmd == CMD_COMPRESS) { throwCantUnpack("bad e_shoff"); } } sz_phdrs = e_phnum * e_phentsize; if (f && Elf32_Ehdr::ET_DYN!=e_type) { unsigned const len = sz_phdrs + e_phoff; alloc_file_image(file_image, len); f->seek(0, SEEK_SET); f->readx(file_image, len); phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !! } if (f && Elf32_Ehdr::ET_DYN==e_type) { // The DT_SYMTAB has no designated length. Read the whole file. alloc_file_image(file_image, file_size); f->seek(0, SEEK_SET); f->readx(file_image, file_size); phdri= (Elf32_Phdr *)(e_phoff + file_image); // do not free() !! shdri= (Elf32_Shdr *)(e_shoff + file_image); // do not free() !! if (opt->cmd != CMD_COMPRESS) { shdri = NULL; } sec_dynsym = elf_find_section_type(Elf32_Shdr::SHT_DYNSYM); if (sec_dynsym) { unsigned t = get_te32(&sec_dynsym->sh_link); if (e_shnum <= t) throwCantPack("bad dynsym->sh_link"); sec_dynstr = &shdri[t]; } Elf32_Phdr const *phdr= phdri; for (int j = e_phnum; --j>=0; ++phdr) if (Elf32_Phdr::PT_DYNAMIC==get_te32(&phdr->p_type)) { dynseg= (Elf32_Dyn const *)(check_pt_dynamic(phdr) + file_image); invert_pt_dynamic(dynseg); } else if (PT_LOAD32==get_te32(&phdr->p_type)) { check_pt_load(phdr); } // elf_find_dynamic() returns 0 if 0==dynseg. dynstr = (char const *)elf_find_dynamic(Elf32_Dyn::DT_STRTAB); dynsym = (Elf32_Sym const *)elf_find_dynamic(Elf32_Dyn::DT_SYMTAB); gashtab = (unsigned const *)elf_find_dynamic(Elf32_Dyn::DT_GNU_HASH); hashtab = (unsigned const *)elf_find_dynamic(Elf32_Dyn::DT_HASH); if (3& ((uintptr_t)dynsym | (uintptr_t)gashtab | (uintptr_t)hashtab)) { throwCantPack("unaligned DT_SYMTAB, DT_GNU_HASH, or DT_HASH/n"); } jni_onload_sym = elf_lookup("JNI_OnLoad"); if (jni_onload_sym) { jni_onload_va = get_te32(&jni_onload_sym->st_value); jni_onload_va = 0; // FIXME not understood; need example } } }
1
[ "CWE-787" ]
upx
4e2fdb464a885c694408552c31739cb04b77bdcf
268,744,237,030,719,100,000,000,000,000,000,000,000
81
Defend against bad PT_DYNAMIC https://github.com/upx/upx/issues/391 modified: p_lx_elf.cpp modified: p_lx_elf.h
_zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error) { char *r, *o; r = (char *)malloc(nulp ? len+1 : len); if (!r) { _zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } memcpy(r, *buf, len); *buf += len; if (nulp) { /* replace any in-string NUL characters with spaces */ r[len] = 0; for (o=r; o<r+len; o++) if (*o == '\0') *o = ' '; } return r; }
0
[ "CWE-189" ]
php-src
ef8fc4b53d92fbfcd8ef1abbd6f2f5fe2c4a11e5
55,918,233,862,689,220,000,000,000,000,000,000,000
23
Fix bug #69253 - ZIP Integer Overflow leads to writing past heap boundary
bool wsrep_sst_wait () { if (mysql_mutex_lock (&LOCK_wsrep_sst)) abort(); while (!sst_complete) { WSREP_INFO("Waiting for SST to complete."); mysql_cond_wait (&COND_wsrep_sst, &LOCK_wsrep_sst); } if (local_seqno >= 0) { WSREP_INFO("SST complete, seqno: %lld", (long long) local_seqno); } else { WSREP_ERROR("SST failed: %d (%s)", int(-local_seqno), strerror(-local_seqno)); } mysql_mutex_unlock (&LOCK_wsrep_sst); return (local_seqno >= 0); }
0
[ "CWE-77" ]
mysql-wsrep
4ea4b0c6a318209ac09b15aaa906c7b4a13b988c
128,562,313,397,696,520,000,000,000,000,000,000,000
23
codership/mysql-wsrep-bugs#758 Donor uses invalid SST methods
TEST(FormatterTest, UnmatchedBraces) { EXPECT_THROW_MSG(format("{"), FormatError, "invalid format string"); EXPECT_THROW_MSG(format("}"), FormatError, "unmatched '}' in format string"); EXPECT_THROW_MSG(format("{0{}"), FormatError, "invalid format string"); }
0
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
267,855,232,668,271,800,000,000,000,000,000,000,000
5
Fix segfault on complex pointer formatting (#642)
GF_Err gf_filter_pid_raw_new(GF_Filter *filter, const char *url, const char *local_file, const char *mime_type, const char *fext, u8 *probe_data, u32 probe_size, Bool trust_mime, GF_FilterPid **out_pid) { char tmp_ext[50]; u32 ext_len=0; Bool ext_not_trusted, is_new_pid = GF_FALSE; GF_FilterPid *pid = *out_pid; if (!pid) { pid = gf_filter_pid_new(filter); if (!pid) { return GF_OUT_OF_MEM; } pid->max_buffer_unit = 1; is_new_pid = GF_TRUE; *out_pid = pid; } gf_filter_pid_set_property(pid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_FILE) ); if (local_file) gf_filter_pid_set_property(pid, GF_PROP_PID_FILEPATH, &PROP_STRING(local_file)); if (url) { gf_filter_pid_set_property(pid, GF_PROP_PID_URL, &PROP_STRING(url)); if (!strnicmp(url, "isobmff://", 10)) { gf_filter_pid_set_name(pid, "isobmff://"); fext = "mp4"; mime_type = "video/mp4"; if (is_new_pid) gf_filter_pid_set_eos(pid); } else { char *sep = gf_file_basename(url); gf_filter_pid_set_name(pid, sep); } if (fext) { strncpy(tmp_ext, fext, 20); tmp_ext[20] = 0; strlwr(tmp_ext); gf_filter_pid_set_property(pid, GF_PROP_PID_FILE_EXT, &PROP_STRING(tmp_ext)); ext_len = (u32) strlen(tmp_ext); } else { char *ext = gf_file_ext_start(url); if (ext) ext++; if (ext) { char *s = strchr(ext, '#'); if (s) s[0] = 0; strncpy(tmp_ext, ext, 20); tmp_ext[20] = 0; strlwr(tmp_ext); gf_filter_pid_set_property(pid, GF_PROP_PID_FILE_EXT, &PROP_STRING(tmp_ext)); ext_len = (u32) strlen(tmp_ext); if (s) s[0] = '#'; } } } ext_not_trusted = GF_FALSE; //probe data if ((!mime_type || !trust_mime) && !filter->no_probe && is_new_pid && probe_data && probe_size && !(filter->session->flags & GF_FS_FLAG_NO_PROBE)) { u32 i, count; GF_FilterProbeScore score, max_score = GF_FPROBE_NOT_SUPPORTED; const char *probe_mime = NULL; gf_mx_p(filter->session->filters_mx); count = gf_list_count(filter->session->registry); for (i=0; i<count; i++) { const char *a_mime; const GF_FilterRegister *freg = gf_list_get(filter->session->registry, i); if (!freg || !freg->probe_data) continue; score = GF_FPROBE_NOT_SUPPORTED; a_mime = freg->probe_data(probe_data, probe_size, &score); if (score==GF_FPROBE_NOT_SUPPORTED) { u32 k; for (k=0;k<freg->nb_caps && !ext_not_trusted && ext_len; k++) { const char *value; const GF_FilterCapability *cap = &freg->caps[k]; if (!(cap->flags & GF_CAPFLAG_IN_BUNDLE)) continue; if (!(cap->flags & GF_CAPFLAG_INPUT)) continue; if (cap->code != GF_PROP_PID_FILE_EXT) continue; value = cap->val.value.string; while (value && ext_len) { const char *match = strstr(value, tmp_ext); if (!match) break; if (!match[ext_len] || (match[ext_len]=='|')) { ext_not_trusted = GF_TRUE; break; } value = match+ext_len; } } } else if (score==GF_FPROBE_EXT_MATCH) { if (a_mime && ext_len && strstr(a_mime, tmp_ext)) { ext_not_trusted = GF_FALSE; probe_mime = NULL; break; } } else { if (a_mime) { GF_LOG(GF_LOG_INFO, GF_LOG_FILTER, ("Data Prober (filter %s) detected format is%s mime %s\n", freg->name, (score==GF_FPROBE_SUPPORTED) ? "" : "maybe", a_mime)); } if (a_mime && (score > max_score)) { probe_mime = a_mime; max_score = score; } } } gf_mx_v(filter->session->filters_mx); pid->ext_not_trusted = ext_not_trusted; if (probe_mime) { mime_type = probe_mime; } } //we ignore mime type on pid reconfigure - some server will overwrite valid type to application/octet-string or binary/octet-string //on a byte-range request or secondary fetch //this is safe for now as the only reconfig we do is in HTTP streaming context //we furthermore blacklist *octet-* mimes if (mime_type && is_new_pid && !strstr(mime_type, "/octet-")) { strncpy(tmp_ext, mime_type, 50); tmp_ext[49] = 0; strlwr(tmp_ext); gf_filter_pid_set_property(pid, GF_PROP_PID_MIME, &PROP_STRING( tmp_ext )); //we have a mime, disable extension checking pid->ext_not_trusted = GF_TRUE; } return GF_OK; }
0
[ "CWE-787" ]
gpac
da37ec8582266983d0ec4b7550ec907401ec441e
224,613,772,832,450,340,000,000,000,000,000,000,000
133
fixed crashes for very long path - cf #1908
static int netif_alloc_netdev_queues(struct net_device *dev) { unsigned int count = dev->num_tx_queues; struct netdev_queue *tx; size_t sz = count * sizeof(*tx); if (count < 1 || count > 0xffff) return -EINVAL; tx = kvzalloc(sz, GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!tx) return -ENOMEM; dev->_tx = tx; netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); spin_lock_init(&dev->tx_global_lock); return 0;
0
[ "CWE-476" ]
linux
0ad646c81b2182f7fa67ec0c8c825e0ee165696d
249,394,858,704,674,600,000,000,000,000,000,000,000
20
tun: call dev_get_valid_name() before register_netdevice() register_netdevice() could fail early when we have an invalid dev name, in which case ->ndo_uninit() is not called. For tun device, this is a problem because a timer etc. are already initialized and it expects ->ndo_uninit() to clean them up. We could move these initializations into a ->ndo_init() so that register_netdevice() knows better, however this is still complicated due to the logic in tun_detach(). Therefore, I choose to just call dev_get_valid_name() before register_netdevice(), which is quicker and much easier to audit. And for this specific case, it is already enough. Fixes: 96442e42429e ("tuntap: choose the txq based on rxq") Reported-by: Dmitry Alexeev <[email protected]> Cc: Jason Wang <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void jpc_siz_destroyparms(jpc_ms_t *ms) { jpc_siz_t *siz = &ms->parms.siz; if (siz->comps) { jas_free(siz->comps); } }
0
[]
jasper
4031ca321d8cb5798c316ab39c7a5dc88a61fdd7
22,728,077,003,861,644,000,000,000,000,000,000,000
7
Incorporated changes from patch jasper-1.900.3-libjasper-stepsizes-overflow.patch
static void spl_object_storage_dtor(zval *element) /* {{{ */ { spl_SplObjectStorageElement *el = Z_PTR_P(element); zval_ptr_dtor(&el->obj); zval_ptr_dtor(&el->inf); efree(el); } /* }}} */
0
[ "CWE-119", "CWE-787" ]
php-src
61cdd1255d5b9c8453be71aacbbf682796ac77d4
271,871,362,835,160,080,000,000,000,000,000,000,000
7
Fix bug #73257 and bug #73258 - SplObjectStorage unserialize allows use of non-object as key
void ha_partition::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) { handler **file_array; table= table_arg; table_share= share; /* m_file can be NULL when using an old cached table in DROP TABLE, when the table just has REMOVED PARTITIONING, see Bug#42438 */ if (m_file) { file_array= m_file; DBUG_ASSERT(*file_array); do { (*file_array)->change_table_ptr(table_arg, share); } while (*(++file_array)); } if (m_added_file && m_added_file[0]) { /* if in middle of a drop/rename etc */ file_array= m_added_file; do { (*file_array)->change_table_ptr(table_arg, share); } while (*(++file_array)); } }
0
[]
mysql-server
be901b60ae59c93848c829d1b0b2cb523ab8692e
245,265,944,533,662,030,000,000,000,000,000,000,000
29
Bug#26390632: CREATE TABLE CAN CAUSE MYSQL TO EXIT. Analysis ======== CREATE TABLE of InnoDB table with a partition name which exceeds the path limit can cause the server to exit. During the preparation of the partition name, there was no check to identify whether the complete path name for partition exceeds the max supported path length, causing the server to exit during subsequent processing. Fix === During the preparation of partition name, check and report an error if the partition path name exceeds the maximum path name limit. This is a 5.5 patch.
PHP_FUNCTION(imagefilledellipse) { zval *IM; zend_long cx, cy, w, h, color; gdImagePtr im; if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &cx, &cy, &w, &h, &color) == FAILURE) { return; } if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { RETURN_FALSE; } gdImageFilledEllipse(im, cx, cy, w, h, color); RETURN_TRUE; }
0
[ "CWE-787" ]
php-src
28022c9b1fd937436ab67bb3d61f652c108baf96
230,599,746,754,788,340,000,000,000,000,000,000,000
18
Fix bug#72697 - select_colors write out-of-bounds (cherry picked from commit b6f13a5ef9d6280cf984826a5de012a32c396cd4) Conflicts: ext/gd/gd.c
large_bitmap(void) { const int nbits = 1 << 16; unsigned long *bits = kcalloc(BITS_TO_LONGS(nbits), sizeof(long), GFP_KERNEL); if (!bits) return; bitmap_set(bits, 1, 20); bitmap_set(bits, 60000, 15); test("1-20,60000-60014", "%*pbl", nbits, bits); kfree(bits); }
0
[ "CWE-200" ]
linux
ad67b74d2469d9b82aaa572d76474c95bc484d57
181,960,670,568,966,680,000,000,000,000,000,000,000
12
printk: hash addresses printed with %p Currently there exist approximately 14 000 places in the kernel where addresses are being printed using an unadorned %p. This potentially leaks sensitive information regarding the Kernel layout in memory. Many of these calls are stale, instead of fixing every call lets hash the address by default before printing. This will of course break some users, forcing code printing needed addresses to be updated. Code that _really_ needs the address will soon be able to use the new printk specifier %px to print the address. For what it's worth, usage of unadorned %p can be broken down as follows (thanks to Joe Perches). $ git grep -E '%p[^A-Za-z0-9]' | cut -f1 -d"/" | sort | uniq -c 1084 arch 20 block 10 crypto 32 Documentation 8121 drivers 1221 fs 143 include 101 kernel 69 lib 100 mm 1510 net 40 samples 7 scripts 11 security 166 sound 152 tools 2 virt Add function ptr_to_id() to map an address to a 32 bit unique identifier. Hash any unadorned usage of specifier %p and any malformed specifiers. Signed-off-by: Tobin C. Harding <[email protected]>
void ElectronBrowserHandlerImpl::MessageSync(bool internal, const std::string& channel, blink::CloneableMessage arguments, MessageSyncCallback callback) { api::WebContents* api_web_contents = api::WebContents::From(web_contents()); if (api_web_contents) { api_web_contents->MessageSync(internal, channel, std::move(arguments), std::move(callback), GetRenderFrameHost()); } }
1
[]
electron
e9fa834757f41c0b9fe44a4dffe3d7d437f52d34
324,939,230,780,998,770,000,000,000,000,000,000,000
10
fix: ensure ElectronBrowser mojo service is only bound to appropriate render frames (#33344) * fix: ensure ElectronBrowser mojo service is only bound to authorized render frames Notes: no-notes * refactor: extract electron API IPC to its own mojo interface * fix: just check main frame not primary main frame Co-authored-by: Samuel Attard <[email protected]> Co-authored-by: Samuel Attard <[email protected]>
dns_message_getsig0(dns_message_t *msg, dns_name_t **owner) { /* * Get the SIG(0) record for 'msg'. */ REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(owner == NULL || *owner == NULL); if (msg->sig0 != NULL && owner != NULL) { /* If dns_message_getsig0 is called on a rendered message * after the SIG(0) has been applied, we need to return the * root name, not NULL. */ if (msg->sig0name == NULL) *owner = dns_rootname; else *owner = msg->sig0name; } return (msg->sig0); }
0
[ "CWE-617" ]
bind9
6ed167ad0a647dff20c8cb08c944a7967df2d415
163,802,006,204,646,330,000,000,000,000,000,000,000
21
Always keep a copy of the message this allows it to be available even when dns_message_parse() returns a error.
tor_tls_get_pending_bytes(tor_tls_t *tls) { tor_assert(tls); return SSL_pending(tls->ssl); }
0
[ "CWE-264" ]
tor
638fdedcf16cf7d6f7c586d36f7ef335c1c9714f
61,700,102,607,651,850,000,000,000,000,000,000,000
5
Don't send a certificate chain on outgoing TLS connections from non-relays
inline void AveragePool(const PoolParams& params, const RuntimeShape& input_shape, const int16_t* input_data, const RuntimeShape& output_shape, int16_t* output_data) { TFLITE_DCHECK_LE(params.quantized_activation_min, params.quantized_activation_max); TFLITE_DCHECK_EQ(input_shape.DimensionsCount(), 4); TFLITE_DCHECK_EQ(output_shape.DimensionsCount(), 4); const int batches = MatchingDim(input_shape, 0, output_shape, 0); const int depth = MatchingDim(input_shape, 3, output_shape, 3); const int input_height = input_shape.Dims(1); const int input_width = input_shape.Dims(2); const int output_height = output_shape.Dims(1); const int output_width = output_shape.Dims(2); const int stride_height = params.stride_height; const int stride_width = params.stride_width; for (int batch = 0; batch < batches; ++batch) { for (int out_y = 0; out_y < output_height; ++out_y) { for (int out_x = 0; out_x < output_width; ++out_x) { for (int channel = 0; channel < depth; ++channel) { const int in_x_origin = (out_x * stride_width) - params.padding_values.width; const int in_y_origin = (out_y * stride_height) - params.padding_values.height; // Compute the boundaries of the filter region clamped so as to // ensure that the filter window fits in the input array. const int filter_x_start = std::max(0, -in_x_origin); const int filter_x_end = std::min(params.filter_width, input_width - in_x_origin); const int filter_y_start = std::max(0, -in_y_origin); const int filter_y_end = std::min(params.filter_height, input_height - in_y_origin); int32_t acc = 0; int filter_count = 0; for (int filter_y = filter_y_start; filter_y < filter_y_end; ++filter_y) { for (int filter_x = filter_x_start; filter_x < filter_x_end; ++filter_x) { const int in_x = in_x_origin + filter_x; const int in_y = in_y_origin + filter_y; acc += input_data[Offset(input_shape, batch, in_y, in_x, channel)]; filter_count++; } } // Round to the closest integer value. acc = acc > 0 ? (acc + filter_count / 2) / filter_count : (acc - filter_count / 2) / filter_count; acc = std::max(acc, params.quantized_activation_min); acc = std::min(acc, params.quantized_activation_max); output_data[Offset(output_shape, batch, out_y, out_x, channel)] = static_cast<int16_t>(acc); } } } } }
1
[ "CWE-703", "CWE-835" ]
tensorflow
dfa22b348b70bb89d6d6ec0ff53973bacb4f4695
140,919,246,887,249,800,000,000,000,000,000,000,000
58
Prevent a division by 0 in average ops. PiperOrigin-RevId: 385184660 Change-Id: I7affd4554f9b336fca29ac68f633232c094d0bd3
virtio_vq_init(struct virtio_base *base, uint32_t pfn) { struct virtio_vq_info *vq; uint64_t phys; size_t size; char *vb; vq = &base->queues[base->curq]; vq->pfn = pfn; phys = (uint64_t)pfn << VRING_PAGE_BITS; size = vring_size(vq->qsize, VIRTIO_PCI_VRING_ALIGN); vb = paddr_guest2host(base->dev->vmctx, phys, size); if (!vb) goto error; /* First page(s) are descriptors... */ vq->desc = (struct vring_desc *)vb; vb += vq->qsize * sizeof(struct vring_desc); /* ... immediately followed by "avail" ring (entirely uint16_t's) */ vq->avail = (struct vring_avail *)vb; vb += (2 + vq->qsize + 1) * sizeof(uint16_t); /* Then it's rounded up to the next page... */ vb = (char *)roundup2((uintptr_t)vb, VIRTIO_PCI_VRING_ALIGN); /* ... and the last page(s) are the used ring. */ vq->used = (struct vring_used *)vb; /* Start at 0 when we use it. */ vq->last_avail = 0; vq->save_used = 0; /* Mark queue as allocated after initialization is complete. */ mb(); vq->flags = VQ_ALLOC; return; error: vq->flags = 0; pr_err("%s: vq enable failed\n", __func__); }
0
[ "CWE-476" ]
acrn-hypervisor
154fe59531c12b82e26d1b24b5531f5066d224f5
262,121,393,924,580,430,000,000,000,000,000,000,000
43
dm: validate inputs in vq_endchains inputs shall be validated to avoid NULL pointer access. Tracked-On: #6129 Signed-off-by: Yonghua Huang <[email protected]>
const std::array<unsigned char, 16> uuid() const { int len = 0; const char* data = nullptr; if (isBinData(BinDataType::newUUID)) { data = binData(len); } uassert(ErrorCodes::InvalidUUID, "uuid must be a 16-byte binary field with UUID (4) subtype", len == 16); std::array<unsigned char, 16> result; memcpy(&result, data, len); return result; }
0
[ "CWE-613" ]
mongo
e55d6e2292e5dbe2f97153251d8193d1cc89f5d7
244,158,156,467,477,030,000,000,000,000,000,000,000
13
SERVER-38984 Validate unique User ID on UserCache hit
void int_CRYPTO_set_do_dynlock_callback( void (*dyn_cb)(int mode, int type, const char *file, int line)) { do_dynlock_cb = dyn_cb; }
0
[ "CWE-310" ]
openssl
270881316664396326c461ec7a124aec2c6cc081
125,393,933,193,056,610,000,000,000,000,000,000,000
5
Add and use a constant-time memcmp. This change adds CRYPTO_memcmp, which compares two vectors of bytes in an amount of time that's independent of their contents. It also changes several MAC compares in the code to use this over the standard memcmp, which may leak information about the size of a matching prefix. (cherry picked from commit 2ee798880a246d648ecddadc5b91367bee4a5d98) Conflicts: crypto/crypto.h ssl/t1_lib.c (cherry picked from commit dc406b59f3169fe191e58906df08dce97edb727c) Conflicts: crypto/crypto.h ssl/d1_pkt.c ssl/s3_pkt.c
bool const_item() const { return false; }
0
[ "CWE-617" ]
server
807945f2eb5fa22e6f233cc17b85a2e141efe2c8
332,116,846,468,394,420,000,000,000,000,000,000,000
1
MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order... When doing condition pushdown from HAVING into WHERE, Item_equal::create_pushable_equalities() calls item->set_extraction_flag(IMMUTABLE_FL) for constant items. Then, Item::cleanup_excluding_immutables_processor() checks for this flag to see if it should call item->cleanup() or leave the item as-is. The failure happens when a constant item has a non-constant one inside it, like: (tbl.col=0 AND impossible_cond) item->walk(cleanup_excluding_immutables_processor) works in a bottom-up way so it 1. will call Item_func_eq(tbl.col=0)->cleanup() 2. will not call Item_cond_and->cleanup (as the AND is constant) This creates an item tree where a fixed Item has an un-fixed Item inside it which eventually causes an assertion failure. Fixed by introducing this rule: instead of just calling item->set_extraction_flag(IMMUTABLE_FL); we call Item::walk() to set the flag for all sub-items of the item.
PJ_DEF(pj_status_t) pjmedia_sdp_neg_set_prefer_remote_codec_order( pjmedia_sdp_neg *neg, pj_bool_t prefer_remote) { PJ_ASSERT_RETURN(neg, PJ_EINVAL); neg->prefer_remote_codec_order = prefer_remote; return PJ_SUCCESS; }
0
[ "CWE-400", "CWE-200", "CWE-754" ]
pjproject
97b3d7addbaa720b7ddb0af9bf6f3e443e664365
135,161,748,195,259,280,000,000,000,000,000,000,000
8
Merge pull request from GHSA-hvq6-f89p-frvp
void LibRaw::fix_after_rawspeed(int bl) { if (load_raw == &LibRaw::lossy_dng_load_raw) C.maximum = 0xffff; else if (load_raw == &LibRaw::sony_load_raw) C.maximum = 0x3ff0; }
0
[ "CWE-129" ]
LibRaw
89d065424f09b788f443734d44857289489ca9e2
322,931,899,041,354,500,000,000,000,000,000,000,000
7
fixed two more problems found by fuzzer
static int mov_write_uuid_tag_ipod(AVIOContext *pb) { avio_wb32(pb, 28); ffio_wfourcc(pb, "uuid"); avio_wb32(pb, 0x6b6840f2); avio_wb32(pb, 0x5f244fc5); avio_wb32(pb, 0xba39a51b); avio_wb32(pb, 0xcf0323f3); avio_wb32(pb, 0x0); return 28; }
0
[ "CWE-369" ]
FFmpeg
2c0e98a0b478284bdff6d7a4062522605a8beae5
66,684,008,764,339,020,000,000,000,000,000,000,000
11
avformat/movenc: Write version 2 of audio atom if channels is not known The version 1 needs the channel count and would divide by 0 Fixes: division by 0 Fixes: fpe_movenc.c_1108_1.ogg Fixes: fpe_movenc.c_1108_2.ogg Fixes: fpe_movenc.c_1108_3.wav Found-by: #CHEN HONGXU# <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit fa19fbcf712a6a6cc5a5cfdc3254a97b9bce6582) Signed-off-by: Michael Niedermayer <[email protected]>
delete_files (CommonJob *job, GList *files, int *files_skipped) { GList *l; GFile *file; SourceInfo source_info; TransferInfo transfer_info; DeleteData data; if (job_aborted (job)) { return; } scan_sources (files, &source_info, job, OP_KIND_DELETE); if (job_aborted (job)) { return; } g_timer_start (job->time); memset (&transfer_info, 0, sizeof (transfer_info)); report_delete_progress (job, &source_info, &transfer_info); data.job = job; data.source_info = &source_info; data.transfer_info = &transfer_info; for (l = files; l != NULL && !job_aborted (job); l = l->next) { gboolean success; file = l->data; if (should_skip_file (job, file)) { (*files_skipped)++; continue; } success = delete_file_recursively (file, job->cancellable, file_deleted_callback, &data); if (!success) { (*files_skipped)++; } } }
0
[ "CWE-20" ]
nautilus
1630f53481f445ada0a455e9979236d31a8d3bb0
18,751,205,960,623,747,000,000,000,000,000,000,000
57
mime-actions: use file metadata for trusting desktop files Currently we only trust desktop files that have the executable bit set, and don't replace the displayed icon or the displayed name until it's trusted, which prevents for running random programs by a malicious desktop file. However, the executable permission is preserved if the desktop file comes from a compressed file. To prevent this, add a metadata::trusted metadata to the file once the user acknowledges the file as trusted. This adds metadata to the file, which cannot be added unless it has access to the computer. Also remove the SHEBANG "trusted" content we were putting inside the desktop file, since that doesn't add more security since it can come with the file itself. https://bugzilla.gnome.org/show_bug.cgi?id=777991
bool ndp_msg_opt_prefix_flag_on_link(struct ndp_msg *msg, int offset) { struct nd_opt_prefix_info *pi = ndp_msg_payload_opts_offset(msg, offset); return pi->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK; }
0
[ "CWE-284" ]
libndp
a4892df306e0532487f1634ba6d4c6d4bb381c7f
30,671,778,417,449,660,000,000,000,000,000,000,000
7
libndp: validate the IPv6 hop limit None of the NDP messages should ever come from a non-local network; as stated in RFC4861's 6.1.1 (RS), 6.1.2 (RA), 7.1.1 (NS), 7.1.2 (NA), and 8.1. (redirect): - The IP Hop Limit field has a value of 255, i.e., the packet could not possibly have been forwarded by a router. This fixes CVE-2016-3698. Reported by: Julien BERNARD <[email protected]> Signed-off-by: Lubomir Rintel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]>
static void Ins_SDPVTL( INS_ARG ) { Long A, B, C; Long p1, p2; /* was Int in pas type ERROR */ p1 = args[1]; p2 = args[0]; if ( BOUNDS( p2, CUR.zp1.n_points ) || BOUNDS( p1, CUR.zp2.n_points ) ) { CUR.error = TT_Err_Invalid_Reference; return; } A = CUR.zp1.org_x[p2] - CUR.zp2.org_x[p1]; B = CUR.zp1.org_y[p2] - CUR.zp2.org_y[p1]; if ( (CUR.opcode & 1) != 0 ) { C = B; /* CounterClockwise rotation */ B = A; A = -C; } if ( NORMalize( A, B, &CUR.GS.dualVector ) == FAILURE ) return; A = CUR.zp1.cur_x[p2] - CUR.zp2.cur_x[p1]; B = CUR.zp1.cur_y[p2] - CUR.zp2.cur_y[p1]; if ( (CUR.opcode & 1) != 0 ) { C = B; /* CounterClockwise rotation */ B = A; A = -C; } if ( NORMalize( A, B, &CUR.GS.projVector ) == FAILURE ) return; COMPUTE_Funcs(); }
0
[ "CWE-125" ]
ghostpdl
c7c55972758a93350882c32147801a3485b010fe
88,806,208,430,628,170,000,000,000,000,000,000,000
43
Bug 698024: bounds check zone pointer in Ins_MIRP()
plugin_flush (struct backend *b, struct connection *conn, uint32_t flags, int *err) { struct backend_plugin *p = container_of (b, struct backend_plugin, backend); int r; assert (connection_get_handle (conn, 0)); if (p->plugin.flush) r = p->plugin.flush (connection_get_handle (conn, 0), 0); else if (p->plugin._flush_old) r = p->plugin._flush_old (connection_get_handle (conn, 0)); else { *err = EINVAL; return -1; } if (r == -1) *err = get_error (p); return r; }
0
[ "CWE-406" ]
nbdkit
a6b88b195a959b17524d1c8353fd425d4891dc5f
265,648,894,389,843,020,000,000,000,000,000,000,000
20
server: Fix regression for NBD_OPT_INFO before NBD_OPT_GO Most known NBD clients do not bother with NBD_OPT_INFO (except for clients like 'qemu-nbd --list' that don't ever intend to connect), but go straight to NBD_OPT_GO. However, it's not too hard to hack up qemu to add in an extra client step (whether info on the same name, or more interestingly, info on a different name), as a patch against qemu commit 6f214b30445: | diff --git i/nbd/client.c w/nbd/client.c | index f6733962b49b..425292ac5ea9 100644 | --- i/nbd/client.c | +++ w/nbd/client.c | @@ -1038,6 +1038,14 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc, | * TLS). If it is not available, fall back to | * NBD_OPT_LIST for nicer error messages about a missing | * export, then use NBD_OPT_EXPORT_NAME. */ | + if (getenv ("HACK")) | + info->name[0]++; | + result = nbd_opt_info_or_go(ioc, NBD_OPT_INFO, info, errp); | + if (getenv ("HACK")) | + info->name[0]--; | + if (result < 0) { | + return -EINVAL; | + } | result = nbd_opt_info_or_go(ioc, NBD_OPT_GO, info, errp); | if (result < 0) { | return -EINVAL; This works just fine in 1.14.0, where we call .open only once (so the INFO and GO repeat calls into the same plugin handle), but in 1.14.1 it regressed into causing an assertion failure: we are now calling .open a second time on a connection that is already opened: $ nbdkit -rfv null & $ hacked-qemu-io -f raw -r nbd://localhost -c quit ... nbdkit: null[1]: debug: null: open readonly=1 nbdkit: backend.c:179: backend_open: Assertion `h->handle == NULL' failed. Worse, on the mainline development, we have recently made it possible for plugins to actively report different information for different export names; for example, a plugin may choose to report different answers for .can_write on export A than for export B; but if we share cached handles, then an NBD_OPT_INFO on one export prevents correct answers for NBD_OPT_GO on the second export name. (The HACK envvar in my qemu modifications can be used to demonstrate cross-name requests, which are even less likely in a real client). The solution is to call .close after NBD_OPT_INFO, coupled with enough glue logic to reset cached connection handles back to the state expected by .open. This in turn means factoring out another backend_* function, but also gives us an opportunity to change backend_set_handle to no longer accept NULL. The assertion failure is, to some extent, a possible denial of service attack (one client can force nbdkit to exit by merely sending OPT_INFO before OPT_GO, preventing the next client from connecting), although this is mitigated by using TLS to weed out untrusted clients. Still, the fact that we introduced a potential DoS attack while trying to fix a traffic amplification security bug is not very nice. Sadly, as there are no known clients that easily trigger this mode of operation (OPT_INFO before OPT_GO), there is no easy way to cover this via a testsuite addition. I may end up hacking something into libnbd. Fixes: c05686f957 Signed-off-by: Eric Blake <[email protected]>
static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl) { return sys_acl_set_fd(handle, fsp, theacl); }
0
[ "CWE-665" ]
samba
30e724cbff1ecd90e5a676831902d1e41ec1b347
137,611,613,837,518,040,000,000,000,000,000,000,000
4
FSCTL_GET_SHADOW_COPY_DATA: Initialize output array to zero Otherwise num_volumes and the end marker can return uninitialized data to the client. Signed-off-by: Christof Schmitt <[email protected]> Reviewed-by: Jeremy Allison <[email protected]> Reviewed-by: Simo Sorce <[email protected]>
PHP_FUNCTION(dom_document_create_attribute_ns) { zval *id; xmlDocPtr docp; xmlNodePtr nodep = NULL, root; xmlNsPtr nsptr; int ret, uri_len = 0, name_len = 0; char *uri, *name; char *localname = NULL, *prefix = NULL; dom_object *intern; int errorcode; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); root = xmlDocGetRootElement(docp); if (root != NULL) { errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len); if (errorcode == 0) { if (xmlValidateName((xmlChar *) localname, 0) == 0) { nodep = (xmlNodePtr) xmlNewDocProp(docp, localname, NULL); if (nodep != NULL && uri_len > 0) { nsptr = xmlSearchNsByHref (nodep->doc, root, uri); if (nsptr == NULL) { nsptr = dom_get_ns(root, uri, &errorcode, prefix); } xmlSetNs(nodep, nsptr); } } else { errorcode = INVALID_CHARACTER_ERR; } } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document Missing Root Element"); RETURN_FALSE; } xmlFree(localname); if (prefix != NULL) { xmlFree(prefix); } if (errorcode != 0) { if (nodep != NULL) { xmlFreeProp((xmlAttrPtr) nodep); } php_dom_throw_error(errorcode, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } if (nodep == NULL) { RETURN_FALSE; } DOM_RET_OBJ(nodep, &ret, intern); }
0
[ "CWE-20" ]
php-src
52b93f0cfd3cba7ff98cc5198df6ca4f23865f80
108,499,303,209,830,600,000,000,000,000,000,000,000
59
Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
const std::string& FilePath() const { return _testFilePath; }
0
[ "CWE-755" ]
mongo
75f7184eafa78006a698cda4c4adfb57f1290047
46,661,052,162,440,760,000,000,000,000,000,000,000
3
SERVER-50170 fix max staleness read preference parameter for server selection
static void security_info_free(struct security_info *i) { if (!i) return; free(i->id); free(i->type); free(i->load_state); free(i->fragment_path); free(i->user); free(i->protect_home); free(i->protect_system); free(i->root_directory); free(i->root_image); free(i->keyring_mode); free(i->notify_access); free(i->device_policy); strv_free(i->supplementary_groups); strv_free(i->system_call_architectures); set_free_free(i->system_call_filter); }
0
[ "CWE-269" ]
systemd
9d880b70ba5c6ca83c82952f4c90e86e56c7b70c
335,810,483,525,223,700,000,000,000,000,000,000,000
27
analyze: check for RestrictSUIDSGID= in "systemd-analyze security" And let's give it a heigh weight, since it pretty much can be used for bad things only.
CImg<T>& assign(const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1) { const size_t siz = safe_size(size_x,size_y,size_z,size_c); if (!siz) return assign(); const size_t curr_siz = (size_t)size(); if (siz!=curr_siz) { if (_is_shared) throw CImgArgumentException(_cimg_instance "assign(): Invalid assignment request of shared instance from specified " "image (%u,%u,%u,%u).", cimg_instance, size_x,size_y,size_z,size_c); else { delete[] _data; try { _data = new T[siz]; } catch (...) { _width = _height = _depth = _spectrum = 0; _data = 0; throw CImgInstanceException(_cimg_instance "assign(): Failed to allocate memory (%s) for image (%u,%u,%u,%u).", cimg_instance, cimg::strbuffersize(sizeof(T)*size_x*size_y*size_z*size_c), size_x,size_y,size_z,size_c); } } } _width = size_x; _height = size_y; _depth = size_z; _spectrum = size_c; return *this; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
103,217,977,993,639,370,000,000,000,000,000,000,000
27
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
_equalCreateOpFamilyStmt(const CreateOpFamilyStmt *a, const CreateOpFamilyStmt *b) { COMPARE_NODE_FIELD(opfamilyname); COMPARE_STRING_FIELD(amname); return true; }
0
[ "CWE-362" ]
postgres
5f173040e324f6c2eebb90d86cf1b0cdb5890f0a
111,076,853,163,079,070,000,000,000,000,000,000,000
7
Avoid repeated name lookups during table and index DDL. If the name lookups come to different conclusions due to concurrent activity, we might perform some parts of the DDL on a different table than other parts. At least in the case of CREATE INDEX, this can be used to cause the permissions checks to be performed against a different table than the index creation, allowing for a privilege escalation attack. This changes the calling convention for DefineIndex, CreateTrigger, transformIndexStmt, transformAlterTableStmt, CheckIndexCompatible (in 9.2 and newer), and AlterTable (in 9.1 and older). In addition, CheckRelationOwnership is removed in 9.2 and newer and the calling convention is changed in older branches. A field has also been added to the Constraint node (FkConstraint in 8.4). Third-party code calling these functions or using the Constraint node will require updating. Report by Andres Freund. Patch by Robert Haas and Andres Freund, reviewed by Tom Lane. Security: CVE-2014-0062
void r_pkcs7_free_digestalgorithmidentifier (RPKCS7DigestAlgorithmIdentifiers *dai) { ut32 i; if (dai) { for (i = 0; i < dai->length; ++i) { if (dai->elements[i]) { r_x509_free_algorithmidentifier (dai->elements[i]); // r_x509_free_algorithmidentifier doesn't free the pointer // because on x509 the original use was internal. R_FREE (dai->elements[i]); } } R_FREE (dai->elements); // Used internally pkcs #7, so it should't free dai. } }
0
[ "CWE-476" ]
radare2
7ab66cca5bbdf6cb2d69339ef4f513d95e532dbf
17,177,845,835,799,430,000,000,000,000,000,000,000
15
Fix #7152 - Null deref in cms
static int fuse_verify_xattr_list(char *list, size_t size) { size_t origsize = size; while (size) { size_t thislen = strnlen(list, size); if (!thislen || thislen == size) return -EIO; size -= thislen + 1; list += thislen + 1; } return origsize; }
0
[ "CWE-459" ]
linux
5d069dbe8aaf2a197142558b6fb2978189ba3454
219,212,144,442,867,030,000,000,000,000,000,000,000
16
fuse: fix bad inode Jan Kara's analysis of the syzbot report (edited): The reproducer opens a directory on FUSE filesystem, it then attaches dnotify mark to the open directory. After that a fuse_do_getattr() call finds that attributes returned by the server are inconsistent, and calls make_bad_inode() which, among other things does: inode->i_mode = S_IFREG; This then confuses dnotify which doesn't tear down its structures properly and eventually crashes. Avoid calling make_bad_inode() on a live inode: switch to a private flag on the fuse inode. Also add the test to ops which the bad_inode_ops would have caught. This bug goes back to the initial merge of fuse in 2.6.14... Reported-by: [email protected] Signed-off-by: Miklos Szeredi <[email protected]> Tested-by: Jan Kara <[email protected]> Cc: <[email protected]>
int redisFormatSdsCommandArgv(hisds *target, int argc, const char **argv, const size_t *argvlen) { hisds cmd, aux; unsigned long long totlen; int j; size_t len; /* Abort on a NULL target */ if (target == NULL) return -1; /* Calculate our total size */ totlen = 1+countDigits(argc)+2; for (j = 0; j < argc; j++) { len = argvlen ? argvlen[j] : strlen(argv[j]); totlen += bulklen(len); } /* Use an SDS string for command construction */ cmd = hi_sdsempty(); if (cmd == NULL) return -1; /* We already know how much storage we need */ aux = hi_sdsMakeRoomFor(cmd, totlen); if (aux == NULL) { hi_sdsfree(cmd); return -1; } cmd = aux; /* Construct command */ cmd = hi_sdscatfmt(cmd, "*%i\r\n", argc); for (j=0; j < argc; j++) { len = argvlen ? argvlen[j] : strlen(argv[j]); cmd = hi_sdscatfmt(cmd, "$%u\r\n", len); cmd = hi_sdscatlen(cmd, argv[j], len); cmd = hi_sdscatlen(cmd, "\r\n", sizeof("\r\n")-1); } assert(hi_sdslen(cmd)==totlen); *target = cmd; return totlen; }
0
[ "CWE-190", "CWE-680" ]
redis
0215324a66af949be39b34be2d55143232c1cb71
330,988,123,409,925,370,000,000,000,000,000,000,000
47
Fix redis-cli / redis-sential overflow on some platforms (CVE-2021-32762) (#9587) The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. Co-authored-by: Yossi Gottlieb <[email protected]>
static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head, struct canfd_frame *frames, int has_timestamp) { struct sk_buff *skb; struct canfd_frame *firstframe; struct sockaddr_can *addr; struct sock *sk = op->sk; unsigned int datalen = head->nframes * op->cfsiz; int err; skb = alloc_skb(sizeof(*head) + datalen, gfp_any()); if (!skb) return; skb_put_data(skb, head, sizeof(*head)); if (head->nframes) { /* CAN frames starting here */ firstframe = (struct canfd_frame *)skb_tail_pointer(skb); skb_put_data(skb, frames, datalen); /* * the BCM uses the flags-element of the canfd_frame * structure for internal purposes. This is only * relevant for updates that are generated by the * BCM, where nframes is 1 */ if (head->nframes == 1) firstframe->flags &= BCM_CAN_FLAGS_MASK; } if (has_timestamp) { /* restore rx timestamp */ skb->tstamp = op->rx_stamp; } /* * Put the datagram to the queue so that bcm_recvmsg() can * get it from there. We need to pass the interface index to * bcm_recvmsg(). We pass a whole struct sockaddr_can in skb->cb * containing the interface index. */ sock_skb_cb_check_size(sizeof(struct sockaddr_can)); addr = (struct sockaddr_can *)skb->cb; memset(addr, 0, sizeof(*addr)); addr->can_family = AF_CAN; addr->can_ifindex = op->rx_ifindex; err = sock_queue_rcv_skb(sk, skb); if (err < 0) { struct bcm_sock *bo = bcm_sk(sk); kfree_skb(skb); /* don't care about overflows in this statistic */ bo->dropped_usr_msgs++; } }
0
[ "CWE-362" ]
linux
d5f9023fa61ee8b94f37a93f08e94b136cf1e463
182,962,786,325,777,460,000,000,000,000,000,000,000
59
can: bcm: delay release of struct bcm_op after synchronize_rcu() can_rx_register() callbacks may be called concurrently to the call to can_rx_unregister(). The callbacks and callback data, though, are protected by RCU and the struct sock reference count. So the callback data is really attached to the life of sk, meaning that it should be released on sk_destruct. However, bcm_remove_op() calls tasklet_kill(), and RCU callbacks may be called under RCU softirq, so that cannot be used on kernels before the introduction of HRTIMER_MODE_SOFT. However, bcm_rx_handler() is called under RCU protection, so after calling can_rx_unregister(), we may call synchronize_rcu() in order to wait for any RCU read-side critical sections to finish. That is, bcm_rx_handler() won't be called anymore for those ops. So, we only free them, after we do that synchronize_rcu(). Fixes: ffd980f976e7 ("[CAN]: Add broadcast manager (bcm) protocol") Link: https://lore.kernel.org/r/[email protected] Cc: linux-stable <[email protected]> Reported-by: [email protected] Reported-by: Norbert Slusarek <[email protected]> Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Acked-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
TEST_F(RouterTest, PoolFailureDueToConnectTimeout) { ON_CALL(callbacks_.route_->route_entry_, priority()) .WillByDefault(Return(Upstream::ResourcePriority::High)); EXPECT_CALL(cm_.thread_local_cluster_, httpConnPool(Upstream::ResourcePriority::High, _, &router_)); EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _)) .WillOnce(Invoke([&](Http::StreamDecoder&, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { callbacks.onPoolFailure(ConnectionPool::PoolFailureReason::Timeout, "connect_timeout", cm_.thread_local_cluster_.conn_pool_.host_); return nullptr; })); Http::TestResponseHeaderMapImpl response_headers{ {":status", "503"}, {"content-length", "134"}, {"content-type", "text/plain"}}; EXPECT_CALL(callbacks_, encodeHeaders_(HeaderMapEqualRef(&response_headers), false)); EXPECT_CALL(callbacks_, encodeData(_, true)); EXPECT_CALL(callbacks_.stream_info_, setResponseFlag(StreamInfo::ResponseFlag::UpstreamConnectionFailure)); EXPECT_CALL(callbacks_.stream_info_, onUpstreamHostSelected(_)) .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { EXPECT_EQ(host_address_, host->address()); })); Http::TestRequestHeaderMapImpl headers; HttpTestUtility::addDefaultHeaders(headers); router_.decodeHeaders(headers, true); EXPECT_TRUE(verifyHostUpstreamStats(0, 1)); // Pool failure, so upstream request was not initiated. EXPECT_EQ(0U, callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value()); EXPECT_EQ(callbacks_.details(), "upstream_reset_before_response_started{connection failure,connect_timeout}"); }
0
[ "CWE-703" ]
envoy
18871dbfb168d3512a10c78dd267ff7c03f564c6
87,079,723,665,292,690,000,000,000,000,000,000,000
34
[1.18] CVE-2022-21655 Crash with direct_response Signed-off-by: Otto van der Schaaf <[email protected]>
setCurlURL(instanceData *pData, uchar **tpls) { char authBuf[1024]; uchar *searchIndex; uchar *searchType; uchar *parent; uchar *bulkId; es_str_t *url; int rLocal; int r; DEFiRet; setBaseURL(pData, &url); if(pData->bulkmode) { r = es_addBuf(&url, "_bulk", sizeof("_bulk")-1); parent = NULL; } else { getIndexTypeAndParent(pData, tpls, &searchIndex, &searchType, &parent, &bulkId); r = es_addBuf(&url, (char*)searchIndex, ustrlen(searchIndex)); if(r == 0) r = es_addChar(&url, '/'); if(r == 0) r = es_addBuf(&url, (char*)searchType, ustrlen(searchType)); } if(r == 0) r = es_addChar(&url, '?'); if(pData->asyncRepl) { if(r == 0) r = es_addBuf(&url, "replication=async&", sizeof("replication=async&")-1); } if(pData->timeout != NULL) { if(r == 0) r = es_addBuf(&url, "timeout=", sizeof("timeout=")-1); if(r == 0) r = es_addBuf(&url, (char*)pData->timeout, ustrlen(pData->timeout)); if(r == 0) r = es_addChar(&url, '&'); } if(parent != NULL) { if(r == 0) r = es_addBuf(&url, "parent=", sizeof("parent=")-1); if(r == 0) r = es_addBuf(&url, (char*)parent, ustrlen(parent)); } free(pData->restURL); pData->restURL = (uchar*)es_str2cstr(url, NULL); curl_easy_setopt(pData->curlHandle, CURLOPT_URL, pData->restURL); es_deleteStr(url); DBGPRINTF("omelasticsearch: using REST URL: '%s'\n", pData->restURL); if(pData->uid != NULL) { rLocal = snprintf(authBuf, sizeof(authBuf), "%s:%s", pData->uid, (pData->pwd == NULL) ? "" : (char*)pData->pwd); if(rLocal < 1) { errmsg.LogError(0, RS_RET_ERR, "omelasticsearch: snprintf failed " "when trying to build auth string (return %d)\n", rLocal); ABORT_FINALIZE(RS_RET_ERR); } curl_easy_setopt(pData->curlHandle, CURLOPT_USERPWD, authBuf); curl_easy_setopt(pData->curlHandle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); } finalize_it: RETiRet; }
0
[ "CWE-399" ]
rsyslog
80f88242982c9c6ad6ce8628fc5b94ea74051cf4
126,406,900,006,017,630,000,000,000,000,000,000,000
59
bugfix: double-free in omelasticsearch closes: http://bugzilla.adiscon.com/show_bug.cgi?id=461 Thanks to Marius Ionescu for providing a detailled bug report
CotpConnection_parseIncomingMessage(CotpConnection* self) { CotpIndication indication = parseCotpMessage(self); self->readBuffer->size = 0; self->packetSize = 0; return indication; }
0
[ "CWE-122" ]
libiec61850
033ab5b6488250c8c3b838f25a7cbc3e099230bb
260,031,883,440,343,800,000,000,000,000,000,000,000
9
- COTP: fixed possible heap buffer overflow when handling message with invalid (zero) value in length field (#250)
static void __init apply_trace_boot_options(void) { char *buf = trace_boot_options_buf; char *option; while (true) { option = strsep(&buf, ","); if (!option) break; if (*option) trace_set_options(&global_trace, option); /* Put back the comma to allow this to be called again */ if (buf) *(buf - 1) = ','; } }
0
[ "CWE-415" ]
linux
4397f04575c44e1440ec2e49b6302785c95fd2f8
117,221,522,482,041,480,000,000,000,000,000,000,000
19
tracing: Fix possible double free on failure of allocating trace buffer Jing Xia and Chunyan Zhang reported that on failing to allocate part of the tracing buffer, memory is freed, but the pointers that point to them are not initialized back to NULL, and later paths may try to free the freed memory again. Jing and Chunyan fixed one of the locations that does this, but missed a spot. Link: http://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: 737223fbca3b1 ("tracing: Consolidate buffer allocation code") Reported-by: Jing Xia <[email protected]> Reported-by: Chunyan Zhang <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
int epo_draw_thin_line(gx_device *dev, fixed fx0, fixed fy0, fixed fx1, fixed fy1, const gx_drawing_color *pdcolor, gs_logical_operation_t lop, fixed adjustx, fixed adjusty) { int code = epo_handle_erase_page(dev); if (code != 0) return code; return dev_proc(dev, draw_thin_line)(dev, fx0, fy0, fx1, fy1, pdcolor, lop, adjustx, adjusty); }
0
[]
ghostpdl
c9b362ba908ca4b1d7c72663a33229588012d7d9
236,957,612,605,208,660,000,000,000,000,000,000,000
10
Bug 699670: disallow copying of the epo device The erasepage optimisation (epo) subclass device shouldn't be allowed to be copied because the subclass private data, child and parent pointers end up being shared between the original device and the copy. Add an epo_finish_copydevice which NULLs the three offending pointers, and then communicates to the caller that copying is not allowed. This also exposed a separate issue with the stype for subclasses devices. Devices are, I think, unique in having two stype objects associated with them: the usual one in the memory manager header, and the other stored in the device structere directly. In order for the stype to be correct, we have to use the stype for the incoming device, with the ssize of the original device (ssize should reflect the size of the memory allocation). We correctly did so with the stype in the device structure, but then used the prototype device's stype to patch the memory manager stype - meaning the ssize potentially no longer matched the allocated memory. This caused problems in the garbager where there is an implicit assumption that the size of a single object clump (c_alone == 1) is also the size (+ memory manager overheads) of the single object it contains. The solution is to use the same stype instance to patch the memory manager data as we do in the device structure (with the correct ssize).
clientListenerConnectionOpened(AnyP::PortCfgPointer &s, const Ipc::FdNoteId portTypeNote, const Subscription::Pointer &sub) { Must(s != NULL); if (!OpenedHttpSocket(s->listenConn, portTypeNote)) return; Must(Comm::IsConnOpen(s->listenConn)); // TCP: setup a job to handle accept() with subscribed handler AsyncJob::Start(new Comm::TcpAcceptor(s, FdNote(portTypeNote), sub)); debugs(1, DBG_IMPORTANT, "Accepting " << (s->flags.natIntercept ? "NAT intercepted " : "") << (s->flags.tproxyIntercept ? "TPROXY intercepted " : "") << (s->flags.tunnelSslBumping ? "SSL bumped " : "") << (s->flags.accelSurrogate ? "reverse-proxy " : "") << FdNote(portTypeNote) << " connections at " << s->listenConn); Must(AddOpenedHttpSocket(s->listenConn)); // otherwise, we have received a fd we did not ask for #if USE_SYSTEMD // When the very first port opens, tell systemd we are able to serve connections. // Subsequent sd_notify() calls, including calls during reconfiguration, // do nothing because the first call parameter is 1. // XXX: Send the notification only after opening all configured ports. if (opt_foreground || opt_no_daemon) { const auto result = sd_notify(1, "READY=1"); if (result < 0) { debugs(1, DBG_IMPORTANT, "WARNING: failed to send start-up notification to systemd" << Debug::Extra << "sd_notify() error: " << xstrerr(-result)); } } #endif }
0
[ "CWE-444" ]
squid
fd68382860633aca92065e6c343cfd1b12b126e7
248,477,666,967,991,220,000,000,000,000,000,000,000
36
Improve Transfer-Encoding handling (#702) Reject messages containing Transfer-Encoding header with coding other than chunked or identity. Squid does not support other codings. For simplicity and security sake, also reject messages where Transfer-Encoding contains unnecessary complex values that are technically equivalent to "chunked" or "identity" (e.g., ",,chunked" or "identity, chunked"). RFC 7230 formally deprecated and removed identity coding, but it is still used by some agents.
void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, int r0, int c0, int r1, int c1) { int i; if (mat0->data_) { if (!(mat0->flags_ & JAS_MATRIX_REF)) { jas_free(mat0->data_); } mat0->data_ = 0; mat0->datasize_ = 0; } if (mat0->rows_) { jas_free(mat0->rows_); mat0->rows_ = 0; } mat0->flags_ |= JAS_MATRIX_REF; mat0->numrows_ = r1 - r0 + 1; mat0->numcols_ = c1 - c0 + 1; mat0->maxrows_ = mat0->numrows_; mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *)); for (i = 0; i < mat0->numrows_; ++i) { mat0->rows_[i] = mat1->rows_[r0 + i] + c0; } mat0->xstart_ = mat1->xstart_ + c0; mat0->ystart_ = mat1->ystart_ + r0; mat0->xend_ = mat0->xstart_ + mat0->numcols_; mat0->yend_ = mat0->ystart_ + mat0->numrows_; }
1
[ "CWE-189" ]
jasper
3c55b399c36ef46befcb21e4ebc4799367f89684
323,202,212,214,647,750,000,000,000,000,000,000,000
30
At many places in the code, jas_malloc or jas_recalloc was being invoked with the size argument being computed in a manner that would not allow integer overflow to be detected. Now, these places in the code have been modified to use special-purpose memory allocation functions (e.g., jas_alloc2, jas_alloc3, jas_realloc2) that check for overflow. This should fix many security problems.
TEST(ExistsMatchExpression, MatchesScalar) { ExistsMatchExpression exists("a"); ASSERT(exists.matchesBSON(BSON("a" << 1), NULL)); ASSERT(exists.matchesBSON(BSON("a" << BSONNULL), NULL)); ASSERT(!exists.matchesBSON(BSON("b" << 1), NULL)); }
0
[]
mongo
64095239f41e9f3841d8be9088347db56d35c891
56,554,947,109,169,365,000,000,000,000,000,000,000
6
SERVER-51083 Reject invalid UTF-8 from $regex match expressions
static double mp_max(_cimg_math_parser& mp) { const unsigned int i_end = (unsigned int)mp.opcode[2]; double val = _mp_arg(3); for (unsigned int i = 4; i<i_end; ++i) val = std::max(val,_mp_arg(i)); return val; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
272,232,191,155,145,500,000,000,000,000,000,000,000
6
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
static void jpc_dec_destroy(jpc_dec_t *dec) { if (dec->cstate) { jpc_cstate_destroy(dec->cstate); } if (dec->pkthdrstreams) { jpc_streamlist_destroy(dec->pkthdrstreams); } if (dec->image) { jas_image_destroy(dec->image); } if (dec->cp) { jpc_dec_cp_destroy(dec->cp); } if (dec->cmpts) { jas_free(dec->cmpts); } if (dec->tiles) { int tileno; jpc_dec_tile_t *tile; for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno, ++tile) { if (tile->state != JPC_TILE_DONE) { jpc_dec_tilefini(dec, tile); } } jas_free(dec->tiles); } jas_free(dec); }
0
[ "CWE-787" ]
jasper
e2f2e5f4022baef2386eec25c57b63debfe4cb20
223,905,072,948,580,500,000,000,000,000,000,000,000
36
jas_seq: check bounds in jas_seq2d_bindsub() Fixes CVE-2017-5503, CVE-2017-5504, CVE-2017-5505, Closes https://github.com/jasper-maint/jasper/issues/3 Closes https://github.com/jasper-maint/jasper/issues/4 Closes https://github.com/jasper-maint/jasper/issues/5 Closes https://github.com/mdadams/jasper/issues/88 Closes https://github.com/mdadams/jasper/issues/89 Closes https://github.com/mdadams/jasper/issues/90
static Bool session_should_abort(GF_FilterSession *fs) { if (fs->run_status<GF_OK) return GF_TRUE; if (!fs->run_status) return GF_FALSE; return fs->in_final_flush; }
0
[ "CWE-787" ]
gpac
da37ec8582266983d0ec4b7550ec907401ec441e
23,356,603,386,204,815,000,000,000,000,000,000,000
6
fixed crashes for very long path - cf #1908
static int vfat_fill_super(struct super_block *sb, void *data, int silent) { return fat_fill_super(sb, data, silent, 1, setup); }
0
[ "CWE-119", "CWE-787" ]
linux
0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd
339,012,180,152,127,800,000,000,000,000,000,000,000
4
NLS: improve UTF8 -> UTF16 string conversion routine The utf8s_to_utf16s conversion routine needs to be improved. Unlike its utf16s_to_utf8s sibling, it doesn't accept arguments specifying the maximum length of the output buffer or the endianness of its 16-bit output. This patch (as1501) adds the two missing arguments, and adjusts the only two places in the kernel where the function is called. A follow-on patch will add a third caller that does utilize the new capabilities. The two conversion routines are still annoyingly inconsistent in the way they handle invalid byte combinations. But that's a subject for a different patch. Signed-off-by: Alan Stern <[email protected]> CC: Clemens Ladisch <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static void __d_rehash(struct dentry *entry) { struct hlist_bl_head *b = d_hash(entry->d_name.hash); BUG_ON(!d_unhashed(entry)); hlist_bl_lock(b); hlist_bl_add_head_rcu(&entry->d_hash, b); hlist_bl_unlock(b); }
0
[ "CWE-362", "CWE-399" ]
linux
49d31c2f389acfe83417083e1208422b4091cd9e
320,603,441,307,911,500,000,000,000,000,000,000,000
8
dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <[email protected]>
static USBDevice *ehci_find_device(EHCIState *ehci, uint8_t addr) { USBDevice *dev; USBPort *port; int i; for (i = 0; i < NB_PORTS; i++) { port = &ehci->ports[i]; if (!(ehci->portsc[i] & PORTSC_PED)) { DPRINTF("Port %d not enabled\n", i); continue; } dev = usb_find_device(port, addr); if (dev != NULL) { return dev; } } return NULL; }
0
[]
qemu
791f97758e223de3290592d169f8e6339c281714
196,637,487,082,238,440,000,000,000,000,000,000,000
19
usb: ehci: fix memory leak in ehci_init_transfer In ehci_init_transfer function, if the 'cpage' is bigger than 4, it doesn't free the 'p->sgl' once allocated previously thus leading a memory leak issue. This patch avoid this. Signed-off-by: Li Qiang <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]>
poly_contained(PG_FUNCTION_ARGS) { Datum polya = PG_GETARG_DATUM(0); Datum polyb = PG_GETARG_DATUM(1); /* Just switch the arguments and pass it off to poly_contain */ PG_RETURN_DATUM(DirectFunctionCall2(poly_contain, polyb, polya)); }
0
[ "CWE-703", "CWE-189" ]
postgres
31400a673325147e1205326008e32135a78b4d8a
219,227,451,224,147,330,000,000,000,000,000,000,000
8
Predict integer overflow to avoid buffer overruns. Several functions, mostly type input functions, calculated an allocation size such that the calculation wrapped to a small positive value when arguments implied a sufficiently-large requirement. Writes past the end of the inadvertent small allocation followed shortly thereafter. Coverity identified the path_in() vulnerability; code inspection led to the rest. In passing, add check_stack_depth() to prevent stack overflow in related functions. Back-patch to 8.4 (all supported versions). The non-comment hstore changes touch code that did not exist in 8.4, so that part stops at 9.0. Noah Misch and Heikki Linnakangas, reviewed by Tom Lane. Security: CVE-2014-0064
loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info) { memset(info, 0, sizeof(*info)); info->lo_number = info64->lo_number; info->lo_device = info64->lo_device; info->lo_inode = info64->lo_inode; info->lo_rdevice = info64->lo_rdevice; info->lo_offset = info64->lo_offset; info->lo_encrypt_type = info64->lo_encrypt_type; info->lo_encrypt_key_size = info64->lo_encrypt_key_size; info->lo_flags = info64->lo_flags; info->lo_init[0] = info64->lo_init[0]; info->lo_init[1] = info64->lo_init[1]; if (info->lo_encrypt_type == LO_CRYPT_CRYPTOAPI) memcpy(info->lo_name, info64->lo_crypt_name, LO_NAME_SIZE); else memcpy(info->lo_name, info64->lo_file_name, LO_NAME_SIZE); memcpy(info->lo_encrypt_key, info64->lo_encrypt_key, LO_KEY_SIZE); /* error in case values were truncated */ if (info->lo_device != info64->lo_device || info->lo_rdevice != info64->lo_rdevice || info->lo_inode != info64->lo_inode || info->lo_offset != info64->lo_offset) return -EOVERFLOW; return 0; }
0
[ "CWE-416", "CWE-362" ]
linux
ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5
309,995,229,688,518,920,000,000,000,000,000,000,000
28
loop: fix concurrent lo_open/lo_release 范龙飞 reports that KASAN can report a use-after-free in __lock_acquire. The reason is due to insufficient serialization in lo_release(), which will continue to use the loop device even after it has decremented the lo_refcnt to zero. In the meantime, another process can come in, open the loop device again as it is being shut down. Confusion ensues. Reported-by: 范龙飞 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
static void put_ctx(struct perf_event_context *ctx) { if (atomic_dec_and_test(&ctx->refcount)) { if (ctx->parent_ctx) put_ctx(ctx->parent_ctx); if (ctx->task && ctx->task != TASK_TOMBSTONE) put_task_struct(ctx->task); call_rcu(&ctx->rcu_head, free_ctx); } }
0
[ "CWE-362", "CWE-125" ]
linux
321027c1fe77f892f4ea07846aeae08cefbbb290
120,822,504,298,675,300,000,000,000,000,000,000,000
10
perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context. The problem is exactly that described in commit: f63a8daa5812 ("perf: Fix event->ctx locking") ... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us. That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly. So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead). Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks. Reported-by: Di Shen (Keen Lab) Tested-by: John Dias <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Min Chong <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Fixes: f63a8daa5812 ("perf: Fix event->ctx locking") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
static int __netdev_adjacent_dev_link_lists(struct net_device *dev, struct net_device *upper_dev, struct list_head *up_list, struct list_head *down_list, void *private, bool master) { int ret; ret = __netdev_adjacent_dev_insert(dev, upper_dev, up_list, private, master); if (ret) return ret; ret = __netdev_adjacent_dev_insert(upper_dev, dev, down_list, private, false); if (ret) { __netdev_adjacent_dev_remove(dev, upper_dev, 1, up_list); return ret; } return 0;
0
[ "CWE-476" ]
linux
0ad646c81b2182f7fa67ec0c8c825e0ee165696d
53,972,020,418,415,800,000,000,000,000,000,000,000
22
tun: call dev_get_valid_name() before register_netdevice() register_netdevice() could fail early when we have an invalid dev name, in which case ->ndo_uninit() is not called. For tun device, this is a problem because a timer etc. are already initialized and it expects ->ndo_uninit() to clean them up. We could move these initializations into a ->ndo_init() so that register_netdevice() knows better, however this is still complicated due to the logic in tun_detach(). Therefore, I choose to just call dev_get_valid_name() before register_netdevice(), which is quicker and much easier to audit. And for this specific case, it is already enough. Fixes: 96442e42429e ("tuntap: choose the txq based on rxq") Reported-by: Dmitry Alexeev <[email protected]> Cc: Jason Wang <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
bool ZrtpQueue::isMitmMode() { return mitmMode; }
0
[ "CWE-119" ]
ZRTPCPP
c8617100f359b217a974938c5539a1dd8a120b0e
192,074,045,818,666,440,000,000,000,000,000,000,000
3
Fix vulnerabilities found and reported by Mark Dowd - limit length of memcpy - limit number of offered algorithms in Hello packet - length check in PING packet - fix a small coding error
fb_blank(struct fb_info *info, int blank) { struct fb_event event; int ret = -EINVAL, early_ret; if (blank > FB_BLANK_POWERDOWN) blank = FB_BLANK_POWERDOWN; event.info = info; event.data = &blank; early_ret = fb_notifier_call_chain(FB_EARLY_EVENT_BLANK, &event); if (info->fbops->fb_blank) ret = info->fbops->fb_blank(blank, info); if (!ret) fb_notifier_call_chain(FB_EVENT_BLANK, &event); else { /* * if fb_blank is failed then revert effects of * the early blank event. */ if (!early_ret) fb_notifier_call_chain(FB_R_EARLY_EVENT_BLANK, &event); } return ret; }
0
[ "CWE-703", "CWE-189" ]
linux
fc9bbca8f650e5f738af8806317c0a041a48ae4a
296,571,947,831,743,160,000,000,000,000,000,000,000
29
vm: convert fb_mmap to vm_iomap_memory() helper This is my example conversion of a few existing mmap users. The fb_mmap() case is a good example because it is a bit more complicated than some: fb_mmap() mmaps one of two different memory areas depending on the page offset of the mmap (but happily there is never any mixing of the two, so the helper function still works). Signed-off-by: Linus Torvalds <[email protected]>
NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx NCURSES_COLOR_T color, NCURSES_COLOR_T r, NCURSES_COLOR_T g, NCURSES_COLOR_T b) { return _nc_init_color(SP_PARM, color, r, g, b); }
0
[]
ncurses
790a85dbd4a81d5f5d8dd02a44d84f01512ef443
310,938,078,401,527,800,000,000,000,000,000,000,000
8
ncurses 6.2 - patch 20200531 + correct configure version-check/warnng for g++ to allow for 10.x + re-enable "bel" in konsole-base (report by Nia Huang) + add linux-s entry (patch by Alexandre Montaron). + drop long-obsolete convert_configure.pl + add test/test_parm.c, for checking tparm changes. + improve parameter-checking for tparm, adding function _nc_tiparm() to handle the most-used case, which accepts only numeric parameters (report/testcase by "puppet-meteor"). + use a more conservative estimate of the buffer-size in lib_tparm.c's save_text() and save_number(), in case the sprintf() function passes-through unexpected characters from a format specifier (report/testcase by "puppet-meteor"). + add a check for end-of-string in cvtchar to handle a malformed string in infotocap (report/testcase by "puppet-meteor").
GF_Err gf_filter_set_source_restricted(GF_Filter *filter, GF_Filter *link_from, const char *link_ext) { GF_Err e = gf_filter_set_source(filter, link_from, link_ext); if (e) return e; if (link_from->restricted_source_id) gf_free(link_from->restricted_source_id); link_from->restricted_source_id = gf_strdup(link_from->id); return GF_OK; }
0
[ "CWE-787" ]
gpac
da37ec8582266983d0ec4b7550ec907401ec441e
260,599,814,244,411,300,000,000,000,000,000,000,000
10
fixed crashes for very long path - cf #1908
const char* ExpressionArrayElemAt::getOpName() const { return "$arrayElemAt"; }
0
[ "CWE-835" ]
mongo
0a076417d1d7fba3632b73349a1fd29a83e68816
279,659,236,077,935,730,000,000,000,000,000,000,000
3
SERVER-38070 fix infinite loop in agg expression
load_binint(UnpicklerObject *self) { char *s; if (_Unpickler_Read(self, &s, 4) < 0) return -1; return load_binintx(self, s, 4); }
0
[ "CWE-190", "CWE-369" ]
cpython
a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd
100,473,346,001,320,980,000,000,000,000,000,000,000
9
closes bpo-34656: Avoid relying on signed overflow in _pickle memos. (GH-9261)
ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, ext4_lblk_t block) { struct ext4_extent_header *eh = path->p_hdr; struct ext4_extent *r, *l, *m; if (eh->eh_entries == 0) { /* * this leaf is empty: * we get such a leaf in split/add case */ return; } ext_debug("binsearch for %u: ", block); l = EXT_FIRST_EXTENT(eh) + 1; r = EXT_LAST_EXTENT(eh); while (l <= r) { m = l + (r - l) / 2; if (block < le32_to_cpu(m->ee_block)) r = m - 1; else l = m + 1; ext_debug("%p(%u):%p(%u):%p(%u) ", l, le32_to_cpu(l->ee_block), m, le32_to_cpu(m->ee_block), r, le32_to_cpu(r->ee_block)); } path->p_ext = l - 1; ext_debug(" -> %d:%llu:[%d]%d ", le32_to_cpu(path->p_ext->ee_block), ext4_ext_pblock(path->p_ext), ext4_ext_is_uninitialized(path->p_ext), ext4_ext_get_actual_len(path->p_ext)); #ifdef CHECK_BINSEARCH { struct ext4_extent *chex, *ex; int k; chex = ex = EXT_FIRST_EXTENT(eh); for (k = 0; k < le16_to_cpu(eh->eh_entries); k++, ex++) { BUG_ON(k && le32_to_cpu(ex->ee_block) <= le32_to_cpu(ex[-1].ee_block)); if (block < le32_to_cpu(ex->ee_block)) break; chex = ex; } BUG_ON(chex != path->p_ext); } #endif }
0
[ "CWE-362" ]
linux-2.6
dee1f973ca341c266229faa5a1a5bb268bed3531
238,947,459,161,891,700,000,000,000,000,000,000,000
55
ext4: race-condition protection for ext4_convert_unwritten_extents_endio We assumed that at the time we call ext4_convert_unwritten_extents_endio() extent in question is fully inside [map.m_lblk, map->m_len] because it was already split during submission. But this may not be true due to a race between writeback vs fallocate. If extent in question is larger than requested we will split it again. Special precautions should being done if zeroout required because [map.m_lblk, map->m_len] already contains valid data. Signed-off-by: Dmitry Monakhov <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: [email protected]
Value ExpressionAnyElementTrue::evaluate(const Document& root) const { const Value arr = vpOperand[0]->evaluate(root); uassert(17041, str::stream() << getOpName() << "'s argument must be an array, but is " << typeName(arr.getType()), arr.isArray()); const vector<Value>& array = arr.getArray(); for (vector<Value>::const_iterator it = array.begin(); it != array.end(); ++it) { if (it->coerceToBool()) { return Value(true); } } return Value(false); }
0
[ "CWE-835" ]
mongo
0a076417d1d7fba3632b73349a1fd29a83e68816
243,328,783,631,534,540,000,000,000,000,000,000,000
14
SERVER-38070 fix infinite loop in agg expression
bool fields_are_impossible() { // no select or it is last select with no tables (service select) return !select_stack_head() || (select_stack_top == 1 && select_stack[0]->is_service_select); }
0
[ "CWE-703" ]
server
39feab3cd31b5414aa9b428eaba915c251ac34a2
91,661,990,942,112,000,000,000,000,000,000,000,000
7
MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT IF an INSERT/REPLACE SELECT statement contained an ON expression in the top level select and this expression used a subquery with a column reference that could not be resolved then an attempt to resolve this reference as an outer reference caused a crash of the server. This happened because the outer context field in the Name_resolution_context structure was not set to NULL for such references. Rather it pointed to the first element in the select_stack. Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select() method when parsing a SELECT construct. Approved by Oleksandr Byelkin <[email protected]>
uint32_t BinaryProtocolWriter::serializedSizeMapBegin( TType /*keyType*/, TType /*valType*/, uint32_t /*size*/) const { return serializedSizeByte() + serializedSizeByte() + serializedSizeI32(); }
0
[ "CWE-703", "CWE-770" ]
fbthrift
c9a903e5902834e95bbd4ab0e9fa53ba0189f351
73,420,055,839,268,200,000,000,000,000,000,000,000
6
Better handling of truncated data when reading strings Summary: Currently we read string size and blindly pre-allocate it. This allows malicious attacker to send a few bytes message and cause server to allocate huge amount of memory (>1GB). This diff changes the logic to check if we have enough data in the buffer before allocating the string. This is a second part of a fix for CVE-2019-3553. Reviewed By: vitaut Differential Revision: D14393393 fbshipit-source-id: e2046d2f5b087d3abc9a9d2c6c107cf088673057
HTTPSession::onMessageComplete(HTTPCodec::StreamID streamID, bool upgrade) { DestructorGuard dg(this); // The codec's parser detected the end of the ingress message for // this transaction. VLOG(4) << "processing ingress message complete for " << *this << ", streamID=" << streamID; HTTPTransaction* txn = findTransaction(streamID); if (!txn) { invalidStream(streamID); return; } if (upgrade) { /* Send the upgrade callback to the transaction and the handler. * Currently we support upgrades for only HTTP sessions and not SPDY * sessions. */ ingressUpgraded_ = true; txn->onIngressUpgrade(UpgradeProtocol::TCP); return; } // txnIngressFinished = !1xx response const bool txnIngressFinished = txn->isDownstream() || !txn->extraResponseExpected(); if (txnIngressFinished) { decrementTransactionCount(txn, true, false); } txn->onIngressEOM(); // The codec knows, based on the semantics of whatever protocol it // supports, whether it's valid for any more ingress messages to arrive // after this one. For example, an HTTP/1.1 request containing // "Connection: close" indicates the end of the ingress, whereas a // SPDY session generally can handle more messages at any time. // // If the connection is not reusable, we close the read side of it // but not the write side. There are two reasons why more writes // may occur after this point: // * If there are previous writes buffered up in the pendingWrites_ // queue, we need to attempt to complete them. // * The Handler associated with the transaction may want to // produce more egress data when the ingress message is fully // complete. (As a common example, an application that handles // form POSTs may not be able to even start generating a response // until it has received the full request body.) // // There may be additional checks that need to be performed that are // specific to requests or responses, so we call the subclass too. if (!codec_->isReusable() && txnIngressFinished && !codec_->supportsParallelRequests()) { VLOG(4) << *this << " cannot reuse ingress"; shutdownTransport(true, false); } }
0
[ "CWE-20" ]
proxygen
0600ebe59c3e82cd012def77ca9ca1918da74a71
110,662,311,599,045,900,000,000,000,000,000,000,000
57
Check that a secondary auth manager is set before dereferencing. Summary: CVE-2018-6343 Reviewed By: mingtaoy Differential Revision: D12994423 fbshipit-source-id: 9229ec11da8085f1fa153595e8e5353e19d06fb7
static ssize_t hfi1_file_write(struct file *fp, const char __user *data, size_t count, loff_t *offset) { const struct hfi1_cmd __user *ucmd; struct hfi1_filedata *fd = fp->private_data; struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_cmd cmd; struct hfi1_user_info uinfo; struct hfi1_tid_info tinfo; unsigned long addr; ssize_t consumed = 0, copy = 0, ret = 0; void *dest = NULL; __u64 user_val = 0; int uctxt_required = 1; int must_be_root = 0; /* FIXME: This interface cannot continue out of staging */ if (WARN_ON_ONCE(!ib_safe_file_access(fp))) return -EACCES; if (count < sizeof(cmd)) { ret = -EINVAL; goto bail; } ucmd = (const struct hfi1_cmd __user *)data; if (copy_from_user(&cmd, ucmd, sizeof(cmd))) { ret = -EFAULT; goto bail; } consumed = sizeof(cmd); switch (cmd.type) { case HFI1_CMD_ASSIGN_CTXT: uctxt_required = 0; /* assigned user context not required */ copy = sizeof(uinfo); dest = &uinfo; break; case HFI1_CMD_SDMA_STATUS_UPD: case HFI1_CMD_CREDIT_UPD: copy = 0; break; case HFI1_CMD_TID_UPDATE: case HFI1_CMD_TID_FREE: case HFI1_CMD_TID_INVAL_READ: copy = sizeof(tinfo); dest = &tinfo; break; case HFI1_CMD_USER_INFO: case HFI1_CMD_RECV_CTRL: case HFI1_CMD_POLL_TYPE: case HFI1_CMD_ACK_EVENT: case HFI1_CMD_CTXT_INFO: case HFI1_CMD_SET_PKEY: case HFI1_CMD_CTXT_RESET: copy = 0; user_val = cmd.addr; break; case HFI1_CMD_EP_INFO: case HFI1_CMD_EP_ERASE_CHIP: case HFI1_CMD_EP_ERASE_RANGE: case HFI1_CMD_EP_READ_RANGE: case HFI1_CMD_EP_WRITE_RANGE: uctxt_required = 0; /* assigned user context not required */ must_be_root = 1; /* validate user */ copy = 0; break; default: ret = -EINVAL; goto bail; } /* If the command comes with user data, copy it. */ if (copy) { if (copy_from_user(dest, (void __user *)cmd.addr, copy)) { ret = -EFAULT; goto bail; } consumed += copy; } /* * Make sure there is a uctxt when needed. */ if (uctxt_required && !uctxt) { ret = -EINVAL; goto bail; } /* only root can do these operations */ if (must_be_root && !capable(CAP_SYS_ADMIN)) { ret = -EPERM; goto bail; } switch (cmd.type) { case HFI1_CMD_ASSIGN_CTXT: ret = assign_ctxt(fp, &uinfo); if (ret < 0) goto bail; ret = setup_ctxt(fp); if (ret) goto bail; ret = user_init(fp); break; case HFI1_CMD_CTXT_INFO: ret = get_ctxt_info(fp, (void __user *)(unsigned long) user_val, cmd.len); break; case HFI1_CMD_USER_INFO: ret = get_base_info(fp, (void __user *)(unsigned long) user_val, cmd.len); break; case HFI1_CMD_SDMA_STATUS_UPD: break; case HFI1_CMD_CREDIT_UPD: if (uctxt && uctxt->sc) sc_return_credits(uctxt->sc); break; case HFI1_CMD_TID_UPDATE: ret = hfi1_user_exp_rcv_setup(fp, &tinfo); if (!ret) { /* * Copy the number of tidlist entries we used * and the length of the buffer we registered. * These fields are adjacent in the structure so * we can copy them at the same time. */ addr = (unsigned long)cmd.addr + offsetof(struct hfi1_tid_info, tidcnt); if (copy_to_user((void __user *)addr, &tinfo.tidcnt, sizeof(tinfo.tidcnt) + sizeof(tinfo.length))) ret = -EFAULT; } break; case HFI1_CMD_TID_INVAL_READ: ret = hfi1_user_exp_rcv_invalid(fp, &tinfo); if (ret) break; addr = (unsigned long)cmd.addr + offsetof(struct hfi1_tid_info, tidcnt); if (copy_to_user((void __user *)addr, &tinfo.tidcnt, sizeof(tinfo.tidcnt))) ret = -EFAULT; break; case HFI1_CMD_TID_FREE: ret = hfi1_user_exp_rcv_clear(fp, &tinfo); if (ret) break; addr = (unsigned long)cmd.addr + offsetof(struct hfi1_tid_info, tidcnt); if (copy_to_user((void __user *)addr, &tinfo.tidcnt, sizeof(tinfo.tidcnt))) ret = -EFAULT; break; case HFI1_CMD_RECV_CTRL: ret = manage_rcvq(uctxt, fd->subctxt, (int)user_val); break; case HFI1_CMD_POLL_TYPE: uctxt->poll_type = (typeof(uctxt->poll_type))user_val; break; case HFI1_CMD_ACK_EVENT: ret = user_event_ack(uctxt, fd->subctxt, user_val); break; case HFI1_CMD_SET_PKEY: if (HFI1_CAP_IS_USET(PKEY_CHECK)) ret = set_ctxt_pkey(uctxt, fd->subctxt, user_val); else ret = -EPERM; break; case HFI1_CMD_CTXT_RESET: { struct send_context *sc; struct hfi1_devdata *dd; if (!uctxt || !uctxt->dd || !uctxt->sc) { ret = -EINVAL; break; } /* * There is no protection here. User level has to * guarantee that no one will be writing to the send * context while it is being re-initialized. * If user level breaks that guarantee, it will break * it's own context and no one else's. */ dd = uctxt->dd; sc = uctxt->sc; /* * Wait until the interrupt handler has marked the * context as halted or frozen. Report error if we time * out. */ wait_event_interruptible_timeout( sc->halt_wait, (sc->flags & SCF_HALTED), msecs_to_jiffies(SEND_CTXT_HALT_TIMEOUT)); if (!(sc->flags & SCF_HALTED)) { ret = -ENOLCK; break; } /* * If the send context was halted due to a Freeze, * wait until the device has been "unfrozen" before * resetting the context. */ if (sc->flags & SCF_FROZEN) { wait_event_interruptible_timeout( dd->event_queue, !(ACCESS_ONCE(dd->flags) & HFI1_FROZEN), msecs_to_jiffies(SEND_CTXT_HALT_TIMEOUT)); if (dd->flags & HFI1_FROZEN) { ret = -ENOLCK; break; } if (dd->flags & HFI1_FORCED_FREEZE) { /* * Don't allow context reset if we are into * forced freeze */ ret = -ENODEV; break; } sc_disable(sc); ret = sc_enable(sc); hfi1_rcvctrl(dd, HFI1_RCVCTRL_CTXT_ENB, uctxt->ctxt); } else { ret = sc_restart(sc); } if (!ret) sc_return_credits(sc); break; } case HFI1_CMD_EP_INFO: case HFI1_CMD_EP_ERASE_CHIP: case HFI1_CMD_EP_ERASE_RANGE: case HFI1_CMD_EP_READ_RANGE: case HFI1_CMD_EP_WRITE_RANGE: ret = handle_eprom_command(fp, &cmd); break; } if (ret >= 0) ret = consumed; bail: return ret; }
0
[ "CWE-284", "CWE-264" ]
linux
e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3
306,716,780,887,398,840,000,000,000,000,000,000,000
248
IB/security: Restrict use of the write() interface The drivers/infiniband stack uses write() as a replacement for bi-directional ioctl(). This is not safe. There are ways to trigger write calls that result in the return structure that is normally written to user space being shunted off to user specified kernel memory instead. For the immediate repair, detect and deny suspicious accesses to the write API. For long term, update the user space libraries and the kernel API to something that doesn't present the same security vulnerabilities (likely a structured ioctl() interface). The impacted uAPI interfaces are generally only available if hardware from drivers/infiniband is installed in the system. Reported-by: Jann Horn <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> [ Expanded check to all known write() entry points ] Cc: [email protected] Signed-off-by: Doug Ledford <[email protected]>
static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, __be32 *p, struct nfs_readres *res) { struct xdr_stream xdr; struct compound_hdr hdr; int status; xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); status = decode_compound_hdr(&xdr, &hdr); if (status) goto out; status = decode_putfh(&xdr); if (status) goto out; status = decode_read(&xdr, rqstp, res); if (!status) status = res->count; out: return status; }
0
[ "CWE-703" ]
linux
dc0b027dfadfcb8a5504f7d8052754bf8d501ab9
319,205,819,905,614,700,000,000,000,000,000,000,000
19
NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <[email protected]>
static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) { struct kern_ipc_perm *ipcp = ipc_obtain_object_idr(&msg_ids(ns), id); if (IS_ERR(ipcp)) return ERR_CAST(ipcp); return container_of(ipcp, struct msg_queue, q_perm); }
0
[ "CWE-362", "CWE-401" ]
linux
b9a532277938798b53178d5a66af6e2915cb27cf
111,070,657,721,790,030,000,000,000,000,000,000,000
9
Initialize msg/shm IPC objects before doing ipc_addid() As reported by Dmitry Vyukov, we really shouldn't do ipc_addid() before having initialized the IPC object state. Yes, we initialize the IPC object in a locked state, but with all the lockless RCU lookup work, that IPC object lock no longer means that the state cannot be seen. We already did this for the IPC semaphore code (see commit e8577d1f0329: "ipc/sem.c: fully initialize sem_array before making it visible") but we clearly forgot about msg and shm. Reported-by: Dmitry Vyukov <[email protected]> Cc: Manfred Spraul <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
int luaRedisReplicateCommandsCommand(lua_State *lua) { if (server.lua_write_dirty) { lua_pushboolean(lua,0); } else { server.lua_replicate_commands = 1; /* When we switch to single commands replication, we can provide * different math.random() sequences at every call, which is what * the user normally expects. */ redisSrand48(rand()); lua_pushboolean(lua,1); } return 1; }
0
[ "CWE-703", "CWE-125" ]
redis
6ac3c0b7abd35f37201ed2d6298ecef4ea1ae1dd
156,443,413,433,270,610,000,000,000,000,000,000,000
13
Fix protocol parsing on 'ldbReplParseCommand' (CVE-2021-32672) The protocol parsing on 'ldbReplParseCommand' (LUA debugging) Assumed protocol correctness. This means that if the following is given: *1 $100 test The parser will try to read additional 94 unallocated bytes after the client buffer. This commit fixes this issue by validating that there are actually enough bytes to read. It also limits the amount of data that can be sent by the debugger client to 1M so the client will not be able to explode the memory.
free_config_ttl( config_tree *ptree ) { FREE_INT_FIFO(ptree->ttl); }
0
[ "CWE-19" ]
ntp
fe46889f7baa75fc8e6c0fcde87706d396ce1461
31,557,429,852,904,280,000,000,000,000,000,000,000
6
[Sec 2942]: Off-path DoS attack on auth broadcast mode. HStenn.
bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...) { struct ldb_dn *child; char *child_str; va_list ap; bool ret; if ( !dn || dn->invalid) { return false; } va_start(ap, child_fmt); child_str = talloc_vasprintf(dn, child_fmt, ap); va_end(ap); if (child_str == NULL) { return false; } child = ldb_dn_new(child_str, dn->ldb, child_str); ret = ldb_dn_add_child(dn, child); talloc_free(child_str); return ret; }
0
[ "CWE-200" ]
samba
7f51ec8c4ed9ba1f53d722e44fb6fb3cde933b72
333,949,163,180,029,500,000,000,000,000,000,000,000
27
CVE-2015-5330: ldb_dn: simplify and fix ldb_dn_escape_internal() Previously we relied on NUL terminated strings and jumped back and forth between copying escaped bytes and memcpy()ing un-escaped chunks. This simple version is easier to reason about and works with unterminated strings. It may also be faster as it avoids reading the string twice (first with strcspn, then with memcpy). Bug: https://bugzilla.samba.org/show_bug.cgi?id=11599 Signed-off-by: Douglas Bagnall <[email protected]> Pair-programmed-with: Andrew Bartlett <[email protected]> Reviewed-by: Ralph Boehme <[email protected]>
static inline void pni_mutex_lock(pni_mutex_t *m) { EnterCriticalSection(m); }
0
[]
qpid-proton
4aea0fd8502f5e9af7f22fd60645eeec07bce0b2
308,259,687,797,250,020,000,000,000,000,000,000,000
1
PROTON-2014: [c] Ensure SSL mutual authentication (cherry picked from commit 97c7733f07712665f3d08091c82c393e4c3adbf7)
fr_window_archive_extract_here (FrWindow *window, gboolean skip_older, gboolean overwrite, gboolean junk_paths, gboolean ask_to_open_destination) { ExtractData *edata; edata = extract_data_new (window, NULL, NULL, NULL, skip_older, overwrite, junk_paths, TRUE, ask_to_open_destination); fr_window_set_current_batch_action (window, FR_BATCH_ACTION_EXTRACT, edata, (GFreeFunc) extract_data_free); if (archive_is_encrypted (window, NULL) && (window->priv->password == NULL)) { dlg_ask_password (window); return; } _archive_operation_started (window, FR_ACTION_EXTRACTING_FILES); fr_archive_extract_here (window->archive, edata->skip_older, edata->overwrite, edata->junk_paths, window->priv->password, window->priv->cancellable, archive_extraction_ready_cb, edata); }
0
[ "CWE-22" ]
file-roller
b147281293a8307808475e102a14857055f81631
73,429,377,886,568,925,000,000,000,000,000,000,000
38
libarchive: sanitize filenames before extracting
Perl_my_popen(pTHX_ const char *cmd, const char *mode) { PERL_FLUSHALL_FOR_CHILD; /* Call system's popen() to get a FILE *, then import it. used 0 for 2nd parameter to PerlIO_importFILE; apparently not used */ return PerlIO_importFILE(djgpp_popen(cmd, mode), 0); }
0
[ "CWE-119", "CWE-703", "CWE-787" ]
perl5
34716e2a6ee2af96078d62b065b7785c001194be
761,281,306,380,904,800,000,000,000,000,000,000
9
Perl_my_setenv(); handle integer wrap RT #133204 Wean this function off int/I32 and onto UV/Size_t. Also, replace all malloc-ish calls with a wrapper that does overflow checks, In particular, it was doing (nlen + vlen + 2) which could wrap when the combined length of the environment variable name and value exceeded around 0x7fffffff. The wrapper check function is probably overkill, but belt and braces... NB this function has several variant parts, #ifdef'ed by platform type; I have blindly changed the parts that aren't compiled under linux.
void FoFiTrueType::cvtSfnts(FoFiOutputFunc outputFunc, void *outputStream, GooString *name, GBool needVerticalMetrics, int *maxUsedGlyph) { Guchar headData[54]; TrueTypeLoca *locaTable; Guchar *locaData; TrueTypeTable newTables[nT42Tables]; Guchar tableDir[12 + nT42Tables*16]; GBool ok; Guint checksum; int nNewTables; int glyfTableLen, length, pos, glyfPos, i, j, k, vmtxTabLength; Guchar vheaTab[36] = { 0, 1, 0, 0, // table version number 0, 0, // ascent 0, 0, // descent 0, 0, // reserved 0, 0, // max advance height 0, 0, // min top side bearing 0, 0, // min bottom side bearing 0, 0, // y max extent 0, 0, // caret slope rise 0, 1, // caret slope run 0, 0, // caret offset 0, 0, // reserved 0, 0, // reserved 0, 0, // reserved 0, 0, // reserved 0, 0, // metric data format 0, 1 // number of advance heights in vmtx table }; Guchar *vmtxTab; GBool needVhea, needVmtx; int advance; // construct the 'head' table, zero out the font checksum i = seekTable("head"); if (i < 0 || i >= nTables) { return; } pos = tables[i].offset; if (!checkRegion(pos, 54)) { return; } memcpy(headData, file + pos, 54); headData[8] = headData[9] = headData[10] = headData[11] = (Guchar)0; // check for a bogus loca format field in the 'head' table // (I've encountered fonts with loca format set to 0x0100 instead of 0x0001) if (locaFmt != 0 && locaFmt != 1) { headData[50] = 0; headData[51] = 1; } // read the original 'loca' table, pad entries out to 4 bytes, and // sort it into proper order -- some (non-compliant) fonts have // out-of-order loca tables; in order to correctly handle the case // where (compliant) fonts have empty entries in the middle of the // table, cmpTrueTypeLocaOffset uses offset as its primary sort key, // and idx as its secondary key (ensuring that adjacent entries with // the same pos value remain in the same order) locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + 1, sizeof(TrueTypeLoca)); i = seekTable("loca"); pos = tables[i].offset; i = seekTable("glyf"); glyfTableLen = tables[i].len; ok = gTrue; for (i = 0; i <= nGlyphs; ++i) { locaTable[i].idx = i; if (locaFmt) { locaTable[i].origOffset = (int)getU32BE(pos + i*4, &ok); } else { locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok); } if (locaTable[i].origOffset > glyfTableLen) { locaTable[i].origOffset = glyfTableLen; } } std::sort(locaTable, locaTable + nGlyphs + 1, cmpTrueTypeLocaOffsetFunctor()); for (i = 0; i < nGlyphs; ++i) { locaTable[i].len = locaTable[i+1].origOffset - locaTable[i].origOffset; } locaTable[nGlyphs].len = 0; std::sort(locaTable, locaTable + nGlyphs + 1, cmpTrueTypeLocaIdxFunctor()); pos = 0; *maxUsedGlyph = -1; for (i = 0; i <= nGlyphs; ++i) { locaTable[i].newOffset = pos; pos += locaTable[i].len; if (pos & 3) { pos += 4 - (pos & 3); } if (locaTable[i].len > 0) { *maxUsedGlyph = i; } } // construct the new 'loca' table locaData = (Guchar *)gmallocn(nGlyphs + 1, (locaFmt ? 4 : 2)); for (i = 0; i <= nGlyphs; ++i) { pos = locaTable[i].newOffset; if (locaFmt) { locaData[4*i ] = (Guchar)(pos >> 24); locaData[4*i+1] = (Guchar)(pos >> 16); locaData[4*i+2] = (Guchar)(pos >> 8); locaData[4*i+3] = (Guchar) pos; } else { locaData[2*i ] = (Guchar)(pos >> 9); locaData[2*i+1] = (Guchar)(pos >> 1); } } // count the number of tables nNewTables = 0; for (i = 0; i < nT42Tables; ++i) { if (t42Tables[i].required || seekTable(t42Tables[i].tag) >= 0) { ++nNewTables; } } vmtxTab = NULL; // make gcc happy vmtxTabLength = 0; advance = 0; // make gcc happy if (needVerticalMetrics) { needVhea = seekTable("vhea") < 0; needVmtx = seekTable("vmtx") < 0; if (needVhea || needVmtx) { i = seekTable("head"); advance = getU16BE(tables[i].offset + 18, &ok); // units per em if (needVhea) { ++nNewTables; } if (needVmtx) { ++nNewTables; } } } // construct the new table headers, including table checksums // (pad each table out to a multiple of 4 bytes) pos = 12 + nNewTables*16; k = 0; for (i = 0; i < nT42Tables; ++i) { length = -1; checksum = 0; // make gcc happy if (i == t42HeadTable) { length = 54; checksum = computeTableChecksum(headData, 54); } else if (i == t42LocaTable) { length = (nGlyphs + 1) * (locaFmt ? 4 : 2); checksum = computeTableChecksum(locaData, length); } else if (i == t42GlyfTable) { length = 0; checksum = 0; glyfPos = tables[seekTable("glyf")].offset; for (j = 0; j < nGlyphs; ++j) { length += locaTable[j].len; if (length & 3) { length += 4 - (length & 3); } if (checkRegion(glyfPos + locaTable[j].origOffset, locaTable[j].len)) { checksum += computeTableChecksum(file + glyfPos + locaTable[j].origOffset, locaTable[j].len); } } } else { if ((j = seekTable(t42Tables[i].tag)) >= 0) { length = tables[j].len; if (checkRegion(tables[j].offset, length)) { checksum = computeTableChecksum(file + tables[j].offset, length); } } else if (needVerticalMetrics && i == t42VheaTable) { vheaTab[10] = advance / 256; // max advance height vheaTab[11] = advance % 256; length = sizeof(vheaTab); checksum = computeTableChecksum(vheaTab, length); } else if (needVerticalMetrics && i == t42VmtxTable) { length = 4 + (nGlyphs - 1) * 2; vmtxTabLength = length; vmtxTab = (Guchar *)gmalloc(length); vmtxTab[0] = advance / 256; vmtxTab[1] = advance % 256; for (j = 2; j < length; j += 2) { vmtxTab[j] = 0; vmtxTab[j+1] = 0; } checksum = computeTableChecksum(vmtxTab, length); } else if (t42Tables[i].required) { //~ error(-1, "Embedded TrueType font is missing a required table ('%s')", //~ t42Tables[i].tag); length = 0; checksum = 0; } } if (length >= 0) { newTables[k].tag = ((t42Tables[i].tag[0] & 0xff) << 24) | ((t42Tables[i].tag[1] & 0xff) << 16) | ((t42Tables[i].tag[2] & 0xff) << 8) | (t42Tables[i].tag[3] & 0xff); newTables[k].checksum = checksum; newTables[k].offset = pos; newTables[k].len = length; pos += length; if (pos & 3) { pos += 4 - (length & 3); } ++k; } } // construct the table directory tableDir[0] = 0x00; // sfnt version tableDir[1] = 0x01; tableDir[2] = 0x00; tableDir[3] = 0x00; tableDir[4] = 0; // numTables tableDir[5] = nNewTables; tableDir[6] = 0; // searchRange tableDir[7] = (Guchar)128; tableDir[8] = 0; // entrySelector tableDir[9] = 3; tableDir[10] = 0; // rangeShift tableDir[11] = (Guchar)(16 * nNewTables - 128); pos = 12; for (i = 0; i < nNewTables; ++i) { tableDir[pos ] = (Guchar)(newTables[i].tag >> 24); tableDir[pos+ 1] = (Guchar)(newTables[i].tag >> 16); tableDir[pos+ 2] = (Guchar)(newTables[i].tag >> 8); tableDir[pos+ 3] = (Guchar) newTables[i].tag; tableDir[pos+ 4] = (Guchar)(newTables[i].checksum >> 24); tableDir[pos+ 5] = (Guchar)(newTables[i].checksum >> 16); tableDir[pos+ 6] = (Guchar)(newTables[i].checksum >> 8); tableDir[pos+ 7] = (Guchar) newTables[i].checksum; tableDir[pos+ 8] = (Guchar)(newTables[i].offset >> 24); tableDir[pos+ 9] = (Guchar)(newTables[i].offset >> 16); tableDir[pos+10] = (Guchar)(newTables[i].offset >> 8); tableDir[pos+11] = (Guchar) newTables[i].offset; tableDir[pos+12] = (Guchar)(newTables[i].len >> 24); tableDir[pos+13] = (Guchar)(newTables[i].len >> 16); tableDir[pos+14] = (Guchar)(newTables[i].len >> 8); tableDir[pos+15] = (Guchar) newTables[i].len; pos += 16; } // compute the font checksum and store it in the head table checksum = computeTableChecksum(tableDir, 12 + nNewTables*16); for (i = 0; i < nNewTables; ++i) { checksum += newTables[i].checksum; } checksum = 0xb1b0afba - checksum; // because the TrueType spec says so headData[ 8] = (Guchar)(checksum >> 24); headData[ 9] = (Guchar)(checksum >> 16); headData[10] = (Guchar)(checksum >> 8); headData[11] = (Guchar) checksum; // start the sfnts array if (name) { (*outputFunc)(outputStream, "/", 1); (*outputFunc)(outputStream, name->getCString(), name->getLength()); (*outputFunc)(outputStream, " [\n", 3); } else { (*outputFunc)(outputStream, "/sfnts [\n", 9); } // write the table directory dumpString(tableDir, 12 + nNewTables*16, outputFunc, outputStream); // write the tables for (i = 0; i < nNewTables; ++i) { if (i == t42HeadTable) { dumpString(headData, 54, outputFunc, outputStream); } else if (i == t42LocaTable) { length = (nGlyphs + 1) * (locaFmt ? 4 : 2); dumpString(locaData, length, outputFunc, outputStream); } else if (i == t42GlyfTable) { glyfPos = tables[seekTable("glyf")].offset; for (j = 0; j < nGlyphs; ++j) { if (locaTable[j].len > 0 && checkRegion(glyfPos + locaTable[j].origOffset, locaTable[j].len)) { dumpString(file + glyfPos + locaTable[j].origOffset, locaTable[j].len, outputFunc, outputStream); } } } else { // length == 0 means the table is missing and the error was // already reported during the construction of the table // headers if ((length = newTables[i].len) > 0) { if ((j = seekTable(t42Tables[i].tag)) >= 0 && checkRegion(tables[j].offset, tables[j].len)) { dumpString(file + tables[j].offset, tables[j].len, outputFunc, outputStream); } else if (needVerticalMetrics && i == t42VheaTable) { if (unlikely(length > (int)sizeof(vheaTab))) { error(errSyntaxWarning, -1, "length bigger than vheaTab size"); length = sizeof(vheaTab); } dumpString(vheaTab, length, outputFunc, outputStream); } else if (needVerticalMetrics && i == t42VmtxTable) { if (unlikely(length > vmtxTabLength)) { error(errSyntaxWarning, -1, "length bigger than vmtxTab size"); length = vmtxTabLength; } dumpString(vmtxTab, length, outputFunc, outputStream); } } } } // end the sfnts array (*outputFunc)(outputStream, "] def\n", 6); gfree(locaData); gfree(locaTable); if (vmtxTab) { gfree(vmtxTab); } }
0
[ "CWE-125" ]
poppler
bf4aae25a244b1033a2479b9a8f633224f7d5de5
231,962,303,967,574,700,000,000,000,000,000,000,000
321
Off by one fix to the previous crash fix
ec_pow3 (gcry_mpi_t w, const gcry_mpi_t b, mpi_ec_t ctx) { mpi_powm (w, b, mpi_const (MPI_C_THREE), ctx->p); }
0
[ "CWE-200" ]
libgcrypt
88e1358962e902ff1cbec8d53ba3eee46407851a
324,751,720,076,296,500,000,000,000,000,000,000,000
4
ecc: Constant-time multiplication for Weierstrass curve. * mpi/ec.c (_gcry_mpi_ec_mul_point): Use simple left-to-right binary method for Weierstrass curve when SCALAR is secure.
static int jas_iccxyz_output(jas_iccattrval_t *attrval, jas_stream_t *out) { jas_iccxyz_t *xyz = &attrval->data.xyz; if (jas_iccputuint32(out, xyz->x) || jas_iccputuint32(out, xyz->y) || jas_iccputuint32(out, xyz->z)) return -1; return 0; }
0
[ "CWE-189" ]
jasper
3c55b399c36ef46befcb21e4ebc4799367f89684
285,472,644,383,522,470,000,000,000,000,000,000,000
9
At many places in the code, jas_malloc or jas_recalloc was being invoked with the size argument being computed in a manner that would not allow integer overflow to be detected. Now, these places in the code have been modified to use special-purpose memory allocation functions (e.g., jas_alloc2, jas_alloc3, jas_realloc2) that check for overflow. This should fix many security problems.
static struct inode *hugetlbfs_get_root(struct super_block *sb, struct hugetlbfs_config *config) { struct inode *inode; inode = new_inode(sb); if (inode) { struct hugetlbfs_inode_info *info; inode->i_ino = get_next_ino(); inode->i_mode = S_IFDIR | config->mode; inode->i_uid = config->uid; inode->i_gid = config->gid; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; info = HUGETLBFS_I(inode); mpol_shared_policy_init(&info->policy, NULL); inode->i_op = &hugetlbfs_dir_inode_operations; inode->i_fop = &simple_dir_operations; /* directory inodes start off with i_nlink == 2 (for "." entry) */ inc_nlink(inode); } return inode; }
0
[ "CWE-399" ]
linux
90481622d75715bfcb68501280a917dbfe516029
331,103,774,499,734,250,000,000,000,000,000,000,000
22
hugepages: fix use after free bug in "quota" handling hugetlbfs_{get,put}_quota() are badly named. They don't interact with the general quota handling code, and they don't much resemble its behaviour. Rather than being about maintaining limits on on-disk block usage by particular users, they are instead about maintaining limits on in-memory page usage (including anonymous MAP_PRIVATE copied-on-write pages) associated with a particular hugetlbfs filesystem instance. Worse, they work by having callbacks to the hugetlbfs filesystem code from the low-level page handling code, in particular from free_huge_page(). This is a layering violation of itself, but more importantly, if the kernel does a get_user_pages() on hugepages (which can happen from KVM amongst others), then the free_huge_page() can be delayed until after the associated inode has already been freed. If an unmount occurs at the wrong time, even the hugetlbfs superblock where the "quota" limits are stored may have been freed. Andrew Barry proposed a patch to fix this by having hugepages, instead of storing a pointer to their address_space and reaching the superblock from there, had the hugepages store pointers directly to the superblock, bumping the reference count as appropriate to avoid it being freed. Andrew Morton rejected that version, however, on the grounds that it made the existing layering violation worse. This is a reworked version of Andrew's patch, which removes the extra, and some of the existing, layering violation. It works by introducing the concept of a hugepage "subpool" at the lower hugepage mm layer - that is a finite logical pool of hugepages to allocate from. hugetlbfs now creates a subpool for each filesystem instance with a page limit set, and a pointer to the subpool gets added to each allocated hugepage, instead of the address_space pointer used now. The subpool has its own lifetime and is only freed once all pages in it _and_ all other references to it (i.e. superblocks) are gone. subpools are optional - a NULL subpool pointer is taken by the code to mean that no subpool limits are in effect. Previous discussion of this bug found in: "Fix refcounting in hugetlbfs quota handling.". See: https://lkml.org/lkml/2011/8/11/28 or http://marc.info/?l=linux-mm&m=126928970510627&w=1 v2: Fixed a bug spotted by Hillf Danton, and removed the extra parameter to alloc_huge_page() - since it already takes the vma, it is not necessary. Signed-off-by: Andrew Barry <[email protected]> Signed-off-by: David Gibson <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
gxps_fonts_new_font_face (GXPSArchive *zip, const gchar *font_uri, GError **error) { GHashTable *ft_cache; FtFontFace ft_face; FtFontFace *ft_font_face; FT_Face face; cairo_font_face_t *font_face; guchar *font_data; gsize font_data_len; if (!gxps_archive_read_entry (zip, font_uri, &font_data, &font_data_len, error)) { return NULL; } ft_face.font_data = font_data; ft_face.font_data_len = (gssize)font_data_len; ft_cache = get_ft_font_face_cache (); font_face = g_hash_table_lookup (ft_cache, &ft_face); if (font_face) { g_free (font_data); return font_face; } if (!gxps_fonts_new_ft_face (font_uri, font_data, font_data_len, &face)) { g_set_error (error, GXPS_ERROR, GXPS_ERROR_FONT, "Failed to load font %s", font_uri); g_free (font_data); return NULL; } font_face = cairo_ft_font_face_create_for_ft_face (face, 0); if (cairo_font_face_set_user_data (font_face, &ft_cairo_key, face, (cairo_destroy_func_t) FT_Done_Face)) { g_set_error (error, GXPS_ERROR, GXPS_ERROR_FONT, "Failed to load font %s: %s", font_uri, cairo_status_to_string (cairo_font_face_status (font_face))); cairo_font_face_destroy (font_face); FT_Done_Face (face); return NULL; } ft_font_face = ft_font_face_new (font_data, (gssize)font_data_len); g_hash_table_insert (ft_cache, ft_font_face, font_face); return font_face; }
0
[ "CWE-125" ]
libgxps
b458226e162fe1ffe7acb4230c114a52ada5131b
108,477,480,685,497,970,000,000,000,000,000,000,000
61
gxps-archive: Ensure gxps_archive_read_entry() fills the GError in case of failure And fix the callers to not overwrite the GError.
static int tty_ldiscs_seq_show(struct seq_file *m, void *v) { int i = *(loff_t *)v; struct tty_ldisc_ops *ldops; ldops = get_ldops(i); if (IS_ERR(ldops)) return 0; seq_printf(m, "%-10s %2d\n", ldops->name ? ldops->name : "???", i); put_ldops(ldops); return 0; }
0
[ "CWE-200" ]
linux-stable
dd42bf1197144ede075a9d4793123f7689e164bc
125,326,083,738,332,920,000,000,000,000,000,000,000
12
tty: Prevent ldisc drivers from re-using stale tty fields Line discipline drivers may mistakenly misuse ldisc-related fields when initializing. For example, a failure to initialize tty->receive_room in the N_GIGASET_M101 line discipline was recently found and fixed [1]. Now, the N_X25 line discipline has been discovered accessing the previous line discipline's already-freed private data [2]. Harden the ldisc interface against misuse by initializing revelant tty fields before instancing the new line discipline. [1] commit fd98e9419d8d622a4de91f76b306af6aa627aa9c Author: Tilman Schmidt <[email protected]> Date: Tue Jul 14 00:37:13 2015 +0200 isdn/gigaset: reset tty->receive_room when attaching ser_gigaset [2] Report from Sasha Levin <[email protected]> [ 634.336761] ================================================================== [ 634.338226] BUG: KASAN: use-after-free in x25_asy_open_tty+0x13d/0x490 at addr ffff8800a743efd0 [ 634.339558] Read of size 4 by task syzkaller_execu/8981 [ 634.340359] ============================================================================= [ 634.341598] BUG kmalloc-512 (Not tainted): kasan: bad access detected ... [ 634.405018] Call Trace: [ 634.405277] dump_stack (lib/dump_stack.c:52) [ 634.405775] print_trailer (mm/slub.c:655) [ 634.406361] object_err (mm/slub.c:662) [ 634.406824] kasan_report_error (mm/kasan/report.c:138 mm/kasan/report.c:236) [ 634.409581] __asan_report_load4_noabort (mm/kasan/report.c:279) [ 634.411355] x25_asy_open_tty (drivers/net/wan/x25_asy.c:559 (discriminator 1)) [ 634.413997] tty_ldisc_open.isra.2 (drivers/tty/tty_ldisc.c:447) [ 634.414549] tty_set_ldisc (drivers/tty/tty_ldisc.c:567) [ 634.415057] tty_ioctl (drivers/tty/tty_io.c:2646 drivers/tty/tty_io.c:2879) [ 634.423524] do_vfs_ioctl (fs/ioctl.c:43 fs/ioctl.c:607) [ 634.427491] SyS_ioctl (fs/ioctl.c:622 fs/ioctl.c:613) [ 634.427945] entry_SYSCALL_64_fastpath (arch/x86/entry/entry_64.S:188) Cc: Tilman Schmidt <[email protected]> Cc: Sasha Levin <[email protected]> Signed-off-by: Peter Hurley <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
int main(int argc, char **argv) { struct sigaction sigact = { { 0 } }; int cfg_parsed; int ret = EXIT_FAILURE; init_dynload(); config.filename = av_strdup("/etc/ffserver.conf"); parse_loglevel(argc, argv, options); av_register_all(); avformat_network_init(); show_banner(argc, argv, options); my_program_name = argv[0]; parse_options(NULL, argc, argv, options, NULL); unsetenv("http_proxy"); /* Kill the http_proxy */ av_lfg_init(&random_state, av_get_random_seed()); sigact.sa_handler = handle_child_exit; sigact.sa_flags = SA_NOCLDSTOP | SA_RESTART; sigaction(SIGCHLD, &sigact, 0); if ((cfg_parsed = ffserver_parse_ffconfig(config.filename, &config)) < 0) { fprintf(stderr, "Error reading configuration file '%s': %s\n", config.filename, av_err2str(cfg_parsed)); goto bail; } /* open log file if needed */ if (config.logfilename[0] != '\0') { if (!strcmp(config.logfilename, "-")) logfile = stdout; else logfile = fopen(config.logfilename, "a"); av_log_set_callback(http_av_log); } build_file_streams(); if (build_feed_streams() < 0) { http_log("Could not setup feed streams\n"); goto bail; } compute_bandwidth(); /* signal init */ signal(SIGPIPE, SIG_IGN); if (http_server() < 0) { http_log("Could not start server\n"); goto bail; } ret=EXIT_SUCCESS; bail: av_freep (&config.filename); avformat_network_deinit(); return ret; }
0
[ "CWE-119", "CWE-787" ]
FFmpeg
a5d25faa3f4b18dac737fdb35d0dd68eb0dc2156
187,457,005,535,439,320,000,000,000,000,000,000,000
67
ffserver: Check chunk size Fixes out of array access Fixes: poc_ffserver.py Found-by: Paul Cher <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
static void free_fbind(imp_sth_phb_t *fbind) { if (fbind) Safefree(fbind); }
0
[ "CWE-416" ]
DBD-mysql
a56ae87a4c1c1fead7d09c3653905841ccccf1cc
222,253,558,524,144,300,000,000,000,000,000,000,000
5
fix use-after-free crash in RT #97625
static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static const unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; }
1
[ "CWE-787" ]
stb
5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40
285,846,982,414,941,660,000,000,000,000,000,000,000
84
stb_image: Reject fractional JPEG component subsampling ratios The component resamplers are not written to support this and I've never seen it happen in a real (non-crafted) JPEG file so I'm fine rejecting this as outright corrupt. Fixes issue #1178.