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
static unsigned deflateDynamic(ucvector* out, size_t* bp, Hash* hash, const unsigned char* data, size_t datapos, size_t dataend, const LodePNGCompressSettings* settings, unsigned final) { unsigned error = 0; /* A block is compressed as follows: The PNG data is lz77 encoded, resulting in literal bytes and length/distance pairs. This is then huffman compressed with two huffman trees. One huffman tree is used for the lit and len values ("ll"), another huffman tree is used for the dist values ("d"). These two trees are stored using their code lengths, and to compress even more these code lengths are also run-length encoded and huffman compressed. This gives a huffman tree of code lengths "cl". The code lenghts used to describe this third tree are the code length code lengths ("clcl"). */ /*The lz77 encoded data, represented with integers since there will also be length and distance codes in it*/ uivector lz77_encoded; HuffmanTree tree_ll; /*tree for lit,len values*/ HuffmanTree tree_d; /*tree for distance codes*/ HuffmanTree tree_cl; /*tree for encoding the code lengths representing tree_ll and tree_d*/ uivector frequencies_ll; /*frequency of lit,len codes*/ uivector frequencies_d; /*frequency of dist codes*/ uivector frequencies_cl; /*frequency of code length codes*/ uivector bitlen_lld; /*lit,len,dist code lenghts (int bits), literally (without repeat codes).*/ uivector bitlen_lld_e; /*bitlen_lld encoded with repeat codes (this is a rudemtary run length compression)*/ /*bitlen_cl is the code length code lengths ("clcl"). The bit lengths of codes to represent tree_cl (these are written as is in the file, it would be crazy to compress these using yet another huffman tree that needs to be represented by yet another set of code lengths)*/ uivector bitlen_cl; size_t datasize = dataend - datapos; /* Due to the huffman compression of huffman tree representations ("two levels"), there are some anologies: bitlen_lld is to tree_cl what data is to tree_ll and tree_d. bitlen_lld_e is to bitlen_lld what lz77_encoded is to data. bitlen_cl is to bitlen_lld_e what bitlen_lld is to lz77_encoded. */ unsigned BFINAL = final; size_t numcodes_ll, numcodes_d, i; unsigned HLIT, HDIST, HCLEN; uivector_init(&lz77_encoded); HuffmanTree_init(&tree_ll); HuffmanTree_init(&tree_d); HuffmanTree_init(&tree_cl); uivector_init(&frequencies_ll); uivector_init(&frequencies_d); uivector_init(&frequencies_cl); uivector_init(&bitlen_lld); uivector_init(&bitlen_lld_e); uivector_init(&bitlen_cl); /*This while loop never loops due to a break at the end, it is here to allow breaking out of it to the cleanup phase on error conditions.*/ while(!error) { if(settings->use_lz77) { error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize, settings->minmatch, settings->nicematch, settings->lazymatching); if(error) break; } else { if(!uivector_resize(&lz77_encoded, datasize)) ERROR_BREAK(83 /*alloc fail*/); if (!lz77_encoded.data) ERROR_BREAK(83 /* alloc fail */); for(i = datapos; i < dataend; i++) lz77_encoded.data[i] = data[i]; /*no LZ77, but still will be Huffman compressed*/ } if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83 /*alloc fail*/); if(!uivector_resizev(&frequencies_d, 30, 0)) ERROR_BREAK(83 /*alloc fail*/); /*Count the frequencies of lit, len and dist codes*/ for(i = 0; i < lz77_encoded.size; i++) { unsigned symbol; if (!lz77_encoded.data) ERROR_BREAK(83 /* alloc fail */); symbol = lz77_encoded.data[i]; frequencies_ll.data[symbol]++; if(symbol > 256) { unsigned dist = lz77_encoded.data[i + 2]; frequencies_d.data[dist]++; i += 3; } } frequencies_ll.data[256] = 1; /*there will be exactly 1 end code, at the end of the block*/ /*Make both huffman trees, one for the lit and len codes, one for the dist codes*/ error = HuffmanTree_makeFromFrequencies(&tree_ll, frequencies_ll.data, 257, frequencies_ll.size, 15); if(error) break; /*2, not 1, is chosen for mincodes: some buggy PNG decoders require at least 2 symbols in the dist tree*/ error = HuffmanTree_makeFromFrequencies(&tree_d, frequencies_d.data, 2, frequencies_d.size, 15); if(error) break; numcodes_ll = tree_ll.numcodes; if(numcodes_ll > 286) numcodes_ll = 286; numcodes_d = tree_d.numcodes; if(numcodes_d > 30) numcodes_d = 30; /*store the code lengths of both generated trees in bitlen_lld*/ for(i = 0; i < numcodes_ll; i++) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_ll, (unsigned)i)); for(i = 0; i < numcodes_d; i++) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_d, (unsigned)i)); /*run-length compress bitlen_ldd into bitlen_lld_e by using repeat codes 16 (copy length 3-6 times), 17 (3-10 zeroes), 18 (11-138 zeroes)*/ for(i = 0; i < (unsigned)bitlen_lld.size; i++) { unsigned j = 0; /*amount of repititions*/ while(i + j + 1 < (unsigned)bitlen_lld.size && bitlen_lld.data[i + j + 1] == bitlen_lld.data[i]) j++; if(bitlen_lld.data[i] == 0 && j >= 2) /*repeat code for zeroes*/ { j++; /*include the first zero*/ if(j <= 10) /*repeat code 17 supports max 10 zeroes*/ { uivector_push_back(&bitlen_lld_e, 17); uivector_push_back(&bitlen_lld_e, j - 3); } else /*repeat code 18 supports max 138 zeroes*/ { if(j > 138) j = 138; uivector_push_back(&bitlen_lld_e, 18); uivector_push_back(&bitlen_lld_e, j - 11); } i += (j - 1); } else if(j >= 3) /*repeat code for value other than zero*/ { size_t k; unsigned num = j / 6, rest = j % 6; uivector_push_back(&bitlen_lld_e, bitlen_lld.data[i]); for(k = 0; k < num; k++) { uivector_push_back(&bitlen_lld_e, 16); uivector_push_back(&bitlen_lld_e, 6 - 3); } if(rest >= 3) { uivector_push_back(&bitlen_lld_e, 16); uivector_push_back(&bitlen_lld_e, rest - 3); } else j -= rest; i += j; } else /*too short to benefit from repeat code*/ { uivector_push_back(&bitlen_lld_e, bitlen_lld.data[i]); } } /*generate tree_cl, the huffmantree of huffmantrees*/ if(!uivector_resizev(&frequencies_cl, NUM_CODE_LENGTH_CODES, 0)) ERROR_BREAK(83 /*alloc fail*/); for(i = 0; i < bitlen_lld_e.size; i++) { frequencies_cl.data[bitlen_lld_e.data[i]]++; /*after a repeat code come the bits that specify the number of repetitions, those don't need to be in the frequencies_cl calculation*/ if(bitlen_lld_e.data[i] >= 16) i++; } error = HuffmanTree_makeFromFrequencies(&tree_cl, frequencies_cl.data, frequencies_cl.size, frequencies_cl.size, 7); if(error) break; if(!uivector_resize(&bitlen_cl, tree_cl.numcodes)) ERROR_BREAK(83 /*alloc fail*/); for(i = 0; i < tree_cl.numcodes && bitlen_cl.data; i++) { /*lenghts of code length tree is in the order as specified by deflate*/ bitlen_cl.data[i] = HuffmanTree_getLength(&tree_cl, CLCL_ORDER[i]); } while(bitlen_cl.data && bitlen_cl.size > 4 && bitlen_cl.data[bitlen_cl.size - 1] == 0) { /*remove zeros at the end, but minimum size must be 4*/ if(!uivector_resize(&bitlen_cl, bitlen_cl.size - 1)) ERROR_BREAK(83 /*alloc fail*/); } if(error || !bitlen_cl.data) break; /* Write everything into the output After the BFINAL and BTYPE, the dynamic block consists out of the following: - 5 bits HLIT, 5 bits HDIST, 4 bits HCLEN - (HCLEN+4)*3 bits code lengths of code length alphabet - HLIT + 257 code lenghts of lit/length alphabet (encoded using the code length alphabet, + possible repetition codes 16, 17, 18) - HDIST + 1 code lengths of distance alphabet (encoded using the code length alphabet, + possible repetition codes 16, 17, 18) - compressed data - 256 (end code) */ /*Write block type*/ addBitToStream(bp, out, BFINAL); addBitToStream(bp, out, 0); /*first bit of BTYPE "dynamic"*/ addBitToStream(bp, out, 1); /*second bit of BTYPE "dynamic"*/ /*write the HLIT, HDIST and HCLEN values*/ HLIT = (unsigned)(numcodes_ll - 257); HDIST = (unsigned)(numcodes_d - 1); HCLEN = 0; if (bitlen_cl.size > 4) HCLEN = (unsigned)bitlen_cl.size - 4; /*trim zeroes for HCLEN. HLIT and HDIST were already trimmed at tree creation*/ while(HCLEN > 0 && !bitlen_cl.data[HCLEN + 4 - 1]) HCLEN--; addBitsToStream(bp, out, HLIT, 5); addBitsToStream(bp, out, HDIST, 5); addBitsToStream(bp, out, HCLEN, 4); /*write the code lenghts of the code length alphabet*/ if (bitlen_cl.size > 4) { for(i = 0; i < HCLEN + 4; i++) addBitsToStream(bp, out, bitlen_cl.data[i], 3); } /*write the lenghts of the lit/len AND the dist alphabet*/ for(i = 0; i < bitlen_lld_e.size; i++) { addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_cl, bitlen_lld_e.data[i]), HuffmanTree_getLength(&tree_cl, bitlen_lld_e.data[i])); /*extra bits of repeat codes*/ if(bitlen_lld_e.data[i] == 16) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 2); else if(bitlen_lld_e.data[i] == 17) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 3); else if(bitlen_lld_e.data[i] == 18) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 7); } /*write the compressed data symbols*/ writeLZ77data(bp, out, &lz77_encoded, &tree_ll, &tree_d); /*error: the length of the end code 256 must be larger than 0*/ if(HuffmanTree_getLength(&tree_ll, 256) == 0) ERROR_BREAK(64); /*write the end code*/ addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, 256), HuffmanTree_getLength(&tree_ll, 256)); break; /*end of error-while*/ } /*cleanup*/ uivector_cleanup(&lz77_encoded); HuffmanTree_cleanup(&tree_ll); HuffmanTree_cleanup(&tree_d); HuffmanTree_cleanup(&tree_cl); uivector_cleanup(&frequencies_ll); uivector_cleanup(&frequencies_d); uivector_cleanup(&frequencies_cl); uivector_cleanup(&bitlen_lld_e); uivector_cleanup(&bitlen_lld); uivector_cleanup(&bitlen_cl); return error; }
0
[ "CWE-401" ]
FreeRDP
9fee4ae076b1ec97b97efb79ece08d1dab4df29a
271,746,118,842,044,000,000,000,000,000,000,000,000
257
Fixed #5645: realloc return handling
void __fastcall TOwnConsole::WindowStateTimer(TObject * /*Sender*/) { DebugAssert(FConsoleWindow != NULL); WINDOWPLACEMENT Placement; memset(&Placement, 0, sizeof(Placement)); Placement.length = sizeof(Placement); if (GetWindowPlacement(FConsoleWindow, &Placement)) { bool Minimized = (Placement.showCmd == SW_SHOWMINIMIZED); if (FMinimized != Minimized) { FMinimized = Minimized; if (FMinimized && WinConfiguration->MinimizeToTray) { FTrayIcon->Visible = true; ShowWindow(FConsoleWindow, SW_HIDE); } else { FTrayIcon->Visible = false; ShowWindow(FConsoleWindow, SW_SHOW); } } } else { DebugFail(); } }
0
[ "CWE-787" ]
winscp
faa96e8144e6925a380f94a97aa382c9427f688d
123,786,712,932,088,980,000,000,000,000,000,000,000
30
Bug 1943: Prevent loading session settings that can lead to remote code execution from handled URLs https://winscp.net/tracker/1943 (cherry picked from commit ec584f5189a856cd79509f754722a6898045c5e0) Source commit: 0f4be408b3f01132b00682da72d925d6c4ee649b
logfmtpacket(dns_message_t *message, const char *description, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, const dns_master_style_t *style, int level, isc_mem_t *mctx) { char addrbuf[ISC_SOCKADDR_FORMATSIZE] = { 0 }; const char *newline = "\n"; const char *space = " "; isc_buffer_t buffer; char *buf = NULL; int len = 1024; isc_result_t result; if (! isc_log_wouldlog(dns_lctx, level)) return; /* * Note that these are multiline debug messages. We want a newline * to appear in the log after each message. */ if (address != NULL) isc_sockaddr_format(address, addrbuf, sizeof(addrbuf)); else newline = space = ""; do { buf = isc_mem_get(mctx, len); if (buf == NULL) break; isc_buffer_init(&buffer, buf, len); result = dns_message_totext(message, style, 0, &buffer); if (result == ISC_R_NOSPACE) { isc_mem_put(mctx, buf, len); len += 1024; } else if (result == ISC_R_SUCCESS) isc_log_write(dns_lctx, category, module, level, "%s%s%s%s%.*s", description, space, addrbuf, newline, (int)isc_buffer_usedlength(&buffer), buf); } while (result == ISC_R_NOSPACE); if (buf != NULL) isc_mem_put(mctx, buf, len); }
0
[ "CWE-617" ]
bind9
6ed167ad0a647dff20c8cb08c944a7967df2d415
118,245,625,434,159,480,000,000,000,000,000,000,000
46
Always keep a copy of the message this allows it to be available even when dns_message_parse() returns a error.
static void sig_complete_format(GList **list, WINDOW_REC *window, const char *word, const char *line, int *want_space) { const char *ptr; int words; g_return_if_fail(list != NULL); g_return_if_fail(word != NULL); g_return_if_fail(line != NULL); ptr = line; words = 0; do { ptr++; words++; ptr = strchr(ptr, ' '); } while (ptr != NULL); if (words > 2) return; *list = completion_get_formats(line, word); if (*list != NULL) signal_stop(); }
0
[ "CWE-125" ]
irssi
e0c66e31224894674356ddaf6d46016c1abc994f
143,727,948,528,568,100,000,000,000,000,000,000,000
26
Previous theme patch fixes by c0ffee git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3058 dbcabf3a-b0e7-0310-adc4-f8d773084564
static bool notify_change_record_identical(struct notify_change_event *c1, struct notify_change_event *c2) { /* Note this is deliberately case sensitive. */ if (c1->action == c2->action && strcmp(c1->name, c2->name) == 0) { return True; } return False; }
0
[ "CWE-266" ]
samba
5dd4c789c13035b805fdd2c3a9c38721657b05b3
206,530,335,082,749,750,000,000,000,000,000,000,000
10
s3: smbd: Ensure change notifies can't get set unless the directory handle is open for SEC_DIR_LIST. Remove knownfail entry. CVE-2020-14318 BUG: https://bugzilla.samba.org/show_bug.cgi?id=14434 Signed-off-by: Jeremy Allison <[email protected]>
static int icmp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6, const struct icmp6_hdr *icp, u_int len) { return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)icp, len, len, IPPROTO_ICMPV6); }
0
[ "CWE-125" ]
tcpdump
d7505276842e85bfd067fa21cdb32b8a2dc3c5e4
40,437,821,301,700,275,000,000,000,000,000,000,000
6
(for 4.9.3) CVE-2018-14882/ICMP6 RPL: Add a missing bounds check Moreover: Add and use *_tstr[] strings. Update four tests outputs accordingly. Fix a space. Wang Junjie of 360 ESG Codesafe Team had independently identified this vulnerability in 2018 by means of fuzzing and provided the packet capture file for the test.
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic) { av_assert0(0); return AVERROR_BUG; }
0
[ "CWE-703" ]
FFmpeg
e5c7229999182ad1cef13b9eca050dba7a5a08da
53,392,670,578,848,420,000,000,000,000,000,000,000
5
avcodec/utils: set AVFrame format unconditional Fixes inconsistency and out of array accesses Fixes: 10cdd7e63e7f66e3e66273939e0863dd-asan_heap-oob_1a4ff32_7078_cov_4056274555_mov_h264_aac__mp4box_frag.mp4 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <[email protected]>
Interval IndexBoundsBuilder::makePointInterval(double d) { BSONObjBuilder bob; bob.append("", d); return makePointInterval(bob.obj()); }
0
[ "CWE-754" ]
mongo
f8f55e1825ee5c7bdb3208fc7c5b54321d172732
117,514,455,699,840,450,000,000,000,000,000,000,000
5
SERVER-44377 generate correct plan for indexed inequalities to null
int ssl_undefined_function(SSL *s) { SSLerr(SSL_F_SSL_UNDEFINED_FUNCTION, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); }
0
[ "CWE-310" ]
openssl
56f1acf5ef8a432992497a04792ff4b3b2c6f286
114,276,298,677,098,210,000,000,000,000,000,000,000
5
Disable SSLv2 default build, default negotiation and weak ciphers. SSLv2 is by default disabled at build-time. Builds that are not configured with "enable-ssl2" will not support SSLv2. Even if "enable-ssl2" is used, users who want to negotiate SSLv2 via the version-flexible SSLv23_method() will need to explicitly call either of: SSL_CTX_clear_options(ctx, SSL_OP_NO_SSLv2); or SSL_clear_options(ssl, SSL_OP_NO_SSLv2); as appropriate. Even if either of those is used, or the application explicitly uses the version-specific SSLv2_method() or its client or server variants, SSLv2 ciphers vulnerable to exhaustive search key recovery have been removed. Specifically, the SSLv2 40-bit EXPORT ciphers, and SSLv2 56-bit DES are no longer available. Mitigation for CVE-2016-0800 Reviewed-by: Emilia Käsper <[email protected]>
void compute_statistics() { if (!empty()) { statistic_increment(*ptr_binlog_cache_use, &LOCK_status); if (cache_log.disk_writes != 0) statistic_increment(*ptr_binlog_cache_disk_use, &LOCK_status); } }
0
[ "CWE-264" ]
mysql-server
48bd8b16fe382be302c6f0b45931be5aa6f29a0e
64,802,819,002,136,620,000,000,000,000,000,000,000
9
Bug#24388753: PRIVILEGE ESCALATION USING MYSQLD_SAFE [This is the 5.5/5.6 version of the bugfix]. The problem was that it was possible to write log files ending in .ini/.cnf that later could be parsed as an options file. This made it possible for users to specify startup options without the permissions to do so. This patch fixes the problem by disallowing general query log and slow query log to be written to files ending in .ini and .cnf.
static int doBundleRestartInstance(struct nc_state_t *nc, ncMetadata * pMeta, char *instanceId) { ncInstance *instance = NULL; // sanity checking if (instanceId == NULL) { LOGERROR("bundle restart instance called with invalid parameters\n"); return (EUCA_ERROR); } // find the instance if ((instance = find_instance(&global_instances, instanceId)) == NULL) { LOGERROR("[%s] instance not found\n", instanceId); return (EUCA_NOT_FOUND_ERROR); } // Now restart this instance regardless of bundling success or failure return (restart_instance(instance)); }
0
[]
eucalyptus
c252889a46f41b4c396b89e005ec89836f2524be
260,633,841,705,609,830,000,000,000,000,000,000,000
17
Input validation, shellout hardening on back-end - validating bucketName and bucketPath in BundleInstance - validating device name in Attach and DetachVolume - removed some uses of system() and popen() Fixes EUCA-7572, EUCA-7520
static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fname_len, int use_arg) /* {{{ */ { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC); HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); zval *tmp, *arg = NULL; zval *retval_ptr = NULL; MAKE_STD_ZVAL(tmp); Z_TYPE_P(tmp) = IS_ARRAY; Z_ARRVAL_P(tmp) = aht; if (!use_arg) { aht->nApplyCount++; zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 1, tmp, NULL TSRMLS_CC); aht->nApplyCount--; } else if (use_arg == SPL_ARRAY_METHOD_MAY_USER_ARG) { if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) { Z_TYPE_P(tmp) = IS_NULL; zval_ptr_dtor(&tmp); zend_throw_exception(spl_ce_BadMethodCallException, "Function expects one argument at most", 0 TSRMLS_CC); return; } aht->nApplyCount++; zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, arg? 2 : 1, tmp, arg TSRMLS_CC); aht->nApplyCount--; } else { if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { Z_TYPE_P(tmp) = IS_NULL; zval_ptr_dtor(&tmp); zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC); return; } aht->nApplyCount++; zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 2, tmp, arg TSRMLS_CC); aht->nApplyCount--; } Z_TYPE_P(tmp) = IS_NULL; /* we want to destroy the zval, not the hashtable */ zval_ptr_dtor(&tmp); if (retval_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } } /* }}} */
1
[]
php-src
b7fa67742cd8d2b0ca0c0273b157f6ffee9ad6e2
104,983,625,279,814,640,000,000,000,000,000,000,000
42
Fix bug #70068 (Dangling pointer in the unserialization of ArrayObject items)
*/ PHP_MINIT_FUNCTION(wddx) { le_wddx = zend_register_list_destructors_ex(release_wddx_packet_rsrc, NULL, "wddx", module_number); #if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) php_session_register_serializer("wddx", PS_SERIALIZER_ENCODE_NAME(wddx), PS_SERIALIZER_DECODE_NAME(wddx)); #endif return SUCCESS;
0
[]
php-src
366f9505a4aae98ef2f4ca39a838f628a324b746
140,467,104,189,702,540,000,000,000,000,000,000,000
12
Fixed bug #70661 (Use After Free Vulnerability in WDDX Packet Deserialization) Conflicts: ext/wddx/wddx.c
const QMap<QString, QString> Database::getFriends() { QMap<QString, QString> qm; QSqlQuery query; query.prepare(QLatin1String("SELECT `name`, `hash` FROM `friends`")); query.exec(); while (query.next()) qm.insert(query.value(0).toString(), query.value(1).toString()); return qm; }
0
[ "CWE-310" ]
mumble
5632c35d6759f5e13a7dfe78e4ee6403ff6a8e3e
154,592,070,172,725,820,000,000,000,000,000,000,000
10
Explicitly remove file permissions for settings and DB
static int ntop_stats_get_samplings_of_days_from_epoch(lua_State *vm) { time_t epoch_start, epoch_end; int num_days; int ifid; NetworkInterface* iface; StatsManager *sm; struct statsManagerRetrieval retvals; ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TNUMBER)) return(CONST_LUA_ERROR); ifid = lua_tointeger(vm, 1); if(ifid < 0) return(CONST_LUA_ERROR); if(ntop_lua_check(vm, __FUNCTION__, 2, LUA_TNUMBER)) return(CONST_LUA_ERROR); epoch_end = lua_tointeger(vm, 2); epoch_end -= (epoch_end % 60); if(epoch_end < 0) return(CONST_LUA_ERROR); if(ntop_lua_check(vm, __FUNCTION__, 3, LUA_TNUMBER)) return(CONST_LUA_ERROR); num_days = lua_tointeger(vm, 3); if(num_days < 0) return(CONST_LUA_ERROR); if(!(iface = ntop->getNetworkInterface(ifid)) || !(sm = iface->getStatsManager())) return (CONST_LUA_ERROR); epoch_start = epoch_end - (num_days * 24 * 60 * 60); if(sm->retrieveDayStatsInterval(epoch_start, epoch_end, &retvals)) return(CONST_LUA_ERROR); lua_newtable(vm); for (unsigned i = 0 ; i < retvals.rows.size() ; i++) lua_push_str_table_entry(vm, retvals.rows[i].c_str(), (char*)""); return(CONST_LUA_OK); }
0
[ "CWE-476" ]
ntopng
01f47e04fd7c8d54399c9e465f823f0017069f8f
160,448,177,394,341,390,000,000,000,000,000,000,000
41
Security fix: prevents empty host from being used
static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header) { byte bitString[1 + MAX_LENGTH_SZ + 1]; int algoSz; int bitStringSz; int idx; word32 pubSz = ED25519_PUB_KEY_SIZE; #ifdef WOLFSSL_SMALL_STACK byte* algo = NULL; byte* pub; #else byte algo[MAX_ALGO_SZ]; byte pub[ED25519_PUB_KEY_SIZE]; #endif #ifdef WOLFSSL_SMALL_STACK pub = (byte*)XMALLOC(ECC_BUFSIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (pub == NULL) return MEMORY_E; #endif idx = wc_ed25519_export_public(key, pub, &pubSz); if (idx != 0) { #ifdef WOLFSSL_SMALL_STACK XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return idx; } /* headers */ if (with_header) { #ifdef WOLFSSL_SMALL_STACK algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (algo == NULL) { XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } #endif algoSz = SetAlgoID(ED25519k, algo, oidKeyType, 0); bitStringSz = SetBitString(pubSz, 0, bitString); idx = SetSequence(pubSz + bitStringSz + algoSz, output); /* algo */ XMEMCPY(output + idx, algo, algoSz); idx += algoSz; /* bit string */ XMEMCPY(output + idx, bitString, bitStringSz); idx += bitStringSz; } else idx = 0; /* pub */ XMEMCPY(output + idx, pub, pubSz); idx += pubSz; #ifdef WOLFSSL_SMALL_STACK if (with_header) { XFREE(algo, NULL, DYNAMIC_TYPE_TMP_BUFFER); } XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return idx; }
0
[ "CWE-125", "CWE-345" ]
wolfssl
f93083be72a3b3d956b52a7ec13f307a27b6e093
253,112,363,367,826,580,000,000,000,000,000,000,000
66
OCSP: improve handling of OCSP no check extension
can_compound(slang_T *slang, char_u *word, char_u *flags) { char_u uflags[MAXWLEN * 2]; int i; char_u *p; if (slang->sl_compprog == NULL) return FALSE; if (enc_utf8) { // Need to convert the single byte flags to utf8 characters. p = uflags; for (i = 0; flags[i] != NUL; ++i) p += utf_char2bytes(flags[i], p); *p = NUL; p = uflags; } else p = flags; if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0)) return FALSE; // Count the number of syllables. This may be slow, do it last. If there // are too many syllables AND the number of compound words is above // COMPOUNDWORDMAX then compounding is not allowed. if (slang->sl_compsylmax < MAXWLEN && count_syllables(slang, word) > slang->sl_compsylmax) return (int)STRLEN(flags) < slang->sl_compmax; return TRUE; }
0
[ "CWE-416" ]
vim
2813f38e021c6e6581c0c88fcf107e41788bc835
106,614,026,587,503,460,000,000,000,000,000,000,000
30
patch 8.2.5072: using uninitialized value and freed memory in spell command Problem: Using uninitialized value and freed memory in spell command. Solution: Initialize "attr". Check for empty line early.
bool Item_param::set_longdata(const char *str, ulong length) { DBUG_ENTER("Item_param::set_longdata"); DBUG_ASSERT(value.type_handler()->cmp_type() == STRING_RESULT); /* If client character set is multibyte, end of long data packet may hit at the middle of a multibyte character. Additionally, if binary log is open we must write long data value to the binary log in character set of client. This is why we can't convert long data to connection character set as it comes (here), and first have to concatenate all pieces together, write query to the binary log and only then perform conversion. */ if (value.m_string.length() + length > max_long_data_size) { my_message(ER_UNKNOWN_ERROR, "Parameter of prepared statement which is set through " "mysql_send_long_data() is longer than " "'max_long_data_size' bytes", MYF(0)); DBUG_RETURN(true); } if (value.m_string.append(str, length, &my_charset_bin)) DBUG_RETURN(TRUE); state= LONG_DATA_VALUE; maybe_null= 0; null_value= 0; fix_type(Item::STRING_ITEM); DBUG_RETURN(FALSE); }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
272,944,198,999,731,370,000,000,000,000,000,000,000
33
MDEV-24176 Preparations 1. moved fix_vcol_exprs() call to open_table() mysql_alter_table() doesn't do lock_tables() so it cannot win from fix_vcol_exprs() from there. Tests affected: main.default_session 2. Vanilla cleanups and comments.
static int nfs4_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *fsinfo) { int error; nfs_fattr_init(fsinfo->fattr); error = nfs4_do_fsinfo(server, fhandle, fsinfo); if (error == 0) { /* block layout checks this! */ server->pnfs_blksize = fsinfo->blksize; set_pnfs_layoutdriver(server, fhandle, fsinfo); } return error; }
0
[ "CWE-787" ]
linux
b4487b93545214a9db8cbf32e86411677b0cca21
62,123,179,804,544,650,000,000,000,000,000,000,000
14
nfs: Fix getxattr kernel panic and memory overflow Move the buffer size check to decode_attr_security_label() before memcpy() Only call memcpy() if the buffer is large enough Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS") Signed-off-by: Jeffrey Mitchell <[email protected]> [Trond: clean up duplicate test of label->len != 0] Signed-off-by: Trond Myklebust <[email protected]>
Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path) { const qreal *points = path.points(); const QPainterPath::ElementType *types = path.elements(); QPainterPath p; if (types) { int id = 0; for (int i=0; i<path.elementCount(); ++i) { switch(types[i]) { case QPainterPath::MoveToElement: p.moveTo(QPointF(points[id], points[id+1])); id+=2; break; case QPainterPath::LineToElement: p.lineTo(QPointF(points[id], points[id+1])); id+=2; break; case QPainterPath::CurveToElement: { QPointF p1(points[id], points[id+1]); QPointF p2(points[id+2], points[id+3]); QPointF p3(points[id+4], points[id+5]); p.cubicTo(p1, p2, p3); id+=6; break; } case QPainterPath::CurveToDataElement: ; break; } } } else { p.moveTo(QPointF(points[0], points[1])); int id = 2; for (int i=1; i<path.elementCount(); ++i) { p.lineTo(QPointF(points[id], points[id+1])); id+=2; } } if (path.hints() & QVectorPath::WindingFill) p.setFillRule(Qt::WindingFill); return p; }
0
[ "CWE-787" ]
qtbase
6b400e3147dcfd8cc3a393ace1bd118c93762e0c
278,032,113,856,391,740,000,000,000,000,000,000,000
44
Improve fix for avoiding huge number of tiny dashes Some pathological cases were not caught by the previous fix. Fixes: QTBUG-95239 Pick-to: 6.2 6.1 5.15 Change-Id: I0337ee3923ff93ccb36c4d7b810a9c0667354cc5 Reviewed-by: Robert Löhning <[email protected]>
rsvg_filter_free_pair (gpointer value) { RsvgFilterPrimitiveOutput *output; output = (RsvgFilterPrimitiveOutput *) value; g_object_unref (output->result); g_free (output); }
0
[]
librsvg
34c95743ca692ea0e44778e41a7c0a129363de84
202,026,477,244,032,750,000,000,000,000,000,000,000
8
Store node type separately in RsvgNode The node name (formerly RsvgNode:type) cannot be used to infer the sub-type of RsvgNode that we're dealing with, since for unknown elements we put type = node-name. This lead to a (potentially exploitable) crash e.g. when the element name started with "fe" which tricked the old code into considering it as a RsvgFilterPrimitive. CVE-2011-3146 https://bugzilla.gnome.org/show_bug.cgi?id=658014
static WORD_LIST * expand_string_leave_quoted (string, quoted) char *string; int quoted; { WORD_LIST *tlist; WORD_LIST *tresult; if (string == 0 || *string == '\0') return ((WORD_LIST *)NULL); tlist = expand_string_internal (string, quoted); if (tlist) { tresult = word_list_split (tlist); dispose_words (tlist); return (tresult); } return ((WORD_LIST *)NULL);
0
[ "CWE-20" ]
bash
4f747edc625815f449048579f6e65869914dd715
288,470,802,401,405,260,000,000,000,000,000,000,000
20
Bash-4.4 patch 7
int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum) { struct qeth_card *card = dev->ml_priv; int rc = 0; switch (regnum) { case MII_BMCR: /* Basic mode control register */ rc = BMCR_FULLDPLX; if ((card->info.link_type != QETH_LINK_TYPE_GBIT_ETH) && (card->info.link_type != QETH_LINK_TYPE_OSN) && (card->info.link_type != QETH_LINK_TYPE_10GBIT_ETH)) rc |= BMCR_SPEED100; break; case MII_BMSR: /* Basic mode status register */ rc = BMSR_ERCAP | BMSR_ANEGCOMPLETE | BMSR_LSTATUS | BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | BMSR_100FULL | BMSR_100BASE4; break; case MII_PHYSID1: /* PHYS ID 1 */ rc = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 8) | dev->dev_addr[2]; rc = (rc >> 5) & 0xFFFF; break; case MII_PHYSID2: /* PHYS ID 2 */ rc = (dev->dev_addr[2] << 10) & 0xFFFF; break; case MII_ADVERTISE: /* Advertisement control reg */ rc = ADVERTISE_ALL; break; case MII_LPA: /* Link partner ability reg */ rc = LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL | LPA_100BASE4 | LPA_LPACK; break; case MII_EXPANSION: /* Expansion register */ break; case MII_DCOUNTER: /* disconnect counter */ break; case MII_FCSCOUNTER: /* false carrier counter */ break; case MII_NWAYTEST: /* N-way auto-neg test register */ break; case MII_RERRCOUNTER: /* rx error counter */ rc = card->stats.rx_errors; break; case MII_SREVISION: /* silicon revision */ break; case MII_RESV1: /* reserved 1 */ break; case MII_LBRERROR: /* loopback, rx, bypass error */ break; case MII_PHYADDR: /* physical address */ break; case MII_RESV2: /* reserved 2 */ break; case MII_TPISTATUS: /* TPI status for 10mbps */ break; case MII_NCONFIG: /* network interface config */ break; default: break; } return rc; }
0
[ "CWE-200", "CWE-119" ]
linux
6fb392b1a63ae36c31f62bc3fc8630b49d602b62
286,624,242,111,441,550,000,000,000,000,000,000,000
63
qeth: avoid buffer overflow in snmp ioctl Check user-defined length in snmp ioctl request and allow request only if it fits into a qeth command buffer. Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: Frank Blaschka <[email protected]> Reviewed-by: Heiko Carstens <[email protected]> Reported-by: Nico Golde <[email protected]> Reported-by: Fabian Yamaguchi <[email protected]> Cc: <[email protected]> Signed-off-by: David S. Miller <[email protected]>
set_photo (EBookBackendEws *bbews, const EwsId *item_id, EContact *contact, EContactPhoto *photo, gchar **new_change_key, GCancellable *cancellable, GError **error) { EEwsAttachmentInfo *info; EwsId *id = NULL; GSList *files = NULL; const guchar *data; gsize len; if (!item_id) { id = g_new0 (EwsId, 1); id->id = e_contact_get (contact, E_CONTACT_UID); id->change_key = e_vcard_util_dup_x_attribute (E_VCARD (contact), X_EWS_CHANGEKEY); if (!id->change_key) id->change_key = e_contact_get (contact, E_CONTACT_REV); item_id = id; } data = e_contact_photo_get_inlined (photo, &len); info = e_ews_attachment_info_new (E_EWS_ATTACHMENT_INFO_TYPE_INLINED); e_ews_attachment_info_set_inlined_data (info, data, len); e_ews_attachment_info_set_mime_type (info, "image/jpeg"); e_ews_attachment_info_set_filename (info, "ContactPicture.jpg"); files = g_slist_append (files, info); e_ews_connection_create_attachments_sync ( bbews->priv->cnc, EWS_PRIORITY_MEDIUM, item_id, files, TRUE, new_change_key, NULL, cancellable, error); if (id) { g_free (id->change_key); g_free (id->id); g_free (id); } g_slist_free_full (files, (GDestroyNotify) e_ews_attachment_info_free); }
0
[ "CWE-295" ]
evolution-ews
915226eca9454b8b3e5adb6f2fff9698451778de
162,064,865,900,527,050,000,000,000,000,000,000,000
52
I#27 - SSL Certificates are not validated This depends on https://gitlab.gnome.org/GNOME/evolution-data-server/commit/6672b8236139bd6ef41ecb915f4c72e2a052dba5 too. Closes https://gitlab.gnome.org/GNOME/evolution-ews/issues/27
krb5_init_creds_free(krb5_context context, krb5_init_creds_context ctx) { free_init_creds_ctx(context, ctx); free(ctx); }
0
[ "CWE-320" ]
heimdal
2f7f3d9960aa6ea21358bdf3687cee5149aa35cf
276,093,763,677,103,500,000,000,000,000,000,000,000
6
CVE-2019-12098: krb5: always confirm PA-PKINIT-KX for anon PKINIT RFC8062 Section 7 requires verification of the PA-PKINIT-KX key excahnge when anonymous PKINIT is used. Failure to do so can permit an active attacker to become a man-in-the-middle. Introduced by a1ef548600c5bb51cf52a9a9ea12676506ede19f. First tagged release Heimdal 1.4.0. CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N (4.8) Change-Id: I6cc1c0c24985936468af08693839ac6c3edda133 Signed-off-by: Jeffrey Altman <[email protected]> Approved-by: Jeffrey Altman <[email protected]> (cherry picked from commit 38c797e1ae9b9c8f99ae4aa2e73957679031fd2b)
int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) { struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; int ret; init_emulate_ctxt(vcpu); ctxt->op_bytes = 2; ctxt->ad_bytes = 2; ctxt->_eip = ctxt->eip + inc_eip; ret = emulate_int_real(ctxt, irq); if (ret != X86EMUL_CONTINUE) return EMULATE_FAIL; ctxt->eip = ctxt->_eip; memcpy(vcpu->arch.regs, ctxt->regs, sizeof ctxt->regs); kvm_rip_write(vcpu, ctxt->eip); kvm_set_rflags(vcpu, ctxt->eflags); if (irq == NMI_VECTOR) vcpu->arch.nmi_pending = 0; else vcpu->arch.interrupt.pending = false; return EMULATE_DONE; }
0
[]
kvm
0769c5de24621141c953fbe1f943582d37cb4244
301,065,027,666,092,700,000,000,000,000,000,000,000
27
KVM: x86: extend "struct x86_emulate_ops" with "get_cpuid" In order to be able to proceed checks on CPU-specific properties within the emulator, function "get_cpuid" is introduced. With "get_cpuid" it is possible to virtually call the guests "cpuid"-opcode without changing the VM's context. [mtosatti: cleanup/beautify code] Signed-off-by: Stephan Baerwolf <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
TEST_F(DocumentSourceMatchTest, ClauseAndedWithCommentShouldAddDependencies) { auto match = DocumentSourceMatch::create(fromjson("{a: 4, $comment: 'irrelevant'}"), getExpCtx()); DepsTracker dependencies; ASSERT_EQUALS(DepsTracker::State::SEE_NEXT, match->getDependencies(&dependencies)); ASSERT_EQUALS(1U, dependencies.fields.count("a")); ASSERT_EQUALS(1U, dependencies.fields.size()); ASSERT_EQUALS(false, dependencies.needWholeDocument); ASSERT_EQUALS(false, dependencies.getNeedsMetadata(DocumentMetadataFields::kTextScore)); }
0
[]
mongo
b3107d73a2c58d7e016b834dae0acfd01c0db8d7
28,516,668,656,906,320,000,000,000,000,000,000,000
10
SERVER-59299: Flatten top-level nested $match stages in doOptimizeAt (cherry picked from commit 4db5eceda2cff697f35c84cd08232bac8c33beec)
TfLiteStatus SoftmaxPrepare(TfLiteContext* context, TfLiteNode* node) { auto* params = reinterpret_cast<TfLiteSoftmaxParams*>(node->builtin_data); SoftmaxOpData* data = reinterpret_cast<SoftmaxOpData*>(node->user_data); TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output)); if (output->type == kTfLiteInt16) { TF_LITE_ENSURE(context, input->type == kTfLiteInt8 || input->type == kTfLiteUInt8 || input->type == kTfLiteInt16); } else { TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type); } TF_LITE_ENSURE(context, NumDimensions(input) >= 1); if (input->type == kTfLiteUInt8 || input->type == kTfLiteInt8) { switch (output->type) { case kTfLiteUInt8: case kTfLiteInt8: #ifdef TFLITE_SOFTMAX_USE_UINT16_LUT // Only apply when both input & output are uint8/int8 & build with clang // on aarch64. // TODO(b/143709993): Port to ARMv7 and other platforms. data->params.uint8_table1 = data->uint8_table1; data->params.uint8_table2 = data->uint8_table2; optimized_ops::PopulateSoftmaxUInt8LookupTable( &data->params, input->params.scale, params->beta); break; #endif case kTfLiteInt16: default: data->params.table = data->table; optimized_ops::PopulateSoftmaxLookupTable( &data->params, input->params.scale, params->beta); } data->params.zero_point = output->params.zero_point; data->params.scale = output->params.scale; } if (input->type == kTfLiteInt16) { TF_LITE_ENSURE_EQ(context, output->params.zero_point, 0); data->params.exp_lut = data->exp_lut; // exp LUT only used on nagative values // we consider exp(-10.0) is insignificant to accumulation gen_lut([](double value) { return std::exp(value); }, -10.0, 0.0, data->params.exp_lut, data->kInt16LUTArraySize); data->params.one_over_one_plus_x_lut = data->one_over_one_plus_x_lut; gen_lut([](double value) { return 1.0 / (1.0 + value); }, 0.0, 1.0, data->params.one_over_one_plus_x_lut, data->kInt16LUTArraySize); data->params.zero_point = output->params.zero_point; data->params.scale = output->params.scale; double input_scale_beta_rescale = input->params.scale * params->beta / (10.0 / 65535.0); // scale the input_diff such that [-65535, 0] // correspond to [-10.0, 0.0] QuantizeMultiplier(input_scale_beta_rescale, &data->params.input_multiplier, &data->params.input_left_shift); } return context->ResizeTensor(context, output, TfLiteIntArrayCopy(input->dims)); }
0
[ "CWE-125", "CWE-787" ]
tensorflow
1970c2158b1ffa416d159d03c3370b9a462aee35
301,772,399,545,705,900,000,000,000,000,000,000,000
70
[tflite]: Insert `nullptr` checks when obtaining tensors. As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages. We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`). PiperOrigin-RevId: 332521299 Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56
cJSON *cJSON_CreateTrue( void ) { cJSON *item = cJSON_New_Item(); if ( item ) item->type = cJSON_True; return item; }
1
[ "CWE-120", "CWE-119", "CWE-787" ]
iperf
91f2fa59e8ed80dfbf400add0164ee0e508e412a
146,480,624,830,980,330,000,000,000,000,000,000,000
7
Fix a buffer overflow / heap corruption issue that could occur if a malformed JSON string was passed on the control channel. This issue, present in the cJSON library, was already fixed upstream, so was addressed here in iperf3 by importing a newer version of cJSON (plus local ESnet modifications). Discovered and reported by Dave McDaniel, Cisco Talos. Based on a patch by @dopheide-esnet, with input from @DaveGamble. Cross-references: TALOS-CAN-0164, ESNET-SECADV-2016-0001, CVE-2016-4303 (cherry picked from commit ed94082be27d971a5e1b08b666e2c217cf470a40) Signed-off-by: Bruce A. Mah <[email protected]>
m4___line__ (struct obstack *obs, int argc, token_data **argv) { if (bad_argc (argv[0], argc, 1, 1)) return; shipout_int (obs, current_line); }
0
[]
m4
5345bb49077bfda9fabd048e563f9e7077fe335d
61,445,806,470,414,070,000,000,000,000,000,000,000
6
Minor security fix: Quote output of mkstemp. * src/builtin.c (mkstemp_helper): Produce quoted output. * doc/m4.texinfo (Mkstemp): Update the documentation and tests. * NEWS: Document this change. Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit bd9900d65eb9cd5add0f107e94b513fa267495ba)
uint32_t xffNumTrustedHops() const override { return 0; }
0
[ "CWE-400", "CWE-703" ]
envoy
afc39bea36fd436e54262f150c009e8d72db5014
235,711,380,554,789,900,000,000,000,000,000,000,000
1
Track byteSize of HeaderMap internally. Introduces a cached byte size updated internally in HeaderMap. The value is stored as an optional, and is cleared whenever a non-const pointer or reference to a HeaderEntry is accessed. The cached value can be set with refreshByteSize() which performs an iteration over the HeaderMap to sum the size of each key and value in the HeaderMap. Signed-off-by: Asra Ali <[email protected]>
static void lo_map_init(struct lo_map *map) { map->elems = NULL; map->nelems = 0; map->freelist = -1; }
0
[]
qemu
6084633dff3a05d63176e06d7012c7e15aba15be
24,414,775,667,412,000,000,000,000,000,000,000,000
6
tools/virtiofsd: xattr name mappings: Add option Add an option to define mappings of xattr names so that the client and server filesystems see different views. This can be used to have different SELinux mappings as seen by the guest, to run the virtiofsd with less privileges (e.g. in a case where it can't set trusted/system/security xattrs but you want the guest to be able to), or to isolate multiple users of the same name; e.g. trusted attributes used by stacking overlayfs. A mapping engine is used with 3 simple rules; the rules can be combined to allow most useful mapping scenarios. The ruleset is defined by -o xattrmap='rules...'. This patch doesn't use the rule maps yet. Signed-off-by: Dr. David Alan Gilbert <[email protected]> Message-Id: <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Signed-off-by: Dr. David Alan Gilbert <[email protected]>
struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk) { const struct tcp_sock *tp = tcp_sk(sk); struct sk_buff *stats; struct tcp_info info; stats = alloc_skb(3 * nla_total_size_64bit(sizeof(u64)), GFP_ATOMIC); if (!stats) return NULL; tcp_get_info_chrono_stats(tp, &info); nla_put_u64_64bit(stats, TCP_NLA_BUSY, info.tcpi_busy_time, TCP_NLA_PAD); nla_put_u64_64bit(stats, TCP_NLA_RWND_LIMITED, info.tcpi_rwnd_limited, TCP_NLA_PAD); nla_put_u64_64bit(stats, TCP_NLA_SNDBUF_LIMITED, info.tcpi_sndbuf_limited, TCP_NLA_PAD); return stats; }
0
[ "CWE-399", "CWE-835" ]
linux
ccf7abb93af09ad0868ae9033d1ca8108bdaec82
69,716,353,456,012,515,000,000,000,000,000,000,000
19
tcp: avoid infinite loop in tcp_splice_read() Splicing from TCP socket is vulnerable when a packet with URG flag is received and stored into receive queue. __tcp_splice_read() returns 0, and sk_wait_data() immediately returns since there is the problematic skb in queue. This is a nice way to burn cpu (aka infinite loop) and trigger soft lockups. Again, this gem was found by syzkaller tool. Fixes: 9c55e01c0cc8 ("[TCP]: Splice receive support.") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Dmitry Vyukov <[email protected]> Cc: Willy Tarreau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void tg3_enable_nvram_access(struct tg3 *tp) { if (tg3_flag(tp, 5750_PLUS) && !tg3_flag(tp, PROTECTED_NVRAM)) { u32 nvaccess = tr32(NVRAM_ACCESS); tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE); } }
0
[ "CWE-476", "CWE-119" ]
linux
715230a44310a8cf66fbfb5a46f9a62a9b2de424
74,231,927,860,724,910,000,000,000,000,000,000,000
8
tg3: fix length overflow in VPD firmware parsing Commit 184b89044fb6e2a74611dafa69b1dce0d98612c6 ("tg3: Use VPD fw version when present") introduced VPD parsing that contained a potential length overflow. Limit the hardware's reported firmware string length (max 255 bytes) to stay inside the driver's firmware string length (32 bytes). On overflow, truncate the formatted firmware string instead of potentially overwriting portions of the tg3 struct. http://cansecwest.com/slides/2013/PrivateCore%20CSW%202013.pdf Signed-off-by: Kees Cook <[email protected]> Reported-by: Oded Horovitz <[email protected]> Reported-by: Brad Spengler <[email protected]> Cc: [email protected] Cc: Matt Carlson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void * cm_copy_private_data(const void *private_data, u8 private_data_len) { void *data; if (!private_data || !private_data_len) return NULL; data = kmemdup(private_data, private_data_len, GFP_KERNEL); if (!data) return ERR_PTR(-ENOMEM); return data; }
0
[ "CWE-20" ]
linux
b2853fd6c2d0f383dbdf7427e263eb576a633867
121,111,002,550,664,570,000,000,000,000,000,000,000
14
IB/core: Don't resolve passive side RoCE L2 address in CMA REQ handler The code that resolves the passive side source MAC within the rdma_cm connection request handler was both redundant and buggy, so remove it. It was redundant since later, when an RC QP is modified to RTR state, the resolution will take place in the ib_core module. It was buggy because this callback also deals with UD SIDR exchange, for which we incorrectly looked at the REQ member of the CM event and dereferenced a random value. Fixes: dd5f03beb4f7 ("IB/core: Ethernet L2 attributes in verbs/cm structures") Signed-off-by: Moni Shoua <[email protected]> Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
void graphic_console_set_hwops(QemuConsole *con, const GraphicHwOps *hw_ops, void *opaque) { con->hw_ops = hw_ops; con->hw = opaque; }
0
[ "CWE-416" ]
qemu
a4afa548fc6dd9842ed86639b4d37d4d1c4ad480
232,428,529,757,616,100,000,000,000,000,000,000,000
7
char: move front end handlers in CharBackend Since the hanlders are associated with a CharBackend, rather than the CharDriverState, it is more appropriate to store in CharBackend. This avoids the handler copy dance in qemu_chr_fe_set_handlers() then mux_chr_update_read_handler(), by storing the CharBackend pointer directly. Also a mux CharDriver should go through mux->backends[focused], since chr->be will stay NULL. Before that, it was possible to call chr->handler by mistake with surprising results, for ex through qemu_chr_be_can_write(), which would result in calling the last set handler front end, not the one with focus. Signed-off-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey) { if (ri->type != CMS_RECIPINFO_TRANS) { CMSerr(CMS_F_CMS_RECIPIENTINFO_SET0_PKEY, CMS_R_NOT_KEY_TRANSPORT); return 0; } EVP_PKEY_free(ri->d.ktri->pkey); ri->d.ktri->pkey = pkey; return 1; }
0
[ "CWE-311", "CWE-327" ]
openssl
08229ad838c50f644d7e928e2eef147b4308ad64
24,575,330,220,518,373,000,000,000,000,000,000,000
10
Fix a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey An attack is simple, if the first CMS_recipientInfo is valid but the second CMS_recipientInfo is chosen ciphertext. If the second recipientInfo decodes to PKCS #1 v1.5 form plaintext, the correct encryption key will be replaced by garbage, and the message cannot be decoded, but if the RSA decryption fails, the correct encryption key is used and the recipient will not notice the attack. As a work around for this potential attack the length of the decrypted key must be equal to the cipher default key length, in case the certifiate is not given and all recipientInfo are tried out. The old behaviour can be re-enabled in the CMS code by setting the CMS_DEBUG_DECRYPT flag. Reviewed-by: Matt Caswell <[email protected]> (Merged from https://github.com/openssl/openssl/pull/9777) (cherry picked from commit 5840ed0cd1e6487d247efbc1a04136a41d7b3a37)
static void _slurm_rpc_job_ready(slurm_msg_t * msg) { int error_code, result; job_id_msg_t *id_msg = (job_id_msg_t *) msg->data; DEF_TIMERS; /* Locks: read job */ slurmctld_lock_t job_read_lock = { NO_LOCK, READ_LOCK, NO_LOCK, NO_LOCK, NO_LOCK }; slurm_msg_t response_msg; return_code_msg_t rc_msg; START_TIMER; lock_slurmctld(job_read_lock); error_code = job_node_ready(id_msg->job_id, &result); unlock_slurmctld(job_read_lock); END_TIMER2("_slurm_rpc_job_ready"); if (error_code) { debug2("_slurm_rpc_job_ready: %s", slurm_strerror(error_code)); slurm_send_rc_msg(msg, error_code); } else { debug2("_slurm_rpc_job_ready(%u)=%d %s", id_msg->job_id, result, TIME_STR); slurm_msg_t_init(&response_msg); response_msg.flags = msg->flags; response_msg.protocol_version = msg->protocol_version; response_msg.address = msg->address; response_msg.conn = msg->conn; rc_msg.return_code = result; response_msg.data = &rc_msg; if(_is_prolog_finished(id_msg->job_id)) { response_msg.msg_type = RESPONSE_JOB_READY; } else { response_msg.msg_type = RESPONSE_PROLOG_EXECUTING; } slurm_send_node_msg(msg->conn_fd, &response_msg); } }
0
[ "CWE-20" ]
slurm
033dc0d1d28b8d2ba1a5187f564a01c15187eb4e
284,291,843,861,806,060,000,000,000,000,000,000,000
39
Fix insecure handling of job requested gid. Only trust MUNGE signed values, unless the RPC was signed by SlurmUser or root. CVE-2018-10995.
static void arcmsr_hbaC_stop_bgrb(struct AdapterControlBlock *pACB) { struct MessageUnit_C __iomem *reg = pACB->pmuC; pACB->acb_flags &= ~ACB_F_MSG_START_BGRB; writel(ARCMSR_INBOUND_MESG0_STOP_BGRB, &reg->inbound_msgaddr0); writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, &reg->inbound_doorbell); if (!arcmsr_hbaC_wait_msgint_ready(pACB)) { printk(KERN_NOTICE "arcmsr%d: wait 'stop adapter background rebulid' timeout\n" , pACB->host->host_no); } return; }
0
[ "CWE-119", "CWE-787" ]
linux
7bc2b55a5c030685b399bb65b6baa9ccc3d1f167
322,609,499,454,563,970,000,000,000,000,000,000,000
13
scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer() We need to put an upper bound on "user_len" so the memcpy() doesn't overflow. Cc: <[email protected]> Reported-by: Marco Grassi <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Tomas Henzl <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
static int ax88179_auto_detach(struct usbnet *dev, int in_pm) { u16 tmp16; u8 tmp8; int (*fnr)(struct usbnet *, u8, u16, u16, u16, void *); int (*fnw)(struct usbnet *, u8, u16, u16, u16, const void *); if (!in_pm) { fnr = ax88179_read_cmd; fnw = ax88179_write_cmd; } else { fnr = ax88179_read_cmd_nopm; fnw = ax88179_write_cmd_nopm; } if (fnr(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0) return 0; if ((tmp16 == 0xFFFF) || (!(tmp16 & 0x0100))) return 0; /* Enable Auto Detach bit */ tmp8 = 0; fnr(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); tmp8 |= AX_CLK_SELECT_ULR; fnw(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); fnr(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); tmp16 |= AX_PHYPWR_RSTCTL_AT; fnw(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); return 0; }
0
[ "CWE-787" ]
linux
57bc3d3ae8c14df3ceb4e17d26ddf9eeab304581
163,839,144,871,899,980,000,000,000,000,000,000,000
33
net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup ax88179_rx_fixup() contains several out-of-bounds accesses that can be triggered by a malicious (or defective) USB device, in particular: - The metadata array (hdr_off..hdr_off+2*pkt_cnt) can be out of bounds, causing OOB reads and (on big-endian systems) OOB endianness flips. - A packet can overlap the metadata array, causing a later OOB endianness flip to corrupt data used by a cloned SKB that has already been handed off into the network stack. - A packet SKB can be constructed whose tail is far beyond its end, causing out-of-bounds heap data to be considered part of the SKB's data. I have tested that this can be used by a malicious USB device to send a bogus ICMPv6 Echo Request and receive an ICMPv6 Echo Reply in response that contains random kernel heap data. It's probably also possible to get OOB writes from this on a little-endian system somehow - maybe by triggering skb_cow() via IP options processing -, but I haven't tested that. Fixes: e2ca90c276e1 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver") Cc: [email protected] Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
storageConnectNumOfDefinedStoragePools(virConnectPtr conn) { if (virConnectNumOfDefinedStoragePoolsEnsureACL(conn) < 0) return -1; return virStoragePoolObjNumOfStoragePools(driver->pools, conn, false, virConnectNumOfDefinedStoragePoolsCheckACL); }
0
[]
libvirt
447f69dec47e1b0bd15ecd7cd49a9fd3b050fb87
93,838,004,646,798,630,000,000,000,000,000,000,000
8
storage_driver: Unlock object on ACL fail in storagePoolLookupByTargetPath 'virStoragePoolObjListSearch' returns a locked and refed object, thus we must release it on ACL permission failure. Fixes: 7aa0e8c0cb8 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1984318 Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Michal Privoznik <[email protected]>
void Http2Stream::OnDataChunk(uv_buf_t* chunk) { CHECK(!this->IsDestroyed()); Isolate* isolate = env()->isolate(); HandleScope scope(isolate); ssize_t len = -1; Local<Object> buf; if (chunk != nullptr) { len = chunk->len; buf = Buffer::New(isolate, chunk->base, len).ToLocalChecked(); } EmitData(len, buf, this->object()); }
0
[]
node
ce22d6f9178507c7a41b04ac4097b9ea902049e3
171,708,677,861,857,070,000,000,000,000,000,000,000
12
http2: add altsvc support Add support for sending and receiving ALTSVC frames. PR-URL: https://github.com/nodejs/node/pull/17917 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
struct sock *vsock_create_connected(struct sock *parent) { return __vsock_create(sock_net(parent), NULL, parent, GFP_KERNEL, parent->sk_type, 0); }
0
[ "CWE-667" ]
linux
c518adafa39f37858697ac9309c6cf1805581446
232,466,772,756,287,040,000,000,000,000,000,000,000
5
vsock: fix the race conditions in multi-transport support There are multiple similar bugs implicitly introduced by the commit c0cfa2d8a788fcf4 ("vsock: add multi-transports support") and commit 6a2c0962105ae8ce ("vsock: prevent transport modules unloading"). The bug pattern: [1] vsock_sock.transport pointer is copied to a local variable, [2] lock_sock() is called, [3] the local variable is used. VSOCK multi-transport support introduced the race condition: vsock_sock.transport value may change between [1] and [2]. Let's copy vsock_sock.transport pointer to local variables after the lock_sock() call. Fixes: c0cfa2d8a788fcf4 ("vsock: add multi-transports support") Signed-off-by: Alexander Popov <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Reviewed-by: Jorgen Hansen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
ssize_t enc_untrusted_getxattr(const char *path, const char *name, void *value, size_t size) { return EnsureInitializedAndDispatchSyscall(asylo::system_call::kSYS_getxattr, path, name, value, size); }
0
[ "CWE-125" ]
asylo
b1d120a2c7d7446d2cc58d517e20a1b184b82200
324,978,419,676,635,570,000,000,000,000,000,000,000
5
Check for return size in enc_untrusted_read Check return size does not exceed requested. The returned result and content still cannot be trusted, but it's expected behavior when not using a secure file system. PiperOrigin-RevId: 333827386 Change-Id: I0bdec0aec9356ea333dc8c647eba5d2772875f29
juniper_atm1_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { int llc_hdrlen; struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_ATM1; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; if (l2info.cookie[0] == 0x80) { /* OAM cell ? */ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC); return l2info.header_len; } if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); if (llc_hdrlen > 0) return l2info.header_len; } if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1); /* FIXME check if frame was recognized */ return l2info.header_len; } if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */ return l2info.header_len; return l2info.header_len; }
1
[ "CWE-125", "CWE-787" ]
tcpdump
1dcd10aceabbc03bf571ea32b892c522cbe923de
179,031,425,222,972,800,000,000,000,000,000,000,000
37
CVE-2017-12897/ISO CLNS: Use ND_TTEST() for the bounds checks in isoclns_print(). This fixes a buffer over-read discovered by Kamil Frankowicz. Don't pass the remaining caplen - that's too hard to get right, and we were getting it wrong in at least one case; just use ND_TTEST(). Add a test using the capture file supplied by the reporter(s).
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
0
[ "CWE-416", "CWE-703" ]
server
08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917
144,662,120,775,489,900,000,000,000,000,000,000,000
1
MDEV-24176 Server crashes after insert in the table with virtual column generated using date_format() and if() vcol_info->expr is allocated on expr_arena at parsing stage. Since expr item is allocated on expr_arena all its containee items must be allocated on expr_arena too. Otherwise fix_session_expr() will encounter prematurely freed item. When table is reopened from cache vcol_info contains stale expression. We refresh expression via TABLE::vcol_fix_exprs() but first we must prepare a proper context (Vcol_expr_context) which meets some requirements: 1. As noted above expr update must be done on expr_arena as there may be new items created. It was a bug in fix_session_expr_for_read() and was just not reproduced because of no second refix. Now refix is done for more cases so it does reproduce. Tests affected: vcol.binlog 2. Also name resolution context must be narrowed to the single table. Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes 3. sql_mode must be clean and not fail expr update. sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc must not affect vcol expression update. If the table was created successfully any further evaluation must not fail. Tests affected: main.func_like Reviewed by: Sergei Golubchik <[email protected]>
MonoArray* mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues) { MonoArray *result; MonoMethodSignature *sig; MonoObject *arg; char *buffer, *p; guint32 buflen, i; MONO_ARCH_SAVE_REGS; if (strcmp (ctor->vtable->klass->name, "MonoCMethod")) { /* sig is freed later so allocate it in the heap */ sig = ctor_builder_to_signature (NULL, (MonoReflectionCtorBuilder*)ctor); } else { sig = mono_method_signature (((MonoReflectionMethod*)ctor)->method); } g_assert (mono_array_length (ctorArgs) == sig->param_count); buflen = 256; p = buffer = g_malloc (buflen); /* write the prolog */ *p++ = 1; *p++ = 0; for (i = 0; i < sig->param_count; ++i) { arg = mono_array_get (ctorArgs, MonoObject*, i); encode_cattr_value (assembly->assembly, buffer, p, &buffer, &p, &buflen, sig->params [i], arg, NULL); } i = 0; if (properties) i += mono_array_length (properties); if (fields) i += mono_array_length (fields); *p++ = i & 0xff; *p++ = (i >> 8) & 0xff; if (properties) { MonoObject *prop; for (i = 0; i < mono_array_length (properties); ++i) { MonoType *ptype; char *pname; prop = mono_array_get (properties, gpointer, i); get_prop_name_and_type (prop, &pname, &ptype); *p++ = 0x54; /* PROPERTY signature */ encode_named_val (assembly, buffer, p, &buffer, &p, &buflen, ptype, pname, (MonoObject*)mono_array_get (propValues, gpointer, i)); g_free (pname); } } if (fields) { MonoObject *field; for (i = 0; i < mono_array_length (fields); ++i) { MonoType *ftype; char *fname; field = mono_array_get (fields, gpointer, i); get_field_name_and_type (field, &fname, &ftype); *p++ = 0x53; /* FIELD signature */ encode_named_val (assembly, buffer, p, &buffer, &p, &buflen, ftype, fname, (MonoObject*)mono_array_get (fieldValues, gpointer, i)); g_free (fname); } } g_assert (p - buffer <= buflen); buflen = p - buffer; result = mono_array_new (mono_domain_get (), mono_defaults.byte_class, buflen); p = mono_array_addr (result, char, 0); memcpy (p, buffer, buflen); g_free (buffer); if (strcmp (ctor->vtable->klass->name, "MonoCMethod")) g_free (sig); return result;
0
[ "CWE-20" ]
mono
4905ef1130feb26c3150b28b97e4a96752e0d399
102,755,620,070,830,530,000,000,000,000,000,000,000
72
Handle invalid instantiation of generic methods. * verify.c: Add new function to internal verifier API to check method instantiations. * reflection.c (mono_reflection_bind_generic_method_parameters): Check the instantiation before returning it. Fixes #655847
rend_service_begin_parse_intro(const uint8_t *request, size_t request_len, uint8_t type, char **err_msg_out) { rend_intro_cell_t *rv = NULL; char *err_msg = NULL; if (!request || request_len <= 0) goto err; if (!(type == 1 || type == 2)) goto err; /* First, check that the cell is long enough to be a sensible INTRODUCE */ /* min key length plus digest length plus nickname length */ if (request_len < (DIGEST_LEN + REND_COOKIE_LEN + (MAX_NICKNAME_LEN + 1) + DH_KEY_LEN + 42)) { if (err_msg_out) { tor_asprintf(&err_msg, "got a truncated INTRODUCE%d cell", (int)type); } goto err; } /* Allocate a new parsed cell structure */ rv = tor_malloc_zero(sizeof(*rv)); /* Set the type */ rv->type = type; /* Copy in the ID */ memcpy(rv->pk, request, DIGEST_LEN); /* Copy in the ciphertext */ rv->ciphertext = tor_malloc(request_len - DIGEST_LEN); memcpy(rv->ciphertext, request + DIGEST_LEN, request_len - DIGEST_LEN); rv->ciphertext_len = request_len - DIGEST_LEN; goto done; err: rend_service_free_intro(rv); rv = NULL; if (err_msg_out && !err_msg) { tor_asprintf(&err_msg, "unknown INTRODUCE%d error", (int)type); } done: if (err_msg_out) *err_msg_out = err_msg; else tor_free(err_msg); return rv; }
0
[ "CWE-532" ]
tor
09ea89764a4d3a907808ed7d4fe42abfe64bd486
245,560,265,724,059,570,000,000,000,000,000,000,000
57
Fix log-uninitialized-stack bug in rend_service_intro_established. Fixes bug 23490; bugfix on 0.2.7.2-alpha. TROVE-2017-008 CVE-2017-0380
struct dentry *kern_path_locked(const char *name, struct path *path) { struct filename *filename = getname_kernel(name); struct nameidata nd; struct dentry *d; int err; if (IS_ERR(filename)) return ERR_CAST(filename); err = filename_lookup(AT_FDCWD, filename, LOOKUP_PARENT, &nd); if (err) { d = ERR_PTR(err); goto out; } if (nd.last_type != LAST_NORM) { path_put(&nd.path); d = ERR_PTR(-EINVAL); goto out; } mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); d = __lookup_hash(&nd.last, nd.path.dentry, 0); if (IS_ERR(d)) { mutex_unlock(&nd.path.dentry->d_inode->i_mutex); path_put(&nd.path); goto out; } *path = nd.path; out: putname(filename); return d; }
0
[ "CWE-416" ]
linux
f15133df088ecadd141ea1907f2c96df67c729f0
64,644,250,480,151,710,000,000,000,000,000,000,000
32
path_openat(): fix double fput() path_openat() jumps to the wrong place after do_tmpfile() - it has already done path_cleanup() (as part of path_lookupat() called by do_tmpfile()), so doing that again can lead to double fput(). Cc: [email protected] # v3.11+ Signed-off-by: Al Viro <[email protected]>
operator()(Halfedge_handle e, const Tag_true& ) const { return D_.face(e)==f_ || D_.face(D_.twin(e))==f_; }
0
[ "CWE-269" ]
cgal
618b409b0fbcef7cb536a4134ae3a424ef5aae45
196,521,565,289,887,730,000,000,000,000,000,000,000
4
Fix Nef_2 and Nef_S2 IO
bool handlers_empty() const { return handlers_.empty(); }
0
[]
nghttp2
95efb3e19d174354ca50c65d5d7227d92bcd60e1
242,162,295,606,703,550,000,000,000,000,000,000,000
1
Don't read too greedily
static inline int tcp_fin_time(const struct sock *sk) { int fin_timeout = tcp_sk(sk)->linger2 ? : sock_net(sk)->ipv4.sysctl_tcp_fin_timeout; const int rto = inet_csk(sk)->icsk_rto; if (fin_timeout < (rto << 2) - (rto >> 1)) fin_timeout = (rto << 2) - (rto >> 1); return fin_timeout; }
0
[ "CWE-416", "CWE-269" ]
linux
bb1fceca22492109be12640d49f5ea5a544c6bb4
74,447,594,894,468,820,000,000,000,000,000,000,000
10
tcp: fix use after free in tcp_xmit_retransmit_queue() When tcp_sendmsg() allocates a fresh and empty skb, it puts it at the tail of the write queue using tcp_add_write_queue_tail() Then it attempts to copy user data into this fresh skb. If the copy fails, we undo the work and remove the fresh skb. Unfortunately, this undo lacks the change done to tp->highest_sack and we can leave a dangling pointer (to a freed skb) Later, tcp_xmit_retransmit_queue() can dereference this pointer and access freed memory. For regular kernels where memory is not unmapped, this might cause SACK bugs because tcp_highest_sack_seq() is buggy, returning garbage instead of tp->snd_nxt, but with various debug features like CONFIG_DEBUG_PAGEALLOC, this can crash the kernel. This bug was found by Marco Grassi thanks to syzkaller. Fixes: 6859d49475d4 ("[TCP]: Abstract tp->highest_sack accessing & point to next skb") Reported-by: Marco Grassi <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Ilpo Järvinen <[email protected]> Cc: Yuchung Cheng <[email protected]> Cc: Neal Cardwell <[email protected]> Acked-by: Neal Cardwell <[email protected]> Reviewed-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void MSLEndElement(void *context,const xmlChar *tag) { ssize_t n; MSLInfo *msl_info; /* Called when the end of an element has been detected. */ (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)", tag); msl_info=(MSLInfo *) context; n=msl_info->n; switch (*tag) { case 'C': case 'c': { if (LocaleCompare((const char *) tag,"comment") == 0 ) { (void) DeleteImageProperty(msl_info->image[n],"comment"); if (msl_info->content == (char *) NULL) break; StripString(msl_info->content); (void) SetImageProperty(msl_info->image[n],"comment", msl_info->content); break; } break; } case 'G': case 'g': { if (LocaleCompare((const char *) tag, "group") == 0 ) { if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 ) { ssize_t i = (ssize_t) (msl_info->group_info[msl_info->number_groups-1].numImages); while ( i-- ) { if (msl_info->image[msl_info->n] != (Image *) NULL) msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]); msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]); msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]); msl_info->n--; } } msl_info->number_groups--; } break; } case 'I': case 'i': { if (LocaleCompare((const char *) tag, "image") == 0) MSLPopImage(msl_info); break; } case 'L': case 'l': { if (LocaleCompare((const char *) tag,"label") == 0 ) { (void) DeleteImageProperty(msl_info->image[n],"label"); if (msl_info->content == (char *) NULL) break; StripString(msl_info->content); (void) SetImageProperty(msl_info->image[n],"label", msl_info->content); break; } break; } case 'M': case 'm': { if (LocaleCompare((const char *) tag, "msl") == 0 ) { /* This our base element. at the moment we don't do anything special but someday we might! */ } break; } default: break; } if (msl_info->content != (char *) NULL) msl_info->content=DestroyString(msl_info->content); }
0
[ "CWE-772" ]
ImageMagick6
bb77f9e905597c7ab1e92042c7de418d999b00bf
146,768,956,227,395,800,000,000,000,000,000,000,000
95
Fixed leaking of the image when writing an MSL image.
dnsc_shared_secrets_delkeyfunc(void *k, void* ATTR_UNUSED(arg)) { struct shared_secret_cache_key* ssk = (struct shared_secret_cache_key*)k; lock_rw_destroy(&ssk->entry.lock); free(ssk); }
0
[ "CWE-190" ]
unbound
02080f6b180232f43b77f403d0c038e9360a460f
217,737,258,242,144,670,000,000,000,000,000,000,000
6
- Fix Integer Overflows in Size Calculations, reported by X41 D-Sec.
static int fixed_mtrr_addr_to_seg(u64 addr) { struct fixed_mtrr_segment *mtrr_seg; int seg, seg_num = ARRAY_SIZE(fixed_seg_table); for (seg = 0; seg < seg_num; seg++) { mtrr_seg = &fixed_seg_table[seg]; if (mtrr_seg->start <= addr && addr < mtrr_seg->end) return seg; } return -1; }
0
[ "CWE-284" ]
linux
9842df62004f366b9fed2423e24df10542ee0dc5
168,039,834,043,308,320,000,000,000,000,000,000,000
13
KVM: MTRR: remove MSR 0x2f8 MSR 0x2f8 accessed the 124th Variable Range MTRR ever since MTRR support was introduced by 9ba075a664df ("KVM: MTRR support"). 0x2f8 became harmful when 910a6aae4e2e ("KVM: MTRR: exactly define the size of variable MTRRs") shrinked the array of VR MTRRs from 256 to 8, which made access to index 124 out of bounds. The surrounding code only WARNs in this situation, thus the guest gained a limited read/write access to struct kvm_arch_vcpu. 0x2f8 is not a valid VR MTRR MSR, because KVM has/advertises only 16 VR MTRR MSRs, 0x200-0x20f. Every VR MTRR is set up using two MSRs, 0x2f8 was treated as a PHYSBASE and 0x2f9 would be its PHYSMASK, but 0x2f9 was not implemented in KVM, therefore 0x2f8 could never do anything useful and getting rid of it is safe. This fixes CVE-2016-3713. Fixes: 910a6aae4e2e ("KVM: MTRR: exactly define the size of variable MTRRs") Cc: [email protected] Reported-by: David Matlack <[email protected]> Signed-off-by: Andy Honig <[email protected]> Signed-off-by: Radim Krčmář <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
void WebContents::PasteAndMatchStyle() { web_contents()->PasteAndMatchStyle(); }
0
[]
electron
e9fa834757f41c0b9fe44a4dffe3d7d437f52d34
223,143,864,529,759,450,000,000,000,000,000,000,000
3
fix: ensure ElectronBrowser mojo service is only bound to appropriate render frames (#33344) * fix: ensure ElectronBrowser mojo service is only bound to authorized render frames Notes: no-notes * refactor: extract electron API IPC to its own mojo interface * fix: just check main frame not primary main frame Co-authored-by: Samuel Attard <[email protected]> Co-authored-by: Samuel Attard <[email protected]>
f_setwinvar(typval_T *argvars, typval_T *rettv UNUSED) { if (in_vim9script() && (check_for_number_arg(argvars, 0) == FAIL || check_for_string_arg(argvars, 1) == FAIL)) return; setwinvar(argvars, 0); }
0
[ "CWE-476" ]
vim
0f6e28f686dbb59ab3b562408ab9b2234797b9b1
121,831,989,678,385,440,000,000,000,000,000,000,000
9
patch 8.2.4428: crash when switching tabpage while in the cmdline window Problem: Crash when switching tabpage while in the cmdline window. Solution: Disallow switching tabpage when in the cmdline window.
void iov_iter_bvec(struct iov_iter *i, int direction, const struct bio_vec *bvec, unsigned long nr_segs, size_t count) { BUG_ON(!(direction & ITER_BVEC)); i->type = direction; i->bvec = bvec; i->nr_segs = nr_segs; i->iov_offset = 0; i->count = count; }
0
[ "CWE-200" ]
linux
b9dc6f65bc5e232d1c05fe34b5daadc7e8bbf1fb
113,739,420,224,955,600,000,000,000,000,000,000,000
11
fix a fencepost error in pipe_advance() The logics in pipe_advance() used to release all buffers past the new position failed in cases when the number of buffers to release was equal to pipe->buffers. If that happened, none of them had been released, leaving pipe full. Worse, it was trivial to trigger and we end up with pipe full of uninitialized pages. IOW, it's an infoleak. Cc: [email protected] # v4.9 Reported-by: "Alan J. Wylie" <[email protected]> Tested-by: "Alan J. Wylie" <[email protected]> Signed-off-by: Al Viro <[email protected]>
SWTPM_CheckHMAC(tlv_data *hmac, tlv_data *encrypted_data, const TPM_SYMMETRIC_KEY_DATA *tpm_symmetric_key_token, const unsigned char *ivec, uint32_t ivec_length) { const unsigned char *data; uint32_t data_length; unsigned int md_len; unsigned char md[EVP_MAX_MD_SIZE]; md_len = EVP_MD_size(EVP_sha256()); if (md_len > hmac->tlv.length) { logprintf(STDOUT_FILENO, "Insufficient bytes for CheckHMAC()\n"); return TPM_FAIL; } data = encrypted_data->u.ptr; data_length = encrypted_data->tlv.length; if (!SWTPM_HMAC(md, &md_len, tpm_symmetric_key_token->userKey, tpm_symmetric_key_token->userKeyLength, data, data_length, ivec, ivec_length)) { logprintf(STDOUT_FILENO, "HMAC() call failed.\n"); return TPM_FAIL; } if (memcmp(hmac->u.ptr, md, md_len)) { logprintf(STDOUT_FILENO, "Verification of HMAC failed. " "Data integrity is compromised\n"); /* TPM_DECRYPT_ERROR indicates (to libtpms) that something exists but we have the wrong key. */ return TPM_DECRYPT_ERROR; } return TPM_SUCCESS; }
0
[]
swtpm
cae5991423826f21b11f7a5bc7f7b2b538bde2a2
102,670,743,510,949,260,000,000,000,000,000,000,000
36
swtpm: Do not follow symlinks when opening lockfile (CVE-2020-28407) This patch addresses CVE-2020-28407. Prevent us from following symliks when we open the lockfile for writing. Signed-off-by: Stefan Berger <[email protected]>
static void perf_event_enable_on_exec(int ctxn) { struct perf_event_context *ctx, *clone_ctx = NULL; struct perf_cpu_context *cpuctx; struct perf_event *event; unsigned long flags; int enabled = 0; local_irq_save(flags); ctx = current->perf_event_ctxp[ctxn]; if (!ctx || !ctx->nr_events) goto out; cpuctx = __get_cpu_context(ctx); perf_ctx_lock(cpuctx, ctx); ctx_sched_out(ctx, cpuctx, EVENT_TIME); list_for_each_entry(event, &ctx->event_list, event_entry) enabled |= event_enable_on_exec(event, ctx); /* * Unclone and reschedule this context if we enabled any event. */ if (enabled) { clone_ctx = unclone_ctx(ctx); ctx_resched(cpuctx, ctx); } perf_ctx_unlock(cpuctx, ctx); out: local_irq_restore(flags); if (clone_ctx) put_ctx(clone_ctx); }
0
[ "CWE-362", "CWE-125" ]
linux
321027c1fe77f892f4ea07846aeae08cefbbb290
65,982,984,897,491,440,000,000,000,000,000,000,000
34
perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context. The problem is exactly that described in commit: f63a8daa5812 ("perf: Fix event->ctx locking") ... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us. That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly. So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead). Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks. Reported-by: Di Shen (Keen Lab) Tested-by: John Dias <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Min Chong <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Fixes: f63a8daa5812 ("perf: Fix event->ctx locking") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
check_for_string_or_func_arg(typval_T *args, int idx) { if (args[idx].v_type != VAR_PARTIAL && args[idx].v_type != VAR_FUNC && args[idx].v_type != VAR_STRING) { semsg(_(e_string_or_function_required_for_argument_nr), idx + 1); return FAIL; } return OK; }
0
[ "CWE-125", "CWE-122" ]
vim
1e56bda9048a9625bce6e660938c834c5c15b07d
125,334,884,475,490,040,000,000,000,000,000,000,000
11
patch 9.0.0104: going beyond allocated memory when evaluating string constant Problem: Going beyond allocated memory when evaluating string constant. Solution: Properly skip over <Key> form.
xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data, const char *filename) { int ret = 0; xmlParserCtxtPtr ctxt; ctxt = xmlCreateFileParserCtxt(filename); if (ctxt == NULL) return -1; if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler) xmlFree(ctxt->sax); ctxt->sax = sax; xmlDetectSAX2(ctxt); if (user_data != NULL) ctxt->userData = user_data; xmlParseDocument(ctxt); if (ctxt->wellFormed) ret = 0; else { if (ctxt->errNo != 0) ret = ctxt->errNo; else ret = -1; } if (sax != NULL) ctxt->sax = NULL; if (ctxt->myDoc != NULL) { xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL; } xmlFreeParserCtxt(ctxt); return ret; }
0
[ "CWE-119" ]
libxml2
6a36fbe3b3e001a8a840b5c1fdd81cefc9947f0d
246,510,422,153,762,800,000,000,000,000,000,000,000
35
Fix potential out of bound access
} void free_last_set(REP_SETS *sets) { sets->count--; sets->extra++;
0
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
173,829,533,125,516,620,000,000,000,000,000,000,000
6
WL#6791 : Redefine client --ssl option to imply enforced encryption # Changed the meaning of the --ssl=1 option of all client binaries to mean force ssl, not try ssl and fail over to eunecrypted # Added a new MYSQL_OPT_SSL_ENFORCE mysql_options() option to specify that an ssl connection is required. # Added a new macro SSL_SET_OPTIONS() to the client SSL handling headers that sets all the relevant SSL options at once. # Revamped all of the current native clients to use the new macro # Removed some Windows line endings. # Added proper handling of the new option into the ssl helper headers. # If SSL is mandatory assume that the media is secure enough for the sha256 plugin to do unencrypted password exchange even before establishing a connection. # Set the default ssl cipher to DHE-RSA-AES256-SHA if none is specified. # updated test cases that require a non-default cipher to spawn a mysql command line tool binary since mysqltest has no support for specifying ciphers. # updated the replication slave connection code to always enforce SSL if any of the SSL config options is present. # test cases added and updated. # added a mysql_get_option() API to return mysql_options() values. Used the new API inside the sha256 plugin. # Fixed compilation warnings because of unused variables. # Fixed test failures (mysql_ssl and bug13115401) # Fixed whitespace issues. # Fully implemented the mysql_get_option() function. # Added a test case for mysql_get_option() # fixed some trailing whitespace issues # fixed some uint/int warnings in mysql_client_test.c # removed shared memory option from non-windows get_options tests # moved MYSQL_OPT_LOCAL_INFILE to the uint options
ex_pwd(exarg_T *eap UNUSED) { if (mch_dirname(NameBuff, MAXPATHL) == OK) { #ifdef BACKSLASH_IN_FILENAME slash_adjust(NameBuff); #endif if (p_verbose > 0) { char *context = "global"; if (last_chdir_reason != NULL) context = last_chdir_reason; else if (curwin->w_localdir != NULL) context = "window"; else if (curtab->tp_localdir != NULL) context = "tabpage"; smsg("[%s] %s", context, (char *)NameBuff); } else msg((char *)NameBuff); } else emsg(_("E187: Unknown")); }
0
[ "CWE-416" ]
vim
e031fe90cf2e375ce861ff5e5e281e4ad229ebb9
131,983,371,761,335,040,000,000,000,000,000,000,000
25
patch 8.2.3741: using freed memory in open command Problem: Using freed memory in open command. Solution: Make a copy of the current line.
MOBI_RET mobi_reconstruct_orth(const MOBIRawml *rawml, MOBIFragment *first, size_t *new_size) { MOBITrie *infl_trie = NULL; bool is_infl_v2 = mobi_indx_has_tag(rawml->orth, INDX_TAGARR_ORTH_INFL); bool is_infl_v1 = false; if (is_infl_v2 == false) { is_infl_v1 = mobi_indx_has_tag(rawml->infl, INDX_TAGARR_INFL_PARTS_V1); } debug_print("Reconstructing orth index %s\n", (is_infl_v1)?"(infl v1)":(is_infl_v2)?"(infl v2)":""); if (is_infl_v1) { size_t total = rawml->infl->entries_count; size_t j = 0; while (j < total) { MOBI_RET ret = mobi_trie_insert_infl(&infl_trie, rawml->infl, j++); if (ret != MOBI_SUCCESS || infl_trie == NULL) { debug_print("Building trie for inflections failed%s", "\n"); mobi_trie_free(infl_trie); is_infl_v1 = false; } } } MOBIFragment *curr = first; size_t i = 0; const size_t count = rawml->orth->entries_count; const char *start_tag1 = "<idx:entry><idx:orth value=\"%s\">%s</idx:orth></idx:entry>"; const char *start_tag2 = "<idx:entry scriptable=\"yes\"><idx:orth value=\"%s\">%s</idx:orth>"; const char *end_tag = "</idx:entry>"; const size_t start_tag1_len = strlen(start_tag1) - 4; const size_t start_tag2_len = strlen(start_tag2) - 4; const size_t end_tag_len = strlen(end_tag); uint32_t prev_startpos = 0; while (i < count) { const MOBIIndexEntry *orth_entry = &rawml->orth->entries[i]; const char *label = orth_entry->label; uint32_t entry_startpos; MOBI_RET ret = mobi_get_indxentry_tagvalue(&entry_startpos, orth_entry, INDX_TAG_ORTH_POSITION); if (ret != MOBI_SUCCESS) { i++; continue; } size_t entry_length = 0; uint32_t entry_textlen = 0; mobi_get_indxentry_tagvalue(&entry_textlen, orth_entry, INDX_TAG_ORTH_LENGTH); char *start_tag; if (entry_textlen == 0) { entry_length += start_tag1_len + strlen(label); start_tag = (char *) start_tag1; } else { entry_length += start_tag2_len + strlen(label); start_tag = (char *) start_tag2; } char *entry_text; if (rawml->infl) { char *infl_tag = malloc(INDX_INFLTAG_SIZEMAX + 1); if (infl_tag == NULL) { debug_print("%s\n", "Memory allocation failed"); mobi_trie_free(infl_trie); return MOBI_MALLOC_FAILED; } infl_tag[0] = '\0'; if (is_infl_v2) { ret = mobi_reconstruct_infl(infl_tag, rawml->infl, orth_entry); } else if (is_infl_v1) { ret = mobi_reconstruct_infl_v1(infl_tag, infl_trie, orth_entry); } else { debug_print("Unknown inflection scheme?%s", "\n"); } if (ret != MOBI_SUCCESS) { free(infl_tag); return ret; } entry_length += strlen(infl_tag); entry_text = malloc(entry_length + 1); if (entry_text == NULL) { debug_print("%s\n", "Memory allocation failed"); mobi_trie_free(infl_trie); free(infl_tag); return MOBI_MALLOC_FAILED; } snprintf(entry_text, entry_length + 1, start_tag, label, infl_tag); free(infl_tag); } else { entry_text = malloc(entry_length + 1); if (entry_text == NULL) { debug_print("%s\n", "Memory allocation failed"); mobi_trie_free(infl_trie); return MOBI_MALLOC_FAILED; } snprintf(entry_text, entry_length + 1, start_tag, label, ""); } if (entry_startpos < prev_startpos) { curr = first; } curr = mobi_list_insert(curr, SIZE_MAX, (unsigned char *) entry_text, entry_length, true, entry_startpos); prev_startpos = entry_startpos; if (curr == NULL) { debug_print("%s\n", "Memory allocation failed"); mobi_trie_free(infl_trie); return MOBI_MALLOC_FAILED; } *new_size += curr->size; if (entry_textlen > 0) { /* FIXME: avoid end_tag duplication */ curr = mobi_list_insert(curr, SIZE_MAX, (unsigned char *) strdup(end_tag), end_tag_len, true, entry_startpos + entry_textlen); if (curr == NULL) { debug_print("%s\n", "Memory allocation failed"); mobi_trie_free(infl_trie); return MOBI_MALLOC_FAILED; } *new_size += curr->size; } i++; } mobi_trie_free(infl_trie); return MOBI_SUCCESS; }
0
[ "CWE-703", "CWE-125" ]
libmobi
fb1ab50e448ddbed746fd27ae07469bc506d838b
276,822,032,415,671,200,000,000,000,000,000,000,000
123
Fix array boundary check when parsing inflections which could result in buffer over-read with corrupt input
TEST(RouterFilterUtilityTest, SetUpstreamScheme) { TestScopedRuntime scoped_runtime; // With no scheme and x-forwarded-proto, set scheme based on encryption level { Http::TestRequestHeaderMapImpl headers; FilterUtility::setUpstreamScheme(headers, false, false); EXPECT_EQ("http", headers.get_(":scheme")); } { Http::TestRequestHeaderMapImpl headers; FilterUtility::setUpstreamScheme(headers, true, true); EXPECT_EQ("https", headers.get_(":scheme")); } // With invalid x-forwarded-proto, still use scheme. { Http::TestRequestHeaderMapImpl headers; headers.setForwardedProto("foo"); FilterUtility::setUpstreamScheme(headers, true, true); EXPECT_EQ("https", headers.get_(":scheme")); } // Use valid x-forwarded-proto. { Http::TestRequestHeaderMapImpl headers; headers.setForwardedProto(Http::Headers::get().SchemeValues.Http); FilterUtility::setUpstreamScheme(headers, true, true); EXPECT_EQ("http", headers.get_(":scheme")); } // Trust scheme over x-forwarded-proto. { Http::TestRequestHeaderMapImpl headers; headers.setScheme(Http::Headers::get().SchemeValues.Https); headers.setForwardedProto(Http::Headers::get().SchemeValues.Http); FilterUtility::setUpstreamScheme(headers, false, false); EXPECT_EQ("https", headers.get_(":scheme")); } // New logic uses downstream crypto { Http::TestRequestHeaderMapImpl headers; FilterUtility::setUpstreamScheme(headers, false, true); EXPECT_EQ("http", headers.get_(":scheme")); } // Legacy logic uses upstream crypto Runtime::LoaderSingleton::getExisting()->mergeValues( {{"envoy.reloadable_features.preserve_downstream_scheme", "false"}}); { Http::TestRequestHeaderMapImpl headers; FilterUtility::setUpstreamScheme(headers, false, true); EXPECT_EQ("https", headers.get_(":scheme")); } }
0
[ "CWE-703" ]
envoy
18871dbfb168d3512a10c78dd267ff7c03f564c6
242,174,381,663,913,300,000,000,000,000,000,000,000
56
[1.18] CVE-2022-21655 Crash with direct_response Signed-off-by: Otto van der Schaaf <[email protected]>
ulong STDCALL mysql_get_server_version(MYSQL *mysql) { ulong major= 0, minor= 0, version= 0; if (mysql->server_version) { char *pos= mysql->server_version, *end_pos; major= strtoul(pos, &end_pos, 10); pos=end_pos+1; minor= strtoul(pos, &end_pos, 10); pos=end_pos+1; version= strtoul(pos, &end_pos, 10); } else { set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); } return major*10000 + minor*100 + version;
0
[ "CWE-254" ]
mysql-server
13380bf81f6bc20d39549f531f9acebdfb5a8c37
268,666,771,558,784,050,000,000,000,000,000,000,000
18
Bug #22295186: CERTIFICATE VALIDATION BUG IN MYSQL MAY ALLOW MITM
static int check_direct_IO(struct inode *inode, struct iov_iter *iter, loff_t offset) { unsigned i_blkbits = READ_ONCE(inode->i_blkbits); unsigned blkbits = i_blkbits; unsigned blocksize_mask = (1 << blkbits) - 1; unsigned long align = offset | iov_iter_alignment(iter); struct block_device *bdev = inode->i_sb->s_bdev; if (align & blocksize_mask) { if (bdev) blkbits = blksize_bits(bdev_logical_block_size(bdev)); blocksize_mask = (1 << blkbits) - 1; if (align & blocksize_mask) return -EINVAL; return 1; } return 0; }
0
[ "CWE-476" ]
linux
4969c06a0d83c9c3dc50b8efcdc8eeedfce896f6
3,562,094,780,025,009,000,000,000,000,000,000,000
19
f2fs: support swap file w/ DIO Signed-off-by: Jaegeuk Kim <[email protected]>
int update_approximate_dstblt_order(ORDER_INFO* orderInfo, const DSTBLT_ORDER* dstblt) { return 32; }
0
[ "CWE-415" ]
FreeRDP
67c2aa52b2ae0341d469071d1bc8aab91f8d2ed8
321,490,037,384,884,240,000,000,000,000,000,000,000
4
Fixed #6013: Check new length is > 0
bool subselect_rowid_merge_engine::partial_match() { Ordered_key *min_key; /* Key that contains the current minimum position. */ rownum_t min_row_num; /* Current row number of min_key. */ Ordered_key *cur_key; rownum_t cur_row_num; uint count_nulls_in_search_key= 0; uint max_null_in_any_row= ((select_materialize_with_stats *) result)->get_max_nulls_in_row(); bool res= FALSE; /* If there is a non-NULL key, it must be the first key in the keys array. */ DBUG_ASSERT(!non_null_key || (non_null_key && merge_keys[0] == non_null_key)); /* The prioryty queue for keys must be empty. */ DBUG_ASSERT(!pq.elements); /* All data accesses during execution are via handler::ha_rnd_pos() */ if (tmp_table->file->ha_rnd_init_with_error(0)) { res= FALSE; goto end; } /* Check if there is a match for the columns of the only non-NULL key. */ if (non_null_key && !non_null_key->lookup()) { res= FALSE; goto end; } /* If all nullable columns contain only NULLs, then there is a guaranteed partial match, and we don't need to search for a matching row. */ if (has_covering_null_columns) { res= TRUE; goto end; } if (non_null_key) queue_insert(&pq, (uchar *) non_null_key); /* Do not add the non_null_key, since it was already processed above. */ bitmap_clear_all(&matching_outer_cols); for (uint i= MY_TEST(non_null_key); i < merge_keys_count; i++) { DBUG_ASSERT(merge_keys[i]->get_column_count() == 1); if (merge_keys[i]->get_search_key(0)->null_value) { ++count_nulls_in_search_key; bitmap_set_bit(&matching_outer_cols, merge_keys[i]->get_keyid()); } else if (merge_keys[i]->lookup()) queue_insert(&pq, (uchar *) merge_keys[i]); } /* If the outer reference consists of only NULLs, or if it has NULLs in all nullable columns (above we guarantee there is a match for the non-null coumns), the result is UNKNOWN. */ if (count_nulls_in_search_key == merge_keys_count - MY_TEST(non_null_key)) { res= TRUE; goto end; } /* If the outer row has NULLs in some columns, and there is no match for any of the remaining columns, and there is a subquery row with NULLs in all unmatched columns, then there is a partial match, otherwise the result is FALSE. */ if (count_nulls_in_search_key && !pq.elements) { DBUG_ASSERT(!non_null_key); /* Check if the intersection of all NULL bitmaps of all keys that are not in matching_outer_cols is non-empty. */ res= exists_complementing_null_row(&matching_outer_cols); goto end; } /* If there is no NULL (sub)row that covers all NULL columns, and there is no match for any of the NULL columns, the result is FALSE. Notice that if there is a non-null key, and there is only one matching key, the non-null key is the matching key. This is so, because this method returns FALSE if the non-null key doesn't have a match. */ if (!count_nulls_in_search_key && (!pq.elements || (pq.elements == 1 && non_null_key && max_null_in_any_row < merge_keys_count-1))) { if (!pq.elements) { DBUG_ASSERT(!non_null_key); /* The case of a covering null row is handled by subselect_partial_match_engine::exec() */ DBUG_ASSERT(max_null_in_any_row != tmp_table->s->fields); } res= FALSE; goto end; } DBUG_ASSERT(pq.elements); min_key= (Ordered_key*) queue_remove_top(&pq); min_row_num= min_key->current(); bitmap_set_bit(&matching_keys, min_key->get_keyid()); bitmap_union(&matching_keys, &matching_outer_cols); if (min_key->next_same()) queue_insert(&pq, (uchar *) min_key); if (pq.elements == 0) { /* Check the only matching row of the only key min_key for NULL matches in the other columns. */ res= test_null_row(min_row_num); goto end; } while (TRUE) { cur_key= (Ordered_key*) queue_remove_top(&pq); cur_row_num= cur_key->current(); if (cur_row_num == min_row_num) bitmap_set_bit(&matching_keys, cur_key->get_keyid()); else { /* Follows from the correct use of priority queue. */ DBUG_ASSERT(cur_row_num > min_row_num); if (test_null_row(min_row_num)) { res= TRUE; goto end; } else { min_key= cur_key; min_row_num= cur_row_num; bitmap_clear_all(&matching_keys); bitmap_set_bit(&matching_keys, min_key->get_keyid()); bitmap_union(&matching_keys, &matching_outer_cols); } } if (cur_key->next_same()) queue_insert(&pq, (uchar *) cur_key); if (pq.elements == 0) { /* Check the last row of the last column in PQ for NULL matches. */ res= test_null_row(min_row_num); goto end; } } /* We should never get here - all branches must be handled explicitly above. */ DBUG_ASSERT(FALSE); end: if (!has_covering_null_columns) bitmap_clear_all(&matching_keys); queue_remove_all(&pq); tmp_table->file->ha_rnd_end(); return res; }
0
[ "CWE-89" ]
server
3c209bfc040ddfc41ece8357d772547432353fd2
310,938,160,304,615,170,000,000,000,000,000,000,000
177
MDEV-25994: Crash with union of my_decimal type in ORDER BY clause When single-row subquery fails with "Subquery reutrns more than 1 row" error, it will raise an error and return NULL. On the other hand, Item_singlerow_subselect sets item->maybe_null=0 for table-less subqueries like "(SELECT not_null_value)" (*) This discrepancy (item with maybe_null=0 returning NULL) causes the code in Type_handler_decimal_result::make_sort_key_part() to crash. Fixed this by allowing inference (*) only when the subquery is NOT a UNION.
static void GCompletionDestroy(GCompletionField *gc) { int i; if ( gc->choice_popup!=NULL ) { GWindow cp = gc->choice_popup; gc->choice_popup = NULL; GDrawSetUserData(cp,NULL); GDrawDestroyWindow(cp); } if ( gc->choices!=NULL ) { for ( i=0; gc->choices[i]!=NULL; ++i ) free(gc->choices[i]); free(gc->choices); gc->choices = NULL; } }
0
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
246,426,540,284,720,630,000,000,000,000,000,000,000
16
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
struct yang_data *yang_data_new_uint16(const char *xpath, uint16_t value) { char value_str[BUFSIZ]; snprintf(value_str, sizeof(value_str), "%u", value); return yang_data_new(xpath, value_str); }
0
[ "CWE-119", "CWE-787" ]
frr
ac3133450de12ba86c051265fc0f1b12bc57b40c
173,861,001,580,070,800,000,000,000,000,000,000,000
7
isisd: fix #10505 using base64 encoding Using base64 instead of the raw string to encode the binary data. Signed-off-by: whichbug <[email protected]>
void SSL_set_debug(SSL *s, int debug) { s->debug = debug; }
0
[ "CWE-310" ]
openssl
cf6da05304d554aaa885151451aa4ecaa977e601
84,131,644,156,208,020,000,000,000,000,000,000,000
4
Support TLS_FALLBACK_SCSV. Reviewed-by: Stephen Henson <[email protected]>
read_eeprom (long ioaddr, int eep_addr) { int i = 1000; outw (EEP_READ | (eep_addr & 0xff), ioaddr + EepromCtrl); while (i-- > 0) { if (!(inw (ioaddr + EepromCtrl) & EEP_BUSY)) { return inw (ioaddr + EepromData); } } return 0; }
0
[ "CWE-284", "CWE-264" ]
linux
1bb57e940e1958e40d51f2078f50c3a96a9b2d75
141,923,629,051,667,300,000,000,000,000,000,000,000
11
dl2k: Clean up rio_ioctl The dl2k driver's rio_ioctl call has a few issues: - No permissions checking - Implements SIOCGMIIREG and SIOCGMIIREG using the SIOCDEVPRIVATE numbers - Has a few ioctls that may have been used for debugging at one point but have no place in the kernel proper. This patch removes all but the MII ioctls, renumbers them to use the standard ones, and adds the proper permission check for SIOCSMIIREG. We can also get rid of the dl2k-specific struct mii_data in favor of the generic struct mii_ioctl_data. Since we have the phyid on hand, we can add the SIOCGMIIPHY ioctl too. Most of the MII code for the driver could probably be converted to use the generic MII library but I don't have a device to test the results. Reported-by: Stephan Mueller <[email protected]> Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: David S. Miller <[email protected]>
cmsBool CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile) { _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile; cmsBool rc = TRUE; cmsUInt32Number i; if (!Icc) return FALSE; // Was open in write mode? if (Icc ->IsWrite) { Icc ->IsWrite = FALSE; // Assure no further writting rc &= cmsSaveProfileToFile(hProfile, Icc ->IOhandler->PhysicalFile); } for (i=0; i < Icc -> TagCount; i++) { if (Icc -> TagPtrs[i]) { cmsTagTypeHandler* TypeHandler = Icc ->TagTypeHandlers[i]; if (TypeHandler != NULL) { TypeHandler ->ContextID = Icc ->ContextID; // As an additional parameters TypeHandler ->ICCVersion = Icc ->Version; TypeHandler ->FreePtr(TypeHandler, Icc -> TagPtrs[i]); } else _cmsFree(Icc ->ContextID, Icc ->TagPtrs[i]); } } if (Icc ->IOhandler != NULL) { rc &= cmsCloseIOhandler(Icc->IOhandler); } _cmsFree(Icc ->ContextID, Icc); // Free placeholder memory return rc; }
0
[]
Little-CMS
886e2f524268efe8a1c3aa838c28e446fda24486
336,613,693,158,219,000,000,000,000,000,000,000,000
40
Fixes from coverity check
debug_print_pgrps () { itrace("original_pgrp = %ld shell_pgrp = %ld terminal_pgrp = %ld", (long)original_pgrp, (long)shell_pgrp, (long)terminal_pgrp); itrace("tcgetpgrp(%d) -> %ld, getpgid(0) -> %ld", shell_tty, (long)tcgetpgrp (shell_tty), (long)getpgid(0)); }
0
[]
bash
955543877583837c85470f7fb8a97b7aa8d45e6c
94,474,402,797,713,300,000,000,000,000,000,000,000
7
bash-4.4-rc2 release
inline bool Item_sp_variable::const_item() const { return TRUE; }
0
[]
mysql-server
f7316aa0c9a3909fc7498e7b95d5d3af044a7e21
236,479,799,019,215,970,000,000,000,000,000,000,000
4
Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), NAME_CONST('NAME', NULL)) Backport of Bug#19143243 fix. NAME_CONST item can return NULL_ITEM type in case of incorrect arguments. NULL_ITEM has special processing in Item_func_in function. In Item_func_in::fix_length_and_dec an array of possible comparators is created. Since NAME_CONST function has NULL_ITEM type, corresponding array element is empty. Then NAME_CONST is wrapped to ITEM_CACHE. ITEM_CACHE can not return proper type(NULL_ITEM) in Item_func_in::val_int(), so the NULL_ITEM is attempted compared with an empty comparator. The fix is to disable the caching of Item_name_const item.
void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { assert(x->number_of_arguments() == 1 || (x->number_of_arguments() == 2 && x->id() == vmIntrinsics::_dpow), "wrong type"); if (x->id() == vmIntrinsics::_dexp || x->id() == vmIntrinsics::_dlog || x->id() == vmIntrinsics::_dpow || x->id() == vmIntrinsics::_dcos || x->id() == vmIntrinsics::_dsin || x->id() == vmIntrinsics::_dtan || x->id() == vmIntrinsics::_dlog10) { do_LibmIntrinsic(x); return; } LIRItem value(x->argument_at(0), this); bool use_fpu = false; #ifndef _LP64 if (UseSSE < 2) { value.set_destroys_register(); } #endif // !LP64 value.load_item(); LIR_Opr calc_input = value.result(); LIR_Opr calc_result = rlock_result(x); LIR_Opr tmp = LIR_OprFact::illegalOpr; #ifdef _LP64 if (UseAVX > 2 && (!VM_Version::supports_avx512vl()) && (x->id() == vmIntrinsics::_dabs)) { tmp = new_register(T_DOUBLE); __ move(LIR_OprFact::doubleConst(-0.0), tmp); } #endif switch(x->id()) { case vmIntrinsics::_dabs: __ abs (calc_input, calc_result, tmp); break; case vmIntrinsics::_dsqrt: __ sqrt (calc_input, calc_result, LIR_OprFact::illegalOpr); break; default: ShouldNotReachHere(); } if (use_fpu) { __ move(calc_result, x->operand()); } }
0
[]
jdk17u
268c0159253b3de5d72eb826ef2329b27bb33fea
150,791,548,862,184,370,000,000,000,000,000,000,000
43
8272014: Better array indexing Reviewed-by: thartmann Backport-of: 937c31d896d05aa24543b74e98a2ea9f05b5d86f
static inline void convertGfxShortColor(SplashColorPtr dest, SplashColorMode colorMode, GfxColorSpace *colorSpace, GfxColor *src) { switch (colorMode) { case splashModeMono1: case splashModeMono8: { GfxGray gray; colorSpace->getGray(src, &gray); dest[0] = colToByte(gray); } break; case splashModeXBGR8: dest[3] = 255; // fallthrough case splashModeBGR8: case splashModeRGB8: { GfxRGB rgb; colorSpace->getRGB(src, &rgb); dest[0] = colToByte(rgb.r); dest[1] = colToByte(rgb.g); dest[2] = colToByte(rgb.b); } break; #ifdef SPLASH_CMYK case splashModeCMYK8: { GfxCMYK cmyk; colorSpace->getCMYK(src, &cmyk); dest[0] = colToByte(cmyk.c); dest[1] = colToByte(cmyk.m); dest[2] = colToByte(cmyk.y); dest[3] = colToByte(cmyk.k); } break; case splashModeDeviceN8: { GfxColor deviceN; colorSpace->getDeviceN(src, &deviceN); for (int i = 0; i < SPOT_NCOMPS + 4; i++) dest[i] = colToByte(deviceN.c[i]); } break; #endif } }
0
[ "CWE-369" ]
poppler
b224e2f5739fe61de9fa69955d016725b2a4b78d
280,039,212,726,558,200,000,000,000,000,000,000,000
48
SplashOutputDev::tilingPatternFill: Fix crash on broken file Issue #802
static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt, enum x86_intercept intercept, enum x86_intercept_stage stage) { struct x86_instruction_info info = { .intercept = intercept, .rep_prefix = ctxt->rep_prefix, .modrm_mod = ctxt->modrm_mod, .modrm_reg = ctxt->modrm_reg, .modrm_rm = ctxt->modrm_rm, .src_val = ctxt->src.val64, .dst_val = ctxt->dst.val64, .src_bytes = ctxt->src.bytes, .dst_bytes = ctxt->dst.bytes, .ad_bytes = ctxt->ad_bytes, .next_rip = ctxt->eip, }; return ctxt->ops->intercept(ctxt, &info, stage); }
0
[]
kvm
d1442d85cc30ea75f7d399474ca738e0bc96f715
166,209,357,174,904,480,000,000,000,000,000,000,000
20
KVM: x86: Handle errors when RIP is set during far jumps Far jmp/call/ret may fault while loading a new RIP. Currently KVM does not handle this case, and may result in failed vm-entry once the assignment is done. The tricky part of doing so is that loading the new CS affects the VMCS/VMCB state, so if we fail during loading the new RIP, we are left in unconsistent state. Therefore, this patch saves on 64-bit the old CS descriptor and restores it if loading RIP failed. This fixes CVE-2014-3647. Cc: [email protected] Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
static int descriptor_modify(struct ldb_module *module, struct ldb_request *req) { struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_request *mod_req; struct ldb_message *msg; struct ldb_result *current_res, *parent_res; const struct ldb_val *old_sd = NULL; const struct ldb_val *parent_sd = NULL; const struct ldb_val *user_sd; struct ldb_dn *dn = req->op.mod.message->dn; struct ldb_dn *parent_dn; struct ldb_message_element *objectclass_element, *sd_element; int ret; uint32_t instanceType; bool explicit_sd_flags = false; uint32_t sd_flags = dsdb_request_sd_flags(req, &explicit_sd_flags); const struct dsdb_schema *schema; DATA_BLOB *sd; const struct dsdb_class *objectclass; static const char * const parent_attrs[] = { "nTSecurityDescriptor", NULL }; static const char * const current_attrs[] = { "nTSecurityDescriptor", "instanceType", "objectClass", NULL }; struct GUID parent_guid = { .time_low = 0 }; struct ldb_control *sd_propagation_control; int cmp_ret = -1; /* do not manipulate our control entries */ if (ldb_dn_is_special(dn)) { return ldb_next_request(module, req); } sd_propagation_control = ldb_request_get_control(req, DSDB_CONTROL_SEC_DESC_PROPAGATION_OID); if (sd_propagation_control != NULL) { if (sd_propagation_control->data != module) { return ldb_operr(ldb); } if (req->op.mod.message->num_elements != 0) { return ldb_operr(ldb); } if (explicit_sd_flags) { return ldb_operr(ldb); } if (sd_flags != 0xF) { return ldb_operr(ldb); } if (sd_propagation_control->critical == 0) { return ldb_operr(ldb); } sd_propagation_control->critical = 0; } sd_element = ldb_msg_find_element(req->op.mod.message, "nTSecurityDescriptor"); if (sd_propagation_control == NULL && sd_element == NULL) { return ldb_next_request(module, req); } /* * nTSecurityDescriptor with DELETE is not supported yet. * TODO: handle this correctly. */ if (sd_propagation_control == NULL && LDB_FLAG_MOD_TYPE(sd_element->flags) == LDB_FLAG_MOD_DELETE) { return ldb_module_error(module, LDB_ERR_UNWILLING_TO_PERFORM, "MOD_DELETE for nTSecurityDescriptor " "not supported yet"); } user_sd = ldb_msg_find_ldb_val(req->op.mod.message, "nTSecurityDescriptor"); /* nTSecurityDescriptor without a value is an error, letting through so it is handled */ if (sd_propagation_control == NULL && user_sd == NULL) { return ldb_next_request(module, req); } ldb_debug(ldb, LDB_DEBUG_TRACE,"descriptor_modify: %s\n", ldb_dn_get_linearized(dn)); ret = dsdb_module_search_dn(module, req, &current_res, dn, current_attrs, DSDB_FLAG_NEXT_MODULE | DSDB_FLAG_AS_SYSTEM | DSDB_SEARCH_SHOW_RECYCLED | DSDB_SEARCH_SHOW_EXTENDED_DN, req); if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR,"descriptor_modify: Could not find %s\n", ldb_dn_get_linearized(dn)); return ret; } instanceType = ldb_msg_find_attr_as_uint(current_res->msgs[0], "instanceType", 0); /* if the object has a parent, retrieve its SD to * use for calculation */ if (!ldb_dn_is_null(current_res->msgs[0]->dn) && !(instanceType & INSTANCE_TYPE_IS_NC_HEAD)) { NTSTATUS status; parent_dn = ldb_dn_get_parent(req, dn); if (parent_dn == NULL) { return ldb_oom(ldb); } ret = dsdb_module_search_dn(module, req, &parent_res, parent_dn, parent_attrs, DSDB_FLAG_NEXT_MODULE | DSDB_FLAG_AS_SYSTEM | DSDB_SEARCH_SHOW_RECYCLED | DSDB_SEARCH_SHOW_EXTENDED_DN, req); if (ret != LDB_SUCCESS) { ldb_debug(ldb, LDB_DEBUG_ERROR, "descriptor_modify: Could not find SD for %s\n", ldb_dn_get_linearized(parent_dn)); return ret; } if (parent_res->count != 1) { return ldb_operr(ldb); } parent_sd = ldb_msg_find_ldb_val(parent_res->msgs[0], "nTSecurityDescriptor"); status = dsdb_get_extended_dn_guid(parent_res->msgs[0]->dn, &parent_guid, "GUID"); if (!NT_STATUS_IS_OK(status)) { return ldb_operr(ldb); } } schema = dsdb_get_schema(ldb, req); objectclass_element = ldb_msg_find_element(current_res->msgs[0], "objectClass"); if (objectclass_element == NULL) { return ldb_operr(ldb); } objectclass = dsdb_get_last_structural_class(schema, objectclass_element); if (objectclass == NULL) { return ldb_operr(ldb); } old_sd = ldb_msg_find_ldb_val(current_res->msgs[0], "nTSecurityDescriptor"); if (old_sd == NULL) { return ldb_operr(ldb); } if (sd_propagation_control != NULL) { /* * This just triggers a recalculation of the * inherited aces. */ user_sd = old_sd; } sd = get_new_descriptor(module, current_res->msgs[0]->dn, req, objectclass, parent_sd, user_sd, old_sd, sd_flags); if (sd == NULL) { return ldb_operr(ldb); } msg = ldb_msg_copy_shallow(req, req->op.mod.message); if (msg == NULL) { return ldb_oom(ldb); } cmp_ret = data_blob_cmp(old_sd, sd); if (sd_propagation_control != NULL) { if (cmp_ret == 0) { /* * The nTSecurityDescriptor is unchanged, * which means we can stop the processing. * * We mark the control as critical again, * as we have not processed it, so the caller * can tell that the descriptor was unchanged. */ sd_propagation_control->critical = 1; return ldb_module_done(req, NULL, NULL, LDB_SUCCESS); } ret = ldb_msg_add_empty(msg, "nTSecurityDescriptor", LDB_FLAG_MOD_REPLACE, &sd_element); if (ret != LDB_SUCCESS) { return ldb_oom(ldb); } ret = ldb_msg_add_value(msg, "nTSecurityDescriptor", sd, NULL); if (ret != LDB_SUCCESS) { return ldb_oom(ldb); } } else if (cmp_ret != 0) { struct GUID guid; struct ldb_dn *nc_root; NTSTATUS status; ret = dsdb_find_nc_root(ldb, msg, current_res->msgs[0]->dn, &nc_root); if (ret != LDB_SUCCESS) { return ldb_oom(ldb); } status = dsdb_get_extended_dn_guid(current_res->msgs[0]->dn, &guid, "GUID"); if (!NT_STATUS_IS_OK(status)) { return ldb_operr(ldb); } /* * Force SD propagation on children of this record */ ret = dsdb_module_schedule_sd_propagation(module, nc_root, guid, parent_guid, false); if (ret != LDB_SUCCESS) { return ldb_operr(ldb); } sd_element->values[0] = *sd; } else { sd_element->values[0] = *sd; } ret = ldb_build_mod_req(&mod_req, ldb, req, msg, req->controls, req, dsdb_next_callback, req); LDB_REQ_SET_LOCATION(mod_req); if (ret != LDB_SUCCESS) { return ret; } return ldb_next_request(module, mod_req); }
1
[ "CWE-200" ]
samba
0a3aa5f908e351201dc9c4d4807b09ed9eedff77
113,849,357,704,879,350,000,000,000,000,000,000,000
241
CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message This aims to minimise usage of the error-prone pattern of searching for a just-added message element in order to make modifications to it (and potentially finding the wrong element). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009 Signed-off-by: Joseph Sutton <[email protected]>
fr_window_stop_batch (FrWindow *window) { if (! window->priv->batch_mode) { fr_window_free_batch_data (window); window->priv->reload_archive = FALSE; return; } window->priv->extract_interact_use_default_dir = FALSE; if (! window->priv->showing_error_dialog) { g_signal_emit (window, fr_window_signals[READY], 0, NULL); gtk_widget_destroy (GTK_WIDGET (window)); } }
0
[ "CWE-22" ]
file-roller
b147281293a8307808475e102a14857055f81631
85,252,909,762,976,670,000,000,000,000,000,000,000
18
libarchive: sanitize filenames before extracting
static int selinux_shm_alloc_security(struct shmid_kernel *shp) { struct ipc_security_struct *isec; struct common_audit_data ad; u32 sid = current_sid(); int rc; rc = ipc_alloc_security(current, &shp->shm_perm, SECCLASS_SHM); if (rc) return rc; isec = shp->shm_perm.security; ad.type = LSM_AUDIT_DATA_IPC; ad.u.ipc_id = shp->shm_perm.key; rc = avc_has_perm(sid, isec->sid, SECCLASS_SHM, SHM__CREATE, &ad); if (rc) { ipc_free_security(&shp->shm_perm); return rc; } return 0; }
0
[ "CWE-264" ]
linux
7b0d0b40cd78cadb525df760ee4cac151533c2b5
71,986,516,728,518,820,000,000,000,000,000,000,000
24
selinux: Permit bounded transitions under NO_NEW_PRIVS or NOSUID. If the callee SID is bounded by the caller SID, then allowing the transition to occur poses no risk of privilege escalation and we can therefore safely allow the transition to occur. Add this exemption for both the case where a transition was explicitly requested by the application and the case where an automatic transition is defined in policy. Signed-off-by: Stephen Smalley <[email protected]> Reviewed-by: Andy Lutomirski <[email protected]> Signed-off-by: Paul Moore <[email protected]>
uint32_t smb1cli_conn_server_session_key(struct smbXcli_conn *conn) { return conn->smb1.server.session_key; }
0
[ "CWE-20" ]
samba
a819d2b440aafa3138d95ff6e8b824da885a70e9
90,054,656,230,610,970,000,000,000,000,000,000,000
4
CVE-2015-5296: libcli/smb: make sure we require signing when we demand encryption on a session BUG: https://bugzilla.samba.org/show_bug.cgi?id=11536 Signed-off-by: Stefan Metzmacher <[email protected]> Reviewed-by: Jeremy Allison <[email protected]>
_clone_pdu_header(netsnmp_pdu *pdu) { netsnmp_pdu *newpdu; struct snmp_secmod_def *sptr; int ret; if (!pdu) return NULL; newpdu = (netsnmp_pdu *) malloc(sizeof(netsnmp_pdu)); if (!newpdu) return NULL; memmove(newpdu, pdu, sizeof(netsnmp_pdu)); /* * reset copied pointers if copy fails */ newpdu->variables = NULL; newpdu->enterprise = NULL; newpdu->community = NULL; newpdu->securityEngineID = NULL; newpdu->securityName = NULL; newpdu->contextEngineID = NULL; newpdu->contextName = NULL; newpdu->transport_data = NULL; /* * copy buffers individually. If any copy fails, all are freed. */ if (snmp_clone_mem((void **) &newpdu->enterprise, pdu->enterprise, sizeof(oid) * pdu->enterprise_length) || snmp_clone_mem((void **) &newpdu->community, pdu->community, pdu->community_len) || snmp_clone_mem((void **) &newpdu->contextEngineID, pdu->contextEngineID, pdu->contextEngineIDLen) || snmp_clone_mem((void **) &newpdu->securityEngineID, pdu->securityEngineID, pdu->securityEngineIDLen) || snmp_clone_mem((void **) &newpdu->contextName, pdu->contextName, pdu->contextNameLen) || snmp_clone_mem((void **) &newpdu->securityName, pdu->securityName, pdu->securityNameLen) || snmp_clone_mem((void **) &newpdu->transport_data, pdu->transport_data, pdu->transport_data_length)) { snmp_free_pdu(newpdu); return NULL; } if (pdu->securityStateRef && pdu->command == SNMP_MSG_TRAP2) { netsnmp_assert(pdu->securityModel == SNMP_DEFAULT_SECMODEL); ret = usm_clone_usmStateReference((struct usmStateReference *) pdu->securityStateRef, (struct usmStateReference **) &newpdu->securityStateRef ); if (ret) { snmp_free_pdu(newpdu); return NULL; } } if ((sptr = find_sec_mod(newpdu->securityModel)) != NULL && sptr->pdu_clone != NULL) { /* * call security model if it needs to know about this */ (*sptr->pdu_clone) (pdu, newpdu); } return newpdu; }
1
[ "CWE-415" ]
net-snmp
5f881d3bf24599b90d67a45cae7a3eb099cd71c9
226,147,770,919,947,900,000,000,000,000,000,000,000
72
libsnmp, USM: Introduce a reference count in struct usmStateReference This patch fixes https://sourceforge.net/p/net-snmp/bugs/2956/.
inline uint64_t make_type() { return 0; }
0
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
3,971,789,516,274,418,400,000,000,000,000,000,000
1
Fix segfault on complex pointer formatting (#642)
static __init int cpu_has_kvm_support(void) { return cpu_has_vmx(); }
0
[ "CWE-20" ]
linux-2.6
16175a796d061833aacfbd9672235f2d2725df65
154,249,822,371,643,300,000,000,000,000,000,000,000
4
KVM: VMX: Don't allow uninhibited access to EFER on i386 vmx_set_msr() does not allow i386 guests to touch EFER, but they can still do so through the default: label in the switch. If they set EFER_LME, they can oops the host. Fix by having EFER access through the normal channel (which will check for EFER_LME) even on i386. Reported-and-tested-by: Benjamin Gilbert <[email protected]> Cc: [email protected] Signed-off-by: Avi Kivity <[email protected]>
static int sasl_sc_sasl2dn( Operation *op, SlapReply *rs ) { struct berval *ndn = op->o_callback->sc_private; if ( rs->sr_type != REP_SEARCH ) return LDAP_SUCCESS; /* We only want to be called once */ if ( !BER_BVISNULL( ndn ) ) { op->o_tmpfree( ndn->bv_val, op->o_tmpmemctx ); BER_BVZERO( ndn ); Debug( LDAP_DEBUG_TRACE, "%s: slap_sc_sasl2dn: search DN returned more than 1 entry\n", op->o_log_prefix, 0, 0 ); return LDAP_UNAVAILABLE; /* short-circuit the search */ } ber_dupbv_x( ndn, &rs->sr_entry->e_nname, op->o_tmpmemctx ); return LDAP_SUCCESS; }
0
[ "CWE-617" ]
openldap
02dfc32d658fadc25e4040f78e36592f6e1e1ca0
39,823,800,616,245,075,000,000,000,000,000,000,000
20
ITS#9406 fix debug msg
bool Scanner::fill(size_t need) { if (eof) return false; pop_finished_files(); DASSERT(bot <= tok && tok <= lim); size_t free = static_cast<size_t>(tok - bot); size_t copy = static_cast<size_t>(lim - tok); if (free >= need) { memmove(bot, tok, copy); shift_ptrs_and_fpos(-static_cast<ptrdiff_t>(free)); } else { BSIZE += std::max(BSIZE, need); char * buf = new char[BSIZE + YYMAXFILL]; if (!buf) fatal("out of memory"); memmove(buf, tok, copy); shift_ptrs_and_fpos(buf - tok); delete [] bot; bot = buf; free = BSIZE - copy; } DASSERT(lim + free <= bot + BSIZE); if (!read(free)) { eof = lim; memset(lim, 0, YYMAXFILL); lim += YYMAXFILL; } return true; }
0
[ "CWE-787" ]
re2c
c4603ba5ce229db83a2a4fb93e6d4b4e3ec3776a
151,319,979,079,810,560,000,000,000,000,000,000,000
36
Fix crash in lexer refill (reported by Agostino Sarubbo). The crash happened in a rare case of a very long lexeme that doen't fit into the buffer, forcing buffer reallocation. The crash was caused by an incorrect calculation of the shift offset (it was smaller than necessary). As a consequence, the data from buffer start and up to the beginning of the current lexeme was not discarded (as it should have been), resulting in less free space for new data than expected.
int diskutil_loop_check(const char *path, const char *lodev) { int ret = EUCA_OK; char *output = NULL; char *oparen = NULL; char *cparen = NULL; if (path && lodev) { output = pruntf(TRUE, "%s %s %s", helpers_path[ROOTWRAP], helpers_path[LOSETUP], lodev); if (output == NULL) return (EUCA_ERROR); // output is expected to look like: /dev/loop4: [0801]:5509589 (/var/lib/eucalyptus/volumes/v*) oparen = strchr(output, '('); cparen = strchr(output, ')'); if ((oparen == NULL) || (cparen == NULL)) { // no parenthesis => unexpected `losetup` output ret = EUCA_ERROR; } else if ((cparen - oparen) < 3) { // strange paren arrangement => unexpected ret = EUCA_ERROR; } else { // extract just the path, possibly truncated, from inside the parens oparen++; cparen--; if (*cparen == '*') { // handle truncated paths, identified with an asterisk cparen--; } // truncate ')' or '*)' *cparen = '\0'; // see if path is in the blobstore if (strstr(path, oparen) == NULL) { ret = EUCA_ERROR; } } EUCA_FREE(output); return (ret); } LOGWARN("bad params: path=%s, lodev=%s\n", SP(path), SP(lodev)); return (EUCA_INVALID_ERROR); }
0
[]
eucalyptus
c252889a46f41b4c396b89e005ec89836f2524be
181,502,584,493,547,900,000,000,000,000,000,000,000
45
Input validation, shellout hardening on back-end - validating bucketName and bucketPath in BundleInstance - validating device name in Attach and DetachVolume - removed some uses of system() and popen() Fixes EUCA-7572, EUCA-7520
onig_builtin_mismatch(OnigCalloutArgs* args ARG_UNUSED, void* user_data ARG_UNUSED) { return ONIG_MISMATCH; }
0
[ "CWE-125" ]
oniguruma
d3e402928b6eb3327f8f7d59a9edfa622fec557b
128,784,314,251,796,220,000,000,000,000,000,000,000
4
fix heap-buffer-overflow
static int shadow_copy2_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname) { time_t timestamp; char *stripped, *tmp; int ret, saved_errno; if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, smb_fname->base_name, &timestamp, &stripped)) { return -1; } if (timestamp == 0) { return SMB_VFS_NEXT_LSTAT(handle, smb_fname); } tmp = smb_fname->base_name; smb_fname->base_name = shadow_copy2_convert( talloc_tos(), handle, stripped, timestamp); TALLOC_FREE(stripped); if (smb_fname->base_name == NULL) { smb_fname->base_name = tmp; return -1; } ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname); saved_errno = errno; TALLOC_FREE(smb_fname->base_name); smb_fname->base_name = tmp; if (ret == 0) { convert_sbuf(handle, smb_fname->base_name, &smb_fname->st); } errno = saved_errno; return ret; }
0
[ "CWE-200" ]
samba
675fd8d771f9d43e354dba53ddd9b5483ae0a1d7
128,595,838,705,361,020,000,000,000,000,000,000,000
38
CVE-2015-5299: s3-shadow-copy2: fix missing access check on snapdir Fix originally from <[email protected]> https://bugzilla.samba.org/show_bug.cgi?id=11529 Signed-off-by: Jeremy Allison <[email protected]> Reviewed-by: David Disseldorp <[email protected]>
static int read_entry( git_index_entry **out, size_t *out_size, git_index *index, const void *buffer, size_t buffer_size, const char *last) { size_t path_length, entry_size; const char *path_ptr; struct entry_short source; git_index_entry entry = {{0}}; bool compressed = index->version >= INDEX_VERSION_NUMBER_COMP; char *tmp_path = NULL; if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size) return -1; /* buffer is not guaranteed to be aligned */ memcpy(&source, buffer, sizeof(struct entry_short)); entry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds); entry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds); entry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds); entry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds); entry.dev = ntohl(source.dev); entry.ino = ntohl(source.ino); entry.mode = ntohl(source.mode); entry.uid = ntohl(source.uid); entry.gid = ntohl(source.gid); entry.file_size = ntohl(source.file_size); git_oid_cpy(&entry.id, &source.oid); entry.flags = ntohs(source.flags); if (entry.flags & GIT_IDXENTRY_EXTENDED) { uint16_t flags_raw; size_t flags_offset; flags_offset = offsetof(struct entry_long, flags_extended); memcpy(&flags_raw, (const char *) buffer + flags_offset, sizeof(flags_raw)); flags_raw = ntohs(flags_raw); memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw)); path_ptr = (const char *) buffer + offsetof(struct entry_long, path); } else path_ptr = (const char *) buffer + offsetof(struct entry_short, path); if (!compressed) { path_length = entry.flags & GIT_IDXENTRY_NAMEMASK; /* if this is a very long string, we must find its * real length without overflowing */ if (path_length == 0xFFF) { const char *path_end; path_end = memchr(path_ptr, '\0', buffer_size); if (path_end == NULL) return -1; path_length = path_end - path_ptr; } entry_size = index_entry_size(path_length, 0, entry.flags); entry.path = (char *)path_ptr; } else { size_t varint_len; size_t strip_len = git_decode_varint((const unsigned char *)path_ptr, &varint_len); size_t last_len = strlen(last); size_t prefix_len = last_len - strip_len; size_t suffix_len = strlen(path_ptr + varint_len); size_t path_len; if (varint_len == 0) return index_error_invalid("incorrect prefix length"); GITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len); GITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1); tmp_path = git__malloc(path_len); GITERR_CHECK_ALLOC(tmp_path); memcpy(tmp_path, last, prefix_len); memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1); entry_size = index_entry_size(suffix_len, varint_len, entry.flags); entry.path = tmp_path; } if (entry_size == 0) return -1; if (INDEX_FOOTER_SIZE + entry_size > buffer_size) return -1; if (index_entry_dup(out, index, &entry) < 0) { git__free(tmp_path); return -1; } git__free(tmp_path); *out_size = entry_size; return 0; }
1
[ "CWE-415", "CWE-190" ]
libgit2
3207ddb0103543da8ad2139ec6539f590f9900c1
100,808,018,942,178,500,000,000,000,000,000,000,000
103
index: fix out-of-bounds read with invalid index entry prefix length The index format in version 4 has prefix-compressed entries, where every index entry can compress its path by using a path prefix of the previous entry. Since implmenting support for this index format version in commit 5625d86b9 (index: support index v4, 2016-05-17), though, we do not correctly verify that the prefix length that we want to reuse is actually smaller or equal to the amount of characters than the length of the previous index entry's path. This can lead to a an integer underflow and subsequently to an out-of-bounds read. Fix this by verifying that the prefix is actually smaller than the previous entry's path length. Reported-by: Krishna Ram Prakash R <[email protected]> Reported-by: Vivek Parikh <[email protected]>
void CLASS canon_sraw_load_raw() { struct jhead jh; short *rp=0, (*ip)[4]; int jwide, slice, scol, ecol, row, col, jrow=0, jcol=0, pix[3], c; int v[3]={0,0,0}, ver, hue; #ifdef LIBRAW_LIBRARY_BUILD int saved_w = width, saved_h = height; #endif char *cp; if (!ljpeg_start (&jh, 0) || jh.clrs < 4) return; jwide = (jh.wide >>= 1) * jh.clrs; #ifdef LIBRAW_LIBRARY_BUILD if(load_flags & 256) { width = raw_width; height = raw_height; } try { #endif for (ecol=slice=0; slice <= cr2_slice[0]; slice++) { scol = ecol; ecol += cr2_slice[1] * 2 / jh.clrs; if (!cr2_slice[0] || ecol > raw_width-1) ecol = raw_width & -2; for (row=0; row < height; row += (jh.clrs >> 1) - 1) { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif ip = (short (*)[4]) image + row*width; for (col=scol; col < ecol; col+=2, jcol+=jh.clrs) { if ((jcol %= jwide) == 0) rp = (short *) ljpeg_row (jrow++, &jh); if (col >= width) continue; #ifdef LIBRAW_LIBRARY_BUILD if(imgdata.params.raw_processing_options & LIBRAW_PROCESSING_SRAW_NO_INTERPOLATE) { FORC (jh.clrs-2) { ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c]; ip[col + (c >> 1)*width + (c & 1)][1] = ip[col + (c >> 1)*width + (c & 1)][2] = 8192; } ip[col][1] = rp[jcol+jh.clrs-2] - 8192; ip[col][2] = rp[jcol+jh.clrs-1] - 8192; } else if(imgdata.params.raw_processing_options & LIBRAW_PROCESSING_SRAW_NO_RGB) { FORC (jh.clrs-2) ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c]; ip[col][1] = rp[jcol+jh.clrs-2] - 8192; ip[col][2] = rp[jcol+jh.clrs-1] - 8192; } else #endif { FORC (jh.clrs-2) ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c]; ip[col][1] = rp[jcol+jh.clrs-2] - 16384; ip[col][2] = rp[jcol+jh.clrs-1] - 16384; } } } } #ifdef LIBRAW_LIBRARY_BUILD } catch (...) { ljpeg_end (&jh); throw ; } #endif #ifdef LIBRAW_LIBRARY_BUILD if(imgdata.params.raw_processing_options & LIBRAW_PROCESSING_SRAW_NO_INTERPOLATE) { ljpeg_end (&jh); maximum = 0x3fff; height = saved_h; width = saved_w; return; } #endif #ifdef LIBRAW_LIBRARY_BUILD try { #endif for (cp=model2; *cp && !isdigit(*cp); cp++); sscanf (cp, "%d.%d.%d", v, v+1, v+2); ver = (v[0]*1000 + v[1])*1000 + v[2]; hue = (jh.sraw+1) << 2; if (unique_id >= 0x80000281 || (unique_id == 0x80000218 && ver > 1000006)) hue = jh.sraw << 1; ip = (short (*)[4]) image; rp = ip[0]; for (row=0; row < height; row++, ip+=width) { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif if (row & (jh.sraw >> 1)) { for (col=0; col < width; col+=2) for (c=1; c < 3; c++) if (row == height-1) { ip[col][c] = ip[col-width][c]; } else { ip[col][c] = (ip[col-width][c] + ip[col+width][c] + 1) >> 1; } } for (col=1; col < width; col+=2) for (c=1; c < 3; c++) if (col == width-1) ip[col][c] = ip[col-1][c]; else ip[col][c] = (ip[col-1][c] + ip[col+1][c] + 1) >> 1; } #ifdef LIBRAW_LIBRARY_BUILD if(!(imgdata.params.raw_processing_options & LIBRAW_PROCESSING_SRAW_NO_RGB) ) #endif for ( ; rp < ip[0]; rp+=4) { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif if (unique_id == 0x80000218 || unique_id == 0x80000250 || unique_id == 0x80000261 || unique_id == 0x80000281 || unique_id == 0x80000287) { rp[1] = (rp[1] << 2) + hue; rp[2] = (rp[2] << 2) + hue; pix[0] = rp[0] + (( 50*rp[1] + 22929*rp[2]) >> 14); pix[1] = rp[0] + ((-5640*rp[1] - 11751*rp[2]) >> 14); pix[2] = rp[0] + ((29040*rp[1] - 101*rp[2]) >> 14); } else { if (unique_id < 0x80000218) rp[0] -= 512; pix[0] = rp[0] + rp[2]; pix[2] = rp[0] + rp[1]; pix[1] = rp[0] + ((-778*rp[1] - (rp[2] << 11)) >> 12); } FORC3 rp[c] = CLIP(pix[c] * sraw_mul[c] >> 10); } #ifdef LIBRAW_LIBRARY_BUILD } catch (...) { ljpeg_end (&jh); throw ; } height = saved_h; width = saved_w; #endif ljpeg_end (&jh); maximum = 0x3fff; }
0
[ "CWE-119", "CWE-125", "CWE-787" ]
LibRaw
d13e8f6d1e987b7491182040a188c16a395f1d21
154,734,733,463,111,470,000,000,000,000,000,000,000
154
CVE-2017-1438 credits; fix for Kodak 65000 out of bounds access
nv_object( cmdarg_T *cap) { int flag; int include; char_u *mps_save; if (cap->cmdchar == 'i') include = FALSE; // "ix" = inner object: exclude white space else include = TRUE; // "ax" = an object: include white space // Make sure (), [], {} and <> are in 'matchpairs' mps_save = curbuf->b_p_mps; curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>"; switch (cap->nchar) { case 'w': // "aw" = a word flag = current_word(cap->oap, cap->count1, include, FALSE); break; case 'W': // "aW" = a WORD flag = current_word(cap->oap, cap->count1, include, TRUE); break; case 'b': // "ab" = a braces block case '(': case ')': flag = current_block(cap->oap, cap->count1, include, '(', ')'); break; case 'B': // "aB" = a Brackets block case '{': case '}': flag = current_block(cap->oap, cap->count1, include, '{', '}'); break; case '[': // "a[" = a [] block case ']': flag = current_block(cap->oap, cap->count1, include, '[', ']'); break; case '<': // "a<" = a <> block case '>': flag = current_block(cap->oap, cap->count1, include, '<', '>'); break; case 't': // "at" = a tag block (xml and html) // Do not adjust oap->end in do_pending_operator() // otherwise there are different results for 'dit' // (note leading whitespace in last line): // 1) <b> 2) <b> // foobar foobar // </b> </b> cap->retval |= CA_NO_ADJ_OP_END; flag = current_tagblock(cap->oap, cap->count1, include); break; case 'p': // "ap" = a paragraph flag = current_par(cap->oap, cap->count1, include, 'p'); break; case 's': // "as" = a sentence flag = current_sent(cap->oap, cap->count1, include); break; case '"': // "a"" = a double quoted string case '\'': // "a'" = a single quoted string case '`': // "a`" = a backtick quoted string flag = current_quote(cap->oap, cap->count1, include, cap->nchar); break; #if 0 // TODO case 'S': // "aS" = a section case 'f': // "af" = a filename case 'u': // "au" = a URL #endif default: flag = FAIL; break; } curbuf->b_p_mps = mps_save; if (flag == FAIL) clearopbeep(cap->oap); adjust_cursor_col(); curwin->w_set_curswant = TRUE; }
0
[ "CWE-416" ]
vim
35a9a00afcb20897d462a766793ff45534810dc3
172,185,206,765,757,520,000,000,000,000,000,000,000
80
patch 8.2.3428: using freed memory when replacing Problem: Using freed memory when replacing. (Dhiraj Mishra) Solution: Get the line pointer after calling ins_copychar().
CImgList<T>& assign(const CImg<t1>& img1, const CImg<t2>& img2, const CImg<t3>& img3, const CImg<t4>& img4, const CImg<t5>& img5, const CImg<t6>& img6, const bool is_shared=false) { assign(6); _data[0].assign(img1,is_shared); _data[1].assign(img2,is_shared); _data[2].assign(img3,is_shared); _data[3].assign(img4,is_shared); _data[4].assign(img5,is_shared); _data[5].assign(img6,is_shared); return *this; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
218,992,871,945,636,900,000,000,000,000,000,000,000
7
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags) { CONNECTION* conn = NULL; ACCOUNT* creds = NULL; IMAP_DATA* idata = NULL; int new = 0; while ((conn = mutt_conn_find (conn, account))) { if (!creds) creds = &conn->account; else memcpy (&conn->account, creds, sizeof (ACCOUNT)); idata = (IMAP_DATA*)conn->data; if (flags & MUTT_IMAP_CONN_NONEW) { if (!idata) { /* This should only happen if we've come to the end of the list */ mutt_socket_free (conn); return NULL; } else if (idata->state < IMAP_AUTHENTICATED) continue; } if (flags & MUTT_IMAP_CONN_NOSELECT && idata && idata->state >= IMAP_SELECTED) continue; if (idata && idata->status == IMAP_FATAL) continue; break; } if (!conn) return NULL; /* this happens when the initial connection fails */ /* The current connection is a new connection */ if (!idata) { idata = imap_new_idata (); conn->data = idata; idata->conn = conn; new = 1; } if (idata->state == IMAP_DISCONNECTED) imap_open_connection (idata); if (idata->state == IMAP_CONNECTED) { if (!imap_authenticate (idata)) { idata->state = IMAP_AUTHENTICATED; FREE (&idata->capstr); new = 1; if (idata->conn->ssf) dprint (2, (debugfile, "Communication encrypted at %d bits\n", idata->conn->ssf)); } else mutt_account_unsetpass (&idata->conn->account); } if (new && idata->state == IMAP_AUTHENTICATED) { /* capabilities may have changed */ imap_exec (idata, "CAPABILITY", IMAP_CMD_FAIL_OK); #if defined(USE_ZLIB) /* RFC 4978 */ if (mutt_bit_isset (idata->capabilities, COMPRESS_DEFLATE)) { if (option (OPTIMAPDEFLATE) && imap_exec (idata, "COMPRESS DEFLATE", IMAP_CMD_FAIL_OK) == 0) mutt_zstrm_wrap_conn (idata->conn); } #endif /* enable RFC6855, if the server supports that */ if (mutt_bit_isset (idata->capabilities, ENABLE)) imap_exec (idata, "ENABLE UTF8=ACCEPT", IMAP_CMD_QUEUE); /* enable QRESYNC. Advertising QRESYNC also means CONDSTORE * is supported (even if not advertised), so flip that bit. */ if (mutt_bit_isset (idata->capabilities, QRESYNC)) { mutt_bit_set (idata->capabilities, CONDSTORE); if (option (OPTIMAPQRESYNC)) imap_exec (idata, "ENABLE QRESYNC", IMAP_CMD_QUEUE); } /* get root delimiter, '/' as default */ idata->delim = '/'; imap_exec (idata, "LIST \"\" \"\"", IMAP_CMD_QUEUE); if (option (OPTIMAPCHECKSUBSCRIBED)) imap_exec (idata, "LSUB \"\" \"*\"", IMAP_CMD_QUEUE); /* we may need the root delimiter before we open a mailbox */ imap_exec (idata, NULL, IMAP_CMD_FAIL_OK); } if (idata->state < IMAP_AUTHENTICATED) return NULL; return idata; }
0
[ "CWE-200", "CWE-319" ]
mutt
3e88866dc60b5fa6aaba6fd7c1710c12c1c3cd01
33,632,509,815,435,655,000,000,000,000,000,000,000
103
Prevent possible IMAP MITM via PREAUTH response. This is similar to CVE-2014-2567 and CVE-2020-12398. STARTTLS is not allowed in the Authenticated state, so previously Mutt would implicitly mark the connection as authenticated and skip any encryption checking/enabling. No credentials are exposed, but it does allow messages to be sent to an attacker, via postpone or fcc'ing for instance. Reuse the $ssl_starttls quadoption "in reverse" to prompt to abort the connection if it is unencrypted. Thanks very much to Damian Poddebniak and Fabian Ising from the Münster University of Applied Sciences for reporting this issue, and their help in testing the fix.
static bool hid_match_one_id(struct hid_device *hdev, const struct hid_device_id *id) { return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) && (id->group == HID_GROUP_ANY || id->group == hdev->group) && (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && (id->product == HID_ANY_ID || id->product == hdev->product); }
0
[ "CWE-125" ]
linux
50220dead1650609206efe91f0cc116132d59b3f
77,421,041,861,375,720,000,000,000,000,000,000,000
8
HID: core: prevent out-of-bound readings Plugging a Logitech DJ receiver with KASAN activated raises a bunch of out-of-bound readings. The fields are allocated up to MAX_USAGE, meaning that potentially, we do not have enough fields to fit the incoming values. Add checks and silence KASAN. Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
static void printk_stack_address(unsigned long address, int reliable, char *log_lvl) { touch_nmi_watchdog(); printk("%s %s%pB\n", log_lvl, reliable ? "" : "? ", (void *)address); }
0
[ "CWE-20" ]
linux
342db04ae71273322f0011384a9ed414df8bdae4
165,324,468,355,977,610,000,000,000,000,000,000,000
6
x86/dumpstack: Don't dump kernel memory based on usermode RIP show_opcodes() is used both for dumping kernel instructions and for dumping user instructions. If userspace causes #PF by jumping to a kernel address, show_opcodes() can be reached with regs->ip controlled by the user, pointing to kernel code. Make sure that userspace can't trick us into dumping kernel memory into dmesg. Fixes: 7cccf0725cf7 ("x86/dumpstack: Add a show_ip() function") Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
_PUBLIC_ char *strupper_talloc_n_handle(struct smb_iconv_handle *iconv_handle, TALLOC_CTX *ctx, const char *src, size_t n) { size_t size=0; char *dest; if (!src) { return NULL; } /* this takes advantage of the fact that upper/lower can't change the length of a character by more than 1 byte */ dest = talloc_array(ctx, char, 2*(n+1)); if (dest == NULL) { return NULL; } while (n-- && *src) { size_t c_size; codepoint_t c = next_codepoint_handle(iconv_handle, src, &c_size); src += c_size; c = toupper_m(c); c_size = push_codepoint_handle(iconv_handle, dest+size, c); if (c_size == -1) { talloc_free(dest); return NULL; } size += c_size; } dest[size] = 0; /* trim it so talloc_append_string() works */ dest = talloc_realloc(ctx, dest, char, size+1); talloc_set_name_const(dest, dest); return dest; }
1
[ "CWE-200" ]
samba
ba5dbda6d0174a59d221c45cca52ecd232820d48
60,720,768,758,998,235,000,000,000,000,000,000,000
41
CVE-2015-5330: Fix handling of unicode near string endings Until now next_codepoint_ext() and next_codepoint_handle_ext() were using strnlen(str, 5) to determine how much string they should try to decode. This ended up looking past the end of the string when it was not null terminated and the final character looked like a multi-byte encoding. The fix is to let the caller say how long the string can be. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11599 Signed-off-by: Douglas Bagnall <[email protected]> Pair-programmed-with: Andrew Bartlett <[email protected]> Reviewed-by: Ralph Boehme <[email protected]>