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
unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit, int *al) { int extdatalen=0; unsigned char *orig = buf; unsigned char *ret = buf; size_t i; custom_srv_ext_record *record; #ifndef OPENSSL_NO_NEXTPROTONEG int next_proto_neg_seen; #endif #ifndef OPENSSL_NO_EC unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey; unsigned long alg_a = s->s3->tmp.new_cipher->algorithm_auth; int using_ecc = (alg_k & (SSL_kECDHE|SSL_kECDHr|SSL_kECDHe)) || (alg_a & SSL_aECDSA); using_ecc = using_ecc && (s->session->tlsext_ecpointformatlist != NULL); #endif /* don't add extensions for SSLv3, unless doing secure renegotiation */ if (s->version == SSL3_VERSION && !s->s3->send_connection_binding) return orig; ret+=2; if (ret>=limit) return NULL; /* this really never occurs, but ... */ if (!s->hit && s->servername_done == 1 && s->session->tlsext_hostname != NULL) { if ((long)(limit - ret - 4) < 0) return NULL; s2n(TLSEXT_TYPE_server_name,ret); s2n(0,ret); } if(s->s3->send_connection_binding) { int el; if(!ssl_add_serverhello_renegotiate_ext(s, 0, &el, 0)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } if((limit - ret - 4 - el) < 0) return NULL; s2n(TLSEXT_TYPE_renegotiate,ret); s2n(el,ret); if(!ssl_add_serverhello_renegotiate_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret += el; } #ifndef OPENSSL_NO_EC if (using_ecc) { const unsigned char *plist; size_t plistlen; /* Add TLS extension ECPointFormats to the ServerHello message */ long lenmax; tls1_get_formatlist(s, &plist, &plistlen); if ((lenmax = limit - ret - 5) < 0) return NULL; if (plistlen > (size_t)lenmax) return NULL; if (plistlen > 255) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_ec_point_formats,ret); s2n(plistlen + 1,ret); *(ret++) = (unsigned char) plistlen; memcpy(ret, plist, plistlen); ret+=plistlen; } /* Currently the server should not respond with a SupportedCurves extension */ #endif /* OPENSSL_NO_EC */ if (s->tlsext_ticket_expected && tls_use_ticket(s)) { if ((long)(limit - ret - 4) < 0) return NULL; s2n(TLSEXT_TYPE_session_ticket,ret); s2n(0,ret); } if (s->tlsext_status_expected) { if ((long)(limit - ret - 4) < 0) return NULL; s2n(TLSEXT_TYPE_status_request,ret); s2n(0,ret); } #ifdef TLSEXT_TYPE_opaque_prf_input if (s->s3->server_opaque_prf_input != NULL) { size_t sol = s->s3->server_opaque_prf_input_len; if ((long)(limit - ret - 6 - sol) < 0) return NULL; if (sol > 0xFFFD) /* can't happen */ return NULL; s2n(TLSEXT_TYPE_opaque_prf_input, ret); s2n(sol + 2, ret); s2n(sol, ret); memcpy(ret, s->s3->server_opaque_prf_input, sol); ret += sol; } #endif if(s->srtp_profile) { int el; ssl_add_serverhello_use_srtp_ext(s, 0, &el, 0); if((limit - ret - 4 - el) < 0) return NULL; s2n(TLSEXT_TYPE_use_srtp,ret); s2n(el,ret); if(ssl_add_serverhello_use_srtp_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret+=el; } if (((s->s3->tmp.new_cipher->id & 0xFFFF)==0x80 || (s->s3->tmp.new_cipher->id & 0xFFFF)==0x81) && (SSL_get_options(s) & SSL_OP_CRYPTOPRO_TLSEXT_BUG)) { const unsigned char cryptopro_ext[36] = { 0xfd, 0xe8, /*65000*/ 0x00, 0x20, /*32 bytes length*/ 0x30, 0x1e, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x09, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x16, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x17}; if (limit-ret<36) return NULL; memcpy(ret,cryptopro_ext,36); ret+=36; } #ifndef OPENSSL_NO_HEARTBEATS /* Add Heartbeat extension if we've received one */ if (s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) { if ((limit - ret - 4 - 1) < 0) return NULL; s2n(TLSEXT_TYPE_heartbeat,ret); s2n(1,ret); /* Set mode: * 1: peer may send requests * 2: peer not allowed to send requests */ if (s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_RECV_REQUESTS) *(ret++) = SSL_TLSEXT_HB_DONT_SEND_REQUESTS; else *(ret++) = SSL_TLSEXT_HB_ENABLED; } #endif #ifndef OPENSSL_NO_NEXTPROTONEG next_proto_neg_seen = s->s3->next_proto_neg_seen; s->s3->next_proto_neg_seen = 0; if (next_proto_neg_seen && s->ctx->next_protos_advertised_cb) { const unsigned char *npa; unsigned int npalen; int r; r = s->ctx->next_protos_advertised_cb(s, &npa, &npalen, s->ctx->next_protos_advertised_cb_arg); if (r == SSL_TLSEXT_ERR_OK) { if ((long)(limit - ret - 4 - npalen) < 0) return NULL; s2n(TLSEXT_TYPE_next_proto_neg,ret); s2n(npalen,ret); memcpy(ret, npa, npalen); ret += npalen; s->s3->next_proto_neg_seen = 1; } } #endif for (i = 0; i < s->ctx->custom_srv_ext_records_count; i++) { const unsigned char *out = NULL; unsigned short outlen = 0; int cb_retval = 0; record = &s->ctx->custom_srv_ext_records[i]; /* NULL callback or -1 omits extension */ if (!record->fn2) continue; cb_retval = record->fn2(s, record->ext_type, &out, &outlen, al, record->arg); if (cb_retval == 0) return NULL; /* error */ if (cb_retval == -1) continue; /* skip this extension */ if (limit < ret + 4 + outlen) return NULL; s2n(record->ext_type, ret); s2n(outlen, ret); memcpy(ret, out, outlen); ret += outlen; } #ifdef TLSEXT_TYPE_encrypt_then_mac if (s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC) { /* Don't use encrypt_then_mac if AEAD: might want * to disable for other ciphersuites too. */ if (s->s3->tmp.new_cipher->algorithm_mac == SSL_AEAD) s->s3->flags &= ~TLS1_FLAGS_ENCRYPT_THEN_MAC; else { s2n(TLSEXT_TYPE_encrypt_then_mac,ret); s2n(0,ret); } } #endif if (s->s3->alpn_selected) { const unsigned char *selected = s->s3->alpn_selected; unsigned len = s->s3->alpn_selected_len; if ((long)(limit - ret - 4 - 2 - 1 - len) < 0) return NULL; s2n(TLSEXT_TYPE_application_layer_protocol_negotiation,ret); s2n(3 + len,ret); s2n(1 + len,ret); *ret++ = len; memcpy(ret, selected, len); ret += len; } if ((extdatalen = ret-orig-2)== 0) return orig; s2n(extdatalen, orig); return ret; }
0
[]
openssl
80bd7b41b30af6ee96f519e629463583318de3b0
23,893,667,744,202,168,000,000,000,000,000,000,000
253
Fix SRP ciphersuite DoS vulnerability. If a client attempted to use an SRP ciphersuite and it had not been set up correctly it would crash with a null pointer read. A malicious server could exploit this in a DoS attack. Thanks to Joonas Kuorilehto and Riku Hietamäki from Codenomicon for reporting this issue. CVE-2014-2970 Reviewed-by: Tim Hudson <[email protected]>
TEST_F(RouterTest, HedgedPerTryTimeoutGlobalTimeout) { enableHedgeOnPerTryTimeout(); NiceMock<Http::MockRequestEncoder> encoder1; Http::ResponseDecoder* response_decoder1 = nullptr; EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _)) .WillOnce(Invoke( [&](Http::ResponseDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { response_decoder1 = &decoder; EXPECT_CALL(*router_.retry_state_, onHostAttempted(_)); callbacks.onPoolReady(encoder1, cm_.thread_local_cluster_.conn_pool_.host_, upstream_stream_info_, Http::Protocol::Http10); return nullptr; })); EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_, putResult(Upstream::Outlier::Result::LocalOriginConnectSuccess, absl::optional<uint64_t>(absl::nullopt))) .Times(2); expectPerTryTimerCreate(); expectResponseTimerCreate(); Http::TestRequestHeaderMapImpl headers{{"x-envoy-upstream-rq-per-try-timeout-ms", "5"}}; HttpTestUtility::addDefaultHeaders(headers); router_.decodeHeaders(headers, true); EXPECT_EQ(1U, callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value()); EXPECT_CALL( cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_, putResult(Upstream::Outlier::Result::LocalOriginTimeout, absl::optional<uint64_t>(504))); EXPECT_CALL(encoder1.stream_, resetStream(_)).Times(0); EXPECT_CALL(callbacks_, encodeHeaders_(_, _)).Times(0); router_.retry_state_->expectHedgedPerTryTimeoutRetry(); per_try_timeout_->invokeCallback(); NiceMock<Http::MockRequestEncoder> encoder2; Http::ResponseDecoder* response_decoder2 = nullptr; EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _)) .WillOnce(Invoke( [&](Http::ResponseDecoder& decoder, Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* { response_decoder2 = &decoder; EXPECT_CALL(*router_.retry_state_, onHostAttempted(_)); callbacks.onPoolReady(encoder2, cm_.thread_local_cluster_.conn_pool_.host_, upstream_stream_info_, Http::Protocol::Http10); return nullptr; })); expectPerTryTimerCreate(); router_.retry_state_->callback_(); EXPECT_EQ(2U, callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value()); EXPECT_TRUE(verifyHostUpstreamStats(0, 0)); // Now trigger global timeout, expect everything to be reset EXPECT_CALL(encoder1.stream_, resetStream(_)); EXPECT_CALL(encoder2.stream_, resetStream(_)); EXPECT_CALL( cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_, putResult(Upstream::Outlier::Result::LocalOriginTimeout, absl::optional<uint64_t>(504))); EXPECT_CALL(callbacks_, encodeHeaders_(_, _)) .WillOnce(Invoke([&](Http::ResponseHeaderMap& headers, bool) -> void { EXPECT_EQ(headers.Status()->value(), "504"); })); response_timeout_->invokeCallback(); EXPECT_TRUE(verifyHostUpstreamStats(0, 2)); EXPECT_EQ(2, cm_.thread_local_cluster_.conn_pool_.host_->stats_.rq_timeout_.value()); // TODO: Verify hedge stats here once they are implemented. }
0
[ "CWE-703" ]
envoy
18871dbfb168d3512a10c78dd267ff7c03f564c6
73,611,702,006,227,800,000,000,000,000,000,000,000
71
[1.18] CVE-2022-21655 Crash with direct_response Signed-off-by: Otto van der Schaaf <[email protected]>
static int dtv_property_process_set(struct dvb_frontend *fe, struct file *file, u32 cmd, u32 data) { int r = 0; struct dtv_frontend_properties *c = &fe->dtv_property_cache; /** Dump DTV command name and value*/ if (!cmd || cmd > DTV_MAX_COMMAND) dev_warn(fe->dvb->device, "%s: SET cmd 0x%08x undefined\n", __func__, cmd); else dev_dbg(fe->dvb->device, "%s: SET cmd 0x%08x (%s) to 0x%08x\n", __func__, cmd, dtv_cmds[cmd].name, data); switch (cmd) { case DTV_CLEAR: /* * Reset a cache of data specific to the frontend here. This does * not effect hardware. */ dvb_frontend_clear_cache(fe); break; case DTV_TUNE: /* * Use the cached Digital TV properties to tune the * frontend */ dev_dbg(fe->dvb->device, "%s: Setting the frontend from property cache\n", __func__); r = dtv_set_frontend(fe); break; case DTV_FREQUENCY: c->frequency = data; break; case DTV_MODULATION: c->modulation = data; break; case DTV_BANDWIDTH_HZ: c->bandwidth_hz = data; break; case DTV_INVERSION: c->inversion = data; break; case DTV_SYMBOL_RATE: c->symbol_rate = data; break; case DTV_INNER_FEC: c->fec_inner = data; break; case DTV_PILOT: c->pilot = data; break; case DTV_ROLLOFF: c->rolloff = data; break; case DTV_DELIVERY_SYSTEM: r = dvbv5_set_delivery_system(fe, data); break; case DTV_VOLTAGE: c->voltage = data; r = dvb_frontend_handle_ioctl(file, FE_SET_VOLTAGE, (void *)c->voltage); break; case DTV_TONE: c->sectone = data; r = dvb_frontend_handle_ioctl(file, FE_SET_TONE, (void *)c->sectone); break; case DTV_CODE_RATE_HP: c->code_rate_HP = data; break; case DTV_CODE_RATE_LP: c->code_rate_LP = data; break; case DTV_GUARD_INTERVAL: c->guard_interval = data; break; case DTV_TRANSMISSION_MODE: c->transmission_mode = data; break; case DTV_HIERARCHY: c->hierarchy = data; break; case DTV_INTERLEAVING: c->interleaving = data; break; /* ISDB-T Support here */ case DTV_ISDBT_PARTIAL_RECEPTION: c->isdbt_partial_reception = data; break; case DTV_ISDBT_SOUND_BROADCASTING: c->isdbt_sb_mode = data; break; case DTV_ISDBT_SB_SUBCHANNEL_ID: c->isdbt_sb_subchannel = data; break; case DTV_ISDBT_SB_SEGMENT_IDX: c->isdbt_sb_segment_idx = data; break; case DTV_ISDBT_SB_SEGMENT_COUNT: c->isdbt_sb_segment_count = data; break; case DTV_ISDBT_LAYER_ENABLED: c->isdbt_layer_enabled = data; break; case DTV_ISDBT_LAYERA_FEC: c->layer[0].fec = data; break; case DTV_ISDBT_LAYERA_MODULATION: c->layer[0].modulation = data; break; case DTV_ISDBT_LAYERA_SEGMENT_COUNT: c->layer[0].segment_count = data; break; case DTV_ISDBT_LAYERA_TIME_INTERLEAVING: c->layer[0].interleaving = data; break; case DTV_ISDBT_LAYERB_FEC: c->layer[1].fec = data; break; case DTV_ISDBT_LAYERB_MODULATION: c->layer[1].modulation = data; break; case DTV_ISDBT_LAYERB_SEGMENT_COUNT: c->layer[1].segment_count = data; break; case DTV_ISDBT_LAYERB_TIME_INTERLEAVING: c->layer[1].interleaving = data; break; case DTV_ISDBT_LAYERC_FEC: c->layer[2].fec = data; break; case DTV_ISDBT_LAYERC_MODULATION: c->layer[2].modulation = data; break; case DTV_ISDBT_LAYERC_SEGMENT_COUNT: c->layer[2].segment_count = data; break; case DTV_ISDBT_LAYERC_TIME_INTERLEAVING: c->layer[2].interleaving = data; break; /* Multistream support */ case DTV_STREAM_ID: case DTV_DVBT2_PLP_ID_LEGACY: c->stream_id = data; break; /* ATSC-MH */ case DTV_ATSCMH_PARADE_ID: fe->dtv_property_cache.atscmh_parade_id = data; break; case DTV_ATSCMH_RS_FRAME_ENSEMBLE: fe->dtv_property_cache.atscmh_rs_frame_ensemble = data; break; case DTV_LNA: c->lna = data; if (fe->ops.set_lna) r = fe->ops.set_lna(fe); if (r < 0) c->lna = LNA_AUTO; break; default: return -EINVAL; } return r; }
0
[ "CWE-416" ]
linux
b1cb7372fa822af6c06c8045963571d13ad6348b
238,634,170,933,862,400,000,000,000,000,000,000,000
174
dvb_frontend: don't use-after-free the frontend struct dvb_frontend_invoke_release() may free the frontend struct. So, the free logic can't update it anymore after calling it. That's OK, as __dvb_frontend_free() is called only when the krefs are zeroed, so nobody is using it anymore. That should fix the following KASAN error: The KASAN report looks like this (running on kernel 3e0cc09a3a2c40ec1ffb6b4e12da86e98feccb11 (4.14-rc5+)): ================================================================== BUG: KASAN: use-after-free in __dvb_frontend_free+0x113/0x120 Write of size 8 at addr ffff880067d45a00 by task kworker/0:1/24 CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc5-43687-g06ab8a23e0e6 #545 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:16 dump_stack+0x292/0x395 lib/dump_stack.c:52 print_address_description+0x78/0x280 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 kasan_report+0x23d/0x350 mm/kasan/report.c:409 __asan_report_store8_noabort+0x1c/0x20 mm/kasan/report.c:435 __dvb_frontend_free+0x113/0x120 drivers/media/dvb-core/dvb_frontend.c:156 dvb_frontend_put+0x59/0x70 drivers/media/dvb-core/dvb_frontend.c:176 dvb_frontend_detach+0x120/0x150 drivers/media/dvb-core/dvb_frontend.c:2803 dvb_usb_adapter_frontend_exit+0xd6/0x160 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:340 dvb_usb_adapter_exit drivers/media/usb/dvb-usb/dvb-usb-init.c:116 dvb_usb_exit+0x9b/0x200 drivers/media/usb/dvb-usb/dvb-usb-init.c:132 dvb_usb_device_exit+0xa5/0xf0 drivers/media/usb/dvb-usb/dvb-usb-init.c:295 usb_unbind_interface+0x21c/0xa90 drivers/usb/core/driver.c:423 __device_release_driver drivers/base/dd.c:861 device_release_driver_internal+0x4f1/0x5c0 drivers/base/dd.c:893 device_release_driver+0x1e/0x30 drivers/base/dd.c:918 bus_remove_device+0x2f4/0x4b0 drivers/base/bus.c:565 device_del+0x5c4/0xab0 drivers/base/core.c:1985 usb_disable_device+0x1e9/0x680 drivers/usb/core/message.c:1170 usb_disconnect+0x260/0x7a0 drivers/usb/core/hub.c:2124 hub_port_connect drivers/usb/core/hub.c:4754 hub_port_connect_change drivers/usb/core/hub.c:5009 port_event drivers/usb/core/hub.c:5115 hub_event+0x1318/0x3740 drivers/usb/core/hub.c:5195 process_one_work+0xc73/0x1d90 kernel/workqueue.c:2119 worker_thread+0x221/0x1850 kernel/workqueue.c:2253 kthread+0x363/0x440 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 Allocated by task 24: save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 kmem_cache_alloc_trace+0x11e/0x2d0 mm/slub.c:2772 kmalloc ./include/linux/slab.h:493 kzalloc ./include/linux/slab.h:666 dtt200u_fe_attach+0x4c/0x110 drivers/media/usb/dvb-usb/dtt200u-fe.c:212 dtt200u_frontend_attach+0x35/0x80 drivers/media/usb/dvb-usb/dtt200u.c:136 dvb_usb_adapter_frontend_init+0x32b/0x660 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:286 dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:86 dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:162 dvb_usb_device_init+0xf73/0x17f0 drivers/media/usb/dvb-usb/dvb-usb-init.c:277 dtt200u_usb_probe+0xa1/0xe0 drivers/media/usb/dvb-usb/dtt200u.c:155 usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361 really_probe drivers/base/dd.c:413 driver_probe_device+0x610/0xa00 drivers/base/dd.c:557 __device_attach_driver+0x230/0x290 drivers/base/dd.c:653 bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463 __device_attach+0x26b/0x3c0 drivers/base/dd.c:710 device_initial_probe+0x1f/0x30 drivers/base/dd.c:757 bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523 device_add+0xd0b/0x1660 drivers/base/core.c:1835 usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932 generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174 usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266 really_probe drivers/base/dd.c:413 driver_probe_device+0x610/0xa00 drivers/base/dd.c:557 __device_attach_driver+0x230/0x290 drivers/base/dd.c:653 bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463 __device_attach+0x26b/0x3c0 drivers/base/dd.c:710 device_initial_probe+0x1f/0x30 drivers/base/dd.c:757 bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523 device_add+0xd0b/0x1660 drivers/base/core.c:1835 usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457 hub_port_connect drivers/usb/core/hub.c:4903 hub_port_connect_change drivers/usb/core/hub.c:5009 port_event drivers/usb/core/hub.c:5115 hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195 process_one_work+0xc73/0x1d90 kernel/workqueue.c:2119 worker_thread+0x221/0x1850 kernel/workqueue.c:2253 kthread+0x363/0x440 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 Freed by task 24: save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:524 slab_free_hook mm/slub.c:1390 slab_free_freelist_hook mm/slub.c:1412 slab_free mm/slub.c:2988 kfree+0xf6/0x2f0 mm/slub.c:3919 dtt200u_fe_release+0x3c/0x50 drivers/media/usb/dvb-usb/dtt200u-fe.c:202 dvb_frontend_invoke_release.part.13+0x1c/0x30 drivers/media/dvb-core/dvb_frontend.c:2790 dvb_frontend_invoke_release drivers/media/dvb-core/dvb_frontend.c:2789 __dvb_frontend_free+0xad/0x120 drivers/media/dvb-core/dvb_frontend.c:153 dvb_frontend_put+0x59/0x70 drivers/media/dvb-core/dvb_frontend.c:176 dvb_frontend_detach+0x120/0x150 drivers/media/dvb-core/dvb_frontend.c:2803 dvb_usb_adapter_frontend_exit+0xd6/0x160 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:340 dvb_usb_adapter_exit drivers/media/usb/dvb-usb/dvb-usb-init.c:116 dvb_usb_exit+0x9b/0x200 drivers/media/usb/dvb-usb/dvb-usb-init.c:132 dvb_usb_device_exit+0xa5/0xf0 drivers/media/usb/dvb-usb/dvb-usb-init.c:295 usb_unbind_interface+0x21c/0xa90 drivers/usb/core/driver.c:423 __device_release_driver drivers/base/dd.c:861 device_release_driver_internal+0x4f1/0x5c0 drivers/base/dd.c:893 device_release_driver+0x1e/0x30 drivers/base/dd.c:918 bus_remove_device+0x2f4/0x4b0 drivers/base/bus.c:565 device_del+0x5c4/0xab0 drivers/base/core.c:1985 usb_disable_device+0x1e9/0x680 drivers/usb/core/message.c:1170 usb_disconnect+0x260/0x7a0 drivers/usb/core/hub.c:2124 hub_port_connect drivers/usb/core/hub.c:4754 hub_port_connect_change drivers/usb/core/hub.c:5009 port_event drivers/usb/core/hub.c:5115 hub_event+0x1318/0x3740 drivers/usb/core/hub.c:5195 process_one_work+0xc73/0x1d90 kernel/workqueue.c:2119 worker_thread+0x221/0x1850 kernel/workqueue.c:2253 kthread+0x363/0x440 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 The buggy address belongs to the object at ffff880067d45500 which belongs to the cache kmalloc-2048 of size 2048 The buggy address is located 1280 bytes inside of 2048-byte region [ffff880067d45500, ffff880067d45d00) The buggy address belongs to the page: page:ffffea00019f5000 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0 flags: 0x100000000008100(slab|head) raw: 0100000000008100 0000000000000000 0000000000000000 00000001000f000f raw: dead000000000100 dead000000000200 ffff88006c002d80 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff880067d45900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff880067d45980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff880067d45a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff880067d45a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff880067d45b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Fixes: ead666000a5f ("media: dvb_frontend: only use kref after initialized") Reported-by: Andrey Konovalov <[email protected]> Suggested-by: Matthias Schwarzott <[email protected]> Tested-by: Andrey Konovalov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
request_counter_remove_request (RequestCounter counter, Request request) { guint i; for (i = 0; i < REQUEST_TYPE_LAST; i++) { if (REQUEST_WANTS_TYPE (request, i)) { counter[i]--; } } }
0
[ "CWE-20" ]
nautilus
1630f53481f445ada0a455e9979236d31a8d3bb0
207,927,024,628,373,360,000,000,000,000,000,000,000
13
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
struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, struct net *net, const union sctp_addr *laddr, const union sctp_addr *paddr) { struct sctp_transport *transport; if ((htons(asoc->base.bind_addr.port) == laddr->v4.sin_port) && (htons(asoc->peer.port) == paddr->v4.sin_port) && net_eq(sock_net(asoc->base.sk), net)) { transport = sctp_assoc_lookup_paddr(asoc, paddr); if (!transport) goto out; if (sctp_bind_addr_match(&asoc->base.bind_addr, laddr, sctp_sk(asoc->base.sk))) goto out; } transport = NULL; out: return transport; }
0
[]
linux
196d67593439b03088913227093e374235596e33
294,472,840,201,423,600,000,000,000,000,000,000,000
23
sctp: Add support to per-association statistics via a new SCTP_GET_ASSOC_STATS call The current SCTP stack is lacking a mechanism to have per association statistics. This is an implementation modeled after OpenSolaris' SCTP_GET_ASSOC_STATS. Userspace part will follow on lksctp if/when there is a general ACK on this. V4: - Move ipackets++ before q->immediate.func() for consistency reasons - Move sctp_max_rto() at the end of sctp_transport_update_rto() to avoid returning bogus RTO values - return asoc->rto_min when max_obs_rto value has not changed V3: - Increase ictrlchunks in sctp_assoc_bh_rcv() as well - Move ipackets++ to sctp_inq_push() - return 0 when no rto updates took place since the last call V2: - Implement partial retrieval of stat struct to cope for future expansion - Kill the rtxpackets counter as it cannot be precise anyway - Rename outseqtsns to outofseqtsns to make it clearer that these are out of sequence unexpected TSNs - Move asoc->ipackets++ under a lock to avoid potential miscounts - Fold asoc->opackets++ into the already existing asoc check - Kill unneeded (q->asoc) test when increasing rtxchunks - Do not count octrlchunks if sending failed (SCTP_XMIT_OK != 0) - Don't count SHUTDOWNs as SACKs - Move SCTP_GET_ASSOC_STATS to the private space API - Adjust the len check in sctp_getsockopt_assoc_stats() to allow for future struct growth - Move association statistics in their own struct - Update idupchunks when we send a SACK with dup TSNs - return min_rto in max_rto when RTO has not changed. Also return the transport when max_rto last changed. Signed-off: Michele Baldessari <[email protected]> Acked-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf) { struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb); buf->f_type = TMPFS_MAGIC; buf->f_bsize = PAGE_CACHE_SIZE; buf->f_namelen = NAME_MAX; if (sbinfo->max_blocks) { buf->f_blocks = sbinfo->max_blocks; buf->f_bavail = buf->f_bfree = sbinfo->max_blocks - percpu_counter_sum(&sbinfo->used_blocks); } if (sbinfo->max_inodes) { buf->f_files = sbinfo->max_inodes; buf->f_ffree = sbinfo->free_inodes; } /* else leave those fields 0 like simple_statfs */ return 0; }
0
[ "CWE-399" ]
linux
5f00110f7273f9ff04ac69a5f85bb535a4fd0987
256,359,787,130,636,500,000,000,000,000,000,000,000
20
tmpfs: fix use-after-free of mempolicy object The tmpfs remount logic preserves filesystem mempolicy if the mpol=M option is not specified in the remount request. A new policy can be specified if mpol=M is given. Before this patch remounting an mpol bound tmpfs without specifying mpol= mount option in the remount request would set the filesystem's mempolicy object to a freed mempolicy object. To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run: # mkdir /tmp/x # mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x # grep /tmp/x /proc/mounts nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0 # mount -o remount,size=200M nodev /tmp/x # grep /tmp/x /proc/mounts nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0 # note ? garbage in mpol=... output above # dd if=/dev/zero of=/tmp/x/f count=1 # panic here Panic: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [< (null)>] (null) [...] Oops: 0010 [#1] SMP DEBUG_PAGEALLOC Call Trace: mpol_shared_policy_init+0xa5/0x160 shmem_get_inode+0x209/0x270 shmem_mknod+0x3e/0xf0 shmem_create+0x18/0x20 vfs_create+0xb5/0x130 do_last+0x9a1/0xea0 path_openat+0xb3/0x4d0 do_filp_open+0x42/0xa0 do_sys_open+0xfe/0x1e0 compat_sys_open+0x1b/0x20 cstar_dispatch+0x7/0x1f Non-debug kernels will not crash immediately because referencing the dangling mpol will not cause a fault. Instead the filesystem will reference a freed mempolicy object, which will cause unpredictable behavior. The problem boils down to a dropped mpol reference below if shmem_parse_options() does not allocate a new mpol: config = *sbinfo shmem_parse_options(data, &config, true) mpol_put(sbinfo->mpol) sbinfo->mpol = config.mpol /* BUG: saves unreferenced mpol */ This patch avoids the crash by not releasing the mempolicy if shmem_parse_options() doesn't create a new mpol. How far back does this issue go? I see it in both 2.6.36 and 3.3. I did not look back further. Signed-off-by: Greg Thelen <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void smtcfb_pci_remove(struct pci_dev *pdev) { struct smtcfb_info *sfb; sfb = pci_get_drvdata(pdev); smtc_unmap_smem(sfb); smtc_unmap_mmio(sfb); unregister_framebuffer(sfb->fb); framebuffer_release(sfb->fb); pci_release_region(pdev, 0); pci_disable_device(pdev); }
0
[ "CWE-787" ]
linux-fbdev
bd771cf5c4254511cc4abb88f3dab3bd58bdf8e8
181,390,827,045,458,830,000,000,000,000,000,000,000
12
video: fbdev: sm712fb: Fix crash in smtcfb_read() Zheyu Ma reported this crash in the sm712fb driver when reading three bytes from the framebuffer: BUG: unable to handle page fault for address: ffffc90001ffffff RIP: 0010:smtcfb_read+0x230/0x3e0 Call Trace: vfs_read+0x198/0xa00 ? do_sys_openat2+0x27d/0x350 ? __fget_light+0x54/0x340 ksys_read+0xce/0x190 do_syscall_64+0x43/0x90 Fix it by removing the open-coded endianess fixup-code and by moving the pointer post decrement out the fb_readl() function. Reported-by: Zheyu Ma <[email protected]> Signed-off-by: Helge Deller <[email protected]> Tested-by: Zheyu Ma <[email protected]> Cc: [email protected]
nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_secinfo *secinfo) { struct xdr_stream *xdr = &resp->xdr; return nfsd4_do_encode_secinfo(xdr, nfserr, secinfo->si_exp); }
0
[ "CWE-20", "CWE-129" ]
linux
f961e3f2acae94b727380c0b74e2d3954d0edf79
15,305,477,166,496,864,000,000,000,000,000,000,000
7
nfsd: encoders mustn't use unitialized values in error cases In error cases, lgp->lg_layout_type may be out of bounds; so we shouldn't be using it until after the check of nfserr. This was seen to crash nfsd threads when the server receives a LAYOUTGET request with a large layout type. GETDEVICEINFO has the same problem. Reported-by: Ari Kauppi <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Cc: [email protected] Signed-off-by: J. Bruce Fields <[email protected]>
static void md_release(struct gendisk *disk, fmode_t mode) { struct mddev *mddev = disk->private_data; BUG_ON(!mddev); atomic_dec(&mddev->openers); mddev_put(mddev); }
0
[ "CWE-200" ]
linux
b6878d9e03043695dbf3fa1caa6dfc09db225b16
281,673,624,416,848,300,000,000,000,000,000,000,000
8
md: use kzalloc() when bitmap is disabled In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a mdu_bitmap_file_t called "file". 5769 file = kmalloc(sizeof(*file), GFP_NOIO); 5770 if (!file) 5771 return -ENOMEM; This structure is copied to user space at the end of the function. 5786 if (err == 0 && 5787 copy_to_user(arg, file, sizeof(*file))) 5788 err = -EFAULT But if bitmap is disabled only the first byte of "file" is initialized with zero, so it's possible to read some bytes (up to 4095) of kernel space memory from user space. This is an information leak. 5775 /* bitmap disabled, zero the first byte and copy out */ 5776 if (!mddev->bitmap_info.file) 5777 file->pathname[0] = '\0'; Signed-off-by: Benjamin Randazzo <[email protected]> Signed-off-by: NeilBrown <[email protected]>
static FP16 float_to_half_full(FP32 f) { FP16 o = {0}; // Based on ISPC reference code (with minor modifications) if (f.s.Exponent == 0) // Signed zero/denormal (which will underflow) o.s.Exponent = 0; else if (f.s.Exponent == 255) // Inf or NaN (all exponent bits set) { o.s.Exponent = 31; o.s.Mantissa = f.s.Mantissa ? 0x200 : 0; // NaN->qNaN and Inf->Inf } else // Normalized number { // Exponent unbias the single, then bias the halfp int newexp = f.s.Exponent - 127 + 15; if (newexp >= 31) // Overflow, return signed infinity o.s.Exponent = 31; else if (newexp <= 0) // Underflow { if ((14 - newexp) <= 24) // Mantissa might be non-zero { unsigned int mant = f.s.Mantissa | 0x800000; // Hidden 1 bit o.s.Mantissa = mant >> (14 - newexp); if ((mant >> (13 - newexp)) & 1) // Check for rounding o.u++; // Round, might overflow into exp bit, but this is OK } } else { o.s.Exponent = static_cast<unsigned int>(newexp); o.s.Mantissa = f.s.Mantissa >> 13; if (f.s.Mantissa & 0x1000) // Check for rounding o.u++; // Round, might overflow to inf, this is OK } } o.s.Sign = f.s.Sign; return o; }
0
[ "CWE-20", "CWE-190" ]
tinyexr
a685e3332f61cd4e59324bf3f669d36973d64270
161,893,011,327,034,720,000,000,000,000,000,000,000
36
Make line_no with too large value(2**20) invalid. Fixes #124
static int jpg_dec_parseopts(char *optstr, jpg_dec_importopts_t *opts) { jas_tvparser_t *tvp; opts->max_samples = 64 * JAS_MEBI; if (!(tvp = jas_tvparser_create(optstr ? optstr : ""))) { return -1; } while (!jas_tvparser_next(tvp)) { switch (jas_taginfo_nonull(jas_taginfos_lookup(decopts, jas_tvparser_gettag(tvp)))->id) { case OPT_MAXSIZE: opts->max_samples = atoi(jas_tvparser_getval(tvp)); break; default: jas_eprintf("warning: ignoring invalid option %s\n", jas_tvparser_gettag(tvp)); break; } } jas_tvparser_destroy(tvp); return 0; }
0
[ "CWE-20", "CWE-190" ]
jasper
d42b2388f7f8e0332c846675133acea151fc557a
195,765,505,453,349,900,000,000,000,000,000,000,000
27
The generation of the configuration file jas_config.h has been completely reworked in order to avoid pollution of the global namespace. Some problematic types like uchar, ulong, and friends have been replaced with names with a jas_ prefix. An option max_samples has been added to the BMP and JPEG decoders to restrict the maximum size of image that they can decode. This change was made as a (possibly temporary) fix to address security concerns. A max_samples command-line option has also been added to imginfo. Whether an image component (for jas_image_t) is stored in memory or on disk is now based on the component size (rather than the image size). Some debug log message were added. Some new integer overflow checks were added. Some new safe integer add/multiply functions were added. More pre-C99 cruft was removed. JasPer has numerous "hacks" to handle pre-C99 compilers. JasPer now assumes C99 support. So, this pre-C99 cruft is unnecessary and can be removed. The regression jasper-doublefree-mem_close.jpg has been re-enabled. Theoretically, it should work more predictably now.
display_set_separations(gx_device_display *dev) { if (((dev->nFormat & DISPLAY_COLORS_MASK) == DISPLAY_COLORS_SEPARATION) && (dev->callback->version_major > DISPLAY_VERSION_MAJOR_V1) && (dev->callback->display_separation != NULL)) { /* Tell the client about the separation to composite mapping */ char name[64]; int num_spot = dev->devn_params.separations.num_separations; int num_std_colorants = dev->devn_params.num_std_colorant_names; int num_comp = num_std_colorants + num_spot; int comp_map[GX_DEVICE_COLOR_MAX_COMPONENTS]; int comp_num; int sep_num; int sep_name_size; unsigned int c, m, y, k; /* Map the separation numbers to component numbers */ memset(comp_map, 0, sizeof(comp_map)); for (sep_num = 0; sep_num < num_comp; sep_num++) { comp_num = dev->devn_params.separation_order_map[sep_num]; if (comp_num >= 0 && comp_num < GX_DEVICE_COLOR_MAX_COMPONENTS) comp_map[comp_num] = sep_num; } /* For each component, tell the client the separation mapping */ for (comp_num = 0; comp_num < num_comp; comp_num++) { c = y = m = k = 0; sep_num = comp_map[comp_num]; /* Get the CMYK equivalent */ if (sep_num < dev->devn_params.num_std_colorant_names) { sep_name_size = strlen(dev->devn_params.std_colorant_names[sep_num]); if (sep_name_size > sizeof(name)-2) sep_name_size = sizeof(name)-1; memcpy(name, dev->devn_params.std_colorant_names[sep_num], sep_name_size); name[sep_name_size] = '\0'; switch (sep_num) { case 0: c = 65535; break; case 1: m = 65535; break; case 2: y = 65535; break; case 3: k = 65535; break; } } else { sep_num -= dev->devn_params.num_std_colorant_names; sep_name_size = dev->devn_params.separations.names[sep_num].size; if (sep_name_size > sizeof(name)-2) sep_name_size = sizeof(name)-1; memcpy(name, dev->devn_params.separations.names[sep_num].data, sep_name_size); name[sep_name_size] = '\0'; if (dev->equiv_cmyk_colors.color[sep_num].color_info_valid) { c = dev->equiv_cmyk_colors.color[sep_num].c * 65535 / frac_1; m = dev->equiv_cmyk_colors.color[sep_num].m * 65535 / frac_1; y = dev->equiv_cmyk_colors.color[sep_num].y * 65535 / frac_1; k = dev->equiv_cmyk_colors.color[sep_num].k * 65535 / frac_1; } } while(dev->parent) dev = (gx_device_display *)dev->parent; (*dev->callback->display_separation)(dev->pHandle, dev, comp_num, name, (unsigned short)c, (unsigned short)m, (unsigned short)y, (unsigned short)k); } } return 0; }
0
[]
ghostpdl
1ef5f08f2c2e27efa978f0010669ff22355c385f
133,704,269,371,394,380,000,000,000,000,000,000,000
74
Fix display device DisplayFormat=16#a0800 (Separation mode) broken by f2cf6829 The ICC profile checking needs to be told that the device supports_devn, so add a spec_op proc to return true when in separation mode, and add a proc for fill_rectangle_hl_color so that fillpage will work in Separation mode. This was fixed for other devices in commit 250b5e83, but the display device was not fixed then.
static void opl3_command (int io_addr, unsigned int addr, unsigned int val) { int i; /* * The original 2-OP synth requires a quite long delay after writing to a * register. The OPL-3 survives with just two INBs */ outb(((unsigned char) (addr & 0xff)), io_addr); if (devc->model != 2) udelay(10); else for (i = 0; i < 2; i++) inb(io_addr); outb(((unsigned char) (val & 0xff)), io_addr + 1); if (devc->model != 2) udelay(30); else for (i = 0; i < 2; i++) inb(io_addr); }
0
[ "CWE-119", "CWE-264", "CWE-284" ]
linux
4d00135a680727f6c3be78f8befaac009030e4df
207,251,536,402,902,600,000,000,000,000,000,000,000
25
sound/oss/opl3: validate voice and channel indexes User-controllable indexes for voice and channel values may cause reading and writing beyond the bounds of their respective arrays, leading to potentially exploitable memory corruption. Validate these indexes. Signed-off-by: Dan Rosenberg <[email protected]> Cc: [email protected] Signed-off-by: Takashi Iwai <[email protected]>
void CommandHelpers::uassertNoDocumentSequences(StringData commandName, const OpMsgRequest& request) { uassert(40472, str::stream() << "The " << commandName << " command does not support document sequences.", request.sequences.empty()); }
0
[ "CWE-20" ]
mongo
722f06f3217c029ef9c50062c8cc775966fd7ead
210,997,448,987,283,650,000,000,000,000,000,000,000
7
SERVER-38275 ban find explain with UUID
flatpak_dir_has_remote (FlatpakDir *self, const char *remote_name, GError **error) { GKeyFile *config = NULL; g_autofree char *group = g_strdup_printf ("remote \"%s\"", remote_name); if (flatpak_dir_maybe_ensure_repo (self, NULL, NULL) && self->repo != NULL) { config = ostree_repo_get_config (self->repo); if (config && g_key_file_has_group (config, group)) return TRUE; } return flatpak_fail_error (error, FLATPAK_ERROR_REMOTE_NOT_FOUND, "Remote \"%s\" not found", remote_name); }
0
[ "CWE-668" ]
flatpak
cd2142888fc4c199723a0dfca1f15ea8788a5483
104,851,073,654,924,980,000,000,000,000,000,000,000
18
Don't expose /proc when running apply_extra As shown by CVE-2019-5736, it is sometimes possible for the sandbox app to access outside files using /proc/self/exe. This is not typically an issue for flatpak as the sandbox runs as the user which has no permissions to e.g. modify the host files. However, when installing apps using extra-data into the system repo we *do* actually run a sandbox as root. So, in this case we disable mounting /proc in the sandbox, which will neuter attacks like this.
bj10v_print_page(gx_device_printer *pdev, gp_file *prn_stream) { int line_size = gdev_prn_raster((gx_device *)pdev); int xres = pdev->x_pixels_per_inch; int yres = pdev->y_pixels_per_inch; const char *mode = (yres == 180 ? (xres == 180 ? "\052\047" : "\052\050") : "|*"); int bits_per_column = 24 * (yres / 180); int bytes_per_column = bits_per_column / 8; int x_skip_unit = bytes_per_column * (xres / 180); int y_skip_unit = (yres / 180); byte *in = (byte *)gs_malloc(pdev->memory->non_gc_memory, 8, line_size, "bj10v_print_page(in)"); byte *out = (byte *)gs_malloc(pdev->memory->non_gc_memory, bits_per_column, line_size, "bj10v_print_page(out)"); int lnum = 0; int y_skip = 0; int code = 0; int blank_lines = 0; int bytes_per_data = ((xres == 360) && (yres == 360)) ? 1 : 3; if ( in == 0 || out == 0 ) return -1; /* Initialize the printer. */ prn_puts(pdev, "\033@"); /* Transfer pixels to printer */ while ( lnum < pdev->height ) { byte *out_beg; byte *out_end; byte *outl, *outp; int count, bnum; /* Copy 1 scan line and test for all zero. */ code = gdev_prn_get_bits(pdev, lnum + blank_lines, in, NULL); if ( code < 0 ) goto xit; /* The mem... or str... functions should be faster than */ /* the following code, but all systems seem to implement */ /* them so badly that this code is faster. */ { register long *zip = (long *)in; register int zcnt = line_size; static const long zeroes[4] = { 0, 0, 0, 0 }; for ( ; zcnt >= 4 * sizeof(long); zip += 4, zcnt -= 4 * sizeof(long) ) { if ( zip[0] | zip[1] | zip[2] | zip[3] ) goto notz; } if ( !memcmp(in, (const char *)zeroes, zcnt) ) { /* Line is all zero, skip */ if (++blank_lines >= y_skip_unit) { lnum += y_skip_unit; y_skip++; blank_lines = 0; } continue; } } notz: blank_lines = 0; out_end = out + bytes_per_column * pdev->width; /* Vertical tab to the appropriate position. */ while ( y_skip > 255 ) { prn_puts(pdev, "\033J\377"); y_skip -= 255; } if ( y_skip ) { prn_puts(pdev, "\033J"); prn_putc(pdev, y_skip); } /* Transpose in blocks of 8 scan lines. */ for ( bnum = 0, outl = out; bnum < bits_per_column; bnum += 8, lnum += 8 ) { int lcnt = gdev_prn_copy_scan_lines(pdev, lnum, in, 8 * line_size); byte *inp = in; if ( lcnt < 0 ) { code = lcnt; goto xit; } if ( lcnt < 8 ) memset(in + lcnt * line_size, 0, (8 - lcnt) * line_size); for (outp = outl ; inp < in + line_size; inp++, outp += bits_per_column ) { memflip8x8(inp, line_size, outp, bytes_per_column); } outl++; } /* Remove trailing 0s. */ /* Note that non zero byte always exists. */ outl = out_end; while ( *--outl == 0 ) ; count = ((out_end - (outl + 1)) / bytes_per_column) * bytes_per_column; out_end -= count; *out_end = 1; /* sentinel */ for ( out_beg = outp = out; outp < out_end; ) { /* Skip a run of leading 0s. */ /* At least 10 bytes are needed to make tabbing worth it. */ byte *zp = outp; int x_skip; while ( *outp == 0 ) outp++; x_skip = ((outp - zp) / x_skip_unit) * x_skip_unit; outp = zp + x_skip; if (x_skip >= 10) { /* Output preceding bit data. */ int bytes = zp - out_beg; if (bytes > 0) /* Only false at beginning of line. */ bj10v_output_run(out_beg, bytes / bytes_per_data, bytes, mode, pdev); /* Tab over to the appropriate position. */ { int skip = x_skip / x_skip_unit; prn_puts(pdev, "\033\\"); prn_putc(pdev, skip & 0xff); prn_putc(pdev, skip >> 8); } out_beg = outp; } else outp += x_skip_unit; } if (out_end > out_beg) { int bytes = out_end - out_beg; bj10v_output_run(out_beg, bytes / bytes_per_data, bytes, mode, pdev); } prn_putc(pdev, '\r'); y_skip = 24; } /* Eject the page */ xit: prn_putc(pdev, 014); /* form feed */ prn_flush(pdev); gs_free(pdev->memory->non_gc_memory, (char *)out, bits_per_column, line_size, "bj10v_print_page(out)"); gs_free(pdev->memory->non_gc_memory, (char *)in, 8, line_size, "bj10v_print_page(in)"); return code; }
0
[]
ghostpdl
4fcbece468706e0e89ed2856729b2ccacbc112be
268,122,616,889,041,440,000,000,000,000,000,000,000
137
Avoid some devices dying due to inappropriate resolutions.
int split_huge_page_to_list(struct page *page, struct list_head *list) { struct page *head = compound_head(page); struct pglist_data *pgdata = NODE_DATA(page_to_nid(head)); struct anon_vma *anon_vma = NULL; struct address_space *mapping = NULL; int count, mapcount, extra_pins, ret; bool mlocked; unsigned long flags; VM_BUG_ON_PAGE(is_huge_zero_page(page), page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageCompound(page), page); if (PageWriteback(page)) return -EBUSY; if (PageAnon(head)) { /* * The caller does not necessarily hold an mmap_sem that would * prevent the anon_vma disappearing so we first we take a * reference to it and then lock the anon_vma for write. This * is similar to page_lock_anon_vma_read except the write lock * is taken to serialise against parallel split or collapse * operations. */ anon_vma = page_get_anon_vma(head); if (!anon_vma) { ret = -EBUSY; goto out; } mapping = NULL; anon_vma_lock_write(anon_vma); } else { mapping = head->mapping; /* Truncated ? */ if (!mapping) { ret = -EBUSY; goto out; } anon_vma = NULL; i_mmap_lock_read(mapping); } /* * Racy check if we can split the page, before freeze_page() will * split PMDs */ if (!can_split_huge_page(head, &extra_pins)) { ret = -EBUSY; goto out_unlock; } mlocked = PageMlocked(page); freeze_page(head); VM_BUG_ON_PAGE(compound_mapcount(head), head); /* Make sure the page is not on per-CPU pagevec as it takes pin */ if (mlocked) lru_add_drain(); /* prevent PageLRU to go away from under us, and freeze lru stats */ spin_lock_irqsave(zone_lru_lock(page_zone(head)), flags); if (mapping) { void **pslot; xa_lock(&mapping->i_pages); pslot = radix_tree_lookup_slot(&mapping->i_pages, page_index(head)); /* * Check if the head page is present in radix tree. * We assume all tail are present too, if head is there. */ if (radix_tree_deref_slot_protected(pslot, &mapping->i_pages.xa_lock) != head) goto fail; } /* Prevent deferred_split_scan() touching ->_refcount */ spin_lock(&pgdata->split_queue_lock); count = page_count(head); mapcount = total_mapcount(head); if (!mapcount && page_ref_freeze(head, 1 + extra_pins)) { if (!list_empty(page_deferred_list(head))) { pgdata->split_queue_len--; list_del(page_deferred_list(head)); } if (mapping) __dec_node_page_state(page, NR_SHMEM_THPS); spin_unlock(&pgdata->split_queue_lock); __split_huge_page(page, list, flags); if (PageSwapCache(head)) { swp_entry_t entry = { .val = page_private(head) }; ret = split_swap_cluster(entry); } else ret = 0; } else { if (IS_ENABLED(CONFIG_DEBUG_VM) && mapcount) { pr_alert("total_mapcount: %u, page_count(): %u\n", mapcount, count); if (PageTail(page)) dump_page(head, NULL); dump_page(page, "total_mapcount(head) > 0"); BUG(); } spin_unlock(&pgdata->split_queue_lock); fail: if (mapping) xa_unlock(&mapping->i_pages); spin_unlock_irqrestore(zone_lru_lock(page_zone(head)), flags); unfreeze_page(head); ret = -EBUSY; } out_unlock: if (anon_vma) { anon_vma_unlock_write(anon_vma); put_anon_vma(anon_vma); } if (mapping) i_mmap_unlock_read(mapping); out: count_vm_event(!ret ? THP_SPLIT_PAGE : THP_SPLIT_PAGE_FAILED); return ret; }
0
[ "CWE-459" ]
linux
eb66ae030829605d61fbef1909ce310e29f78821
257,321,299,446,255,240,000,000,000,000,000,000,000
128
mremap: properly flush TLB before releasing the page Jann Horn points out that our TLB flushing was subtly wrong for the mremap() case. What makes mremap() special is that we don't follow the usual "add page to list of pages to be freed, then flush tlb, and then free pages". No, mremap() obviously just _moves_ the page from one page table location to another. That matters, because mremap() thus doesn't directly control the lifetime of the moved page with a freelist: instead, the lifetime of the page is controlled by the page table locking, that serializes access to the entry. As a result, we need to flush the TLB not just before releasing the lock for the source location (to avoid any concurrent accesses to the entry), but also before we release the destination page table lock (to avoid the TLB being flushed after somebody else has already done something to that page). This also makes the whole "need_flush" logic unnecessary, since we now always end up flushing the TLB for every valid entry. Reported-and-tested-by: Jann Horn <[email protected]> Acked-by: Will Deacon <[email protected]> Tested-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
SetenvFin1(buf, len, data) char *buf; int len; char *data; /* dummy */ { if (!len || !display) return; InputSetenv(buf); }
0
[]
screen
c5db181b6e017cfccb8d7842ce140e59294d9f62
158,291,648,201,828,250,000,000,000,000,000,000,000
9
ansi: add support for xterm OSC 11 It allows for getting and setting the background color. Notably, Vim uses OSC 11 to learn whether it's running on a light or dark colored terminal and choose a color scheme accordingly. Tested with gnome-terminal and xterm. When called with "?" argument the current background color is returned: $ echo -ne "\e]11;?\e\\" $ 11;rgb:2323/2727/2929 Signed-off-by: Lubomir Rintel <[email protected]> (cherry picked from commit 7059bff20a28778f9d3acf81cad07b1388d02309) Signed-off-by: Amadeusz Sławiński <[email protected]
static int nfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data) { struct inode *inode = data->inode; if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { rpc_restart_call(task); return -EAGAIN; } nfs_refresh_inode(inode, data->res.fattr); return 0; }
0
[ "CWE-703" ]
linux
dc0b027dfadfcb8a5504f7d8052754bf8d501ab9
337,562,571,704,755,370,000,000,000,000,000,000,000
11
NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <[email protected]>
static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p, const struct nfs_fh *fhandle) { struct xdr_stream xdr; struct compound_hdr hdr = { .nops = 2, }; int status; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, fhandle); if (status == 0) status = encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS| FATTR4_WORD0_LINK_SUPPORT| FATTR4_WORD0_SYMLINK_SUPPORT| FATTR4_WORD0_ACLSUPPORT); return status; }
0
[ "CWE-703" ]
linux
dc0b027dfadfcb8a5504f7d8052754bf8d501ab9
35,481,880,657,534,364,000,000,000,000,000,000,000
18
NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <[email protected]>
static inline bool cpu_has_vmx_shadow_vmcs(void) { u64 vmx_msr; rdmsrl(MSR_IA32_VMX_MISC, vmx_msr); /* check if the cpu supports writing r/o exit information fields */ if (!(vmx_msr & MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS)) return false; return vmcs_config.cpu_based_2nd_exec_ctrl & SECONDARY_EXEC_SHADOW_VMCS; }
0
[]
kvm
a642fc305053cc1c6e47e4f4df327895747ab485
23,721,644,824,125,017,000,000,000,000,000,000,000
11
kvm: vmx: handle invvpid vm exit gracefully On systems with invvpid instruction support (corresponding bit in IA32_VMX_EPT_VPID_CAP MSR is set) guest invocation of invvpid causes vm exit, which is currently not handled and results in propagation of unknown exit to userspace. Fix this by installing an invvpid vm exit handler. This is CVE-2014-3646. Cc: [email protected] Signed-off-by: Petr Matousek <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
RawTile KakaduImage::getTile( int seq, int ang, unsigned int res, int layers, unsigned int tile ) { // Scale up our output bit depth to the nearest factor of 8 unsigned obpc = bpc; if( bpc <= 16 && bpc > 8 ) obpc = 16; else if( bpc <= 8 ) obpc = 8; #ifdef DEBUG Timer timer; timer.start(); #endif if( res > numResolutions ){ ostringstream tile_no; tile_no << "Kakadu :: Asked for non-existent resolution: " << res; throw file_error( tile_no.str() ); } int vipsres = ( numResolutions - 1 ) - res; unsigned int tw = tile_width; unsigned int th = tile_height; // Get the width and height for last row and column tiles unsigned int rem_x = image_widths[vipsres] % tile_width; unsigned int rem_y = image_heights[vipsres] % tile_height; // Calculate the number of tiles in each direction unsigned int ntlx = (image_widths[vipsres] / tw) + (rem_x == 0 ? 0 : 1); unsigned int ntly = (image_heights[vipsres] / th) + (rem_y == 0 ? 0 : 1); if( tile >= ntlx*ntly ){ ostringstream tile_no; tile_no << "Kakadu :: Asked for non-existent tile: " << tile; throw file_error( tile_no.str() ); } // Alter the tile size if it's in the last column if( ( tile % ntlx == ntlx - 1 ) && ( rem_x != 0 ) ) { tw = rem_x; } // Alter the tile size if it's in the bottom row if( ( tile / ntlx == ntly - 1 ) && rem_y != 0 ) { th = rem_y; } // Calculate the pixel offsets for this tile int xoffset = (tile % ntlx) * tile_width; int yoffset = (unsigned int) floor((double)(tile/ntlx)) * tile_height; #ifdef DEBUG logfile << "Kakadu :: Tile size: " << tw << "x" << th << "@" << channels << endl; #endif // Create our Rawtile object and initialize with data RawTile rawtile( tile, res, seq, ang, tw, th, channels, obpc ); // Create our raw tile buffer and initialize some values if( obpc == 16 ) rawtile.data = new unsigned short[tw*th*channels]; else if( obpc == 8 ) rawtile.data = new unsigned char[tw*th*channels]; else throw file_error( "Kakadu :: Unsupported number of bits" ); rawtile.dataLength = tw*th*channels*(obpc/8); rawtile.filename = getImagePath(); rawtile.timestamp = timestamp; // Process the tile process( res, layers, xoffset, yoffset, tw, th, rawtile.data ); #ifdef DEBUG logfile << "Kakadu :: bytes parsed: " << codestream.get_total_bytes(true) << endl; logfile << "Kakadu :: getTile() :: " << timer.getTime() << " microseconds" << endl; #endif return rawtile; }
0
[ "CWE-190" ]
iipsrv
882925b295a80ec992063deffc2a3b0d803c3195
187,940,139,133,213,680,000,000,000,000,000,000,000
85
- Modified TileManager.cc to verify that malloc() has correctly allocated memory. - Updated numerical types to std::size_t in RawTile.h, TileManager.cc, KakaduImage.cc, OpenJPEG.cc and Transforms.cc when allocating memory via new to avoid integer overflow - fixes remaining problems identified in https://github.com/ruven/iipsrv/issues/223.
xmlFreeRef(xmlLinkPtr lk) { xmlRefPtr ref = (xmlRefPtr)xmlLinkGetData(lk); if (ref == NULL) return; if (ref->value != NULL) xmlFree((xmlChar *)ref->value); if (ref->name != NULL) xmlFree((xmlChar *)ref->name); xmlFree(ref); }
0
[]
libxml2
932cc9896ab41475d4aa429c27d9afd175959d74
244,673,939,605,977,400,000,000,000,000,000,000,000
9
Fix buffer size checks in xmlSnprintfElementContent xmlSnprintfElementContent failed to correctly check the available buffer space in two locations. Fixes bug 781333 (CVE-2017-9047) and bug 781701 (CVE-2017-9048). Thanks to Marcel Böhme and Thuan Pham for the report.
TEST_F(HttpConnectionManagerConfigTest, RemoveAnyPortFalse) { const std::string yaml_string = R"EOF( stat_prefix: ingress_http route_config: name: local_route strip_any_host_port: false http_filters: - name: envoy.filters.http.router )EOF"; HttpConnectionManagerConfig config(parseHttpConnectionManagerFromYaml(yaml_string), context_, date_provider_, route_config_provider_manager_, scoped_routes_config_provider_manager_, http_tracer_manager_, filter_config_provider_manager_); EXPECT_EQ(Http::StripPortType::None, config.stripPortType()); }
0
[ "CWE-22" ]
envoy
5333b928d8bcffa26ab19bf018369a835f697585
178,828,329,308,983,300,000,000,000,000,000,000,000
16
Implement handling of escaped slash characters in URL path Fixes: CVE-2021-29492 Signed-off-by: Yan Avlasov <[email protected]>
cancel_mime_list_for_file (NautilusDirectory *directory, NautilusFile *file) { if (directory->details->mime_list_in_progress != NULL && directory->details->mime_list_in_progress->mime_list_file == file) { mime_list_cancel (directory); } }
0
[]
nautilus
7632a3e13874a2c5e8988428ca913620a25df983
53,544,538,561,305,990,000,000,000,000,000,000,000
8
Check for trusted desktop file launchers. 2009-02-24 Alexander Larsson <[email protected]> * libnautilus-private/nautilus-directory-async.c: Check for trusted desktop file launchers. * libnautilus-private/nautilus-file-private.h: * libnautilus-private/nautilus-file.c: * libnautilus-private/nautilus-file.h: Add nautilus_file_is_trusted_link. Allow unsetting of custom display name. * libnautilus-private/nautilus-mime-actions.c: Display dialog when trying to launch a non-trusted desktop file. svn path=/trunk/; revision=15003
__ip_vs_service_find(struct net *net, int af, __u16 protocol, const union nf_inet_addr *vaddr, __be16 vport) { unsigned int hash; struct ip_vs_service *svc; /* Check for "full" addressed entries */ hash = ip_vs_svc_hashkey(net, af, protocol, vaddr, vport); list_for_each_entry(svc, &ip_vs_svc_table[hash], s_list){ if ((svc->af == af) && ip_vs_addr_equal(af, &svc->addr, vaddr) && (svc->port == vport) && (svc->protocol == protocol) && net_eq(svc->net, net)) { /* HIT */ return svc; } } return NULL; }
0
[ "CWE-200" ]
linux
2d8a041b7bfe1097af21441cb77d6af95f4f4680
330,568,707,860,383,870,000,000,000,000,000,000,000
22
ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT) If at least one of CONFIG_IP_VS_PROTO_TCP or CONFIG_IP_VS_PROTO_UDP is not set, __ip_vs_get_timeouts() does not fully initialize the structure that gets copied to userland and that for leaks up to 12 bytes of kernel stack. Add an explicit memset(0) before passing the structure to __ip_vs_get_timeouts() to avoid the info leak. Signed-off-by: Mathias Krause <[email protected]> Cc: Wensong Zhang <[email protected]> Cc: Simon Horman <[email protected]> Cc: Julian Anastasov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static inline void hid_map_usage(struct hid_input *hidinput, struct hid_usage *usage, unsigned long **bit, int *max, __u8 type, unsigned int c) { struct input_dev *input = hidinput->input; unsigned long *bmap = NULL; unsigned int limit = 0; switch (type) { case EV_ABS: bmap = input->absbit; limit = ABS_MAX; break; case EV_REL: bmap = input->relbit; limit = REL_MAX; break; case EV_KEY: bmap = input->keybit; limit = KEY_MAX; break; case EV_LED: bmap = input->ledbit; limit = LED_MAX; break; } if (unlikely(c > limit || !bmap)) { pr_warn_ratelimited("%s: Invalid code %d type %d\n", input->name, c, type); *bit = NULL; return; } usage->type = type; usage->code = c; *max = limit; *bit = bmap; }
0
[ "CWE-787" ]
linux
35556bed836f8dc07ac55f69c8d17dce3e7f0e25
150,773,222,813,736,730,000,000,000,000,000,000,000
39
HID: core: Sanitize event code and type when mapping input When calling into hid_map_usage(), the passed event code is blindly stored as is, even if it doesn't fit in the associated bitmap. This event code can come from a variety of sources, including devices masquerading as input devices, only a bit more "programmable". Instead of taking the event code at face value, check that it actually fits the corresponding bitmap, and if it doesn't: - spit out a warning so that we know which device is acting up - NULLify the bitmap pointer so that we catch unexpected uses Code paths that can make use of untrusted inputs can now check that the mapping was indeed correct and bail out if not. Cc: [email protected] Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]>
static int do_register_framebuffer(struct fb_info *fb_info) { int i; struct fb_event event; struct fb_videomode mode; if (fb_check_foreignness(fb_info)) return -ENOSYS; do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id, fb_is_primary_device(fb_info)); if (num_registered_fb == FB_MAX) return -ENXIO; num_registered_fb++; for (i = 0 ; i < FB_MAX; i++) if (!registered_fb[i]) break; fb_info->node = i; atomic_set(&fb_info->count, 1); mutex_init(&fb_info->lock); mutex_init(&fb_info->mm_lock); fb_info->dev = device_create(fb_class, fb_info->device, MKDEV(FB_MAJOR, i), NULL, "fb%d", i); if (IS_ERR(fb_info->dev)) { /* Not fatal */ printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev)); fb_info->dev = NULL; } else fb_init_device(fb_info); if (fb_info->pixmap.addr == NULL) { fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL); if (fb_info->pixmap.addr) { fb_info->pixmap.size = FBPIXMAPSIZE; fb_info->pixmap.buf_align = 1; fb_info->pixmap.scan_align = 1; fb_info->pixmap.access_align = 32; fb_info->pixmap.flags = FB_PIXMAP_DEFAULT; } } fb_info->pixmap.offset = 0; if (!fb_info->pixmap.blit_x) fb_info->pixmap.blit_x = ~(u32)0; if (!fb_info->pixmap.blit_y) fb_info->pixmap.blit_y = ~(u32)0; if (!fb_info->modelist.prev || !fb_info->modelist.next) INIT_LIST_HEAD(&fb_info->modelist); fb_var_to_videomode(&mode, &fb_info->var); fb_add_videomode(&mode, &fb_info->modelist); registered_fb[i] = fb_info; event.info = fb_info; if (!lock_fb_info(fb_info)) return -ENODEV; console_lock(); fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event); console_unlock(); unlock_fb_info(fb_info); return 0; }
0
[ "CWE-703", "CWE-189" ]
linux
fc9bbca8f650e5f738af8806317c0a041a48ae4a
283,654,436,129,933,170,000,000,000,000,000,000,000
67
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]>
lt_argz_insert (char **pargz, size_t *pargz_len, char *before, const char *entry) { error_t error; /* Prior to Sep 8, 2005, newlib had a bug where argz_insert(pargz, pargz_len, NULL, entry) failed with EINVAL. */ if (before) error = argz_insert (pargz, pargz_len, before, entry); else error = argz_append (pargz, pargz_len, entry, 1 + strlen (entry)); if (error) { switch (error) { case ENOMEM: LT__SETERROR (NO_MEMORY); break; default: LT__SETERROR (UNKNOWN); break; } return 1; } return 0; }
0
[]
libtool
e91f7b960032074a55fc91273c1917e3082b5338
220,467,681,972,952,100,000,000,000,000,000,000,000
28
Don't load module.la from current directory by default. * libltdl/ltdl.c (try_dlopen): Do not attempt to load an unqualified module.la file from the current directory (by default) since doing so is insecure and is not compliant with the documentation. * tests/testsuite.at: Qualify access to module.la file in current directory so that test passes.
apr_byte_t oidc_util_request_matches_url(request_rec *r, const char *url) { apr_uri_t uri; memset(&uri, 0, sizeof(apr_uri_t)); if ((url == NULL) || (apr_uri_parse(r->pool, url, &uri) != APR_SUCCESS)) return FALSE; oidc_debug(r, "comparing \"%s\"==\"%s\"", r->parsed_uri.path, uri.path); if ((r->parsed_uri.path == NULL) || (uri.path == NULL)) return (r->parsed_uri.path == uri.path); return (apr_strnatcmp(r->parsed_uri.path, uri.path) == 0); }
0
[ "CWE-79" ]
mod_auth_openidc
55ea0a085290cd2c8cdfdd960a230cbc38ba8b56
6,239,374,488,239,038,000,000,000,000,000,000,000
10
Add a function to escape Javascript characters
expectation_create(struct conntrack *ct, ovs_be16 dst_port, const struct conn *parent_conn, bool reply, bool src_ip_wc, bool skip_nat) { union ct_addr src_addr; union ct_addr dst_addr; union ct_addr alg_nat_repl_addr; struct alg_exp_node *alg_exp_node = xzalloc(sizeof *alg_exp_node); if (reply) { src_addr = parent_conn->key.src.addr; dst_addr = parent_conn->key.dst.addr; alg_exp_node->nat_rpl_dst = true; if (skip_nat) { alg_nat_repl_addr = dst_addr; } else if (parent_conn->nat_info && parent_conn->nat_info->nat_action & NAT_ACTION_DST) { alg_nat_repl_addr = parent_conn->rev_key.src.addr; alg_exp_node->nat_rpl_dst = false; } else { alg_nat_repl_addr = parent_conn->rev_key.dst.addr; } } else { src_addr = parent_conn->rev_key.src.addr; dst_addr = parent_conn->rev_key.dst.addr; alg_exp_node->nat_rpl_dst = false; if (skip_nat) { alg_nat_repl_addr = src_addr; } else if (parent_conn->nat_info && parent_conn->nat_info->nat_action & NAT_ACTION_DST) { alg_nat_repl_addr = parent_conn->key.dst.addr; alg_exp_node->nat_rpl_dst = true; } else { alg_nat_repl_addr = parent_conn->key.src.addr; } } if (src_ip_wc) { memset(&src_addr, 0, sizeof src_addr); } alg_exp_node->key.dl_type = parent_conn->key.dl_type; alg_exp_node->key.nw_proto = parent_conn->key.nw_proto; alg_exp_node->key.zone = parent_conn->key.zone; alg_exp_node->key.src.addr = src_addr; alg_exp_node->key.dst.addr = dst_addr; alg_exp_node->key.src.port = ALG_WC_SRC_PORT; alg_exp_node->key.dst.port = dst_port; alg_exp_node->parent_mark = parent_conn->mark; alg_exp_node->parent_label = parent_conn->label; memcpy(&alg_exp_node->parent_key, &parent_conn->key, sizeof alg_exp_node->parent_key); /* Take the write lock here because it is almost 100% * likely that the lookup will fail and * expectation_create() will be called below. */ ovs_rwlock_wrlock(&ct->resources_lock); struct alg_exp_node *alg_exp = expectation_lookup( &ct->alg_expectations, &alg_exp_node->key, ct->hash_basis, src_ip_wc); if (alg_exp) { free(alg_exp_node); ovs_rwlock_unlock(&ct->resources_lock); return; } alg_exp_node->alg_nat_repl_addr = alg_nat_repl_addr; hmap_insert(&ct->alg_expectations, &alg_exp_node->node, conn_key_hash(&alg_exp_node->key, ct->hash_basis)); expectation_ref_create(&ct->alg_expectation_refs, alg_exp_node, ct->hash_basis); ovs_rwlock_unlock(&ct->resources_lock); }
0
[ "CWE-400" ]
ovs
79349cbab0b2a755140eedb91833ad2760520a83
43,766,182,641,461,380,000,000,000,000,000,000,000
70
flow: Support extra padding length. Although not required, padding can be optionally added until the packet length is MTU bytes. A packet with extra padding currently fails sanity checks. Vulnerability: CVE-2020-35498 Fixes: fa8d9001a624 ("miniflow_extract: Properly handle small IP packets.") Reported-by: Joakim Hindersson <[email protected]> Acked-by: Ilya Maximets <[email protected]> Signed-off-by: Flavio Leitner <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) { struct sk_buff *skb; struct wmi_disc_timeout_cmd *cmd; int ret; skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); if (!skb) return -ENOMEM; cmd = (struct wmi_disc_timeout_cmd *) skb->data; cmd->discon_timeout = timeout; ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID, NO_SYNC_WMIFLAG); if (ret == 0) ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); return ret; }
0
[ "CWE-125" ]
linux
5d6751eaff672ea77642e74e92e6c0ac7f9709ab
162,300,945,409,590,600,000,000,000,000,000,000,000
21
ath6kl: add some bounds checking The "ev->traffic_class" and "reply->ac" variables come from the network and they're used as an offset into the wmi->stream_exist_for_ac[] array. Those variables are u8 so they can be 0-255 but the stream_exist_for_ac[] array only has WMM_NUM_AC (4) elements. We need to add a couple bounds checks to prevent array overflows. I also modified one existing check from "if (traffic_class > 3) {" to "if (traffic_class >= WMM_NUM_AC) {" just to make them all consistent. Fixes: bdcd81707973 (" Add ath6kl cleaned up driver") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content, int content_len) { Packet *p = NULL; uint8_t *pcontent; IPV6Hdr ip6h; p = SCCalloc(1, sizeof(*p) + default_packet_size); if (unlikely(p == NULL)) return NULL; PACKET_INITIALIZE(p); gettimeofday(&p->ts, NULL); ip6h.s_ip6_nxt = 44; ip6h.s_ip6_hlim = 2; /* Source and dest address - very bogus addresses. */ ip6h.s_ip6_src[0] = 0x01010101; ip6h.s_ip6_src[1] = 0x01010101; ip6h.s_ip6_src[2] = 0x01010101; ip6h.s_ip6_src[3] = 0x01010101; ip6h.s_ip6_dst[0] = 0x02020202; ip6h.s_ip6_dst[1] = 0x02020202; ip6h.s_ip6_dst[2] = 0x02020202; ip6h.s_ip6_dst[3] = 0x02020202; /* copy content_len crap, we need full length */ PacketCopyData(p, (uint8_t *)&ip6h, sizeof(IPV6Hdr)); p->ip6h = (IPV6Hdr *)GET_PKT_DATA(p); IPV6_SET_RAW_VER(p->ip6h, 6); /* Fragmentation header. */ IPV6FragHdr *fh = (IPV6FragHdr *)(GET_PKT_DATA(p) + sizeof(IPV6Hdr)); fh->ip6fh_nxt = IPPROTO_ICMP; fh->ip6fh_ident = htonl(id); fh->ip6fh_offlg = htons((off << 3) | mf); DecodeIPV6FragHeader(p, (uint8_t *)fh, 8, 8 + content_len, 0); pcontent = SCCalloc(1, content_len); if (unlikely(pcontent == NULL)) return NULL; memset(pcontent, content, content_len); PacketCopyDataOffset(p, sizeof(IPV6Hdr) + sizeof(IPV6FragHdr), pcontent, content_len); SET_PKT_LEN(p, sizeof(IPV6Hdr) + sizeof(IPV6FragHdr) + content_len); SCFree(pcontent); p->ip6h->s_ip6_plen = htons(sizeof(IPV6FragHdr) + content_len); SET_IPV6_SRC_ADDR(p, &p->src); SET_IPV6_DST_ADDR(p, &p->dst); /* Self test. */ if (IPV6_GET_VER(p) != 6) goto error; if (IPV6_GET_NH(p) != 44) goto error; if (IPV6_GET_PLEN(p) != sizeof(IPV6FragHdr) + content_len) goto error; return p; error: fprintf(stderr, "Error building test packet.\n"); if (p != NULL) SCFree(p); return NULL; }
1
[ "CWE-358" ]
suricata
4a04f814b15762eb446a5ead4d69d021512df6f8
255,539,900,191,482,030,000,000,000,000,000,000,000
69
defrag - take protocol into account during re-assembly The IP protocol was not being used to match fragments with their packets allowing a carefully constructed packet with a different protocol to be matched, allowing re-assembly to complete, creating a packet that would not be re-assembled by the destination host.
MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob, const size_t length) { assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); image_info->blob=(void *) blob; image_info->length=length; }
0
[ "CWE-119", "CWE-787" ]
ImageMagick
aecd0ada163a4d6c769cec178955d5f3e9316f2f
230,876,689,742,614,430,000,000,000,000,000,000,000
11
Set pixel cache to undefined if any resource limit is exceeded
static void destroy_device_list(struct f2fs_sb_info *sbi) { int i; for (i = 0; i < sbi->s_ndevs; i++) { blkdev_put(FDEV(i).bdev, FMODE_EXCL); #ifdef CONFIG_BLK_DEV_ZONED kfree(FDEV(i).blkz_type); #endif } kfree(sbi->devs); }
0
[ "CWE-284" ]
linux
b9dd46188edc2f0d1f37328637860bb65a771124
316,774,313,879,423,000,000,000,000,000,000,000,000
12
f2fs: sanity check segment count F2FS uses 4 bytes to represent block address. As a result, supported size of disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments. Signed-off-by: Jin Qian <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
static int grep_sha1(struct grep_opt *opt, const unsigned char *sha1, const char *name, int tree_name_len) { unsigned long size; char *data; enum object_type type; char *to_free = NULL; int hit; data = read_sha1_file(sha1, &type, &size); if (!data) { error("'%s': unable to read %s", name, sha1_to_hex(sha1)); return 0; } if (opt->relative && opt->prefix_length) { static char name_buf[PATH_MAX]; char *cp; int name_len = strlen(name) - opt->prefix_length + 1; if (!tree_name_len) name += opt->prefix_length; else { if (ARRAY_SIZE(name_buf) <= name_len) cp = to_free = xmalloc(name_len); else cp = name_buf; memcpy(cp, name, tree_name_len); strcpy(cp + tree_name_len, name + tree_name_len + opt->prefix_length); name = cp; } } hit = grep_buffer(opt, name, data, size); free(data); free(to_free); return hit; }
0
[]
git
620e2bb93785ed8eb60846d94fd4753d4817c8ec
95,371,693,657,462,020,000,000,000,000,000,000,000
36
Fix buffer overflow in git-grep If PATH_MAX on your system is smaller than any path stored in the git repository, that can cause memory corruption inside of the grep_tree function used by git-grep. Signed-off-by: Dmitry Potapov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
pixWriteTiff(const char *filename, PIX *pix, l_int32 comptype, const char *modestr) { return pixWriteTiffCustom(filename, pix, comptype, modestr, NULL, NULL, NULL, NULL); }
0
[ "CWE-125" ]
leptonica
5ba34b1fe741d69d43a6c8cf767756997eadd87c
36,499,004,606,171,253,000,000,000,000,000,000,000
8
Issue 23654 in oss-fuzz: Heap-buffer-overflow in pixReadFromTiffStream * Increase scanline buffer for reading gray+alpha and converting to RGBA
int ext4_find_dest_de(struct inode *dir, struct inode *inode, struct buffer_head *bh, void *buf, int buf_size, const char *name, int namelen, struct ext4_dir_entry_2 **dest_de) { struct ext4_dir_entry_2 *de; unsigned short reclen = EXT4_DIR_REC_LEN(namelen); int nlen, rlen; unsigned int offset = 0; char *top; de = (struct ext4_dir_entry_2 *)buf; top = buf + buf_size - reclen; while ((char *) de <= top) { if (ext4_check_dir_entry(dir, NULL, de, bh, buf, buf_size, offset)) return -EIO; if (ext4_match(namelen, name, de)) return -EEXIST; nlen = EXT4_DIR_REC_LEN(de->name_len); rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); if ((de->inode ? rlen - nlen : rlen) >= reclen) break; de = (struct ext4_dir_entry_2 *)((char *)de + rlen); offset += rlen; } if ((char *) de > top) return -ENOSPC; *dest_de = de; return 0; }
0
[ "CWE-399" ]
linux
0e9a9a1ad619e7e987815d20262d36a2f95717ca
272,673,146,568,330,730,000,000,000,000,000,000,000
33
ext4: avoid hang when mounting non-journal filesystems with orphan list When trying to mount a file system which does not contain a journal, but which does have a orphan list containing an inode which needs to be truncated, the mount call with hang forever in ext4_orphan_cleanup() because ext4_orphan_del() will return immediately without removing the inode from the orphan list, leading to an uninterruptible loop in kernel code which will busy out one of the CPU's on the system. This can be trivially reproduced by trying to mount the file system found in tests/f_orphan_extents_inode/image.gz from the e2fsprogs source tree. If a malicious user were to put this on a USB stick, and mount it on a Linux desktop which has automatic mounts enabled, this could be considered a potential denial of service attack. (Not a big deal in practice, but professional paranoids worry about such things, and have even been known to allocate CVE numbers for such problems.) Signed-off-by: "Theodore Ts'o" <[email protected]> Reviewed-by: Zheng Liu <[email protected]> Cc: [email protected]
f_reg_executing(typval_T *argvars UNUSED, typval_T *rettv) { return_register(reg_executing, rettv); }
0
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
78,216,695,184,154,860,000,000,000,000,000,000,000
4
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer, int ctrlif) { struct usb_device *dev = mixer->chip->dev; struct usb_interface_assoc_descriptor *assoc; int badd_profile = mixer->chip->badd_profile; struct uac3_badd_profile *f; const struct usbmix_ctl_map *map; int p_chmask = 0, c_chmask = 0, st_chmask = 0; int i; assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc; /* Detect BADD capture/playback channels from AS EP descriptors */ for (i = 0; i < assoc->bInterfaceCount; i++) { int intf = assoc->bFirstInterface + i; struct usb_interface *iface; struct usb_host_interface *alts; struct usb_interface_descriptor *altsd; unsigned int maxpacksize; char dir_in; int chmask, num; if (intf == ctrlif) continue; iface = usb_ifnum_to_if(dev, intf); num = iface->num_altsetting; if (num < 2) return -EINVAL; /* * The number of Channels in an AudioStreaming interface * and the audio sample bit resolution (16 bits or 24 * bits) can be derived from the wMaxPacketSize field in * the Standard AS Audio Data Endpoint descriptor in * Alternate Setting 1 */ alts = &iface->altsetting[1]; altsd = get_iface_desc(alts); if (altsd->bNumEndpoints < 1) return -EINVAL; /* check direction */ dir_in = (get_endpoint(alts, 0)->bEndpointAddress & USB_DIR_IN); maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); switch (maxpacksize) { default: usb_audio_err(mixer->chip, "incorrect wMaxPacketSize 0x%x for BADD profile\n", maxpacksize); return -EINVAL; case UAC3_BADD_EP_MAXPSIZE_SYNC_MONO_16: case UAC3_BADD_EP_MAXPSIZE_ASYNC_MONO_16: case UAC3_BADD_EP_MAXPSIZE_SYNC_MONO_24: case UAC3_BADD_EP_MAXPSIZE_ASYNC_MONO_24: chmask = 1; break; case UAC3_BADD_EP_MAXPSIZE_SYNC_STEREO_16: case UAC3_BADD_EP_MAXPSIZE_ASYNC_STEREO_16: case UAC3_BADD_EP_MAXPSIZE_SYNC_STEREO_24: case UAC3_BADD_EP_MAXPSIZE_ASYNC_STEREO_24: chmask = 3; break; } if (dir_in) c_chmask = chmask; else p_chmask = chmask; } usb_audio_dbg(mixer->chip, "UAC3 BADD profile 0x%x: detected c_chmask=%d p_chmask=%d\n", badd_profile, c_chmask, p_chmask); /* check the mapping table */ for (map = uac3_badd_usbmix_ctl_maps; map->id; map++) { if (map->id == badd_profile) break; } if (!map->id) return -EINVAL; for (f = uac3_badd_profiles; f->name; f++) { if (badd_profile == f->subclass) break; } if (!f->name) return -EINVAL; if (!uac3_badd_func_has_valid_channels(mixer, f, c_chmask, p_chmask)) return -EINVAL; st_chmask = f->st_chmask; /* Playback */ if (p_chmask) { /* Master channel, always writable */ build_feature_ctl_badd(mixer, 0, UAC_FU_MUTE, UAC3_BADD_FU_ID2, map->map); /* Mono/Stereo volume channels, always writable */ build_feature_ctl_badd(mixer, p_chmask, UAC_FU_VOLUME, UAC3_BADD_FU_ID2, map->map); } /* Capture */ if (c_chmask) { /* Master channel, always writable */ build_feature_ctl_badd(mixer, 0, UAC_FU_MUTE, UAC3_BADD_FU_ID5, map->map); /* Mono/Stereo volume channels, always writable */ build_feature_ctl_badd(mixer, c_chmask, UAC_FU_VOLUME, UAC3_BADD_FU_ID5, map->map); } /* Side tone-mixing */ if (st_chmask) { /* Master channel, always writable */ build_feature_ctl_badd(mixer, 0, UAC_FU_MUTE, UAC3_BADD_FU_ID7, map->map); /* Mono volume channel, always writable */ build_feature_ctl_badd(mixer, 1, UAC_FU_VOLUME, UAC3_BADD_FU_ID7, map->map); } /* Insertion Control */ if (f->subclass == UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER) { struct usb_audio_term iterm, oterm; /* Input Term - Insertion control */ memset(&iterm, 0, sizeof(iterm)); iterm.id = UAC3_BADD_IT_ID4; iterm.type = UAC_BIDIR_TERMINAL_HEADSET; build_connector_control(mixer, &iterm, true); /* Output Term - Insertion control */ memset(&oterm, 0, sizeof(oterm)); oterm.id = UAC3_BADD_OT_ID3; oterm.type = UAC_BIDIR_TERMINAL_HEADSET; build_connector_control(mixer, &oterm, false); } return 0; }
0
[ "CWE-674" ]
sound
19bce474c45be69a284ecee660aa12d8f1e88f18
99,014,009,919,135,200,000,000,000,000,000,000,000
148
ALSA: usb-audio: Fix a stack buffer overflow bug in check_input_term `check_input_term` recursively calls itself with input from device side (e.g., uac_input_terminal_descriptor.bCSourceID) as argument (id). In `check_input_term`, if `check_input_term` is called with the same `id` argument as the caller, it triggers endless recursive call, resulting kernel space stack overflow. This patch fixes the bug by adding a bitmap to `struct mixer_build` to keep track of the checked ids and stop the execution if some id has been checked (similar to how parse_audio_unit handles unitid argument). Reported-by: Hui Peng <[email protected]> Reported-by: Mathias Payer <[email protected]> Signed-off-by: Hui Peng <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
int VvcSpsUnit::deserialize() { int rez = VvcUnit::deserialize(); if (rez) return rez; try { sps_id = m_reader.getBits(4); vps_id = m_reader.getBits(4); max_sublayers_minus1 = m_reader.getBits(3); if (max_sublayers_minus1 == 7) return 1; chroma_format_idc = m_reader.getBits(2); unsigned sps_log2_ctu_size_minus5 = m_reader.getBits(2); if (sps_log2_ctu_size_minus5 > 2) return 1; int CtbLog2SizeY = sps_log2_ctu_size_minus5 + 5; unsigned CtbSizeY = 1 << CtbLog2SizeY; bool sps_ptl_dpb_hrd_params_present_flag = m_reader.getBit(); if (sps_id == 0 && !sps_ptl_dpb_hrd_params_present_flag) return 1; if (sps_ptl_dpb_hrd_params_present_flag) if (profile_tier_level(1, max_sublayers_minus1) != 0) return 1; m_reader.skipBit(); // sps_gdr_enabled_flag if (m_reader.getBit()) // sps_ref_pic_resampling_enabled_flag m_reader.skipBit(); // sps_res_change_in_clvs_allowed_flag pic_width_max_in_luma_samples = extractUEGolombCode(); pic_height_max_in_luma_samples = extractUEGolombCode(); unsigned tmpWidthVal = (pic_width_max_in_luma_samples + CtbSizeY - 1) / CtbSizeY; unsigned tmpHeightVal = (pic_height_max_in_luma_samples + CtbSizeY - 1) / CtbSizeY; unsigned sps_conf_win_left_offset = 0; unsigned sps_conf_win_right_offset = 0; unsigned sps_conf_win_top_offset = 0; unsigned sps_conf_win_bottom_offset = 0; if (m_reader.getBit()) // sps_conformance_window_flag { sps_conf_win_left_offset = extractUEGolombCode(); sps_conf_win_right_offset = extractUEGolombCode(); sps_conf_win_top_offset = extractUEGolombCode(); sps_conf_win_bottom_offset = extractUEGolombCode(); } if (m_reader.getBit()) // sps_subpic_info_present_flag { unsigned sps_num_subpics_minus1 = extractUEGolombCode(); if (sps_num_subpics_minus1 > 600) return 1; if (sps_num_subpics_minus1 > 0) { bool sps_independent_subpics_flag = m_reader.getBit(); bool sps_subpic_same_size_flag = m_reader.getBit(); for (size_t i = 0; i <= sps_num_subpics_minus1; i++) { if (!sps_subpic_same_size_flag || i == 0) { if (i != 0 && pic_width_max_in_luma_samples > CtbSizeY) m_reader.skipBits(ceil(log2(tmpWidthVal))); // sps_subpic_ctu_top_left_x[i] if (i != 0 && pic_height_max_in_luma_samples > CtbSizeY) m_reader.skipBits(ceil(log2(tmpHeightVal))); // sps_subpic_ctu_top_left_y[i] if (i < sps_num_subpics_minus1 && pic_width_max_in_luma_samples > CtbSizeY) m_reader.skipBits(ceil(log2(tmpWidthVal))); // sps_subpic_width_minus1[i] if (i < sps_num_subpics_minus1 && pic_height_max_in_luma_samples > CtbSizeY) m_reader.skipBits(ceil(log2(tmpHeightVal))); // sps_subpic_height_minus1[i] } if (!sps_independent_subpics_flag) { m_reader.skipBit(); // sps_subpic_treated_as_pic_flag m_reader.skipBit(); // sps_loop_filter_across_subpic_enabled_flag } } } unsigned sps_subpic_id_len = extractUEGolombCode() + 1; if (sps_subpic_id_len > 16 || (unsigned)(1 << sps_subpic_id_len) < (sps_num_subpics_minus1 + 1)) return 1; if (m_reader.getBit()) // sps_subpic_id_mapping_explicitly_signalled_flag { if (m_reader.getBit()) // sps_subpic_id_mapping_present_flag for (size_t i = 0; i <= sps_num_subpics_minus1; i++) m_reader.skipBits(sps_subpic_id_len); // sps_subpic_id[i] } } bitdepth_minus8 = extractUEGolombCode(); if (bitdepth_minus8 > 2) return 1; int QpBdOffset = 6 * bitdepth_minus8; m_reader.skipBit(); // sps_entropy_coding_sync_enabled_flag m_reader.skipBit(); // vsps_entry_point_offsets_present_flag log2_max_pic_order_cnt_lsb = m_reader.getBits(4) + 4; if (log2_max_pic_order_cnt_lsb > 16) return 1; if (m_reader.getBit()) // sps_poc_msb_cycle_flag { if (extractUEGolombCode() /* sps_poc_msb_cycle_len_minus1 */ > 23 - log2_max_pic_order_cnt_lsb) return 1; } int sps_num_extra_ph_bytes = m_reader.getBits(2); for (size_t i = 0; i < sps_num_extra_ph_bytes; i++) m_reader.skipBits(8); // sps_extra_ph_bit_present_flag[i] int sps_num_extra_sh_bytes = m_reader.getBits(2); for (size_t i = 0; i < sps_num_extra_sh_bytes; i++) m_reader.skipBits(8); // sps_extra_sh_bit_present_flag[i] if (sps_ptl_dpb_hrd_params_present_flag) { bool sps_sublayer_dpb_params_flag = (max_sublayers_minus1 > 0) ? m_reader.getBit() : 0; if (dpb_parameters(max_sublayers_minus1, sps_sublayer_dpb_params_flag)) return 1; } unsigned sps_log2_min_luma_coding_block_size_minus2 = extractUEGolombCode(); if (sps_log2_min_luma_coding_block_size_minus2 > (unsigned)min(4, (int)sps_log2_ctu_size_minus5 + 3)) return 1; unsigned MinCbLog2SizeY = sps_log2_min_luma_coding_block_size_minus2 + 2; unsigned MinCbSizeY = 1 << MinCbLog2SizeY; m_reader.skipBit(); // sps_partition_constraints_override_enabled_flag unsigned sps_log2_diff_min_qt_min_cb_intra_slice_luma = extractUEGolombCode(); if (sps_log2_diff_min_qt_min_cb_intra_slice_luma > min(6, CtbLog2SizeY) - MinCbLog2SizeY) return 1; unsigned MinQtLog2SizeIntraY = sps_log2_diff_min_qt_min_cb_intra_slice_luma + MinCbLog2SizeY; unsigned sps_max_mtt_hierarchy_depth_intra_slice_luma = extractUEGolombCode(); if (sps_max_mtt_hierarchy_depth_intra_slice_luma > 2 * (CtbLog2SizeY - MinCbLog2SizeY)) return 1; if (sps_max_mtt_hierarchy_depth_intra_slice_luma != 0) { if (extractUEGolombCode() > CtbLog2SizeY - MinQtLog2SizeIntraY) // sps_log2_diff_max_bt_min_qt_intra_slice_luma return 1; if (extractUEGolombCode() > min(6, CtbLog2SizeY) - MinQtLog2SizeIntraY) // sps_log2_diff_max_tt_min_qt_intra_slice_luma return 1; } bool sps_qtbtt_dual_tree_intra_flag = (chroma_format_idc != 0 ? m_reader.getBit() : 0); if (sps_qtbtt_dual_tree_intra_flag) { unsigned sps_log2_diff_min_qt_min_cb_intra_slice_chroma = extractUEGolombCode(); if (sps_log2_diff_min_qt_min_cb_intra_slice_chroma > min(6, CtbLog2SizeY) - MinCbLog2SizeY) // return 1; unsigned MinQtLog2SizeIntraC = sps_log2_diff_min_qt_min_cb_intra_slice_chroma + MinCbLog2SizeY; unsigned sps_max_mtt_hierarchy_depth_intra_slice_chroma = extractUEGolombCode(); if (sps_max_mtt_hierarchy_depth_intra_slice_chroma > 2 * (CtbLog2SizeY - MinCbLog2SizeY)) return 1; if (sps_max_mtt_hierarchy_depth_intra_slice_chroma != 0) { if (extractUEGolombCode() > min(6, CtbLog2SizeY) - MinQtLog2SizeIntraC) // sps_log2_diff_max_bt_min_qt_intra_slice_chroma return 1; if (extractUEGolombCode() > min(6, CtbLog2SizeY) - MinQtLog2SizeIntraC) // sps_log2_diff_max_tt_min_qt_intra_slice_chroma return 1; } } unsigned sps_log2_diff_min_qt_min_cb_inter_slice = extractUEGolombCode(); if (sps_log2_diff_min_qt_min_cb_inter_slice > min(6, CtbLog2SizeY) - MinCbLog2SizeY) return 1; unsigned MinQtLog2SizeInterY = sps_log2_diff_min_qt_min_cb_inter_slice + MinCbLog2SizeY; unsigned sps_max_mtt_hierarchy_depth_inter_slice = extractUEGolombCode(); if (sps_max_mtt_hierarchy_depth_inter_slice > 2 * (CtbLog2SizeY - MinCbLog2SizeY)) return 1; if (sps_max_mtt_hierarchy_depth_inter_slice != 0) { if (extractUEGolombCode() > CtbLog2SizeY - MinQtLog2SizeInterY) // sps_log2_diff_max_bt_min_qt_inter_slice return 1; if (extractUEGolombCode() > min(6, CtbLog2SizeY) - MinQtLog2SizeInterY) // sps_log2_diff_max_tt_min_qt_inter_slice return 1; } bool sps_max_luma_transform_size_64_flag = (CtbSizeY > 32 ? m_reader.getBit() : 0); bool sps_transform_skip_enabled_flag = m_reader.getBit(); if (sps_transform_skip_enabled_flag) { if (extractUEGolombCode() > 3) // sps_log2_transform_skip_max_size_minus2 return 1; m_reader.skipBit(); // sps_bdpcm_enabled_flag } if (m_reader.getBit()) // sps_mts_enabled_flag { m_reader.skipBit(); // sps_explicit_mts_intra_enabled_flag m_reader.skipBit(); // sps_explicit_mts_inter_enabled_flag } bool sps_lfnst_enabled_flag = m_reader.getBit(); if (chroma_format_idc != 0) { bool sps_joint_cbcr_enabled_flag = m_reader.getBit(); int numQpTables = m_reader.getBit() /* sps_same_qp_table_for_chroma_flag */ ? 1 : (sps_joint_cbcr_enabled_flag ? 3 : 2); for (int i = 0; i < numQpTables; i++) { int sps_qp_table_start_minus26 = extractSEGolombCode(); if (sps_qp_table_start_minus26 < (-26 - QpBdOffset) || sps_qp_table_start_minus26 > 36) return 1; unsigned sps_num_points_in_qp_table_minus1 = extractUEGolombCode(); if (sps_num_points_in_qp_table_minus1 > (unsigned)(36 - sps_qp_table_start_minus26)) return 1; for (size_t j = 0; j <= sps_num_points_in_qp_table_minus1; j++) { extractUEGolombCode(); // sps_delta_qp_in_val_minus1 extractUEGolombCode(); // sps_delta_qp_diff_val } } } m_reader.skipBit(); // sps_sao_enabled_flag if (m_reader.getBit() /* sps_alf_enabled_flag */ && chroma_format_idc != 0) m_reader.skipBit(); // sps_ccalf_enabled_flag m_reader.skipBit(); // sps_lmcs_enabled_flag weighted_pred_flag = m_reader.getBit(); weighted_bipred_flag = m_reader.getBit(); long_term_ref_pics_flag = m_reader.getBit(); inter_layer_prediction_enabled_flag = (sps_id != 0) ? m_reader.getBit() : 0; m_reader.skipBit(); // sps_idr_rpl_present_flag bool sps_rpl1_same_as_rpl0_flag = m_reader.getBit(); for (size_t i = 0; i < (sps_rpl1_same_as_rpl0_flag ? 1 : 2); i++) { sps_num_ref_pic_lists = extractUEGolombCode(); if (sps_num_ref_pic_lists > 64) return 1; for (size_t j = 0; j < sps_num_ref_pic_lists; j++) ref_pic_list_struct(i, j); } m_reader.skipBit(); // sps_ref_wraparound_enabled_flag bool sps_sbtmvp_enabled_flag = (m_reader.getBit()) /* sps_temporal_mvp_enabled_flag */ ? m_reader.getBit() : 0; bool sps_amvr_enabled_flag = m_reader.getBit(); if (m_reader.getBit()) // sps_bdof_enabled_flag m_reader.skipBit(); // sps_bdof_control_present_in_ph_flag m_reader.skipBit(); // sps_smvd_enabled_flag if (m_reader.getBit()) // sps_dmvr_enabled_flag m_reader.skipBit(); // sps_dmvr_control_present_in_ph_flag if (m_reader.getBit()) // sps_mmvd_enabled_flag m_reader.skipBit(); // sps_mmvd_fullpel_only_enabled_flag unsigned sps_six_minus_max_num_merge_cand = extractUEGolombCode(); if (sps_six_minus_max_num_merge_cand > 5) return 1; unsigned MaxNumMergeCand = 6 - sps_six_minus_max_num_merge_cand; m_reader.skipBit(); // sps_sbt_enabled_flag if (m_reader.getBit()) // sps_affine_enabled_flag { unsigned sps_five_minus_max_num_subblock_merge_cand = extractUEGolombCode(); if (sps_five_minus_max_num_subblock_merge_cand + sps_sbtmvp_enabled_flag > 5) return 1; m_reader.skipBit(); // sps_6param_affine_enabled_flag if (sps_amvr_enabled_flag) m_reader.skipBit(); // sps_affine_amvr_enabled_flag if (m_reader.getBit()) // sps_affine_prof_enabled_flag m_reader.skipBit(); // sps_prof_control_present_in_ph_flag } m_reader.skipBit(); // sps_bcw_enabled_flag m_reader.skipBit(); // sps_ciip_enabled_flag if (MaxNumMergeCand >= 2) { if (m_reader.getBit() /* sps_gpm_enabled_flag */ && MaxNumMergeCand >= 3) { unsigned sps_max_num_merge_cand_minus_max_num_gpm_cand = extractUEGolombCode(); if (sps_max_num_merge_cand_minus_max_num_gpm_cand + 2 > MaxNumMergeCand) return 1; } } unsigned sps_log2_parallel_merge_level_minus2 = extractUEGolombCode(); if (sps_log2_parallel_merge_level_minus2 > CtbLog2SizeY - 2) return 1; bool sps_isp_enabled_flag = m_reader.getBit(); bool sps_mrl_enabled_flag = m_reader.getBit(); bool sps_mip_enabled_flag = m_reader.getBit(); if (chroma_format_idc != 0) bool sps_cclm_enabled_flag = m_reader.getBit(); if (chroma_format_idc == 1) { bool sps_chroma_horizontal_collocated_flag = m_reader.getBit(); bool sps_chroma_vertical_collocated_flag = m_reader.getBit(); } bool sps_palette_enabled_flag = m_reader.getBit(); bool sps_act_enabled_flag = (chroma_format_idc == 3 && !sps_max_luma_transform_size_64_flag) ? m_reader.getBit() : 0; if (sps_transform_skip_enabled_flag || sps_palette_enabled_flag) { unsigned sps_min_qp_prime_ts = extractUEGolombCode(); if (sps_min_qp_prime_ts > 8) return 1; } if (m_reader.getBit()) // sps_ibc_enabled_flag { unsigned sps_six_minus_max_num_ibc_merge_cand = extractUEGolombCode(); if (sps_six_minus_max_num_ibc_merge_cand > 5) return 1; } if (m_reader.getBit()) // sps_ladf_enabled_flag { int sps_num_ladf_intervals_minus2 = m_reader.getBits(2); int sps_ladf_lowest_interval_qp_offset = extractSEGolombCode(); for (int i = 0; i < sps_num_ladf_intervals_minus2 + 1; i++) { int sps_ladf_qp_offset = extractSEGolombCode(); unsigned sps_ladf_delta_threshold_minus1 = extractUEGolombCode(); } } bool sps_explicit_scaling_list_enabled_flag = m_reader.getBit(); if (sps_lfnst_enabled_flag && sps_explicit_scaling_list_enabled_flag) bool sps_scaling_matrix_for_lfnst_disabled_flag = m_reader.getBit(); bool sps_scaling_matrix_for_alternative_colour_space_disabled_flag = (sps_act_enabled_flag && sps_explicit_scaling_list_enabled_flag) ? m_reader.getBit() : 0; if (sps_scaling_matrix_for_alternative_colour_space_disabled_flag) bool sps_scaling_matrix_designated_colour_space_flag = m_reader.getBit(); bool sps_dep_quant_enabled_flag = m_reader.getBit(); bool sps_sign_data_hiding_enabled_flag = m_reader.getBit(); if (m_reader.getBit()) // sps_virtual_boundaries_enabled_flag { if (m_reader.getBit()) // sps_virtual_boundaries_present_flag { unsigned sps_num_ver_virtual_boundaries = extractUEGolombCode(); if (sps_num_ver_virtual_boundaries > (pic_width_max_in_luma_samples <= 8 ? 0 : 3)) return 1; for (size_t i = 0; i < sps_num_ver_virtual_boundaries; i++) { unsigned sps_virtual_boundary_pos_x_minus1 = extractUEGolombCode(); if (sps_virtual_boundary_pos_x_minus1 > ceil(pic_width_max_in_luma_samples / 8) - 2) return 1; } unsigned sps_num_hor_virtual_boundaries = extractUEGolombCode(); if (sps_num_hor_virtual_boundaries > (pic_height_max_in_luma_samples <= 8 ? 0 : 3)) return 1; for (size_t i = 0; i < sps_num_hor_virtual_boundaries; i++) { unsigned sps_virtual_boundary_pos_y_minus1 = extractUEGolombCode(); if (sps_virtual_boundary_pos_y_minus1 > ceil(pic_height_max_in_luma_samples / 8) - 2) return 1; } } } if (sps_ptl_dpb_hrd_params_present_flag) { if (m_reader.getBit()) // sps_timing_hrd_params_present_flag { if (m_sps_hrd.general_timing_hrd_parameters()) return 1; int sps_sublayer_cpb_params_present_flag = (max_sublayers_minus1 > 0) ? m_reader.getBit() : 0; int firstSubLayer = sps_sublayer_cpb_params_present_flag ? 0 : max_sublayers_minus1; m_sps_hrd.ols_timing_hrd_parameters(firstSubLayer, max_sublayers_minus1); } } bool sps_field_seq_flag = m_reader.getBit(); if (m_reader.getBit()) // sps_vui_parameters_present_flag { unsigned sps_vui_payload_size_minus1 = extractUEGolombCode(); if (sps_vui_payload_size_minus1 > 1023) return 1; m_reader.skipBits(m_reader.getBitsLeft() % 8); // sps_vui_alignment_zero_bit vui_parameters(); } bool sps_extension_flag = m_reader.getBit(); return 0; } catch (VodCoreException& e) { return NOT_ENOUGH_BUFFER; } }
0
[ "CWE-22" ]
tsMuxer
3763dd34755a8944d903aa19578fa22cd3734165
300,406,346,019,038,600,000,000,000,000,000,000,000
350
Fix Buffer Overflow Fixes issue #509.
static void SFDDumpBase(FILE *sfd,const char *keyword,struct Base *base) { int i; struct basescript *bs; struct baselangextent *bl; fprintf( sfd, "%s %d", keyword, base->baseline_cnt ); for ( i=0; i<base->baseline_cnt; ++i ) { fprintf( sfd, " '%c%c%c%c'", base->baseline_tags[i]>>24, base->baseline_tags[i]>>16, base->baseline_tags[i]>>8, base->baseline_tags[i]); } putc('\n',sfd); for ( bs=base->scripts; bs!=NULL; bs=bs->next ) { fprintf( sfd, "BaseScript: '%c%c%c%c' %d ", bs->script>>24, bs->script>>16, bs->script>>8, bs->script, bs->def_baseline ); for ( i=0; i<base->baseline_cnt; ++i ) fprintf( sfd, " %d", bs->baseline_pos[i]); for ( bl=bs->langs; bl!=NULL; bl=bl->next ) SFDDumpBaseLang(sfd,bl); putc('\n',sfd); } }
0
[ "CWE-416" ]
fontforge
048a91e2682c1a8936ae34dbc7bd70291ec05410
23,806,373,076,661,580,000,000,000,000,000,000,000
26
Fix for #4084 Use-after-free (heap) in the SFD_GetFontMetaData() function Fix for #4086 NULL pointer dereference in the SFDGetSpiros() function Fix for #4088 NULL pointer dereference in the SFD_AssignLookups() function Add empty sf->fontname string if it isn't set, fixing #4089 #4090 and many other potential issues (many downstream calls to strlen() on the value).
static unsigned short forwardLutFromBitmap( const unsigned char bitmap[BITMAP_SIZE], unsigned short lut[USHORT_RANGE]) { int k = 0; for (int i = 0; i < USHORT_RANGE; ++i) { if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7)))) lut[i] = k++; else lut[i] = 0; } return k - 1; // maximum value stored in lut[], } // i.e. number of ones in bitmap minus 1
0
[ "CWE-20", "CWE-190" ]
tinyexr
a685e3332f61cd4e59324bf3f669d36973d64270
326,044,495,954,338,300,000,000,000,000,000,000,000
13
Make line_no with too large value(2**20) invalid. Fixes #124
virDomainHostdevMatchSubsysUSB(virDomainHostdevDefPtr first, virDomainHostdevDefPtr second) { virDomainHostdevSubsysUSBPtr first_usbsrc = &first->source.subsys.u.usb; virDomainHostdevSubsysUSBPtr second_usbsrc = &second->source.subsys.u.usb; if (first_usbsrc->bus && first_usbsrc->device) { /* specified by bus location on host */ if (first_usbsrc->bus == second_usbsrc->bus && first_usbsrc->device == second_usbsrc->device) return 1; } else { /* specified by product & vendor id */ if (first_usbsrc->product == second_usbsrc->product && first_usbsrc->vendor == second_usbsrc->vendor) return 1; } return 0; }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
146,430,449,022,251,140,000,000,000,000,000,000,000
19
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
void drain_local_pages(struct zone *zone) { int cpu = smp_processor_id(); if (zone) drain_pages_zone(cpu, zone); else drain_pages(cpu); }
0
[]
linux
400e22499dd92613821374c8c6c88c7225359980
264,268,754,512,920,050,000,000,000,000,000,000,000
9
mm: don't warn about allocations which stall for too long Commit 63f53dea0c98 ("mm: warn about allocations which stall for too long") was a great step for reducing possibility of silent hang up problem caused by memory allocation stalls. But this commit reverts it, for it is possible to trigger OOM lockup and/or soft lockups when many threads concurrently called warn_alloc() (in order to warn about memory allocation stalls) due to current implementation of printk(), and it is difficult to obtain useful information due to limitation of synchronous warning approach. Current printk() implementation flushes all pending logs using the context of a thread which called console_unlock(). printk() should be able to flush all pending logs eventually unless somebody continues appending to printk() buffer. Since warn_alloc() started appending to printk() buffer while waiting for oom_kill_process() to make forward progress when oom_kill_process() is processing pending logs, it became possible for warn_alloc() to force oom_kill_process() loop inside printk(). As a result, warn_alloc() significantly increased possibility of preventing oom_kill_process() from making forward progress. ---------- Pseudo code start ---------- Before warn_alloc() was introduced: retry: if (mutex_trylock(&oom_lock)) { while (atomic_read(&printk_pending_logs) > 0) { atomic_dec(&printk_pending_logs); print_one_log(); } // Send SIGKILL here. mutex_unlock(&oom_lock) } goto retry; After warn_alloc() was introduced: retry: if (mutex_trylock(&oom_lock)) { while (atomic_read(&printk_pending_logs) > 0) { atomic_dec(&printk_pending_logs); print_one_log(); } // Send SIGKILL here. mutex_unlock(&oom_lock) } else if (waited_for_10seconds()) { atomic_inc(&printk_pending_logs); } goto retry; ---------- Pseudo code end ---------- Although waited_for_10seconds() becomes true once per 10 seconds, unbounded number of threads can call waited_for_10seconds() at the same time. Also, since threads doing waited_for_10seconds() keep doing almost busy loop, the thread doing print_one_log() can use little CPU resource. Therefore, this situation can be simplified like ---------- Pseudo code start ---------- retry: if (mutex_trylock(&oom_lock)) { while (atomic_read(&printk_pending_logs) > 0) { atomic_dec(&printk_pending_logs); print_one_log(); } // Send SIGKILL here. mutex_unlock(&oom_lock) } else { atomic_inc(&printk_pending_logs); } goto retry; ---------- Pseudo code end ---------- when printk() is called faster than print_one_log() can process a log. One of possible mitigation would be to introduce a new lock in order to make sure that no other series of printk() (either oom_kill_process() or warn_alloc()) can append to printk() buffer when one series of printk() (either oom_kill_process() or warn_alloc()) is already in progress. Such serialization will also help obtaining kernel messages in readable form. ---------- Pseudo code start ---------- retry: if (mutex_trylock(&oom_lock)) { mutex_lock(&oom_printk_lock); while (atomic_read(&printk_pending_logs) > 0) { atomic_dec(&printk_pending_logs); print_one_log(); } // Send SIGKILL here. mutex_unlock(&oom_printk_lock); mutex_unlock(&oom_lock) } else { if (mutex_trylock(&oom_printk_lock)) { atomic_inc(&printk_pending_logs); mutex_unlock(&oom_printk_lock); } } goto retry; ---------- Pseudo code end ---------- But this commit does not go that direction, for we don't want to introduce a new lock dependency, and we unlikely be able to obtain useful information even if we serialized oom_kill_process() and warn_alloc(). Synchronous approach is prone to unexpected results (e.g. too late [1], too frequent [2], overlooked [3]). As far as I know, warn_alloc() never helped with providing information other than "something is going wrong". I want to consider asynchronous approach which can obtain information during stalls with possibly relevant threads (e.g. the owner of oom_lock and kswapd-like threads) and serve as a trigger for actions (e.g. turn on/off tracepoints, ask libvirt daemon to take a memory dump of stalling KVM guest for diagnostic purpose). This commit temporarily loses ability to report e.g. OOM lockup due to unable to invoke the OOM killer due to !__GFP_FS allocation request. But asynchronous approach will be able to detect such situation and emit warning. Thus, let's remove warn_alloc(). [1] https://bugzilla.kernel.org/show_bug.cgi?id=192981 [2] http://lkml.kernel.org/r/CAM_iQpWuPVGc2ky8M-9yukECtS+zKjiDasNymX7rMcBjBFyM_A@mail.gmail.com [3] commit db73ee0d46379922 ("mm, vmscan: do not loop on too_many_isolated for ever")) Link: http://lkml.kernel.org/r/1509017339-4802-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp Signed-off-by: Tetsuo Handa <[email protected]> Reported-by: Cong Wang <[email protected]> Reported-by: yuwang.yuwang <[email protected]> Reported-by: Johannes Weiner <[email protected]> Acked-by: Michal Hocko <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void __init xen_dt_guest_init(void) { struct device_node *xen_node; struct resource res; xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); if (!xen_node) { pr_err("Xen support was detected before, but it has disappeared\n"); return; } xen_events_irq = irq_of_parse_and_map(xen_node, 0); if (of_address_to_resource(xen_node, GRANT_TABLE_INDEX, &res)) { pr_err("Xen grant table region is not found\n"); of_node_put(xen_node); return; } of_node_put(xen_node); xen_grant_frames = res.start; }
0
[]
linux
fa1f57421e0b1c57843902c89728f823abc32f02
189,213,689,019,259,600,000,000,000,000,000,000,000
21
xen/virtio: Enable restricted memory access using Xen grant mappings In order to support virtio in Xen guests add a config option XEN_VIRTIO enabling the user to specify whether in all Xen guests virtio should be able to access memory via Xen grant mappings only on the host side. Also set PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS feature from the guest initialization code on Arm and x86 if CONFIG_XEN_VIRTIO is enabled. Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Oleksandr Tyshchenko <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
gnutls_mac_algorithm_t gnutls_mac_get(gnutls_session_t session) { record_parameters_st *record_params; int ret; ret = _gnutls_epoch_get(session, EPOCH_READ_CURRENT, &record_params); if (ret < 0) return gnutls_assert_val(GNUTLS_MAC_NULL); return record_params->mac->id; }
0
[ "CWE-400" ]
gnutls
1ffb827e45721ef56982d0ffd5c5de52376c428e
64,302,936,944,316,220,000,000,000,000,000,000,000
12
handshake: set a maximum number of warning messages that can be received per handshake That is to avoid DoS due to the assymetry of cost of sending an alert vs the cost of processing.
static int nfs_probe_destination(struct nfs_server *server) { struct inode *inode = d_inode(server->super->s_root); struct nfs_fattr *fattr; int error; fattr = nfs_alloc_fattr(); if (fattr == NULL) return -ENOMEM; /* Sanity: the probe won't work if the destination server * does not recognize the migrated FH. */ error = nfs_probe_fsinfo(server, NFS_FH(inode), fattr); nfs_free_fattr(fattr); return error; }
0
[ "CWE-703" ]
linux
dd99e9f98fbf423ff6d365b37a98e8879170f17c
23,275,823,109,943,357,000,000,000,000,000,000,000
17
NFSv4: Initialise connection to the server in nfs4_alloc_client() Set up the connection to the NFSv4 server in nfs4_alloc_client(), before we've added the struct nfs_client to the net-namespace's nfs_client_list so that a downed server won't cause other mounts to hang in the trunking detection code. Reported-by: Michael Wakabayashi <[email protected]> Fixes: 5c6e5b60aae4 ("NFS: Fix an Oops in the pNFS files and flexfiles connection setup to the DS") Signed-off-by: Trond Myklebust <[email protected]>
void CL_GetPing( int n, char *buf, int buflen, int *pingtime ) { const char *str; int time; int maxPing; if (n < 0 || n >= MAX_PINGREQUESTS || !cl_pinglist[n].adr.port) { // empty or invalid slot buf[0] = '\0'; *pingtime = 0; return; } str = NET_AdrToStringwPort( cl_pinglist[n].adr ); Q_strncpyz( buf, str, buflen ); time = cl_pinglist[n].time; if (!time) { // check for timeout time = Sys_Milliseconds() - cl_pinglist[n].start; maxPing = Cvar_VariableIntegerValue( "cl_maxPing" ); if( maxPing < 100 ) { maxPing = 100; } if (time < maxPing) { // not timed out yet time = 0; } } CL_SetServerInfoByAddress(cl_pinglist[n].adr, cl_pinglist[n].info, cl_pinglist[n].time); *pingtime = time; }
0
[ "CWE-269" ]
ioq3
376267d534476a875d8b9228149c4ee18b74a4fd
306,205,956,844,260,700,000,000,000,000,000,000,000
37
Don't load .pk3s as .dlls, and don't load user config files from .pk3s.
static unsigned long getreg(struct task_struct *child, unsigned long regno) { unsigned long retval = ~0UL; switch (regno >> 2) { case GS: retval = child->thread.gs; break; case DS: case ES: case FS: case SS: case CS: retval = 0xffff; /* fall through */ default: if (regno > FS*4) regno -= 1*4; retval &= get_stack_long(child, regno); } return retval; }
0
[ "CWE-20" ]
linux-2.6
29eb51101c02df517ca64ec472d7501127ad1da8
246,602,627,489,406,920,000,000,000,000,000,000,000
23
Handle bogus %cs selector in single-step instruction decoding The code for LDT segment selectors was not robust in the face of a bogus selector set in %cs via ptrace before the single-step was done. Signed-off-by: Roland McGrath <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void qxl_set_rect_to_surface(PCIQXLDevice *qxl, QXLRect *area) { area->left = 0; area->right = qxl->guest_primary.surface.width; area->top = 0; area->bottom = qxl->guest_primary.surface.height; }
0
[]
qemu
9569f5cb5b4bffa9d3ebc8ba7da1e03830a9a895
146,752,689,822,961,880,000,000,000,000,000,000,000
7
display/qxl-render: fix race condition in qxl_cursor (CVE-2021-4207) Avoid fetching 'width' and 'height' a second time to prevent possible race condition. Refer to security advisory https://starlabs.sg/advisories/22-4207/ for more information. Fixes: CVE-2021-4207 Signed-off-by: Mauro Matteo Cascella <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
PJ_DEF(void) pjsua_msg_data_init(pjsua_msg_data *msg_data) { pj_bzero(msg_data, sizeof(*msg_data)); pj_list_init(&msg_data->hdr_list); pjsip_media_type_init(&msg_data->multipart_ctype, NULL, NULL); pj_list_init(&msg_data->multipart_parts); }
0
[ "CWE-120", "CWE-787" ]
pjproject
d27f79da11df7bc8bb56c2f291d71e54df8d2c47
148,329,329,373,198,800,000,000,000,000,000,000,000
7
Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009) * Use PJ_ASSERT_RETURN on pjsip_auth_create_digest * Use PJ_ASSERT_RETURN on pjsua_init_tpselector() * Fix incorrect check. * Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256() * Modification based on comments.
static void put_v(uint8_t *p, unsigned v) { if (v>>28) *p++ = ((v>>28)&0x7f)|0x80; if (v>>21) *p++ = ((v>>21)&0x7f)|0x80; if (v>>14) *p++ = ((v>>14)&0x7f)|0x80; if (v>>7) *p++ = ((v>>7)&0x7f)|0x80; }
0
[ "CWE-787" ]
FFmpeg
27a99e2c7d450fef15594671eef4465c8a166bd7
158,093,229,963,716,370,000,000,000,000,000,000,000
11
avformat/vividas: improve extradata packing checks in track_header() Fixes: out of array accesses Fixes: 26622/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6581200338288640 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <[email protected]>
xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xsltCompMatchPtr fromPat, double *array, int max) { int amount = 0; int cnt; xmlNodePtr ancestor; xmlNodePtr preceding; xmlXPathParserContextPtr parser; context->xpathCtxt->node = node; parser = xmlXPathNewParserContext(NULL, context->xpathCtxt); if (parser) { /* ancestor-or-self::*[count] */ for (ancestor = node; (ancestor != NULL) && (ancestor->type != XML_DOCUMENT_NODE); ancestor = xmlXPathNextAncestor(parser, ancestor)) { if ((fromPat != NULL) && xsltTestCompMatchList(context, ancestor, fromPat)) break; /* for */ if (xsltTestCompMatchCount(context, ancestor, countPat, node)) { /* count(preceding-sibling::*) */ cnt = 1; for (preceding = xmlXPathNextPrecedingSibling(parser, ancestor); preceding != NULL; preceding = xmlXPathNextPrecedingSibling(parser, preceding)) { if (xsltTestCompMatchCount(context, preceding, countPat, node)) cnt++; } array[amount++] = (double)cnt; if (amount >= max) break; /* for */ } } xmlXPathFreeParserContext(parser); } return amount; }
0
[ "CWE-119" ]
libxslt
d182d8f6ba3071503d96ce17395c9d55871f0242
328,652,105,631,601,370,000,000,000,000,000,000,000
47
Fix xsltNumberFormatGetMultipleLevel Namespace nodes are actually an xmlNs, not an xmlNode. They must be special-cased in xsltNumberFormatGetMultipleLevel to avoid an out-of-bounds heap access. Move the test whether a node matches the "count" pattern to a separate function to make the code more readable. As a side effect, we also compare expanded names when walking up the ancestor axis, fixing an insignificant bug.
static int __destroy_id(struct ucma_context *ctx) { /* * If the refcount is already 0 then ucma_close_id() has already * destroyed the cm_id, otherwise holding the refcount keeps cm_id * valid. Prevent queue_work() from being called. */ if (refcount_inc_not_zero(&ctx->ref)) { rdma_lock_handler(ctx->cm_id); ctx->destroying = 1; rdma_unlock_handler(ctx->cm_id); ucma_put_ctx(ctx); } cancel_work_sync(&ctx->close_work); /* At this point it's guaranteed that there is no inflight closing task */ if (ctx->cm_id) ucma_close_id(&ctx->close_work); return ucma_free_ctx(ctx); }
0
[ "CWE-416" ]
linux
f5449e74802c1112dea984aec8af7a33c4516af1
155,647,446,023,114,470,000,000,000,000,000,000,000
20
RDMA/ucma: Rework ucma_migrate_id() to avoid races with destroy ucma_destroy_id() assumes that all things accessing the ctx will do so via the xarray. This assumption violated only in the case the FD is being closed, then the ctx is reached via the ctx_list. Normally this is OK since ucma_destroy_id() cannot run concurrenty with release(), however with ucma_migrate_id() is involved this can violated as the close of the 2nd FD can run concurrently with destroy on the first: CPU0 CPU1 ucma_destroy_id(fda) ucma_migrate_id(fda -> fdb) ucma_get_ctx() xa_lock() _ucma_find_context() xa_erase() xa_unlock() xa_lock() ctx->file = new_file list_move() xa_unlock() ucma_put_ctx() ucma_close(fdb) _destroy_id() kfree(ctx) _destroy_id() wait_for_completion() // boom, ctx was freed The ctx->file must be modified under the handler and xa_lock, and prior to modification the ID must be rechecked that it is still reachable from cur_file, ie there is no parallel destroy or migrate. To make this work remove the double locking and streamline the control flow. The double locking was obsoleted by the handler lock now directly preventing new uevents from being created, and the ctx_list cannot be read while holding fgets on both files. Removing the double locking also removes the need to check for the same file. Fixes: 88314e4dda1e ("RDMA/cma: add support for rdma_migrate_id()") Link: https://lore.kernel.org/r/[email protected] Reported-and-tested-by: [email protected] Signed-off-by: Jason Gunthorpe <[email protected]>
NOEXPORT int load_pkcs12_file(SERVICE_OPTIONS *section) { size_t len; int i, success; BIO *bio=NULL; PKCS12 *p12=NULL; X509 *cert=NULL; STACK_OF(X509) *ca=NULL; EVP_PKEY *pkey=NULL; char pass[PEM_BUFSIZE]; s_log(LOG_INFO, "Loading certificate and private key from file: %s", section->cert); if(file_permissions(section->cert)) return 1; /* FAILED */ bio=BIO_new_file(section->cert, "rb"); if(!bio) { sslerror("BIO_new_file"); return 1; /* FAILED */ } p12=d2i_PKCS12_bio(bio, NULL); if(!p12) { sslerror("d2i_PKCS12_bio"); BIO_free(bio); return 1; /* FAILED */ } BIO_free(bio); /* try the cached value first */ set_prompt(section->cert); len=(size_t)cache_passwd_get_cb(pass, sizeof pass, 0, NULL); if(len>=sizeof pass) len=sizeof pass-1; pass[len]='\0'; /* null-terminate */ success=PKCS12_parse(p12, pass, &pkey, &cert, &ca); /* invoke the UI */ for(i=0; !success && i<3; i++) { if(!ui_retry()) break; if(i==0) { /* silence the cached attempt */ ERR_clear_error(); } else { sslerror_queue(); /* dump the error queue */ s_log(LOG_ERR, "Wrong passphrase: retrying"); } /* invoke the UI on subsequent calls */ len=(size_t)cache_passwd_set_cb(pass, sizeof pass, 0, NULL); if(len>=sizeof pass) len=sizeof pass-1; pass[len]='\0'; /* null-terminate */ success=PKCS12_parse(p12, pass, &pkey, &cert, &ca); } if(!success) { sslerror("PKCS12_parse"); PKCS12_free(p12); return 1; /* FAILED */ } PKCS12_free(p12); if(!SSL_CTX_use_certificate(section->ctx, cert)) { sslerror("SSL_CTX_use_certificate"); return 1; /* FAILED */ } if(!SSL_CTX_use_PrivateKey(section->ctx, pkey)) { sslerror("SSL_CTX_use_PrivateKey"); return 1; /* FAILED */ } s_log(LOG_INFO, "Certificate and private key loaded from file: %s", section->cert); return 0; /* OK */ }
0
[ "CWE-295" ]
stunnel
ebad9ddc4efb2635f37174c9d800d06206f1edf9
247,465,592,936,528,000,000,000,000,000,000,000,000
73
stunnel-5.57
decompileGOTOFRAME2(int n, SWF_ACTION *actions, int maxn) { int i=0; OUT_BEGIN2(SWF_ACTIONGOTOFRAME2); INDENT if (n+1 < maxn) { if (OpCode(actions, n+1, maxn) == SWFACTION_PLAY || OpCode(actions, n+1, maxn) == SWFACTION_STOP) i=1; if (OpCode(actions, n+1, maxn) == SWFACTION_PLAY) puts("gotoAndPlay("); else { if (OpCode(actions, n+1, maxn) == SWFACTION_STOP) puts("gotoAndStop("); else { if (sact->f.FlagBits.PlayFlag) puts("gotoAndPlay("); else puts("gotoAndStop("); } } } else { if (sact->f.FlagBits.PlayFlag) puts("gotoAndPlay("); else puts("gotoAndStop("); } decompilePUSHPARAM(pop(),0); println(");"); return i; }
0
[ "CWE-119", "CWE-125" ]
libming
da9d86eab55cbf608d5c916b8b690f5b76bca462
63,842,559,060,951,150,000,000,000,000,000,000,000
36
decompileAction: Prevent heap buffer overflow and underflow with using OpCode
xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, xmlParserErrors error, xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED, xmlNodePtr node, xmlSchemaTypePtr type, const char *expected, const xmlChar *value, const char *message, const xmlChar *str1, const xmlChar *str2) { xmlChar *msg = NULL; xmlSchemaFormatNodeForError(&msg, ACTXT_CAST ctxt, node); if (message == NULL) { /* * Use default messages. */ if (type != NULL) { if (node->type == XML_ATTRIBUTE_NODE) msg = xmlStrcat(msg, BAD_CAST "'%s' is not a valid value of "); else msg = xmlStrcat(msg, BAD_CAST "The character content is not a " "valid value of "); if (! xmlSchemaIsGlobalItem(type)) msg = xmlStrcat(msg, BAD_CAST "the local "); else msg = xmlStrcat(msg, BAD_CAST "the "); if (WXS_IS_ATOMIC(type)) msg = xmlStrcat(msg, BAD_CAST "atomic type"); else if (WXS_IS_LIST(type)) msg = xmlStrcat(msg, BAD_CAST "list type"); else if (WXS_IS_UNION(type)) msg = xmlStrcat(msg, BAD_CAST "union type"); if (xmlSchemaIsGlobalItem(type)) { xmlChar *str = NULL; msg = xmlStrcat(msg, BAD_CAST " '"); if (type->builtInType != 0) { msg = xmlStrcat(msg, BAD_CAST "xs:"); str = xmlStrdup(type->name); } else { const xmlChar *qName = xmlSchemaFormatQName(&str, type->targetNamespace, type->name); if (!str) str = xmlStrdup(qName); } msg = xmlStrcat(msg, xmlEscapeFormatString(&str)); msg = xmlStrcat(msg, BAD_CAST "'."); FREE_AND_NULL(str); } } else { if (node->type == XML_ATTRIBUTE_NODE) msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not valid."); else msg = xmlStrcat(msg, BAD_CAST "The character content is not " "valid."); } if (expected) { msg = xmlStrcat(msg, BAD_CAST " Expected is '"); xmlChar *expectedEscaped = xmlCharStrdup(expected); msg = xmlStrcat(msg, xmlEscapeFormatString(&expectedEscaped)); FREE_AND_NULL(expectedEscaped); msg = xmlStrcat(msg, BAD_CAST "'.\n"); } else msg = xmlStrcat(msg, BAD_CAST "\n"); if (node->type == XML_ATTRIBUTE_NODE) xmlSchemaPErr(ctxt, node, error, (const char *) msg, value, NULL); else xmlSchemaPErr(ctxt, node, error, (const char *) msg, NULL, NULL); } else { msg = xmlStrcat(msg, BAD_CAST message); msg = xmlStrcat(msg, BAD_CAST ".\n"); xmlSchemaPErrExt(ctxt, node, error, NULL, NULL, NULL, (const char*) msg, str1, str2, NULL, NULL, NULL); } /* Cleanup. */ FREE_AND_NULL(msg) }
0
[ "CWE-134" ]
libxml2
502f6a6d08b08c04b3ddfb1cd21b2f699c1b7f5b
143,048,756,502,754,260,000,000,000,000,000,000,000
79
More format string warnings with possible format string vulnerability For https://bugzilla.gnome.org/show_bug.cgi?id=761029 adds a new xmlEscapeFormatString() function to escape composed format strings
pci_serr_error(unsigned char reason, struct pt_regs *regs) { pr_emerg("NMI: PCI system error (SERR) for reason %02x on CPU %d.\n", reason, smp_processor_id()); /* * On some machines, PCI SERR line is used to report memory * errors. EDAC makes use of it. */ #if defined(CONFIG_EDAC) if (edac_handler_set()) { edac_atomic_assert_error(); return; } #endif if (panic_on_unrecovered_nmi) panic("NMI: Not continuing"); pr_emerg("Dazed and confused, but trying to continue\n"); /* Clear and disable the PCI SERR error line. */ reason = (reason & NMI_REASON_CLEAR_MASK) | NMI_REASON_CLEAR_SERR; outb(reason, NMI_REASON_PORT); }
0
[ "CWE-400" ]
linux-stable-rt
e5d4e1c3ccee18c68f23d62ba77bda26e893d4f0
300,394,328,477,200,200,000,000,000,000,000,000,000
25
x86: Do not disable preemption in int3 on 32bit Preemption must be disabled before enabling interrupts in do_trap on x86_64 because the stack in use for int3 and debug is a per CPU stack set by th IST. But 32bit does not have an IST and the stack still belongs to the current task and there is no problem in scheduling out the task. Keep preemption enabled on X86_32 when enabling interrupts for do_trap(). The name of the function is changed from preempt_conditional_sti/cli() to conditional_sti/cli_ist(), to annotate that this function is used when the stack is on the IST. Cc: [email protected] Signed-off-by: Steven Rostedt <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
const char *diff_get_color(int diff_use_color, enum color_diff ix) { if (diff_use_color) return diff_colors[ix]; return ""; }
0
[ "CWE-119" ]
git
fd55a19eb1d49ae54008d932a65f79cd6fda45c9
135,339,440,677,114,100,000,000,000,000,000,000,000
6
Fix buffer overflow in git diff If PATH_MAX on your system is smaller than a path stored, it may cause buffer overflow and stack corruption in diff_addremove() and diff_change() functions when running git-diff Signed-off-by: Dmitry Potapov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
static int cap_sem_alloc_security(struct sem_array *sma) { return 0; }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
273,509,797,238,080,200,000,000,000,000,000,000,000
4
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
static int cms_signerinfo_verify_cert(CMS_SignerInfo *si, X509_STORE *store, STACK_OF(X509) *certs, STACK_OF(X509_CRL) *crls, unsigned int flags) { X509_STORE_CTX ctx; X509 *signer; int i, j, r = 0; CMS_SignerInfo_get0_algs(si, NULL, &signer, NULL, NULL); if (!X509_STORE_CTX_init(&ctx, store, signer, certs)) { CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CERT, CMS_R_STORE_INIT_ERROR); goto err; } X509_STORE_CTX_set_default(&ctx, "smime_sign"); if (crls) X509_STORE_CTX_set0_crls(&ctx, crls); i = X509_verify_cert(&ctx); if (i <= 0) { j = X509_STORE_CTX_get_error(&ctx); CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY_CERT, CMS_R_CERTIFICATE_VERIFY_ERROR); ERR_add_error_data(2, "Verify error:", X509_verify_cert_error_string(j)); goto err; } r = 1; err: X509_STORE_CTX_cleanup(&ctx); return r; }
0
[ "CWE-399" ]
openssl
dd90a91d8771fd1ad5083fd46a2b3da16a587757
62,896,947,412,685,130,000,000,000,000,000,000,000
33
Fix infinite loop in CMS Fix loop in do_free_upto if cmsbio is NULL: this will happen when attempting to verify and a digest is not recognised. Reported by Johannes Bauer. CVE-2015-1792 Reviewed-by: Matt Caswell <[email protected]>
path_send(PG_FUNCTION_ARGS) { PATH *path = PG_GETARG_PATH_P(0); StringInfoData buf; int32 i; pq_begintypsend(&buf); pq_sendbyte(&buf, path->closed ? 1 : 0); pq_sendint(&buf, path->npts, sizeof(int32)); for (i = 0; i < path->npts; i++) { pq_sendfloat8(&buf, path->p[i].x); pq_sendfloat8(&buf, path->p[i].y); } PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); }
0
[ "CWE-703", "CWE-189" ]
postgres
31400a673325147e1205326008e32135a78b4d8a
321,848,827,214,946,200,000,000,000,000,000,000,000
16
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
int main(int argc, char ** argv) { int c; unsigned long flags = MS_MANDLOCK; char * orgoptions = NULL; char * share_name = NULL; const char * ipaddr = NULL; char * uuid = NULL; char * mountpoint = NULL; char * options = NULL; char * optionstail; char * resolved_path = NULL; char * temp; char * dev_name; int rc = 0; int rsize = 0; int wsize = 0; int nomtab = 0; int uid = 0; int gid = 0; int optlen = 0; int orgoptlen = 0; size_t options_size = 0; size_t current_len; int retry = 0; /* set when we have to retry mount with uppercase */ struct addrinfo *addrhead = NULL, *addr; struct utsname sysinfo; struct mntent mountent; struct sockaddr_in *addr4; struct sockaddr_in6 *addr6; FILE * pmntfile; /* setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); */ if(argc && argv) thisprogram = argv[0]; else mount_cifs_usage(stderr); if(thisprogram == NULL) thisprogram = "mount.cifs"; uname(&sysinfo); /* BB add workstation name and domain and pass down */ /* #ifdef _GNU_SOURCE fprintf(stderr, " node: %s machine: %s sysname %s domain %s\n", sysinfo.nodename,sysinfo.machine,sysinfo.sysname,sysinfo.domainname); #endif */ if(argc > 2) { dev_name = argv[1]; share_name = strndup(argv[1], MAX_UNC_LEN); if (share_name == NULL) { fprintf(stderr, "%s: %s", argv[0], strerror(ENOMEM)); exit(EX_SYSERR); } mountpoint = argv[2]; } else if (argc == 2) { if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) { print_cifs_mount_version(); exit(0); } if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "--help") == 0)) mount_cifs_usage(stdout); mount_cifs_usage(stderr); } else { mount_cifs_usage(stderr); } /* add sharename in opts string as unc= parm */ while ((c = getopt_long (argc, argv, "afFhilL:no:O:rsSU:vVwt:", longopts, NULL)) != -1) { switch (c) { /* No code to do the following options yet */ /* case 'l': list_with_volumelabel = 1; break; case 'L': volumelabel = optarg; break; */ /* case 'a': ++mount_all; break; */ case '?': case 'h': /* help */ mount_cifs_usage(stdout); case 'n': ++nomtab; break; case 'b': #ifdef MS_BIND flags |= MS_BIND; #else fprintf(stderr, "option 'b' (MS_BIND) not supported\n"); #endif break; case 'm': #ifdef MS_MOVE flags |= MS_MOVE; #else fprintf(stderr, "option 'm' (MS_MOVE) not supported\n"); #endif break; case 'o': orgoptions = strdup(optarg); break; case 'r': /* mount readonly */ flags |= MS_RDONLY; break; case 'U': uuid = optarg; break; case 'v': ++verboseflag; break; case 'V': print_cifs_mount_version(); exit (0); case 'w': flags &= ~MS_RDONLY; break; case 'R': rsize = atoi(optarg) ; break; case 'W': wsize = atoi(optarg); break; case '1': if (isdigit(*optarg)) { char *ep; uid = strtoul(optarg, &ep, 10); if (*ep) { fprintf(stderr, "bad uid value \"%s\"\n", optarg); exit(EX_USAGE); } } else { struct passwd *pw; if (!(pw = getpwnam(optarg))) { fprintf(stderr, "bad user name \"%s\"\n", optarg); exit(EX_USAGE); } uid = pw->pw_uid; endpwent(); } break; case '2': if (isdigit(*optarg)) { char *ep; gid = strtoul(optarg, &ep, 10); if (*ep) { fprintf(stderr, "bad gid value \"%s\"\n", optarg); exit(EX_USAGE); } } else { struct group *gr; if (!(gr = getgrnam(optarg))) { fprintf(stderr, "bad user name \"%s\"\n", optarg); exit(EX_USAGE); } gid = gr->gr_gid; endpwent(); } break; case 'u': got_user = 1; user_name = optarg; break; case 'd': domain_name = optarg; /* BB fix this - currently ignored */ got_domain = 1; break; case 'p': if(mountpassword == NULL) mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); if(mountpassword) { got_password = 1; strlcpy(mountpassword,optarg,MOUNT_PASSWD_SIZE+1); } break; case 'S': get_password_from_file(0 /* stdin */,NULL); break; case 't': break; case 'f': ++fakemnt; break; default: fprintf(stderr, "unknown mount option %c\n",c); mount_cifs_usage(stderr); } } if((argc < 3) || (dev_name == NULL) || (mountpoint == NULL)) { mount_cifs_usage(stderr); } /* make sure mountpoint is legit */ rc = chdir(mountpoint); if (rc) { fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint, strerror(errno)); rc = EX_USAGE; goto mount_exit; } rc = check_mountpoint(thisprogram, mountpoint); if (rc) goto mount_exit; /* sanity check for unprivileged mounts */ if (getuid()) { rc = check_fstab(thisprogram, mountpoint, dev_name, &orgoptions); if (rc) goto mount_exit; /* enable any default user mount flags */ flags |= CIFS_SETUID_FLAGS; } if (getenv("PASSWD")) { if(mountpassword == NULL) mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); if(mountpassword) { strlcpy(mountpassword,getenv("PASSWD"),MOUNT_PASSWD_SIZE+1); got_password = 1; } } else if (getenv("PASSWD_FD")) { get_password_from_file(atoi(getenv("PASSWD_FD")),NULL); } else if (getenv("PASSWD_FILE")) { get_password_from_file(0, getenv("PASSWD_FILE")); } if (orgoptions && parse_options(&orgoptions, &flags)) { rc = EX_USAGE; goto mount_exit; } if (getuid()) { #if !CIFS_LEGACY_SETUID_CHECK if (!(flags & (MS_USERS|MS_USER))) { fprintf(stderr, "%s: permission denied\n", thisprogram); rc = EX_USAGE; goto mount_exit; } #endif /* !CIFS_LEGACY_SETUID_CHECK */ if (geteuid()) { fprintf(stderr, "%s: not installed setuid - \"user\" " "CIFS mounts not supported.", thisprogram); rc = EX_FAIL; goto mount_exit; } } flags &= ~(MS_USERS|MS_USER); addrhead = addr = parse_server(&share_name); if((addrhead == NULL) && (got_ip == 0)) { fprintf(stderr, "No ip address specified and hostname not found\n"); rc = EX_USAGE; goto mount_exit; } /* BB save off path and pop after mount returns? */ resolved_path = (char *)malloc(PATH_MAX+1); if (!resolved_path) { fprintf(stderr, "Unable to allocate memory.\n"); rc = EX_SYSERR; goto mount_exit; } /* Note that if we can not canonicalize the name, we get another chance to see if it is valid when we chdir to it */ if(!realpath(".", resolved_path)) { fprintf(stderr, "Unable to resolve %s to canonical path: %s\n", mountpoint, strerror(errno)); rc = EX_SYSERR; goto mount_exit; } mountpoint = resolved_path; if(got_user == 0) { /* Note that the password will not be retrieved from the USER env variable (ie user%password form) as there is already a PASSWD environment varaible */ if (getenv("USER")) user_name = strdup(getenv("USER")); if (user_name == NULL) user_name = getusername(); got_user = 1; } if(got_password == 0) { char *tmp_pass = getpass("Password: "); /* BB obsolete sys call but no good replacement yet. */ mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); if (!tmp_pass || !mountpassword) { fprintf(stderr, "Password not entered, exiting\n"); exit(EX_USAGE); } strlcpy(mountpassword, tmp_pass, MOUNT_PASSWD_SIZE+1); got_password = 1; } /* FIXME launch daemon (handles dfs name resolution and credential change) remember to clear parms and overwrite password field before launching */ if(orgoptions) { optlen = strlen(orgoptions); orgoptlen = optlen; } else optlen = 0; if(share_name) optlen += strlen(share_name) + 4; else { fprintf(stderr, "No server share name specified\n"); fprintf(stderr, "\nMounting the DFS root for server not implemented yet\n"); exit(EX_USAGE); } if(user_name) optlen += strlen(user_name) + 6; optlen += MAX_ADDRESS_LEN + 4; if(mountpassword) optlen += strlen(mountpassword) + 6; mount_retry: SAFE_FREE(options); options_size = optlen + 10 + DOMAIN_SIZE; options = (char *)malloc(options_size /* space for commas in password */ + 8 /* space for domain= , domain name itself was counted as part of the length username string above */); if(options == NULL) { fprintf(stderr, "Could not allocate memory for mount options\n"); exit(EX_SYSERR); } strlcpy(options, "unc=", options_size); strlcat(options,share_name,options_size); /* scan backwards and reverse direction of slash */ temp = strrchr(options, '/'); if(temp > options + 6) *temp = '\\'; if(user_name) { /* check for syntax like user=domain\user */ if(got_domain == 0) domain_name = check_for_domain(&user_name); strlcat(options,",user=",options_size); strlcat(options,user_name,options_size); } if(retry == 0) { if(domain_name) { /* extra length accounted for in option string above */ strlcat(options,",domain=",options_size); strlcat(options,domain_name,options_size); } } strlcat(options,",ver=",options_size); strlcat(options,MOUNT_CIFS_VERSION_MAJOR,options_size); if(orgoptions) { strlcat(options,",",options_size); strlcat(options,orgoptions,options_size); } if(prefixpath) { strlcat(options,",prefixpath=",options_size); strlcat(options,prefixpath,options_size); /* no need to cat the / */ } /* convert all '\\' to '/' in share portion so that /proc/mounts looks pretty */ replace_char(dev_name, '\\', '/', strlen(share_name)); if (!got_ip && addr) { strlcat(options, ",ip=", options_size); current_len = strnlen(options, options_size); optionstail = options + current_len; switch (addr->ai_addr->sa_family) { case AF_INET6: addr6 = (struct sockaddr_in6 *) addr->ai_addr; ipaddr = inet_ntop(AF_INET6, &addr6->sin6_addr, optionstail, options_size - current_len); break; case AF_INET: addr4 = (struct sockaddr_in *) addr->ai_addr; ipaddr = inet_ntop(AF_INET, &addr4->sin_addr, optionstail, options_size - current_len); break; default: ipaddr = NULL; } /* if the address looks bogus, try the next one */ if (!ipaddr) { addr = addr->ai_next; if (addr) goto mount_retry; rc = EX_SYSERR; goto mount_exit; } } if (addr->ai_addr->sa_family == AF_INET6 && addr6->sin6_scope_id) { strlcat(options, "%", options_size); current_len = strnlen(options, options_size); optionstail = options + current_len; snprintf(optionstail, options_size - current_len, "%u", addr6->sin6_scope_id); } if(verboseflag) fprintf(stderr, "\nmount.cifs kernel mount options: %s", options); if (mountpassword) { /* * Commas have to be doubled, or else they will * look like the parameter separator */ if(retry == 0) check_for_comma(&mountpassword); strlcat(options,",pass=",options_size); strlcat(options,mountpassword,options_size); if (verboseflag) fprintf(stderr, ",pass=********"); } if (verboseflag) fprintf(stderr, "\n"); rc = check_mtab(thisprogram, dev_name, mountpoint); if (rc) goto mount_exit; if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) { switch (errno) { case ECONNREFUSED: case EHOSTUNREACH: if (addr) { addr = addr->ai_next; if (addr) goto mount_retry; } break; case ENODEV: fprintf(stderr, "mount error: cifs filesystem not supported by the system\n"); break; case ENXIO: if(retry == 0) { retry = 1; if (uppercase_string(dev_name) && uppercase_string(share_name) && uppercase_string(prefixpath)) { fprintf(stderr, "retrying with upper case share name\n"); goto mount_retry; } } } fprintf(stderr, "mount error(%d): %s\n", errno, strerror(errno)); fprintf(stderr, "Refer to the mount.cifs(8) manual page (e.g. man " "mount.cifs)\n"); rc = EX_FAIL; goto mount_exit; } if (nomtab) goto mount_exit; atexit(unlock_mtab); rc = lock_mtab(); if (rc) { fprintf(stderr, "cannot lock mtab"); goto mount_exit; } pmntfile = setmntent(MOUNTED, "a+"); if (!pmntfile) { fprintf(stderr, "could not update mount table\n"); unlock_mtab(); rc = EX_FILEIO; goto mount_exit; } mountent.mnt_fsname = dev_name; mountent.mnt_dir = mountpoint; mountent.mnt_type = (char *)(void *)cifs_fstype; mountent.mnt_opts = (char *)malloc(220); if(mountent.mnt_opts) { char * mount_user = getusername(); memset(mountent.mnt_opts,0,200); if(flags & MS_RDONLY) strlcat(mountent.mnt_opts,"ro",220); else strlcat(mountent.mnt_opts,"rw",220); if(flags & MS_MANDLOCK) strlcat(mountent.mnt_opts,",mand",220); if(flags & MS_NOEXEC) strlcat(mountent.mnt_opts,",noexec",220); if(flags & MS_NOSUID) strlcat(mountent.mnt_opts,",nosuid",220); if(flags & MS_NODEV) strlcat(mountent.mnt_opts,",nodev",220); if(flags & MS_SYNCHRONOUS) strlcat(mountent.mnt_opts,",sync",220); if(mount_user) { if(getuid() != 0) { strlcat(mountent.mnt_opts, ",user=", 220); strlcat(mountent.mnt_opts, mount_user, 220); } } } mountent.mnt_freq = 0; mountent.mnt_passno = 0; rc = addmntent(pmntfile,&mountent); endmntent(pmntfile); unlock_mtab(); SAFE_FREE(mountent.mnt_opts); if (rc) rc = EX_FILEIO; mount_exit: if(mountpassword) { int len = strlen(mountpassword); memset(mountpassword,0,len); SAFE_FREE(mountpassword); } if (addrhead) freeaddrinfo(addrhead); SAFE_FREE(options); SAFE_FREE(orgoptions); SAFE_FREE(resolved_path); SAFE_FREE(share_name); exit(rc); }
1
[ "CWE-59" ]
samba
a0c31ec1c8d1220a5884e40d9ba6b191a04a24d5
104,386,252,348,365,600,000,000,000,000,000,000,000
546
mount.cifs: don't allow it to be run as setuid root program mount.cifs has been the subject of several "security" fire drills due to distributions installing it as a setuid root program. This program has not been properly audited for security and the Samba team highly recommends that it not be installed as a setuid root program at this time. To make that abundantly clear, this patch forcibly disables the ability for mount.cifs to run as a setuid root program. People are welcome to trivially patch this out, but they do so at their own peril. A security audit and redesign of this program is in progress and we hope that we'll be able to remove this in the near future. Signed-off-by: Jeff Layton <[email protected]>
xfs_attr_shortform_create( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; struct xfs_ifork *ifp = dp->i_afp; struct xfs_attr_sf_hdr *hdr; trace_xfs_attr_sf_create(args); ASSERT(ifp->if_bytes == 0); if (ifp->if_format == XFS_DINODE_FMT_EXTENTS) { ifp->if_flags &= ~XFS_IFEXTENTS; /* just in case */ ifp->if_format = XFS_DINODE_FMT_LOCAL; ifp->if_flags |= XFS_IFINLINE; } else { ASSERT(ifp->if_flags & XFS_IFINLINE); } xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; hdr->count = 0; hdr->totsize = cpu_to_be16(sizeof(*hdr)); xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); }
0
[ "CWE-131" ]
linux
f4020438fab05364018c91f7e02ebdd192085933
107,055,482,186,086,760,000,000,000,000,000,000,000
23
xfs: fix boundary test in xfs_attr_shortform_verify The boundary test for the fixed-offset parts of xfs_attr_sf_entry in xfs_attr_shortform_verify is off by one, because the variable array at the end is defined as nameval[1] not nameval[]. Hence we need to subtract 1 from the calculation. This can be shown by: # touch file # setfattr -n root.a file and verifications will fail when it's written to disk. This only matters for a last attribute which has a single-byte name and no value, otherwise the combination of namelen & valuelen will push endp further out and this test won't fail. Fixes: 1e1bbd8e7ee06 ("xfs: create structure verifier function for shortform xattrs") Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
static int attach_child_main(void* data) { struct attach_clone_payload* payload = (struct attach_clone_payload*)data; int ipc_socket = payload->ipc_socket; int procfd = payload->procfd; lxc_attach_options_t* options = payload->options; struct lxc_proc_context_info* init_ctx = payload->init_ctx; #if HAVE_SYS_PERSONALITY_H long new_personality; #endif int ret; int status; int expected; long flags; int fd; uid_t new_uid; gid_t new_gid; /* wait for the initial thread to signal us that it's ready * for us to start initializing */ expected = 0; status = -1; ret = lxc_read_nointr_expect(ipc_socket, &status, sizeof(status), &expected); if (ret <= 0) { ERROR("error using IPC to receive notification from initial process (0)"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } /* A description of the purpose of this functionality is * provided in the lxc-attach(1) manual page. We have to * remount here and not in the parent process, otherwise * /proc may not properly reflect the new pid namespace. */ if (!(options->namespaces & CLONE_NEWNS) && (options->attach_flags & LXC_ATTACH_REMOUNT_PROC_SYS)) { ret = lxc_attach_remount_sys_proc(); if (ret < 0) { shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } } /* now perform additional attachments*/ #if HAVE_SYS_PERSONALITY_H if (options->personality < 0) new_personality = init_ctx->personality; else new_personality = options->personality; if (options->attach_flags & LXC_ATTACH_SET_PERSONALITY) { ret = personality(new_personality); if (ret < 0) { SYSERROR("could not ensure correct architecture"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } } #endif if (options->attach_flags & LXC_ATTACH_DROP_CAPABILITIES) { ret = lxc_attach_drop_privs(init_ctx); if (ret < 0) { ERROR("could not drop privileges"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } } /* always set the environment (specify (LXC_ATTACH_KEEP_ENV, NULL, NULL) if you want this to be a no-op) */ ret = lxc_attach_set_environment(options->env_policy, options->extra_env_vars, options->extra_keep_env); if (ret < 0) { ERROR("could not set initial environment for attached process"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } /* set user / group id */ new_uid = 0; new_gid = 0; /* ignore errors, we will fall back to root in that case * (/proc was not mounted etc.) */ if (options->namespaces & CLONE_NEWUSER) lxc_attach_get_init_uidgid(&new_uid, &new_gid); if (options->uid != (uid_t)-1) new_uid = options->uid; if (options->gid != (gid_t)-1) new_gid = options->gid; /* setup the control tty */ if (options->stdin_fd && isatty(options->stdin_fd)) { if (setsid() < 0) { SYSERROR("unable to setsid"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } if (ioctl(options->stdin_fd, TIOCSCTTY, (char *)NULL) < 0) { SYSERROR("unable to TIOCSTTY"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } } /* try to set the uid/gid combination */ if ((new_gid != 0 || options->namespaces & CLONE_NEWUSER)) { if (setgid(new_gid) || setgroups(0, NULL)) { SYSERROR("switching to container gid"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } } if ((new_uid != 0 || options->namespaces & CLONE_NEWUSER) && setuid(new_uid)) { SYSERROR("switching to container uid"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } /* tell initial process it may now put us into the cgroups */ status = 1; ret = lxc_write_nointr(ipc_socket, &status, sizeof(status)); if (ret != sizeof(status)) { ERROR("error using IPC to notify initial process for initialization (1)"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } /* wait for the initial thread to signal us that it has done * everything for us when it comes to cgroups etc. */ expected = 2; status = -1; ret = lxc_read_nointr_expect(ipc_socket, &status, sizeof(status), &expected); if (ret <= 0) { ERROR("error using IPC to receive final notification from initial process (2)"); shutdown(ipc_socket, SHUT_RDWR); rexit(-1); } shutdown(ipc_socket, SHUT_RDWR); close(ipc_socket); /* set new apparmor profile/selinux context */ if ((options->namespaces & CLONE_NEWNS) && (options->attach_flags & LXC_ATTACH_LSM) && init_ctx->lsm_label) { int on_exec; on_exec = options->attach_flags & LXC_ATTACH_LSM_EXEC ? 1 : 0; if (lsm_set_label_at(procfd, on_exec, init_ctx->lsm_label) < 0) { rexit(-1); } } if (init_ctx->container && init_ctx->container->lxc_conf && lxc_seccomp_load(init_ctx->container->lxc_conf) != 0) { ERROR("Loading seccomp policy"); rexit(-1); } lxc_proc_put_context_info(init_ctx); /* The following is done after the communication socket is * shut down. That way, all errors that might (though * unlikely) occur up until this point will have their messages * printed to the original stderr (if logging is so configured) * and not the fd the user supplied, if any. */ /* fd handling for stdin, stdout and stderr; * ignore errors here, user may want to make sure * the fds are closed, for example */ if (options->stdin_fd >= 0 && options->stdin_fd != 0) dup2(options->stdin_fd, 0); if (options->stdout_fd >= 0 && options->stdout_fd != 1) dup2(options->stdout_fd, 1); if (options->stderr_fd >= 0 && options->stderr_fd != 2) dup2(options->stderr_fd, 2); /* close the old fds */ if (options->stdin_fd > 2) close(options->stdin_fd); if (options->stdout_fd > 2) close(options->stdout_fd); if (options->stderr_fd > 2) close(options->stderr_fd); /* try to remove CLOEXEC flag from stdin/stdout/stderr, * but also here, ignore errors */ for (fd = 0; fd <= 2; fd++) { flags = fcntl(fd, F_GETFL); if (flags < 0) continue; if (flags & FD_CLOEXEC) { if (fcntl(fd, F_SETFL, flags & ~FD_CLOEXEC) < 0) { SYSERROR("Unable to clear CLOEXEC from fd"); } } } /* we don't need proc anymore */ close(procfd); /* we're done, so we can now do whatever the user intended us to do */ rexit(payload->exec_function(payload->exec_payload)); }
0
[ "CWE-17" ]
lxc
5c3fcae78b63ac9dd56e36075903921bd9461f9e
274,163,844,499,855,880,000,000,000,000,000,000,000
206
CVE-2015-1334: Don't use the container's /proc during attach A user could otherwise over-mount /proc and prevent the apparmor profile or selinux label from being written which combined with a modified /bin/sh or other commonly used binary would lead to unconfined code execution. Reported-by: Roman Fiedler Signed-off-by: Stéphane Graber <[email protected]>
*/ static void php_wddx_serialize_unset(wddx_packet *packet) { php_wddx_add_chunk_static(packet, WDDX_NULL);
0
[]
php-src
366f9505a4aae98ef2f4ca39a838f628a324b746
328,865,643,877,967,330,000,000,000,000,000,000,000
4
Fixed bug #70661 (Use After Free Vulnerability in WDDX Packet Deserialization) Conflicts: ext/wddx/wddx.c
static struct page *khugepaged_alloc_hugepage(void) { struct page *hpage; do { hpage = alloc_hugepage(khugepaged_defrag()); if (!hpage) { count_vm_event(THP_COLLAPSE_ALLOC_FAILED); khugepaged_alloc_sleep(); } else count_vm_event(THP_COLLAPSE_ALLOC); } while (unlikely(!hpage) && likely(khugepaged_enabled())); return hpage; }
0
[ "CWE-399" ]
linux
78f11a255749d09025f54d4e2df4fbcb031530e2
121,001,253,108,346,800,000,000,000,000,000,000,000
15
mm: thp: fix /dev/zero MAP_PRIVATE and vm_flags cleanups The huge_memory.c THP page fault was allowed to run if vm_ops was null (which would succeed for /dev/zero MAP_PRIVATE, as the f_op->mmap wouldn't setup a special vma->vm_ops and it would fallback to regular anonymous memory) but other THP logics weren't fully activated for vmas with vm_file not NULL (/dev/zero has a not NULL vma->vm_file). So this removes the vm_file checks so that /dev/zero also can safely use THP (the other albeit safer approach to fix this bug would have been to prevent the THP initial page fault to run if vm_file was set). After removing the vm_file checks, this also makes huge_memory.c stricter in khugepaged for the DEBUG_VM=y case. It doesn't replace the vm_file check with a is_pfn_mapping check (but it keeps checking for VM_PFNMAP under VM_BUG_ON) because for a is_cow_mapping() mapping VM_PFNMAP should only be allowed to exist before the first page fault, and in turn when vma->anon_vma is null (so preventing khugepaged registration). So I tend to think the previous comment saying if vm_file was set, VM_PFNMAP might have been set and we could still be registered in khugepaged (despite anon_vma was not NULL to be registered in khugepaged) was too paranoid. The is_linear_pfn_mapping check is also I think superfluous (as described by comment) but under DEBUG_VM it is safe to stay. Addresses https://bugzilla.kernel.org/show_bug.cgi?id=33682 Signed-off-by: Andrea Arcangeli <[email protected]> Reported-by: Caspar Zhang <[email protected]> Acked-by: Mel Gorman <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: <[email protected]> [2.6.38.x] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
enum dc_status dce100_add_stream_to_ctx( struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream) { enum dc_status result = DC_ERROR_UNEXPECTED; result = resource_map_pool_resources(dc, new_ctx, dc_stream); if (result == DC_OK) result = resource_map_clock_resources(dc, new_ctx, dc_stream); if (result == DC_OK) result = build_mapped_resource(dc, new_ctx, dc_stream); return result; }
0
[ "CWE-400", "CWE-401" ]
linux
104c307147ad379617472dd91a5bcb368d72bd6d
224,006,116,621,969,280,000,000,000,000,000,000,000
17
drm/amd/display: prevent memory leak In dcn*_create_resource_pool the allocated memory should be released if construct pool fails. Reviewed-by: Harry Wentland <[email protected]> Signed-off-by: Navid Emamdoost <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
static ZEND_MODULE_GLOBALS_CTOR_D(zlib) { zlib_globals->ob_gzhandler = NULL; zlib_globals->handler_registered = 0; }
0
[ "CWE-20" ]
php-src
52b93f0cfd3cba7ff98cc5198df6ca4f23865f80
7,818,234,987,187,023,000,000,000,000,000,000,000
5
Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, unsigned char *buf, size_t *olen ) { if( ssl->alpn_chosen == NULL ) { *olen = 0; return; } MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, adding alpn extension" ) ); /* * 0 . 1 ext identifier * 2 . 3 ext length * 4 . 5 protocol list length * 6 . 6 protocol name length * 7 . 7+n protocol name */ buf[0] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN >> 8 ) & 0xFF ); buf[1] = (unsigned char)( ( MBEDTLS_TLS_EXT_ALPN ) & 0xFF ); *olen = 7 + strlen( ssl->alpn_chosen ); buf[2] = (unsigned char)( ( ( *olen - 4 ) >> 8 ) & 0xFF ); buf[3] = (unsigned char)( ( ( *olen - 4 ) ) & 0xFF ); buf[4] = (unsigned char)( ( ( *olen - 6 ) >> 8 ) & 0xFF ); buf[5] = (unsigned char)( ( ( *olen - 6 ) ) & 0xFF ); buf[6] = (unsigned char)( ( ( *olen - 7 ) ) & 0xFF ); memcpy( buf + 7, ssl->alpn_chosen, *olen - 7 ); }
0
[ "CWE-20", "CWE-190" ]
mbedtls
83c9f495ffe70c7dd280b41fdfd4881485a3bc28
251,144,307,699,684,900,000,000,000,000,000,000,000
33
Prevent bounds check bypass through overflow in PSK identity parsing The check `if( *p + n > end )` in `ssl_parse_client_psk_identity` is unsafe because `*p + n` might overflow, thus bypassing the check. As `n` is a user-specified value up to 65K, this is relevant if the library happens to be located in the last 65K of virtual memory. This commit replaces the check by a safe version.
static int cmm_resume(void) { cmm_suspended = 0; cmm_kick_thread(); return 0; }
0
[]
linux
b8e51a6a9db94bc1fb18ae831b3dab106b5a4b5f
223,397,275,141,669,100,000,000,000,000,000,000,000
6
s390/cmm: fix information leak in cmm_timeout_handler() The problem is that we were putting the NUL terminator too far: buf[sizeof(buf) - 1] = '\0'; If the user input isn't NUL terminated and they haven't initialized the whole buffer then it leads to an info leak. The NUL terminator should be: buf[len - 1] = '\0'; Signed-off-by: Yihui Zeng <[email protected]> Cc: [email protected] Signed-off-by: Dan Carpenter <[email protected]> [[email protected]: keep semantics of how *lenp and *ppos are handled] Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/) { fi->seek(0, SEEK_SET); fi->readx(&ehdri, sizeof(ehdri)); assert(e_phoff == sizeof(Elf64_Ehdr)); // checked by canPack() sz_phdrs = e_phnum * get_te16(&ehdri.e_phentsize); Elf64_Phdr *phdr = phdri; note_size = 0; for (unsigned j=0; j < e_phnum; ++phdr, ++j) { if (PT_NOTE64 == get_te32(&phdr->p_type)) { note_size += up4(get_te64(&phdr->p_filesz)); } } if (note_size) { note_body = New(unsigned char, note_size); note_size = 0; } phdr = phdri; for (unsigned j=0; j < e_phnum; ++phdr, ++j) { unsigned const type = get_te32(&phdr->p_type); if (PT_NOTE64 == type) { unsigned const len = get_te64(&phdr->p_filesz); fi->seek(get_te64(&phdr->p_offset), SEEK_SET); fi->readx(&note_body[note_size], len); note_size += up4(len); } if (PT_LOAD64 == type) { unsigned x = get_te64(&phdr->p_align) >> lg2_page; while (x>>=1) { ++lg2_page; } } if (PT_GNU_STACK64 == type) { gnu_stack = phdr; } } page_size = 1u <<lg2_page; page_mask = ~0ull<<lg2_page; progid = 0; // getRandomId(); not useful, so do not clutter sz_elf_hdrs = sizeof(ehdri) + sz_phdrs; if (0!=xct_off) { // shared library sz_elf_hdrs = xct_off; lowmem.alloc(xct_off + (!opt->o_unix.android_shlib ? 0 : e_shnum * sizeof(Elf64_Shdr))); memcpy(lowmem, file_image, xct_off); // android omits Shdr here fo->write(lowmem, xct_off); // < SHF_EXECINSTR (typ: in .plt or .init) if (opt->o_unix.android_shlib) { // In order to pacify the runtime linker on Android "O" ("Oreo"), // we will splice-in a 4KiB page that contains an "extra" copy // of the Shdr, any PT_NOTE above xct_off, and shstrtab. // File order: Ehdr, Phdr[], section contents below xct_off, // Shdr_copy[], PT_NOTEs.hi, shstrtab. xct_va += asl_delta; //xct_off += asl_delta; // not yet // Relocate PT_DYNAMIC (in 2nd PT_LOAD) Elf64_Dyn *dyn = const_cast<Elf64_Dyn *>(dynseg); for (; dyn->d_tag; ++dyn) { upx_uint64_t d_tag = get_te64(&dyn->d_tag); if (Elf64_Dyn::DT_FINI == d_tag || Elf64_Dyn::DT_FINI_ARRAY == d_tag || Elf64_Dyn::DT_INIT_ARRAY == d_tag || Elf64_Dyn::DT_PREINIT_ARRAY == d_tag || Elf64_Dyn::DT_PLTGOT == d_tag) { upx_uint64_t d_val = get_te64(&dyn->d_val); set_te64(&dyn->d_val, asl_delta + d_val); } } // Relocate dynsym (DT_SYMTAB) which is below xct_va upx_uint64_t const off_dynsym = get_te64(&sec_dynsym->sh_offset); upx_uint64_t const sz_dynsym = get_te64(&sec_dynsym->sh_size); Elf64_Sym *dyntym = (Elf64_Sym *)lowmem.subref( "bad dynsym", off_dynsym, sz_dynsym); Elf64_Sym *sym = dyntym; for (int j = sz_dynsym / sizeof(Elf64_Sym); --j>=0; ++sym) { upx_uint64_t symval = get_te64(&sym->st_value); unsigned symsec = get_te16(&sym->st_shndx); if (Elf64_Sym::SHN_UNDEF != symsec && Elf64_Sym::SHN_ABS != symsec && xct_off <= symval) { set_te64(&sym->st_value, asl_delta + symval); } } // Relocate Phdr virtual addresses, but not physical offsets and sizes unsigned char buf_notes[512]; memset(buf_notes, 0, sizeof(buf_notes)); unsigned len_notes = 0; phdr = (Elf64_Phdr *)lowmem.subref( "bad e_phoff", e_phoff, e_phnum * sizeof(Elf64_Phdr)); for (unsigned j = 0; j < e_phnum; ++j, ++phdr) { upx_uint64_t offset = get_te64(&phdr->p_offset); if (xct_off <= offset) { // above the extra page if (PT_NOTE64 == get_te32(&phdr->p_type)) { upx_uint64_t memsz = get_te64(&phdr->p_memsz); if (sizeof(buf_notes) < (memsz + len_notes)) { throwCantPack("PT_NOTES too big"); } set_te64(&phdr->p_vaddr, len_notes + (e_shnum * sizeof(Elf64_Shdr)) + xct_off); phdr->p_offset = phdr->p_paddr = phdr->p_vaddr; memcpy(&buf_notes[len_notes], &file_image[offset], memsz); len_notes += memsz; } else { //set_te64(&phdr->p_offset, asl_delta + offset); // physical upx_uint64_t addr = get_te64(&phdr->p_paddr); set_te64(&phdr->p_paddr, asl_delta + addr); addr = get_te64(&phdr->p_vaddr); set_te64(&phdr->p_vaddr, asl_delta + addr); } } // .p_filesz,.p_memsz are updated in ::pack3 } Elf64_Ehdr *const ehdr = (Elf64_Ehdr *)&lowmem[0]; upx_uint64_t e_entry = get_te64(&ehdr->e_entry); if (xct_off < e_entry) { set_te64(&ehdr->e_entry, asl_delta + e_entry); } // Relocate Shdr; and Rela, Rel (below xct_off) set_te64(&ehdr->e_shoff, xct_off); memcpy(&lowmem[xct_off], shdri, e_shnum * sizeof(Elf64_Shdr)); Elf64_Shdr *const shdro = (Elf64_Shdr *)&lowmem[xct_off]; Elf64_Shdr *shdr = shdro; upx_uint64_t sz_shstrtab = get_te64(&sec_strndx->sh_size); for (unsigned j = 0; j < e_shnum; ++j, ++shdr) { unsigned sh_type = get_te32(&shdr->sh_type); upx_uint64_t sh_size = get_te64(&shdr->sh_size); upx_uint64_t sh_offset = get_te64(&shdr->sh_offset); upx_uint64_t sh_entsize = get_te64(&shdr->sh_entsize); if (xct_off <= sh_offset) { upx_uint64_t addr = get_te64(&shdr->sh_addr); set_te64(&shdr->sh_addr, asl_delta + addr); } if (Elf64_Shdr::SHT_RELA == sh_type) { if (sizeof(Elf64_Rela) != sh_entsize) { char msg[50]; snprintf(msg, sizeof(msg), "bad Rela.sh_entsize %lu", (long)sh_entsize); throwCantPack(msg); } n_jmp_slot = 0; plt_off = ~0ull; Elf64_Rela *const relb = (Elf64_Rela *)lowmem.subref( "bad Rela offset", sh_offset, sh_size); Elf64_Rela *rela = relb; for (int k = sh_size / sh_entsize; --k >= 0; ++rela) { upx_uint64_t r_addend = get_te64(&rela->r_addend); upx_uint64_t r_offset = get_te64(&rela->r_offset); upx_uint64_t r_info = get_te64(&rela->r_info); unsigned r_type = ELF64_R_TYPE(r_info); if (xct_off <= r_offset) { set_te64(&rela->r_offset, asl_delta + r_offset); } if (Elf64_Ehdr::EM_AARCH64 == e_machine) { if (R_AARCH64_RELATIVE == r_type) { if (xct_off <= r_addend) { set_te64(&rela->r_addend, asl_delta + r_addend); } } if (R_AARCH64_JUMP_SLOT == r_type) { // .rela.plt contains offset of the "first time" target if (plt_off > r_offset) { plt_off = r_offset; } upx_uint64_t d = elf_get_offset_from_address(r_offset); upx_uint64_t w = get_te64(&file_image[d]); if (xct_off <= w) { set_te64(&file_image[d], asl_delta + w); } ++n_jmp_slot; } } } fo->seek(sh_offset, SEEK_SET); fo->rewrite(relb, sh_size); } if (Elf64_Shdr::SHT_REL == sh_type) { if (sizeof(Elf64_Rel) != sh_entsize) { char msg[50]; snprintf(msg, sizeof(msg), "bad Rel.sh_entsize %lu", (long)sh_entsize); throwCantPack(msg); } Elf64_Rel *rel = (Elf64_Rel *)lowmem.subref( "bad Rel sh_offset", sh_offset, sh_size); for (int k = sh_size / sh_entsize; --k >= 0; ++rel) { upx_uint64_t r_offset = get_te64(&rel->r_offset); if (xct_off <= r_offset) { set_te64(&rel->r_offset, asl_delta + r_offset); } // r_offset must be in 2nd PT_LOAD; .p_vaddr was already relocated upx_uint64_t d = elf_get_offset_from_address(asl_delta + r_offset); upx_uint64_t w = get_te64(&file_image[d]); upx_uint64_t r_info = get_te64(&rel->r_info); unsigned r_type = ELF64_R_TYPE(r_info); if (xct_off <= w && Elf64_Ehdr::EM_AARCH64 == e_machine && ( R_AARCH64_RELATIVE == r_type || R_AARCH64_JUMP_SLOT == r_type)) { set_te64(&file_image[d], asl_delta + w); } } } if (Elf64_Shdr::SHT_NOTE == sh_type) { if (xct_off <= sh_offset) { set_te64(&shdr->sh_offset, (e_shnum * sizeof(Elf64_Shdr)) + xct_off); shdr->sh_addr = shdr->sh_offset; } } } // shstrndx will move set_te64(&shdro[get_te16(&ehdri.e_shstrndx)].sh_offset, len_notes + e_shnum * sizeof(Elf64_Shdr) + xct_off); // (Re-)write all changes below xct_off fo->seek(0, SEEK_SET); fo->rewrite(lowmem, xct_off); // New copy of Shdr Elf64_Shdr blank; memset(&blank, 0, sizeof(blank)); set_te64(&blank.sh_offset, xct_off); // hint for "upx -d" fo->write(&blank, sizeof(blank)); fo->write(&shdro[1], (-1+ e_shnum) * sizeof(Elf64_Shdr)); if (len_notes) { fo->write(buf_notes, len_notes); } // New copy of Shdr[.e_shstrndx].[ sh_offset, +.sh_size ) fo->write(shstrtab, sz_shstrtab); sz_elf_hdrs = fpad8(fo); //xct_off += asl_delta; // wait until ::pack3 } memset(&linfo, 0, sizeof(linfo)); fo->write(&linfo, sizeof(linfo)); } // only execute if option present if (opt->o_unix.preserve_build_id) { // set this so we can use elf_find_section_name e_shnum = get_te16(&ehdri.e_shnum); if (!shdri) { shdri = (Elf64_Shdr *)&file_image[get_te32(&ehdri.e_shoff)]; } //set the shstrtab sec_strndx = &shdri[get_te16(&ehdri.e_shstrndx)]; char *strtab = New(char, sec_strndx->sh_size); fi->seek(0,SEEK_SET); fi->seek(sec_strndx->sh_offset,SEEK_SET); fi->readx(strtab,sec_strndx->sh_size); shstrtab = (const char*)strtab; Elf64_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id"); if (buildid) { unsigned char *data = New(unsigned char, buildid->sh_size); memset(data,0,buildid->sh_size); fi->seek(0,SEEK_SET); fi->seek(buildid->sh_offset,SEEK_SET); fi->readx(data,buildid->sh_size); buildid_data = data; o_elf_shnum = 3; memset(&shdrout,0,sizeof(shdrout)); //setup the build-id memcpy(&shdrout.shdr[1], buildid, sizeof(shdrout.shdr[1])); shdrout.shdr[1].sh_name = 1; //setup the shstrtab memcpy(&shdrout.shdr[2], sec_strndx, sizeof(shdrout.shdr[2])); shdrout.shdr[2].sh_name = 20; shdrout.shdr[2].sh_size = 29; //size of our static shstrtab } } }
0
[ "CWE-415" ]
upx
d9288213ec156dffc435566b9d393d23e87c6914
214,348,852,675,470,200,000,000,000,000,000,000,000
284
More checking of PT_DYNAMIC and its contents. https://github.com/upx/upx/issues/206 modified: p_lx_elf.cpp
inserted_bytes(linenr_T lnum, colnr_T col, int added UNUSED) { #ifdef FEAT_PROP_POPUP if (curbuf->b_has_textprop && added != 0) adjust_prop_columns(lnum, col, added, 0); #endif changed_bytes(lnum, col); }
0
[ "CWE-120" ]
vim
7ce5b2b590256ce53d6af28c1d203fb3bc1d2d97
127,336,864,454,624,850,000,000,000,000,000,000,000
9
patch 8.2.4969: changing text in Visual mode may cause invalid memory access Problem: Changing text in Visual mode may cause invalid memory access. Solution: Check the Visual position after making a change.
MagickExport void DestroyXResources(void) { register int i; unsigned int number_windows; XWindowInfo *magick_windows[MaxXWindows]; XWindows *windows; DestroyXWidget(); windows=XSetWindows((XWindows *) ~0); if ((windows == (XWindows *) NULL) || (windows->display == (Display *) NULL)) return; number_windows=0; magick_windows[number_windows++]=(&windows->context); magick_windows[number_windows++]=(&windows->group_leader); magick_windows[number_windows++]=(&windows->backdrop); magick_windows[number_windows++]=(&windows->icon); magick_windows[number_windows++]=(&windows->image); magick_windows[number_windows++]=(&windows->info); magick_windows[number_windows++]=(&windows->magnify); magick_windows[number_windows++]=(&windows->pan); magick_windows[number_windows++]=(&windows->command); magick_windows[number_windows++]=(&windows->widget); magick_windows[number_windows++]=(&windows->popup); for (i=0; i < (int) number_windows; i++) { if (magick_windows[i]->mapped != MagickFalse) { (void) XWithdrawWindow(windows->display,magick_windows[i]->id, magick_windows[i]->screen); magick_windows[i]->mapped=MagickFalse; } if (magick_windows[i]->name != (char *) NULL) magick_windows[i]->name=(char *) RelinquishMagickMemory(magick_windows[i]->name); if (magick_windows[i]->icon_name != (char *) NULL) magick_windows[i]->icon_name=(char *) RelinquishMagickMemory(magick_windows[i]->icon_name); if (magick_windows[i]->cursor != (Cursor) NULL) { (void) XFreeCursor(windows->display,magick_windows[i]->cursor); magick_windows[i]->cursor=(Cursor) NULL; } if (magick_windows[i]->busy_cursor != (Cursor) NULL) { (void) XFreeCursor(windows->display,magick_windows[i]->busy_cursor); magick_windows[i]->busy_cursor=(Cursor) NULL; } if (magick_windows[i]->highlight_stipple != (Pixmap) NULL) { (void) XFreePixmap(windows->display, magick_windows[i]->highlight_stipple); magick_windows[i]->highlight_stipple=(Pixmap) NULL; } if (magick_windows[i]->shadow_stipple != (Pixmap) NULL) { (void) XFreePixmap(windows->display,magick_windows[i]->shadow_stipple); magick_windows[i]->shadow_stipple=(Pixmap) NULL; } if (magick_windows[i]->ximage != (XImage *) NULL) { XDestroyImage(magick_windows[i]->ximage); magick_windows[i]->ximage=(XImage *) NULL; } if (magick_windows[i]->pixmap != (Pixmap) NULL) { (void) XFreePixmap(windows->display,magick_windows[i]->pixmap); magick_windows[i]->pixmap=(Pixmap) NULL; } if (magick_windows[i]->id != (Window) NULL) { (void) XDestroyWindow(windows->display,magick_windows[i]->id); magick_windows[i]->id=(Window) NULL; } if (magick_windows[i]->destroy != MagickFalse) { if (magick_windows[i]->image != (Image *) NULL) { magick_windows[i]->image=DestroyImage(magick_windows[i]->image); magick_windows[i]->image=NewImageList(); } if (magick_windows[i]->matte_pixmap != (Pixmap) NULL) { (void) XFreePixmap(windows->display, magick_windows[i]->matte_pixmap); magick_windows[i]->matte_pixmap=(Pixmap) NULL; } } if (magick_windows[i]->segment_info != (void *) NULL) { #if defined(MAGICKCORE_HAVE_SHARED_MEMORY) XShmSegmentInfo *segment_info; segment_info=(XShmSegmentInfo *) magick_windows[i]->segment_info; if (segment_info != (XShmSegmentInfo *) NULL) if (segment_info[0].shmid >= 0) { if (segment_info[0].shmaddr != NULL) (void) shmdt(segment_info[0].shmaddr); (void) shmctl(segment_info[0].shmid,IPC_RMID,0); segment_info[0].shmaddr=NULL; segment_info[0].shmid=(-1); } #endif magick_windows[i]->segment_info=(void *) RelinquishMagickMemory( magick_windows[i]->segment_info); } } windows->icon_resources=(XResourceInfo *) RelinquishMagickMemory(windows->icon_resources); if (windows->icon_pixel != (XPixelInfo *) NULL) { if (windows->icon_pixel->pixels != (unsigned long *) NULL) windows->icon_pixel->pixels=(unsigned long *) RelinquishMagickMemory(windows->icon_pixel->pixels); if (windows->icon_pixel->annotate_context != (GC) NULL) XFreeGC(windows->display,windows->icon_pixel->annotate_context); windows->icon_pixel=(XPixelInfo *) RelinquishMagickMemory(windows->icon_pixel); } if (windows->pixel_info != (XPixelInfo *) NULL) { if (windows->pixel_info->pixels != (unsigned long *) NULL) windows->pixel_info->pixels=(unsigned long *) RelinquishMagickMemory(windows->pixel_info->pixels); if (windows->pixel_info->annotate_context != (GC) NULL) XFreeGC(windows->display,windows->pixel_info->annotate_context); if (windows->pixel_info->widget_context != (GC) NULL) XFreeGC(windows->display,windows->pixel_info->widget_context); if (windows->pixel_info->highlight_context != (GC) NULL) XFreeGC(windows->display,windows->pixel_info->highlight_context); windows->pixel_info=(XPixelInfo *) RelinquishMagickMemory(windows->pixel_info); } if (windows->font_info != (XFontStruct *) NULL) { XFreeFont(windows->display,windows->font_info); windows->font_info=(XFontStruct *) NULL; } if (windows->class_hints != (XClassHint *) NULL) { if (windows->class_hints->res_name != (char *) NULL) windows->class_hints->res_name=DestroyString( windows->class_hints->res_name); if (windows->class_hints->res_class != (char *) NULL) windows->class_hints->res_class=DestroyString( windows->class_hints->res_class); XFree(windows->class_hints); windows->class_hints=(XClassHint *) NULL; } if (windows->manager_hints != (XWMHints *) NULL) { XFree(windows->manager_hints); windows->manager_hints=(XWMHints *) NULL; } if (windows->map_info != (XStandardColormap *) NULL) { XFree(windows->map_info); windows->map_info=(XStandardColormap *) NULL; } if (windows->icon_map != (XStandardColormap *) NULL) { XFree(windows->icon_map); windows->icon_map=(XStandardColormap *) NULL; } if (windows->visual_info != (XVisualInfo *) NULL) { XFree(windows->visual_info); windows->visual_info=(XVisualInfo *) NULL; } if (windows->icon_visual != (XVisualInfo *) NULL) { XFree(windows->icon_visual); windows->icon_visual=(XVisualInfo *) NULL; } (void) XSetWindows((XWindows *) NULL); }
1
[ "CWE-401" ]
ImageMagick6
13801f5d0bd7a6fdb119682d34946636afdb2629
25,210,127,886,049,386,000,000,000,000,000,000,000
184
https://github.com/ImageMagick/ImageMagick/issues/1531
void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t& frompos, string& ret, int recurs, size_t& wirelength) { if(recurs > 100) // the forward reference-check below should make this test 100% obsolete throw MOADNSException("Loop"); int pos = frompos; // it is tempting to call reserve on ret, but it turns out it creates a malloc/free storm in the loop for(;;) { unsigned char labellen=content.at(frompos++); wirelength++; if (wirelength > 255) { throw MOADNSException("Overly long DNS name ("+lexical_cast<string>(wirelength)+")"); } if(!labellen) { if(ret.empty()) ret.append(1,'.'); break; } else if((labellen & 0xc0) == 0xc0) { uint16_t offset=256*(labellen & ~0xc0) + (unsigned int)content.at(frompos++) - sizeof(dnsheader); // cout<<"This is an offset, need to go to: "<<offset<<endl; if(offset >= pos) throw MOADNSException("forward reference during label decompression"); /* the compression pointer does not count into the wire length */ return getLabelFromContent(content, offset, ret, ++recurs, --wirelength); } else if(labellen > 63) throw MOADNSException("Overly long label during label decompression ("+lexical_cast<string>((unsigned int)labellen)+")"); else { if (wirelength + labellen > 255) { throw MOADNSException("Overly long DNS name ("+lexical_cast<string>(wirelength)+")"); } wirelength += labellen; // XXX FIXME THIS MIGHT BE VERY SLOW! for(string::size_type n = 0 ; n < labellen; ++n, frompos++) { if(content.at(frompos)=='.' || content.at(frompos)=='\\') { ret.append(1, '\\'); ret.append(1, content[frompos]); } else if(content.at(frompos)==' ') { ret+="\\032"; } else ret.append(1, content[frompos]); } ret.append(1,'.'); } if (ret.length() > 1024) throw MOADNSException("Total name too long"); } }
0
[ "CWE-399" ]
pdns
881b5b03a590198d03008e4200dd00cc537712f3
198,300,434,679,477,800,000,000,000,000,000,000,000
53
Reject qname's wirelength > 255, `chopOff()` handle dot inside labels
static void usage_free(struct snd_seq_usage *res, int num) { res->cur -= num; }
0
[ "CWE-703" ]
linux
030e2c78d3a91dd0d27fef37e91950dde333eba1
177,588,249,315,780,930,000,000,000,000,000,000,000
4
ALSA: seq: Fix missing NULL check at remove_events ioctl snd_seq_ioctl_remove_events() calls snd_seq_fifo_clear() unconditionally even if there is no FIFO assigned, and this leads to an Oops due to NULL dereference. The fix is just to add a proper NULL check. Reported-by: Dmitry Vyukov <[email protected]> Tested-by: Dmitry Vyukov <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
latin_head_off(char_u *base UNUSED, char_u *p UNUSED) { return 0; }
0
[ "CWE-122", "CWE-787" ]
vim
f6d39c31d2177549a986d170e192d8351bd571e2
305,412,509,364,112,460,000,000,000,000,000,000,000
4
patch 9.0.0220: invalid memory access with for loop over NULL string Problem: Invalid memory access with for loop over NULL string. Solution: Make sure mb_ptr2len() consistently returns zero for NUL.
TEST_P(DownstreamProtocolIntegrationTest, LargeCookieParsingConcatenated) { if (downstreamProtocol() == Http::CodecClient::Type::HTTP3) { // QUICHE Qpack splits concatenated cookies into crumbs to increase // compression ratio. On the receiver side, the total size of these crumbs // may be larger than coalesced cookie headers. Increase the max request // header size to avoid QUIC_HEADERS_TOO_LARGE stream error. config_helper_.addConfigModifier( [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& hcm) -> void { hcm.mutable_max_request_headers_kb()->set_value(96); hcm.mutable_common_http_protocol_options()->mutable_max_headers_count()->set_value(8000); }); } if (upstreamProtocol() == FakeHttpConnection::Type::HTTP3) { setMaxRequestHeadersKb(96); setMaxRequestHeadersCount(8000); } initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); Http::TestRequestHeaderMapImpl request_headers{{":method", "POST"}, {":path", "/test/long/url"}, {":scheme", "http"}, {":authority", "host"}, {"content-length", "0"}}; std::vector<std::string> cookie_pieces; cookie_pieces.reserve(7000); for (int i = 0; i < 7000; i++) { cookie_pieces.push_back(fmt::sprintf("a%x=b", i)); } request_headers.addCopy("cookie", absl::StrJoin(cookie_pieces, "; ")); auto response = sendRequestAndWaitForResponse(request_headers, 0, default_response_headers_, 0); ASSERT_TRUE(response->complete()); EXPECT_EQ("200", response->headers().getStatusValue()); }
0
[ "CWE-22" ]
envoy
5333b928d8bcffa26ab19bf018369a835f697585
99,664,663,538,591,380,000,000,000,000,000,000,000
36
Implement handling of escaped slash characters in URL path Fixes: CVE-2021-29492 Signed-off-by: Yan Avlasov <[email protected]>
int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (SSL *ssl, SSL_SESSION *sess) { return ctx->new_session_cb; }
0
[ "CWE-362" ]
openssl
939b4960276b040fc0ed52232238fcc9e2e9ec21
22,354,099,049,502,830,000,000,000,000,000,000,000
3
Fix race condition in NewSessionTicket If a NewSessionTicket is received by a multi-threaded client when attempting to reuse a previous ticket then a race condition can occur potentially leading to a double free of the ticket data. CVE-2015-1791 This also fixes RT#3808 where a session ID is changed for a session already in the client session cache. Since the session ID is the key to the cache this breaks the cache access. Parts of this patch were inspired by this Akamai change: https://github.com/akamai/openssl/commit/c0bf69a791239ceec64509f9f19fcafb2461b0d3 Reviewed-by: Rich Salz <[email protected]> (cherry picked from commit 27c76b9b8010b536687318739c6f631ce4194688) Conflicts: ssl/ssl.h ssl/ssl_err.c
static struct dentry *shmem_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { return mount_nodev(fs_type, flags, data, shmem_fill_super); }
0
[ "CWE-399" ]
linux
5f00110f7273f9ff04ac69a5f85bb535a4fd0987
30,912,872,382,599,140,000,000,000,000,000,000,000
5
tmpfs: fix use-after-free of mempolicy object The tmpfs remount logic preserves filesystem mempolicy if the mpol=M option is not specified in the remount request. A new policy can be specified if mpol=M is given. Before this patch remounting an mpol bound tmpfs without specifying mpol= mount option in the remount request would set the filesystem's mempolicy object to a freed mempolicy object. To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run: # mkdir /tmp/x # mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x # grep /tmp/x /proc/mounts nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0 # mount -o remount,size=200M nodev /tmp/x # grep /tmp/x /proc/mounts nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0 # note ? garbage in mpol=... output above # dd if=/dev/zero of=/tmp/x/f count=1 # panic here Panic: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [< (null)>] (null) [...] Oops: 0010 [#1] SMP DEBUG_PAGEALLOC Call Trace: mpol_shared_policy_init+0xa5/0x160 shmem_get_inode+0x209/0x270 shmem_mknod+0x3e/0xf0 shmem_create+0x18/0x20 vfs_create+0xb5/0x130 do_last+0x9a1/0xea0 path_openat+0xb3/0x4d0 do_filp_open+0x42/0xa0 do_sys_open+0xfe/0x1e0 compat_sys_open+0x1b/0x20 cstar_dispatch+0x7/0x1f Non-debug kernels will not crash immediately because referencing the dangling mpol will not cause a fault. Instead the filesystem will reference a freed mempolicy object, which will cause unpredictable behavior. The problem boils down to a dropped mpol reference below if shmem_parse_options() does not allocate a new mpol: config = *sbinfo shmem_parse_options(data, &config, true) mpol_put(sbinfo->mpol) sbinfo->mpol = config.mpol /* BUG: saves unreferenced mpol */ This patch avoids the crash by not releasing the mempolicy if shmem_parse_options() doesn't create a new mpol. How far back does this issue go? I see it in both 2.6.36 and 3.3. I did not look back further. Signed-off-by: Greg Thelen <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static int hidp_add_connection(struct input_device *idev) { struct hidp_connadd_req *req; sdp_record_t *rec; char src_addr[18], dst_addr[18]; char filename[PATH_MAX]; GKeyFile *key_file; char handle[11], *str; GError *gerr = NULL; int err; req = g_new0(struct hidp_connadd_req, 1); req->ctrl_sock = g_io_channel_unix_get_fd(idev->ctrl_io); req->intr_sock = g_io_channel_unix_get_fd(idev->intr_io); req->flags = 0; req->idle_to = idle_timeout; ba2str(&idev->src, src_addr); ba2str(&idev->dst, dst_addr); snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", src_addr, dst_addr); sprintf(handle, "0x%8.8X", idev->handle); key_file = g_key_file_new(); g_key_file_load_from_file(key_file, filename, 0, NULL); str = g_key_file_get_string(key_file, "ServiceRecords", handle, NULL); g_key_file_free(key_file); if (!str) { error("Rejected connection from unknown device %s", dst_addr); err = -EPERM; goto cleanup; } rec = record_from_string(str); g_free(str); err = extract_hid_record(rec, req); sdp_record_free(rec); if (err < 0) { error("Could not parse HID SDP record: %s (%d)", strerror(-err), -err); goto cleanup; } req->vendor = btd_device_get_vendor(idev->device); req->product = btd_device_get_product(idev->device); req->version = btd_device_get_version(idev->device); if (device_name_known(idev->device)) device_get_name(idev->device, req->name, sizeof(req->name)); /* Encryption is mandatory for keyboards */ if (req->subclass & 0x40) { if (!bt_io_set(idev->intr_io, &gerr, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM, BT_IO_OPT_INVALID)) { error("btio: %s", gerr->message); g_error_free(gerr); err = -EFAULT; goto cleanup; } idev->req = req; idev->sec_watch = g_io_add_watch(idev->intr_io, G_IO_OUT, encrypt_notify, idev); return 0; } if (idev->uhid) err = uhid_connadd(idev, req); else err = ioctl_connadd(req); cleanup: g_free(req->rd_data); g_free(req); return err; }
1
[]
bluez
3cccdbab2324086588df4ccf5f892fb3ce1f1787
31,892,317,915,449,616,000,000,000,000,000,000,000
82
HID accepts bonded device connections only. This change adds a configuration for platforms to choose a more secure posture for the HID profile. While some older mice are known to not support pairing or encryption, some platform may choose a more secure posture by requiring the device to be bonded and require the connection to be encrypted when bonding is required. Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00352.html
static inline void atalk_destroy_socket(struct sock *sk) { atalk_remove_socket(sk); skb_queue_purge(&sk->sk_receive_queue); if (sk_has_allocations(sk)) { timer_setup(&sk->sk_timer, atalk_destroy_timer, 0); sk->sk_timer.expires = jiffies + SOCK_DESTROY_TIME; add_timer(&sk->sk_timer); } else sock_put(sk); }
0
[ "CWE-416" ]
linux
6377f787aeb945cae7abbb6474798de129e1f3ac
287,623,509,565,206,270,000,000,000,000,000,000,000
12
appletalk: Fix use-after-free in atalk_proc_exit KASAN report this: BUG: KASAN: use-after-free in pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71 Read of size 8 at addr ffff8881f41fe5b0 by task syz-executor.0/2806 CPU: 0 PID: 2806 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xfa/0x1ce lib/dump_stack.c:113 print_address_description+0x65/0x270 mm/kasan/report.c:187 kasan_report+0x149/0x18d mm/kasan/report.c:317 pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71 remove_proc_entry+0xe8/0x420 fs/proc/generic.c:667 atalk_proc_exit+0x18/0x820 [appletalk] atalk_exit+0xf/0x5a [appletalk] __do_sys_delete_module kernel/module.c:1018 [inline] __se_sys_delete_module kernel/module.c:961 [inline] __x64_sys_delete_module+0x3dc/0x5e0 kernel/module.c:961 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x462e99 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb2de6b9c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200001c0 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fb2de6ba6bc R13: 00000000004bccaa R14: 00000000006f6bc8 R15: 00000000ffffffff Allocated by task 2806: set_track mm/kasan/common.c:85 [inline] __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:496 slab_post_alloc_hook mm/slab.h:444 [inline] slab_alloc_node mm/slub.c:2739 [inline] slab_alloc mm/slub.c:2747 [inline] kmem_cache_alloc+0xcf/0x250 mm/slub.c:2752 kmem_cache_zalloc include/linux/slab.h:730 [inline] __proc_create+0x30f/0xa20 fs/proc/generic.c:408 proc_mkdir_data+0x47/0x190 fs/proc/generic.c:469 0xffffffffc10c01bb 0xffffffffc10c0166 do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 2806: set_track mm/kasan/common.c:85 [inline] __kasan_slab_free+0x130/0x180 mm/kasan/common.c:458 slab_free_hook mm/slub.c:1409 [inline] slab_free_freelist_hook mm/slub.c:1436 [inline] slab_free mm/slub.c:2986 [inline] kmem_cache_free+0xa6/0x2a0 mm/slub.c:3002 pde_put+0x6e/0x80 fs/proc/generic.c:647 remove_proc_entry+0x1d3/0x420 fs/proc/generic.c:684 0xffffffffc10c031c 0xffffffffc10c0166 do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8881f41fe500 which belongs to the cache proc_dir_entry of size 256 The buggy address is located 176 bytes inside of 256-byte region [ffff8881f41fe500, ffff8881f41fe600) The buggy address belongs to the page: page:ffffea0007d07f80 count:1 mapcount:0 mapping:ffff8881f6e69a00 index:0x0 flags: 0x2fffc0000000200(slab) raw: 02fffc0000000200 dead000000000100 dead000000000200 ffff8881f6e69a00 raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881f41fe480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff8881f41fe500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881f41fe580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881f41fe600: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ffff8881f41fe680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb It should check the return value of atalk_proc_init fails, otherwise atalk_exit will trgger use-after-free in pde_subdir_find while unload the module.This patch fix error cleanup path of atalk_init Reported-by: Hulk Robot <[email protected]> Signed-off-by: YueHaibing <[email protected]> Signed-off-by: David S. Miller <[email protected]>
ast_for_while_stmt(struct compiling *c, const node *n) { /* while_stmt: 'while' test ':' suite ['else' ':' suite] */ REQ(n, while_stmt); int end_lineno, end_col_offset; if (NCH(n) == 4) { expr_ty expression; asdl_seq *suite_seq; expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; suite_seq = ast_for_suite(c, CHILD(n, 3)); if (!suite_seq) return NULL; get_last_end_pos(suite_seq, &end_lineno, &end_col_offset); return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, end_lineno, end_col_offset, c->c_arena); } else if (NCH(n) == 7) { expr_ty expression; asdl_seq *seq1, *seq2; expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; seq1 = ast_for_suite(c, CHILD(n, 3)); if (!seq1) return NULL; seq2 = ast_for_suite(c, CHILD(n, 6)); if (!seq2) return NULL; get_last_end_pos(seq2, &end_lineno, &end_col_offset); return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, end_lineno, end_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, "wrong number of tokens for 'while' statement: %d", NCH(n)); return NULL; }
0
[ "CWE-125" ]
cpython
a4d78362397fc3bced6ea80fbc7b5f4827aec55e
247,804,034,832,249,600,000,000,000,000,000,000,000
44
bpo-36495: Fix two out-of-bounds array reads (GH-12641) Research and fix by @bradlarsen.
TEST_F(QuantizedConv2DTest, OddPadding) { const int stride = 2; TF_ASSERT_OK(NodeDefBuilder("quantized_conv_op", "QuantizedConv2D") .Input(FakeInput(DT_QUINT8)) .Input(FakeInput(DT_QUINT8)) .Input(FakeInput(DT_FLOAT)) .Input(FakeInput(DT_FLOAT)) .Input(FakeInput(DT_FLOAT)) .Input(FakeInput(DT_FLOAT)) .Attr("out_type", DataTypeToEnum<qint32>::v()) .Attr("strides", {1, stride, stride, 1}) .Attr("padding", "SAME") .Finalize(node_def())); TF_ASSERT_OK(InitOp()); const int depth = 1; const int image_width = 4; const int image_height = 4; const int image_batch_count = 1; AddInputFromArray<quint8>( TensorShape({image_batch_count, image_height, image_width, depth}), {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); const int filter_size = 3; const int filter_count = 1; AddInputFromArray<quint8>( TensorShape({filter_size, filter_size, depth, filter_count}), {1, 2, 3, 4, 5, 6, 7, 8, 9}); AddInputFromArray<float>(TensorShape({}), {0}); AddInputFromArray<float>(TensorShape({}), {255.0f}); AddInputFromArray<float>(TensorShape({}), {0}); AddInputFromArray<float>(TensorShape({}), {255.0f}); TF_ASSERT_OK(RunOpKernel()); const int expected_width = image_width / stride; const int expected_height = (image_height * filter_count) / stride; Tensor expected(DT_QINT32, TensorShape({image_batch_count, expected_height, expected_width, filter_count})); test::FillValues<qint32>(&expected, {348, 252, 274, 175}); test::ExpectTensorEqual<qint32>(expected, *GetOutput(0)); }
0
[ "CWE-20", "CWE-476" ]
tensorflow
0f0b080ecde4d3dfec158d6f60da34d5e31693c4
274,029,129,526,022,200,000,000,000,000,000,000,000
40
Fix undefined behavior in QuantizedConv2D Added more input validation and tests. Prior to this, we could get `nullptr` exceptions when attempting to access 0th elements of 0-sized inputs, leading to security vulnerability bugs. Also needed to modify `quantized_conv_ops_test.cc` for consistency. Previously the CPU kernel did technically support passing tensors of rank larger than 0 for min/max values. However, the XLA kernels do not. PiperOrigin-RevId: 445518507
R_API RBinJavaAttrInfo *r_bin_java_deprecated_attr_new(ut8 *buffer, ut64 sz, ut64 buf_offset) { RBinJavaAttrInfo *attr = NULL; ut64 offset = 0; attr = r_bin_java_default_attr_new (buffer, sz, buf_offset); offset += 6; if (attr) { attr->type = R_BIN_JAVA_ATTR_TYPE_DEPRECATED_ATTR; attr->size = offset; } // IFDBG r_bin_java_print_deprecated_attr_summary(attr); return attr; }
0
[ "CWE-125" ]
radare2
e9ce0d64faf19fa4e9c260250fbdf25e3c11e152
237,945,183,905,237,200,000,000,000,000,000,000,000
12
Fix #10498 - Fix crash in fuzzed java files (#10511)
vrrp_vscript_fall_handler(vector_t *strvec) { vrrp_script_t *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script); unsigned fall; if (!read_unsigned_strvec(strvec, 1, &fall, 1, INT_MAX, true)) { report_config_error(CONFIG_GENERAL_ERROR, "(%s): vrrp script fall value '%s' invalid, defaulting to 1", vscript->sname, FMT_STR_VSLOT(strvec, 1)); vscript->fall = 1; } else vscript->fall = fall; }
0
[ "CWE-59", "CWE-61" ]
keepalived
04f2d32871bb3b11d7dc024039952f2fe2750306
181,426,633,070,606,200,000,000,000,000,000,000,000
12
When opening files for write, ensure they aren't symbolic links Issue #1048 identified that if, for example, a non privileged user created a symbolic link from /etc/keepalvied.data to /etc/passwd, writing to /etc/keepalived.data (which could be invoked via DBus) would cause /etc/passwd to be overwritten. This commit stops keepalived writing to pathnames where the ultimate component is a symbolic link, by setting O_NOFOLLOW whenever opening a file for writing. This might break some setups, where, for example, /etc/keepalived.data was a symbolic link to /home/fred/keepalived.data. If this was the case, instead create a symbolic link from /home/fred/keepalived.data to /tmp/keepalived.data, so that the file is still accessible via /home/fred/keepalived.data. There doesn't appear to be a way around this backward incompatibility, since even checking if the pathname is a symbolic link prior to opening for writing would create a race condition. Signed-off-by: Quentin Armitage <[email protected]>
static void tun_set_sndbuf(struct tun_struct *tun) { struct tun_file *tfile; int i; for (i = 0; i < tun->numqueues; i++) { tfile = rtnl_dereference(tun->tfiles[i]); tfile->socket.sk->sk_sndbuf = tun->sndbuf; } }
0
[ "CWE-476" ]
linux
0ad646c81b2182f7fa67ec0c8c825e0ee165696d
285,269,986,851,379,960,000,000,000,000,000,000,000
10
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]>
**/ CImg<T>& load_gif_external(const char *const filename, const char axis='z', const float align=0) { return get_load_gif_external(filename,axis,align).move_to(*this);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
294,451,533,545,417,150,000,000,000,000,000,000,000
4
Fix other issues in 'CImg<T>::load_bmp()'.
char* crypto_cert_fingerprint_by_hash(X509* xcert, const char* hash) { UINT32 fp_len, i; BYTE* fp; char* p; char* fp_buffer; fp = crypto_cert_hash(xcert, hash, &fp_len); if (!fp) return NULL; fp_buffer = calloc(fp_len * 3 + 1, sizeof(char)); if (!fp_buffer) goto fail; p = fp_buffer; for (i = 0; i < (fp_len - 1); i++) { sprintf_s(p, (fp_len - i) * 3, "%02" PRIx8 ":", fp[i]); p = &fp_buffer[(i + 1) * 3]; } sprintf_s(p, (fp_len - i) * 3, "%02" PRIx8 "", fp[i]); fail: free(fp); return fp_buffer; }
0
[ "CWE-787" ]
FreeRDP
8305349a943c68b1bc8c158f431dc607655aadea
137,722,397,787,957,960,000,000,000,000,000,000,000
29
Fixed GHSL-2020-102 heap overflow (cherry picked from commit 197b16cc15a12813c2e4fa2d6ae9cd9c4a57e581)
rb_enc_strlen_cr(const char *p, const char *e, rb_encoding *enc, int *cr) { long c; const char *q; int ret; *cr = 0; if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) { return (e - p + rb_enc_mbminlen(enc) - 1) / rb_enc_mbminlen(enc); } else if (rb_enc_asciicompat(enc)) { c = 0; while (p < e) { if (ISASCII(*p)) { q = search_nonascii(p, e); if (!q) { if (!*cr) *cr = ENC_CODERANGE_7BIT; return c + (e - p); } c += q - p; p = q; } ret = rb_enc_precise_mbclen(p, e, enc); if (MBCLEN_CHARFOUND_P(ret)) { *cr |= ENC_CODERANGE_VALID; p += MBCLEN_CHARFOUND_LEN(ret); } else { *cr = ENC_CODERANGE_BROKEN; p++; } c++; } if (!*cr) *cr = ENC_CODERANGE_7BIT; return c; } for (c=0; p<e; c++) { ret = rb_enc_precise_mbclen(p, e, enc); if (MBCLEN_CHARFOUND_P(ret)) { *cr |= ENC_CODERANGE_VALID; p += MBCLEN_CHARFOUND_LEN(ret); } else { *cr = ENC_CODERANGE_BROKEN; p++; } } if (!*cr) *cr = ENC_CODERANGE_7BIT; return c; }
0
[ "CWE-119" ]
ruby
1c2ef610358af33f9ded3086aa2d70aac03dcac5
145,644,860,643,187,730,000,000,000,000,000,000,000
51
* string.c (rb_str_justify): CVE-2009-4124. Fixes a bug reported by Emmanouel Kellinis <Emmanouel.Kellinis AT kpmg.co.uk>, KPMG London; Patch by nobu. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
gxps_images_create_from_png (GXPSArchive *zip, const gchar *image_uri, GError **error) { #ifdef HAVE_LIBPNG GInputStream *stream; GXPSImage *image = NULL; char *png_err_msg = NULL; png_struct *png; png_info *info; png_byte *data = NULL; png_byte **row_pointers = NULL; png_uint_32 png_width, png_height; int depth, color_type, interlace, stride; unsigned int i; cairo_format_t format; cairo_status_t status; stream = gxps_archive_open (zip, image_uri); if (!stream) { g_set_error (error, GXPS_ERROR, GXPS_ERROR_SOURCE_NOT_FOUND, "Image source %s not found in archive", image_uri); return NULL; } png = png_create_read_struct (PNG_LIBPNG_VER_STRING, &png_err_msg, png_error_callback, png_warning_callback); if (png == NULL) { fill_png_error (error, image_uri, NULL); g_object_unref (stream); return NULL; } info = png_create_info_struct (png); if (info == NULL) { fill_png_error (error, image_uri, NULL); g_object_unref (stream); png_destroy_read_struct (&png, NULL, NULL); return NULL; } png_set_read_fn (png, stream, _read_png); if (setjmp (png_jmpbuf (png))) { fill_png_error (error, image_uri, png_err_msg); g_free (png_err_msg); g_object_unref (stream); png_destroy_read_struct (&png, &info, NULL); gxps_image_free (image); g_free (row_pointers); g_free (data); return NULL; } png_read_info (png, info); png_get_IHDR (png, info, &png_width, &png_height, &depth, &color_type, &interlace, NULL, NULL); /* convert palette/gray image to rgb */ if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb (png); /* expand gray bit depth if needed */ if (color_type == PNG_COLOR_TYPE_GRAY) png_set_expand_gray_1_2_4_to_8 (png); /* transform transparency to alpha */ if (png_get_valid (png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha (png); if (depth == 16) png_set_strip_16 (png); if (depth < 8) png_set_packing (png); /* convert grayscale to RGB */ if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb (png); if (interlace != PNG_INTERLACE_NONE) png_set_interlace_handling (png); png_set_filler (png, 0xff, PNG_FILLER_AFTER); /* recheck header after setting EXPAND options */ png_read_update_info (png, info); png_get_IHDR (png, info, &png_width, &png_height, &depth, &color_type, &interlace, NULL, NULL); if (depth != 8 || !(color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA)) { fill_png_error (error, image_uri, NULL); g_object_unref (stream); png_destroy_read_struct (&png, &info, NULL); return NULL; } switch (color_type) { default: g_assert_not_reached(); /* fall-through just in case ;-) */ case PNG_COLOR_TYPE_RGB_ALPHA: format = CAIRO_FORMAT_ARGB32; png_set_read_user_transform_fn (png, premultiply_data); break; case PNG_COLOR_TYPE_RGB: format = CAIRO_FORMAT_RGB24; png_set_read_user_transform_fn (png, convert_bytes_to_data); break; } stride = cairo_format_stride_for_width (format, png_width); if (stride < 0) { fill_png_error (error, image_uri, NULL); g_object_unref (stream); png_destroy_read_struct (&png, &info, NULL); return NULL; } image = g_slice_new0 (GXPSImage); image->res_x = png_get_x_pixels_per_meter (png, info) * METERS_PER_INCH; if (image->res_x == 0) image->res_x = 96; image->res_y = png_get_y_pixels_per_meter (png, info) * METERS_PER_INCH; if (image->res_y == 0) image->res_y = 96; data = g_malloc (png_height * stride); row_pointers = g_new (png_byte *, png_height); for (i = 0; i < png_height; i++) row_pointers[i] = &data[i * stride]; png_read_image (png, row_pointers); png_read_end (png, info); png_destroy_read_struct (&png, &info, NULL); g_object_unref (stream); g_free (row_pointers); image->surface = cairo_image_surface_create_for_data (data, format, png_width, png_height, stride); if (cairo_surface_status (image->surface)) { fill_png_error (error, image_uri, NULL); gxps_image_free (image); g_free (data); return NULL; } status = cairo_surface_set_user_data (image->surface, &image_data_cairo_key, data, (cairo_destroy_func_t) g_free); if (status) { fill_png_error (error, image_uri, NULL); gxps_image_free (image); g_free (data); return NULL; } return image; #else return NULL; #endif /* HAVE_LIBPNG */ }
1
[]
libgxps
123dd99c6a1ae2ef6fcb5547e51fa58e8c954b51
205,045,707,066,746,700,000,000,000,000,000,000,000
177
gxps-images: fix integer overflow in png decoder
static int dvb_usbv2_i2c_init(struct dvb_usb_device *d) { int ret; dev_dbg(&d->udev->dev, "%s:\n", __func__); if (!d->props->i2c_algo) return 0; strlcpy(d->i2c_adap.name, d->name, sizeof(d->i2c_adap.name)); d->i2c_adap.algo = d->props->i2c_algo; d->i2c_adap.dev.parent = &d->udev->dev; i2c_set_adapdata(&d->i2c_adap, d); ret = i2c_add_adapter(&d->i2c_adap); if (ret < 0) { d->i2c_adap.algo = NULL; goto err; } return 0; err: dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); return ret; }
0
[ "CWE-119", "CWE-787" ]
linux
005145378c9ad7575a01b6ce1ba118fb427f583a
288,642,451,742,466,500,000,000,000,000,000,000,000
24
[media] dvb-usb-v2: avoid use-after-free I ran into a stack frame size warning because of the on-stack copy of the USB device structure: drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_disconnect': drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:1029:1: error: the frame size of 1104 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Copying a device structure like this is wrong for a number of other reasons too aside from the possible stack overflow. One of them is that the dev_info() call will print the name of the device later, but AFAICT we have only copied a pointer to the name earlier and the actual name has been freed by the time it gets printed. This removes the on-stack copy of the device and instead copies the device name using kstrdup(). I'm ignoring the possible failure here as both printk() and kfree() are able to deal with NULL pointers. Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
unsigned long zslGetRank(zskiplist *zsl, double score, sds ele) { zskiplistNode *x; unsigned long rank = 0; int i; x = zsl->header; for (i = zsl->level-1; i >= 0; i--) { while (x->level[i].forward && (x->level[i].forward->score < score || (x->level[i].forward->score == score && sdscmp(x->level[i].forward->ele,ele) <= 0))) { rank += x->level[i].span; x = x->level[i].forward; } /* x might be equal to zsl->header, so test if obj is non-NULL */ if (x->ele && sdscmp(x->ele,ele) == 0) { return rank; } } return 0; }
0
[ "CWE-190" ]
redis
f6a40570fa63d5afdd596c78083d754081d80ae3
250,411,358,202,966,700,000,000,000,000,000,000,000
22
Fix ziplist and listpack overflows and truncations (CVE-2021-32627, CVE-2021-32628) - fix possible heap corruption in ziplist and listpack resulting by trying to allocate more than the maximum size of 4GB. - prevent ziplist (hash and zset) from reaching size of above 1GB, will be converted to HT encoding, that's not a useful size. - prevent listpack (stream) from reaching size of above 1GB. - XADD will start a new listpack if the new record may cause the previous listpack to grow over 1GB. - XADD will respond with an error if a single stream record is over 1GB - List type (ziplist in quicklist) was truncating strings that were over 4GB, now it'll respond with an error.
CmdUpdateRole() : Command("updateRole") {}
0
[ "CWE-613" ]
mongo
64d8e9e1b12d16b54d6a592bae8110226c491b4e
220,542,488,321,688,850,000,000,000,000,000,000,000
1
SERVER-38984 Validate unique User ID on UserCache hit (cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7)
static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t size, int flags) { struct sock *sk = sock->sk; struct ddpehdr *ddp; int copied = 0; int offset = 0; int err = 0; struct sk_buff *skb; skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &err); lock_sock(sk); if (!skb) goto out; /* FIXME: use skb->cb to be able to use shared skbs */ ddp = ddp_hdr(skb); copied = ntohs(ddp->deh_len_hops) & 1023; if (sk->sk_type != SOCK_RAW) { offset = sizeof(*ddp); copied -= offset; } if (copied > size) { copied = size; msg->msg_flags |= MSG_TRUNC; } err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied); if (!err && msg->msg_name) { struct sockaddr_at *sat = msg->msg_name; sat->sat_family = AF_APPLETALK; sat->sat_port = ddp->deh_sport; sat->sat_addr.s_node = ddp->deh_snode; sat->sat_addr.s_net = ddp->deh_snet; msg->msg_namelen = sizeof(*sat); } skb_free_datagram(sk, skb); /* Free the datagram. */ out: release_sock(sk); return err ? : copied; }
0
[ "CWE-20", "CWE-269" ]
linux
f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
239,376,306,332,974,260,000,000,000,000,000,000,000
47
net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <[email protected]> Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
int xasprintf(char **strp, const char *format, ...) { va_list args; int result; va_start (args, format); result = vasprintf (strp, format, args); va_end (args); if (result < 0) *strp = NULL; return result; }
0
[]
augeas
1a66739c3fc14b3257af5d4a32d0a2a714a7b39d
224,912,213,255,227,060,000,000,000,000,000,000,000
11
* src/transform.c (xread_file): catch failed fopen, e.g. EACCES
ExecutePlan(EState *estate, PlanState *planstate, CmdType operation, bool sendTuples, long numberTuples, ScanDirection direction, DestReceiver *dest) { TupleTableSlot *slot; long current_tuple_count; /* * initialize local variables */ current_tuple_count = 0; /* * Set the direction. */ estate->es_direction = direction; /* * Loop until we've processed the proper number of tuples from the plan. */ for (;;) { /* Reset the per-output-tuple exprcontext */ ResetPerTupleExprContext(estate); /* * Execute the plan and obtain a tuple */ slot = ExecProcNode(planstate); /* * if the tuple is null, then we assume there is nothing more to * process so we just end the loop... */ if (TupIsNull(slot)) break; /* * If we have a junk filter, then project a new tuple with the junk * removed. * * Store this new "clean" tuple in the junkfilter's resultSlot. * (Formerly, we stored it back over the "dirty" tuple, which is WRONG * because that tuple slot has the wrong descriptor.) */ if (estate->es_junkFilter != NULL) slot = ExecFilterJunk(estate->es_junkFilter, slot); /* * If we are supposed to send the tuple somewhere, do so. (In * practice, this is probably always the case at this point.) */ if (sendTuples) (*dest->receiveSlot) (slot, dest); /* * Count tuples processed, if this is a SELECT. (For other operation * types, the ModifyTable plan node must count the appropriate * events.) */ if (operation == CMD_SELECT) (estate->es_processed)++; /* * check our tuple count.. if we've processed the proper number then * quit, else loop again and process more tuples. Zero numberTuples * means no limit. */ current_tuple_count++; if (numberTuples && numberTuples == current_tuple_count) break; } }
0
[ "CWE-209" ]
postgres
804b6b6db4dcfc590a468e7be390738f9f7755fb
16,388,468,630,970,628,000,000,000,000,000,000,000
77
Fix column-privilege leak in error-message paths While building error messages to return to the user, BuildIndexValueDescription, ExecBuildSlotValueDescription and ri_ReportViolation would happily include the entire key or entire row in the result returned to the user, even if the user didn't have access to view all of the columns being included. Instead, include only those columns which the user is providing or which the user has select rights on. If the user does not have any rights to view the table or any of the columns involved then no detail is provided and a NULL value is returned from BuildIndexValueDescription and ExecBuildSlotValueDescription. Note that, for key cases, the user must have access to all of the columns for the key to be shown; a partial key will not be returned. Further, in master only, do not return any data for cases where row security is enabled on the relation and row security should be applied for the user. This required a bit of refactoring and moving of things around related to RLS- note the addition of utils/misc/rls.c. Back-patch all the way, as column-level privileges are now in all supported versions. This has been assigned CVE-2014-8161, but since the issue and the patch have already been publicized on pgsql-hackers, there's no point in trying to hide this commit.
MagickPrivate void XMakeWindow(Display *display,Window parent,char **argv, int argc,XClassHint *class_hint,XWMHints *manager_hints, XWindowInfo *window_info) { #define MinWindowSize 64 Atom atom_list[2]; int gravity; static XTextProperty icon_name, window_name; Status status; XSizeHints *size_hints; /* Set window info hints. */ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(display != (Display *) NULL); assert(window_info != (XWindowInfo *) NULL); size_hints=XAllocSizeHints(); if (size_hints == (XSizeHints *) NULL) ThrowXWindowFatalException(XServerFatalError,"UnableToMakeXWindow",argv[0]); size_hints->flags=(int) window_info->flags; size_hints->x=window_info->x; size_hints->y=window_info->y; size_hints->width=(int) window_info->width; size_hints->height=(int) window_info->height; if (window_info->immutable != MagickFalse) { /* Window size cannot be changed. */ size_hints->min_width=size_hints->width; size_hints->min_height=size_hints->height; size_hints->max_width=size_hints->width; size_hints->max_height=size_hints->height; size_hints->flags|=PMinSize; size_hints->flags|=PMaxSize; } else { /* Window size can be changed. */ size_hints->min_width=(int) window_info->min_width; size_hints->min_height=(int) window_info->min_height; size_hints->flags|=PResizeInc; size_hints->width_inc=(int) window_info->width_inc; size_hints->height_inc=(int) window_info->height_inc; #if !defined(PRE_R4_ICCCM) size_hints->flags|=PBaseSize; size_hints->base_width=size_hints->width_inc; size_hints->base_height=size_hints->height_inc; #endif } gravity=NorthWestGravity; if (window_info->geometry != (char *) NULL) { char default_geometry[MagickPathExtent], geometry[MagickPathExtent]; int flags; register char *p; /* User specified geometry. */ (void) FormatLocaleString(default_geometry,MagickPathExtent,"%dx%d", size_hints->width,size_hints->height); (void) CopyMagickString(geometry,window_info->geometry,MagickPathExtent); p=geometry; while (strlen(p) != 0) { if ((isspace((int) ((unsigned char) *p)) == 0) && (*p != '%')) p++; else (void) memmove(p,p+1,MagickPathExtent-(p-geometry)); } flags=XWMGeometry(display,window_info->screen,geometry,default_geometry, window_info->border_width,size_hints,&size_hints->x,&size_hints->y, &size_hints->width,&size_hints->height,&gravity); if ((flags & WidthValue) && (flags & HeightValue)) size_hints->flags|=USSize; if ((flags & XValue) && (flags & YValue)) { size_hints->flags|=USPosition; window_info->x=size_hints->x; window_info->y=size_hints->y; } } #if !defined(PRE_R4_ICCCM) size_hints->win_gravity=gravity; size_hints->flags|=PWinGravity; #endif if (window_info->id == (Window) NULL) window_info->id=XCreateWindow(display,parent,window_info->x,window_info->y, (unsigned int) size_hints->width,(unsigned int) size_hints->height, window_info->border_width,(int) window_info->depth,InputOutput, window_info->visual,(unsigned long) window_info->mask, &window_info->attributes); else { MagickStatusType mask; XEvent sans_event; XWindowChanges window_changes; /* Window already exists; change relevant attributes. */ (void) XChangeWindowAttributes(display,window_info->id,(unsigned long) window_info->mask,&window_info->attributes); mask=ConfigureNotify; while (XCheckTypedWindowEvent(display,window_info->id,(int) mask,&sans_event)) ; window_changes.x=window_info->x; window_changes.y=window_info->y; window_changes.width=(int) window_info->width; window_changes.height=(int) window_info->height; mask=(MagickStatusType) (CWWidth | CWHeight); if (window_info->flags & USPosition) mask|=CWX | CWY; (void) XReconfigureWMWindow(display,window_info->id,window_info->screen, mask,&window_changes); } if (window_info->id == (Window) NULL) ThrowXWindowFatalException(XServerFatalError,"UnableToCreateWindow", window_info->name); status=XStringListToTextProperty(&window_info->name,1,&window_name); if (status == False) ThrowXWindowFatalException(XServerFatalError,"UnableToCreateTextProperty", window_info->name); status=XStringListToTextProperty(&window_info->icon_name,1,&icon_name); if (status == False) ThrowXWindowFatalException(XServerFatalError,"UnableToCreateTextProperty", window_info->icon_name); if (window_info->icon_geometry != (char *) NULL) { int flags, height, width; /* User specified icon geometry. */ size_hints->flags|=USPosition; flags=XWMGeometry(display,window_info->screen,window_info->icon_geometry, (char *) NULL,0,size_hints,&manager_hints->icon_x, &manager_hints->icon_y,&width,&height,&gravity); if ((flags & XValue) && (flags & YValue)) manager_hints->flags|=IconPositionHint; } XSetWMProperties(display,window_info->id,&window_name,&icon_name,argv,argc, size_hints,manager_hints,class_hint); if (window_name.value != (void *) NULL) { (void) XFree((void *) window_name.value); window_name.value=(unsigned char *) NULL; window_name.nitems=0; } if (icon_name.value != (void *) NULL) { (void) XFree((void *) icon_name.value); icon_name.value=(unsigned char *) NULL; icon_name.nitems=0; } atom_list[0]=XInternAtom(display,"WM_DELETE_WINDOW",MagickFalse); atom_list[1]=XInternAtom(display,"WM_TAKE_FOCUS",MagickFalse); (void) XSetWMProtocols(display,window_info->id,atom_list,2); (void) XFree((void *) size_hints); if (window_info->shape != MagickFalse) { #if defined(MAGICKCORE_HAVE_SHAPE) int error_base, event_base; /* Can we apply a non-rectangular shaping mask? */ error_base=0; event_base=0; if (XShapeQueryExtension(display,&error_base,&event_base) == 0) window_info->shape=MagickFalse; #else window_info->shape=MagickFalse; #endif } if (window_info->shared_memory) { #if defined(MAGICKCORE_HAVE_SHARED_MEMORY) /* Can we use shared memory with this window? */ if (XShmQueryExtension(display) == 0) window_info->shared_memory=MagickFalse; #else window_info->shared_memory=MagickFalse; #endif } window_info->image=NewImageList(); window_info->destroy=MagickFalse; }
0
[]
ImageMagick
f391a5f4554fe47eb56d6277ac32d1f698572f0e
63,528,549,009,447,230,000,000,000,000,000,000,000
220
https://github.com/ImageMagick/ImageMagick/issues/1531
static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { MirrorBDSOpaque *s = bs->opaque; if (s->stop) { /* * If the job is to be stopped, we do not need to forward * anything to the real image. */ *nperm = 0; *nshared = BLK_PERM_ALL; return; } bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); if (s->is_commit) { /* * For commit jobs, we cannot take CONSISTENT_READ, because * that permission is unshared for everything above the base * node (except for filters on the base node). * We also have to force-share the WRITE permission, or * otherwise we would block ourselves at the base node (if * writes are blocked for a node, they are also blocked for * its backing file). * (We could also share RESIZE, because it may be needed for * the target if its size is less than the top node's; but * bdrv_default_perms_for_cow() automatically shares RESIZE * for backing nodes if WRITE is shared, so there is no need * to do it here.) */ *nperm &= ~BLK_PERM_CONSISTENT_READ; *nshared |= BLK_PERM_WRITE; } }
0
[ "CWE-476" ]
qemu
66fed30c9cd11854fc878a4eceb507e915d7c9cd
16,661,523,300,916,725,000,000,000,000,000,000,000
40
block/mirror: fix NULL pointer dereference in mirror_wait_on_conflicts() In mirror_iteration() we call mirror_wait_on_conflicts() with `self` parameter set to NULL. Starting from commit d44dae1a7c we dereference `self` pointer in mirror_wait_on_conflicts() without checks if it is not NULL. Backtrace: Program terminated with signal SIGSEGV, Segmentation fault. #0 mirror_wait_on_conflicts (self=0x0, s=<optimized out>, offset=<optimized out>, bytes=<optimized out>) at ../block/mirror.c:172 172 self->waiting_for_op = op; [Current thread is 1 (Thread 0x7f0908931ec0 (LWP 380249))] (gdb) bt #0 mirror_wait_on_conflicts (self=0x0, s=<optimized out>, offset=<optimized out>, bytes=<optimized out>) at ../block/mirror.c:172 #1 0x00005610c5d9d631 in mirror_run (job=0x5610c76a2c00, errp=<optimized out>) at ../block/mirror.c:491 #2 0x00005610c5d58726 in job_co_entry (opaque=0x5610c76a2c00) at ../job.c:917 #3 0x00005610c5f046c6 in coroutine_trampoline (i0=<optimized out>, i1=<optimized out>) at ../util/coroutine-ucontext.c:173 #4 0x00007f0909975820 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__start_context.S:91 from /usr/lib64/libc.so.6 Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2001404 Fixes: d44dae1a7c ("block/mirror: fix active mirror dead-lock in mirror_wait_on_conflicts") Signed-off-by: Stefano Garzarella <[email protected]> Message-Id: <[email protected]> Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]> Signed-off-by: Hanna Reitz <[email protected]>