func
stringlengths
0
484k
target
int64
0
1
cwe
sequencelengths
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
GBool isReverseVideo() { return reverseVideo; }
0
[]
poppler
abf167af8b15e5f3b510275ce619e6fdb42edd40
200,308,617,566,846,700,000,000,000,000,000,000,000
1
Implement tiling/patterns in SplashOutputDev Fixes bug 13518
Character(char ch) : ch_(ch) {}
0
[ "CWE-125" ]
cpp-peglib
b3b29ce8f3acf3a32733d930105a17d7b0ba347e
60,461,608,608,223,270,000,000,000,000,000,000,000
1
Fix #122
static char *auto_complete(CHANNEL_REC *channel, const char *line) { GList *comp; const char *p; char *nick, *ret; p = strstr(line, completion_char); if (p == NULL) return NULL; nick = g_strndup(line, (int) (p-line)); ret = NULL; if (nicklist_find(channel, nick) == NULL) { /* not an exact match, use the first possible completion */ comp = completion_channel_nicks(channel, nick, NULL); if (comp != NULL) { ret = g_strconcat(comp->data, p, NULL); g_list_foreach(comp, (GFunc) g_free, NULL); g_list_free(comp); } } g_free(nick); return ret; }
0
[ "CWE-416" ]
irssi
36564717c9f701e3a339da362ab46d220d27e0c1
251,556,549,473,699,030,000,000,000,000,000,000,000
27
Merge branch 'security' into 'master' Security See merge request irssi/irssi!34 (cherry picked from commit b0d9cb33cd9ef9da7c331409e8b7c57a6f3aef3f)
static void test23(char const* infile, char const* password, char const* outfile, char const* outfile2) { QPDF_ERROR_CODE status = 0; qpdf_read(qpdf, infile, password); status = qpdf_check_pdf(qpdf); printf("status: %d\n", status); report_errors(); }
0
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
66,720,826,248,246,200,000,000,000,000,000,000,000
11
Fix sign and conversion warnings (major) This makes all integer type conversions that have potential data loss explicit with calls that do range checks and raise an exception. After this commit, qpdf builds with no warnings when -Wsign-conversion -Wconversion is used with gcc or clang or when -W3 -Wd4800 is used with MSVC. This significantly reduces the likelihood of potential crashes from bogus integer values. There are some parts of the code that take int when they should take size_t or an offset. Such places would make qpdf not support files with more than 2^31 of something that usually wouldn't be so large. In the event that such a file shows up and is valid, at least qpdf would raise an error in the right spot so the issue could be legitimately addressed rather than failing in some weird way because of a silent overflow condition.
static void register_hooks(apr_pool_t *p) { static const char * const cfgPost[]={ "http_core.c", NULL }; static const char * const parsePre[]={ "mod_proxy.c", NULL }; ap_hook_pre_config(pre_init, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_post_config(initialize_module, NULL, cfgPost, APR_HOOK_MIDDLE); ap_hook_child_init(initialize_child, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_post_read_request(parse_hdr_and_update_nc, parsePre, NULL, APR_HOOK_MIDDLE); ap_hook_check_authn(authenticate_digest_user, NULL, NULL, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF); ap_hook_fixups(add_auth_info, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_note_auth_failure(hook_note_digest_auth_failure, NULL, NULL, APR_HOOK_MIDDLE); }
0
[ "CWE-787" ]
httpd
3b6431eb9c9dba603385f70a2131ab4a01bf0d3b
60,486,314,079,750,730,000,000,000,000,000,000,000
17
Merge r1885659 from trunk: mod_auth_digest: Fast validation of the nonce's base64 to fail early if the format can't match anyway. Submitted by: ylavic Reviewed by: ylavic, covener, jailletc36 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1885666 13f79535-47bb-0310-9956-ffa450edef68
static bool uhid_send_input_report(struct input_device *idev, const uint8_t *data, size_t size) { struct uhid_event ev; int err; if (data == NULL) size = 0; if (size > sizeof(ev.u.input.data)) size = sizeof(ev.u.input.data); if (!idev->uhid_created) { DBG("HID report (%zu bytes) dropped", size); return false; } memset(&ev, 0, sizeof(ev)); ev.type = UHID_INPUT; ev.u.input.size = size; if (size > 0) memcpy(ev.u.input.data, data, size); err = bt_uhid_send(idev->uhid, &ev); if (err < 0) { error("bt_uhid_send: %s (%d)", strerror(-err), -err); return false; } DBG("HID report (%zu bytes)", size); return true; }
0
[]
bluez
3cccdbab2324086588df4ccf5f892fb3ce1f1787
298,845,394,353,987,000,000,000,000,000,000,000,000
34
HID accepts bonded device connections only. This change adds a configuration for platforms to choose a more secure posture for the HID profile. While some older mice are known to not support pairing or encryption, some platform may choose a more secure posture by requiring the device to be bonded and require the connection to be encrypted when bonding is required. Reference: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00352.html
static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, u32 portid, u32 seq, int event, unsigned int flags) { struct net_device *dev = idev->dev; struct ifinfomsg *hdr; struct nlmsghdr *nlh; void *protoinfo; nlh = nlmsg_put(skb, portid, seq, event, sizeof(*hdr), flags); if (nlh == NULL) return -EMSGSIZE; hdr = nlmsg_data(nlh); hdr->ifi_family = AF_INET6; hdr->__ifi_pad = 0; hdr->ifi_type = dev->type; hdr->ifi_index = dev->ifindex; hdr->ifi_flags = dev_get_flags(dev); hdr->ifi_change = 0; if (nla_put_string(skb, IFLA_IFNAME, dev->name) || (dev->addr_len && nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || nla_put_u32(skb, IFLA_MTU, dev->mtu) || (dev->ifindex != dev->iflink && nla_put_u32(skb, IFLA_LINK, dev->iflink))) goto nla_put_failure; protoinfo = nla_nest_start(skb, IFLA_PROTINFO); if (protoinfo == NULL) goto nla_put_failure; if (inet6_fill_ifla6_attrs(skb, idev) < 0) goto nla_put_failure; nla_nest_end(skb, protoinfo); return nlmsg_end(skb, nlh); nla_put_failure: nlmsg_cancel(skb, nlh); return -EMSGSIZE; }
0
[]
net
4b08a8f1bd8cb4541c93ec170027b4d0782dab52
64,392,894,602,204,150,000,000,000,000,000,000,000
41
ipv6: remove max_addresses check from ipv6_create_tempaddr Because of the max_addresses check attackers were able to disable privacy extensions on an interface by creating enough autoconfigured addresses: <http://seclists.org/oss-sec/2012/q4/292> But the check is not actually needed: max_addresses protects the kernel to install too many ipv6 addresses on an interface and guards addrconf_prefix_rcv to install further addresses as soon as this limit is reached. We only generate temporary addresses in direct response of a new address showing up. As soon as we filled up the maximum number of addresses of an interface, we stop installing more addresses and thus also stop generating more temp addresses. Even if the attacker tries to generate a lot of temporary addresses by announcing a prefix and removing it again (lifetime == 0) we won't install more temp addresses, because the temporary addresses do count to the maximum number of addresses, thus we would stop installing new autoconfigured addresses when the limit is reached. This patch fixes CVE-2013-0343 (but other layer-2 attacks are still possible). Thanks to Ding Tianhong to bring this topic up again. Cc: Ding Tianhong <[email protected]> Cc: George Kargiotakis <[email protected]> Cc: P J P <[email protected]> Cc: YOSHIFUJI Hideaki <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Acked-by: Ding Tianhong <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int fname_decrypt(struct inode *inode, const struct fscrypt_str *iname, struct fscrypt_str *oname) { struct skcipher_request *req = NULL; DECLARE_FS_COMPLETION_RESULT(ecr); struct scatterlist src_sg, dst_sg; struct fscrypt_info *ci = inode->i_crypt_info; struct crypto_skcipher *tfm = ci->ci_ctfm; int res = 0; char iv[FS_CRYPTO_BLOCK_SIZE]; unsigned lim; lim = inode->i_sb->s_cop->max_namelen(inode); if (iname->len <= 0 || iname->len > lim) return -EIO; /* Allocate request */ req = skcipher_request_alloc(tfm, GFP_NOFS); if (!req) { printk_ratelimited(KERN_ERR "%s: crypto_request_alloc() failed\n", __func__); return -ENOMEM; } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, fname_crypt_complete, &ecr); /* Initialize IV */ memset(iv, 0, FS_CRYPTO_BLOCK_SIZE); /* Create decryption request */ sg_init_one(&src_sg, iname->name, iname->len); sg_init_one(&dst_sg, oname->name, oname->len); skcipher_request_set_crypt(req, &src_sg, &dst_sg, iname->len, iv); res = crypto_skcipher_decrypt(req); if (res == -EINPROGRESS || res == -EBUSY) { wait_for_completion(&ecr.completion); res = ecr.res; } skcipher_request_free(req); if (res < 0) { printk_ratelimited(KERN_ERR "%s: Error (error code %d)\n", __func__, res); return res; } oname->len = strnlen(oname->name, iname->len); return 0; }
0
[ "CWE-416", "CWE-476" ]
linux
1b53cf9815bb4744958d41f3795d5d5a1d365e2d
208,816,448,682,556,140,000,000,000,000,000,000,000
50
fscrypt: remove broken support for detecting keyring key revocation Filesystem encryption ostensibly supported revoking a keyring key that had been used to "unlock" encrypted files, causing those files to become "locked" again. This was, however, buggy for several reasons, the most severe of which was that when key revocation happened to be detected for an inode, its fscrypt_info was immediately freed, even while other threads could be using it for encryption or decryption concurrently. This could be exploited to crash the kernel or worse. This patch fixes the use-after-free by removing the code which detects the keyring key having been revoked, invalidated, or expired. Instead, an encrypted inode that is "unlocked" now simply remains unlocked until it is evicted from memory. Note that this is no worse than the case for block device-level encryption, e.g. dm-crypt, and it still remains possible for a privileged user to evict unused pages, inodes, and dentries by running 'sync; echo 3 > /proc/sys/vm/drop_caches', or by simply unmounting the filesystem. In fact, one of those actions was already needed anyway for key revocation to work even somewhat sanely. This change is not expected to break any applications. In the future I'd like to implement a real API for fscrypt key revocation that interacts sanely with ongoing filesystem operations --- waiting for existing operations to complete and blocking new operations, and invalidating and sanitizing key material and plaintext from the VFS caches. But this is a hard problem, and for now this bug must be fixed. This bug affected almost all versions of ext4, f2fs, and ubifs encryption, and it was potentially reachable in any kernel configured with encryption support (CONFIG_EXT4_ENCRYPTION=y, CONFIG_EXT4_FS_ENCRYPTION=y, CONFIG_F2FS_FS_ENCRYPTION=y, or CONFIG_UBIFS_FS_ENCRYPTION=y). Note that older kernels did not use the shared fs/crypto/ code, but due to the potential security implications of this bug, it may still be worthwhile to backport this fix to them. Fixes: b7236e21d55f ("ext4 crypto: reorganize how we store keys in the inode") Cc: [email protected] # v4.2+ Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Acked-by: Michael Halcrow <[email protected]>
void CLASS Canon_WBpresets(int skip1, int skip2) { int c; FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Daylight][c ^ (c >> 1)] = get2(); if (skip1) fseek(ifp, skip1, SEEK_CUR); FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Shade][c ^ (c >> 1)] = get2(); if (skip1) fseek(ifp, skip1, SEEK_CUR); FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Cloudy][c ^ (c >> 1)] = get2(); if (skip1) fseek(ifp, skip1, SEEK_CUR); FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Tungsten][c ^ (c >> 1)] = get2(); if (skip1) fseek(ifp, skip1, SEEK_CUR); FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_FL_W][c ^ (c >> 1)] = get2(); if (skip2) fseek(ifp, skip2, SEEK_CUR); FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Flash][c ^ (c >> 1)] = get2(); return; }
0
[ "CWE-476", "CWE-119" ]
LibRaw
d7c3d2cb460be10a3ea7b32e9443a83c243b2251
125,399,763,498,859,880,000,000,000,000,000,000,000
21
Secunia SA75000 advisory: several buffer overruns
bool stringHasTokenAtIndex(size_t index, const std::string& input, const std::string& token) { if (token.size() + index > input.size()) { return false; } return input.compare(index, token.size(), token) == 0; }
0
[ "CWE-835" ]
mongo
0a076417d1d7fba3632b73349a1fd29a83e68816
302,502,622,415,357,950,000,000,000,000,000,000,000
6
SERVER-38070 fix infinite loop in agg expression
symbols_pack (void) { symbols = xcalloc (nsyms, sizeof *symbols); for (int i = 0; symbols_sorted[i]; ++i) symbol_pack (symbols_sorted[i]); /* Aliases leave empty slots in symbols, so remove them. */ { int nsyms_old = nsyms; for (int writei = 0, readi = 0; readi < nsyms_old; readi += 1) { if (symbols[readi] == NULL) { nsyms -= 1; ntokens -= 1; } else { symbols[writei] = symbols[readi]; symbols[writei]->content->number = writei; writei += 1; } } } symbols = xnrealloc (symbols, nsyms, sizeof *symbols); symbols_token_translations_init (); if (startsymbol->content->class == unknown_sym) complain (&startsymbol_loc, fatal, _("the start symbol %s is undefined"), startsymbol->tag); else if (startsymbol->content->class == token_sym) complain (&startsymbol_loc, fatal, _("the start symbol %s is a token"), startsymbol->tag); // If some user tokens are internationalized, the internal ones // should be too. if (has_translations ()) { const bool eof_is_user_defined = !eoftoken->alias || STRNEQ (eoftoken->alias->tag, "$end"); if (!eof_is_user_defined) eoftoken->alias->translatable = true; undeftoken->alias->translatable = true; errtoken->alias->translatable = true; } }
0
[]
bison
b7aab2dbad43aaf14eebe78d54aafa245a000988
339,126,648,436,386,600,000,000,000,000,000,000,000
49
fix: crash when redefining the EOF token Reported by Agency for Defense Development. https://lists.gnu.org/r/bug-bison/2020-08/msg00008.html On an empty such as %token FOO BAR FOO 0 %% input: %empty we crash because when we find FOO 0, we decrement ntokens (since FOO was discovered to be EOF, which is already known to be a token, so we increment ntokens for it, and need to cancel this). This "works well" when EOF is properly defined in one go, but here it is first defined and later only assign token code 0. In the meanwhile BAR was given the token number that we just decremented. To fix this, assign symbol numbers after parsing, not during parsing, so that we also saw all the explicit token codes. To maintain the current numbers (I'd like to keep no difference in the output, not just equivalence), we need to make sure the symbols are numbered in the same order: that of appearance in the source file. So we need the locations to be correct, which was almost the case, except for nterms that appeared several times as LHS (i.e., several times as "foo: ..."). Fixing the use of location_of_lhs sufficed (it appears it was intended for this use, but its implementation was unfinished: it was always set to "false" only). * src/symtab.c (symbol_location_as_lhs_set): Update location_of_lhs. (symbol_code_set): Remove broken hack that decremented ntokens. (symbol_class_set, dummy_symbol_get): Don't set number, ntokens and nnterms. (symbol_check_defined): Do it. (symbols): Don't count nsyms here. Actually, don't count nsyms at all: let it be done in... * src/reader.c (check_and_convert_grammar): here. Define nsyms from ntokens and nnterms after parsing. * tests/input.at (EOF redeclared): New. * examples/c/bistromathic/bistromathic.test: Adjust the traces: in "%nterm <double> exp %% input: ...", exp used to be numbered before input.
struct io_cancel_data *cd) __must_hold(&ctx->completion_lock) { struct io_kiocb *req; int i; for (i = 0; i < (1U << ctx->cancel_hash_bits); i++) { struct hlist_head *list; list = &ctx->cancel_hash[i]; hlist_for_each_entry(req, list, hash_node) { if (!(cd->flags & IORING_ASYNC_CANCEL_ANY) && req->file != cd->file) continue; if (cd->seq == req->work.cancel_seq) continue; req->work.cancel_seq = cd->seq; return req; } } return NULL;
0
[ "CWE-416" ]
linux
9cae36a094e7e9d6e5fe8b6dcd4642138b3eb0c7
131,624,708,677,940,780,000,000,000,000,000,000,000
21
io_uring: reinstate the inflight tracking After some debugging, it was realized that we really do still need the old inflight tracking for any file type that has io_uring_fops assigned. If we don't, then trivial circular references will mean that we never get the ctx cleaned up and hence it'll leak. Just bring back the inflight tracking, which then also means we can eliminate the conditional dropping of the file when task_work is queued. Fixes: d5361233e9ab ("io_uring: drop the old style inflight file tracking") Signed-off-by: Jens Axboe <[email protected]>
static CURLcode bearssl_sha256sum(const unsigned char *input, size_t inputlen, unsigned char *sha256sum, size_t sha256len UNUSED_PARAM) { br_sha256_context ctx; br_sha256_init(&ctx); br_sha256_update(&ctx, input, inputlen); br_sha256_out(&ctx, sha256sum); return CURLE_OK; }
0
[ "CWE-290" ]
curl
b09c8ee15771c614c4bf3ddac893cdb12187c844
128,290,714,367,840,230,000,000,000,000,000,000,000
12
vtls: add 'isproxy' argument to Curl_ssl_get/addsessionid() To make sure we set and extract the correct session. Reported-by: Mingtao Yang Bug: https://curl.se/docs/CVE-2021-22890.html CVE-2021-22890
static GF_Err gf_isom_dump_ttxt_track(GF_ISOFile *the_file, u32 track, FILE *dump, Bool box_dump) { u32 i, j, count, di, nb_descs, shift_offset[20], so_count; u64 last_DTS; size_t len; GF_Box *a; Bool has_scroll; char szDur[100]; GF_Tx3gSampleEntryBox *txt; GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, track); if (!trak) return GF_BAD_PARAM; switch (trak->Media->handler->handlerType) { case GF_ISOM_MEDIA_TEXT: case GF_ISOM_MEDIA_SUBT: break; default: return GF_BAD_PARAM; } txt = (GF_Tx3gSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, 0); switch (txt->type) { case GF_ISOM_BOX_TYPE_TX3G: case GF_ISOM_BOX_TYPE_TEXT: break; case GF_ISOM_BOX_TYPE_STPP: case GF_ISOM_BOX_TYPE_SBTT: default: return GF_BAD_PARAM; } if (box_dump) { fprintf(dump, "<TextTrack trackID=\"%d\" version=\"1.1\">\n", gf_isom_get_track_id(the_file, track) ); } else { fprintf(dump, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); fprintf(dump, "<!-- GPAC 3GPP Text Stream -->\n"); fprintf(dump, "<TextStream version=\"1.1\">\n"); } fprintf(dump, "<TextStreamHeader width=\"%d\" height=\"%d\" layer=\"%d\" translation_x=\"%d\" translation_y=\"%d\">\n", trak->Header->width >> 16 , trak->Header->height >> 16, trak->Header->layer, trak->Header->matrix[6] >> 16, trak->Header->matrix[7] >> 16); nb_descs = gf_list_count(trak->Media->information->sampleTable->SampleDescription->other_boxes); for (i=0; i<nb_descs; i++) { GF_Tx3gSampleEntryBox *txt = (GF_Tx3gSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, i); if (box_dump) { gf_isom_box_dump((GF_Box*) txt, dump); } else if (txt->type==GF_ISOM_BOX_TYPE_TX3G) { fprintf(dump, "<TextSampleDescription horizontalJustification=\""); switch (txt->horizontal_justification) { case 1: fprintf(dump, "center"); break; case -1: fprintf(dump, "right"); break; default: fprintf(dump, "left"); break; } fprintf(dump, "\" verticalJustification=\""); switch (txt->vertical_justification) { case 1: fprintf(dump, "center"); break; case -1: fprintf(dump, "bottom"); break; default: fprintf(dump, "top"); break; } fprintf(dump, "\" "); tx3g_dump_rgba8(dump, "backColor", txt->back_color); fprintf(dump, " verticalText=\"%s\"", (txt->displayFlags & GF_TXT_VERTICAL) ? "yes" : "no"); fprintf(dump, " fillTextRegion=\"%s\"", (txt->displayFlags & GF_TXT_FILL_REGION) ? "yes" : "no"); fprintf(dump, " continuousKaraoke=\"%s\"", (txt->displayFlags & GF_TXT_KARAOKE) ? "yes" : "no"); has_scroll = GF_FALSE; if (txt->displayFlags & GF_TXT_SCROLL_IN) { has_scroll = GF_TRUE; if (txt->displayFlags & GF_TXT_SCROLL_OUT) fprintf(dump, " scroll=\"InOut\""); else fprintf(dump, " scroll=\"In\""); } else if (txt->displayFlags & GF_TXT_SCROLL_OUT) { has_scroll = GF_TRUE; fprintf(dump, " scroll=\"Out\""); } else { fprintf(dump, " scroll=\"None\""); } if (has_scroll) { u32 mode = (txt->displayFlags & GF_TXT_SCROLL_DIRECTION)>>7; switch (mode) { case GF_TXT_SCROLL_CREDITS: fprintf(dump, " scrollMode=\"Credits\""); break; case GF_TXT_SCROLL_MARQUEE: fprintf(dump, " scrollMode=\"Marquee\""); break; case GF_TXT_SCROLL_DOWN: fprintf(dump, " scrollMode=\"Down\""); break; case GF_TXT_SCROLL_RIGHT: fprintf(dump, " scrollMode=\"Right\""); break; default: fprintf(dump, " scrollMode=\"Unknown\""); break; } } fprintf(dump, ">\n"); fprintf(dump, "<FontTable>\n"); if (txt->font_table) { for (j=0; j<txt->font_table->entry_count; j++) { fprintf(dump, "<FontTableEntry fontName=\"%s\" fontID=\"%d\"/>\n", txt->font_table->fonts[j].fontName, txt->font_table->fonts[j].fontID); } } fprintf(dump, "</FontTable>\n"); if ((txt->default_box.bottom == txt->default_box.top) || (txt->default_box.right == txt->default_box.left)) { txt->default_box.top = txt->default_box.left = 0; txt->default_box.right = trak->Header->width / 65536; txt->default_box.bottom = trak->Header->height / 65536; } tx3g_dump_box_nobox(dump, &txt->default_box); tx3g_dump_style_nobox(dump, &txt->default_style, NULL, 0); fprintf(dump, "</TextSampleDescription>\n"); } else { GF_TextSampleEntryBox *text = (GF_TextSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->other_boxes, i); fprintf(dump, "<TextSampleDescription horizontalJustification=\""); switch (text->textJustification) { case 1: fprintf(dump, "center"); break; case -1: fprintf(dump, "right"); break; default: fprintf(dump, "left"); break; } fprintf(dump, "\""); tx3g_dump_rgb16(dump, " backColor", text->background_color); if ((text->default_box.bottom == text->default_box.top) || (text->default_box.right == text->default_box.left)) { text->default_box.top = text->default_box.left = 0; text->default_box.right = trak->Header->width / 65536; text->default_box.bottom = trak->Header->height / 65536; } if (text->displayFlags & GF_TXT_SCROLL_IN) { if (text->displayFlags & GF_TXT_SCROLL_OUT) fprintf(dump, " scroll=\"InOut\""); else fprintf(dump, " scroll=\"In\""); } else if (text->displayFlags & GF_TXT_SCROLL_OUT) { fprintf(dump, " scroll=\"Out\""); } else { fprintf(dump, " scroll=\"None\""); } fprintf(dump, ">\n"); tx3g_dump_box_nobox(dump, &text->default_box); fprintf(dump, "</TextSampleDescription>\n"); } } fprintf(dump, "</TextStreamHeader>\n"); last_DTS = 0; count = gf_isom_get_sample_count(the_file, track); for (i=0; i<count; i++) { GF_BitStream *bs; GF_TextSample *txt; GF_ISOSample *s = gf_isom_get_sample(the_file, track, i+1, &di); if (!s) continue; fprintf(dump, "<TextSample sampleTime=\"%s\" sampleDescriptionIndex=\"%d\"", tx3g_format_time(s->DTS, trak->Media->mediaHeader->timeScale, szDur, GF_FALSE), di); bs = gf_bs_new(s->data, s->dataLength, GF_BITSTREAM_READ); txt = gf_isom_parse_texte_sample(bs); gf_bs_del(bs); if (!box_dump) { if (txt->highlight_color) { fprintf(dump, " "); tx3g_dump_rgba8(dump, "highlightColor", txt->highlight_color->hil_color); } if (txt->scroll_delay) { Double delay = txt->scroll_delay->scroll_delay; delay /= trak->Media->mediaHeader->timeScale; fprintf(dump, " scrollDelay=\"%g\"", delay); } if (txt->wrap) fprintf(dump, " wrap=\"%s\"", (txt->wrap->wrap_flag==0x01) ? "Automatic" : "None"); } so_count = 0; fprintf(dump, " xml:space=\"preserve\">"); if (!txt->len) { last_DTS = (u32) trak->Media->mediaHeader->duration; } else { unsigned short utf16Line[10000]; last_DTS = s->DTS; /*UTF16*/ if ((txt->len>2) && ((unsigned char) txt->text[0] == (unsigned char) 0xFE) && ((unsigned char) txt->text[1] == (unsigned char) 0xFF)) { /*copy 2 more chars because the lib always add 2 '0' at the end for UTF16 end of string*/ memcpy((char *) utf16Line, txt->text+2, sizeof(char) * (txt->len)); len = gf_utf8_wcslen((const u16*)utf16Line); } else { char *str; str = txt->text; len = gf_utf8_mbstowcs((u16*)utf16Line, 10000, (const char **) &str); } if (len != (size_t) -1) { utf16Line[len] = 0; for (j=0; j<len; j++) { if ((utf16Line[j]=='\n') || (utf16Line[j]=='\r') || (utf16Line[j]==0x85) || (utf16Line[j]==0x2028) || (utf16Line[j]==0x2029) ) { fprintf(dump, "\n"); if ((utf16Line[j]=='\r') && (utf16Line[j+1]=='\n')) { shift_offset[so_count] = j; so_count++; j++; } } else { switch (utf16Line[j]) { case '\'': fprintf(dump, "&apos;"); break; case '\"': fprintf(dump, "&quot;"); break; case '&': fprintf(dump, "&amp;"); break; case '>': fprintf(dump, "&gt;"); break; case '<': fprintf(dump, "&lt;"); break; default: if (utf16Line[j] < 128) { fprintf(dump, "%c", (u8) utf16Line[j]); } else { fprintf(dump, "&#%d;", utf16Line[j]); } break; } } } } } if (box_dump) { if (txt->highlight_color) gf_isom_box_dump((GF_Box*) txt->highlight_color, dump); if (txt->scroll_delay) gf_isom_box_dump((GF_Box*) txt->scroll_delay, dump); if (txt->wrap) gf_isom_box_dump((GF_Box*) txt->wrap, dump); if (txt->box) gf_isom_box_dump((GF_Box*) txt->box, dump); if (txt->styles) gf_isom_box_dump((GF_Box*) txt->styles, dump); } else { if (txt->box) tx3g_dump_box_nobox(dump, &txt->box->box); if (txt->styles) { for (j=0; j<txt->styles->entry_count; j++) { tx3g_dump_style_nobox(dump, &txt->styles->styles[j], shift_offset, so_count); } } } j=0; while ((a = (GF_Box *)gf_list_enum(txt->others, &j))) { if (box_dump) { gf_isom_box_dump((GF_Box*) a, dump); continue; } switch (a->type) { case GF_ISOM_BOX_TYPE_HLIT: fprintf(dump, "<Highlight "); tx3g_print_char_offsets(dump, ((GF_TextHighlightBox *)a)->startcharoffset, ((GF_TextHighlightBox *)a)->endcharoffset, shift_offset, so_count); fprintf(dump, "/>\n"); break; case GF_ISOM_BOX_TYPE_HREF: { GF_TextHyperTextBox *ht = (GF_TextHyperTextBox *)a; fprintf(dump, "<HyperLink "); tx3g_print_char_offsets(dump, ht->startcharoffset, ht->endcharoffset, shift_offset, so_count); fprintf(dump, "URL=\"%s\" URLToolTip=\"%s\"/>\n", ht->URL ? ht->URL : "", ht->URL_hint ? ht->URL_hint : ""); } break; case GF_ISOM_BOX_TYPE_BLNK: fprintf(dump, "<Blinking "); tx3g_print_char_offsets(dump, ((GF_TextBlinkBox *)a)->startcharoffset, ((GF_TextBlinkBox *)a)->endcharoffset, shift_offset, so_count); fprintf(dump, "/>\n"); break; case GF_ISOM_BOX_TYPE_KROK: { u32 k; Double t; GF_TextKaraokeBox *krok = (GF_TextKaraokeBox *)a; t = krok->highlight_starttime; t /= trak->Media->mediaHeader->timeScale; fprintf(dump, "<Karaoke startTime=\"%g\">\n", t); for (k=0; k<krok->nb_entries; k++) { t = krok->records[k].highlight_endtime; t /= trak->Media->mediaHeader->timeScale; fprintf(dump, "<KaraokeRange "); tx3g_print_char_offsets(dump, krok->records[k].start_charoffset, krok->records[k].end_charoffset, shift_offset, so_count); fprintf(dump, "endTime=\"%g\"/>\n", t); } fprintf(dump, "</Karaoke>\n"); } break; } } fprintf(dump, "</TextSample>\n"); gf_isom_sample_del(&s); gf_isom_delete_text_sample(txt); gf_set_progress("TTXT Extract", i, count); } if (last_DTS < trak->Media->mediaHeader->duration) { fprintf(dump, "<TextSample sampleTime=\"%s\" text=\"\" />\n", tx3g_format_time(trak->Media->mediaHeader->duration, trak->Media->mediaHeader->timeScale, szDur, GF_FALSE)); } if (box_dump) { fprintf(dump, "</TextTrack>\n"); } else { fprintf(dump, "</TextStream>\n"); } if (count) gf_set_progress("TTXT Extract", count, count); return GF_OK; }
0
[ "CWE-125" ]
gpac
bceb03fd2be95097a7b409ea59914f332fb6bc86
26,158,964,388,090,650,000,000,000,000,000,000,000
335
fixed 2 possible heap overflows (inc. #1088)
int Field_varstring::key_cmp(const uchar *key_ptr, uint max_key_length) { uint length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); uint local_char_length= max_key_length / field_charset->mbmaxlen; local_char_length= my_charpos(field_charset, ptr + length_bytes, ptr + length_bytes + length, local_char_length); set_if_smaller(length, local_char_length); return field_charset->coll->strnncollsp(field_charset, ptr + length_bytes, length, key_ptr+ HA_KEY_BLOB_LENGTH, uint2korr(key_ptr)); }
0
[ "CWE-120" ]
server
eca207c46293bc72dd8d0d5622153fab4d3fccf1
63,719,946,544,344,530,000,000,000,000,000,000,000
15
MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size. Precision should be kept below DECIMAL_MAX_SCALE for computations. It can be bigger in Item_decimal. I'd fix this too but it changes the existing behaviour so problemmatic to ix.
_gnutls_x509_decode_string(unsigned int etype, const uint8_t * der, size_t der_size, gnutls_datum_t * output, unsigned allow_ber) { int ret; uint8_t *str; unsigned int str_size, len; gnutls_datum_t td; #ifdef HAVE_ASN1_DECODE_SIMPLE_BER if (allow_ber) ret = asn1_decode_simple_ber(etype, der, der_size, &str, &str_size, NULL); else #endif ret = asn1_decode_simple_der(etype, der, der_size, (const uint8_t**)&str, &str_size); if (ret != ASN1_SUCCESS) { gnutls_assert(); ret = _gnutls_asn2err(ret); return ret; } td.size = str_size; td.data = gnutls_malloc(str_size + 1); if (td.data == NULL) return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); memcpy(td.data, str, str_size); td.data[str_size] = 0; #ifdef HAVE_ASN1_DECODE_SIMPLE_BER if (allow_ber) free(str); #endif ret = make_printable_string(etype, &td, output); if (ret == GNUTLS_E_INVALID_REQUEST) { /* unsupported etype */ output->data = td.data; output->size = td.size; ret = 0; } else if (ret <= 0) { _gnutls_free_datum(&td); } /* Refuse to deal with strings containing NULs. */ if (etype != ASN1_ETYPE_OCTET_STRING) { if (output->data) len = strlen((void *) output->data); else len = 0; if (len != (size_t) output->size) { _gnutls_free_datum(output); ret = gnutls_assert_val(GNUTLS_E_ASN1_DER_ERROR); } } return ret; }
0
[]
gnutls
272854367efc130fbd4f1a51840d80c630214e12
332,758,606,039,787,300,000,000,000,000,000,000,000
60
Reset the output value on error in _gnutls_x509_dn_to_string() Reported by Kurt Roeckx.
gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, struct x86_exception *exception) { struct kvm_mmu *mmu = vcpu->arch.walk_mmu; return mmu->gva_to_gpa(vcpu, mmu, gva, 0, exception); }
0
[ "CWE-476" ]
linux
55749769fe608fa3f4a075e42e89d237c8e37637
220,280,158,132,763,250,000,000,000,000,000,000,000
7
KVM: x86: Fix wall clock writes in Xen shared_info not to mark page dirty When dirty ring logging is enabled, any dirty logging without an active vCPU context will cause a kernel oops. But we've already declared that the shared_info page doesn't get dirty tracking anyway, since it would be kind of insane to mark it dirty every time we deliver an event channel interrupt. Userspace is supposed to just assume it's always dirty any time a vCPU can run or event channels are routed. So stop using the generic kvm_write_wall_clock() and just write directly through the gfn_to_pfn_cache that we already have set up. We can make kvm_write_wall_clock() static in x86.c again now, but let's not remove the 'sec_hi_ofs' argument even though it's not used yet. At some point we *will* want to use that for KVM guests too. Fixes: 629b5348841a ("KVM: x86/xen: update wallclock region") Reported-by: butt3rflyh4ck <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
void SELECT_LEX::lex_start(LEX *plex) { SELECT_LEX_UNIT *unit= &plex->unit; /* 'parent_lex' is used in init_query() so it must be before it. */ parent_lex= plex; init_query(); master= unit; prev= &unit->slave; link_next= slave= next= 0; link_prev= (st_select_lex_node**)&(plex->all_selects_list); DBUG_ASSERT(!group_list_ptrs); select_number= 1; in_sum_expr=0; ftfunc_list_alloc.empty(); ftfunc_list= &ftfunc_list_alloc; group_list.empty(); order_list.empty(); gorder_list.empty(); }
0
[ "CWE-703" ]
server
39feab3cd31b5414aa9b428eaba915c251ac34a2
147,598,666,820,068,300,000,000,000,000,000,000,000
19
MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT IF an INSERT/REPLACE SELECT statement contained an ON expression in the top level select and this expression used a subquery with a column reference that could not be resolved then an attempt to resolve this reference as an outer reference caused a crash of the server. This happened because the outer context field in the Name_resolution_context structure was not set to NULL for such references. Rather it pointed to the first element in the select_stack. Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select() method when parsing a SELECT construct. Approved by Oleksandr Byelkin <[email protected]>
static void do_json_objects(QPDF& pdf, Options& o, JSON& j) { // Add all objects. Do this first before other code below modifies // things by doing stuff like calling // pushInheritedAttributesToPage. bool all_objects = o.json_objects.empty(); std::set<QPDFObjGen> wanted_og; for (std::set<std::string>::iterator iter = o.json_objects.begin(); iter != o.json_objects.end(); ++iter) { bool trailer; int obj = 0; int gen = 0; parse_object_id(*iter, trailer, obj, gen); if (obj) { wanted_og.insert(QPDFObjGen(obj, gen)); } } JSON j_objects = j.addDictionaryMember("objects", JSON::makeDictionary()); if (all_objects || o.json_objects.count("trailer")) { j_objects.addDictionaryMember( "trailer", pdf.getTrailer().getJSON(true)); } std::vector<QPDFObjectHandle> objects = pdf.getAllObjects(); for (std::vector<QPDFObjectHandle>::iterator iter = objects.begin(); iter != objects.end(); ++iter) { if (all_objects || wanted_og.count((*iter).getObjGen())) { j_objects.addDictionaryMember( (*iter).unparse(), (*iter).getJSON(true)); } } }
0
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
67,837,725,085,317,800,000,000,000,000,000,000,000
36
Fix sign and conversion warnings (major) This makes all integer type conversions that have potential data loss explicit with calls that do range checks and raise an exception. After this commit, qpdf builds with no warnings when -Wsign-conversion -Wconversion is used with gcc or clang or when -W3 -Wd4800 is used with MSVC. This significantly reduces the likelihood of potential crashes from bogus integer values. There are some parts of the code that take int when they should take size_t or an offset. Such places would make qpdf not support files with more than 2^31 of something that usually wouldn't be so large. In the event that such a file shows up and is valid, at least qpdf would raise an error in the right spot so the issue could be legitimately addressed rather than failing in some weird way because of a silent overflow condition.
static void mg_dns_free(struct dns_data *d) { LIST_DELETE(struct dns_data, &s_reqs, d); free(d); }
0
[ "CWE-552" ]
mongoose
c65c8fdaaa257e0487ab0aaae9e8f6b439335945
291,098,667,406,549,600,000,000,000,000,000,000,000
4
Protect against the directory traversal in mg_upload()
qf_get_nth_above_entry(qfline_T *entry, int n, int linewise, int *errornr) { while (n-- > 0 && !got_int) { if (entry->qf_prev == NULL || entry->qf_prev->qf_fnum != entry->qf_fnum) break; entry = entry->qf_prev; --*errornr; // If multiple entries are on the same line, then use the first entry if (linewise) entry = qf_find_first_entry_on_line(entry, errornr); } }
0
[ "CWE-416" ]
vim
4f1b083be43f351bc107541e7b0c9655a5d2c0bb
176,962,817,644,785,730,000,000,000,000,000,000,000
16
patch 9.0.0322: crash when no errors and 'quickfixtextfunc' is set Problem: Crash when no errors and 'quickfixtextfunc' is set. Solution: Do not handle errors if there aren't any.
int handler::update_auto_increment() { ulonglong nr, nb_reserved_values; bool append= FALSE; THD *thd= table->in_use; struct system_variables *variables= &thd->variables; int result=0, tmp; DBUG_ENTER("handler::update_auto_increment"); /* next_insert_id is a "cursor" into the reserved interval, it may go greater than the interval, but not smaller. */ DBUG_ASSERT(next_insert_id >= auto_inc_interval_for_cur_row.minimum()); if ((nr= table->next_number_field->val_int()) != 0 || (table->auto_increment_field_not_null && thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)) { /* There could be an error reported because value was truncated when strict mode is enabled. */ if (thd->is_error()) DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); /* Update next_insert_id if we had already generated a value in this statement (case of INSERT VALUES(null),(3763),(null): the last NULL needs to insert 3764, not the value of the first NULL plus 1). Ignore negative values. */ if ((longlong) nr > 0 || (table->next_number_field->flags & UNSIGNED_FLAG)) adjust_next_insert_id_after_explicit_value(nr); insert_id_for_cur_row= 0; // didn't generate anything DBUG_RETURN(0); } if (table->versioned()) { Field *end= table->vers_end_field(); DBUG_ASSERT(end); bitmap_set_bit(table->read_set, end->field_index); if (!end->is_max()) { if (thd->lex->sql_command == SQLCOM_ALTER_TABLE) { if (!table->next_number_field->real_maybe_null()) DBUG_RETURN(HA_ERR_UNSUPPORTED); table->next_number_field->set_null(); } DBUG_RETURN(0); } } // ALTER TABLE ... ADD COLUMN ... AUTO_INCREMENT if (thd->lex->sql_command == SQLCOM_ALTER_TABLE) table->next_number_field->set_notnull(); if ((nr= next_insert_id) >= auto_inc_interval_for_cur_row.maximum()) { /* next_insert_id is beyond what is reserved, so we reserve more. */ const Discrete_interval *forced= thd->auto_inc_intervals_forced.get_next(); if (forced != NULL) { nr= forced->minimum(); nb_reserved_values= forced->values(); } else { /* handler::estimation_rows_to_insert was set by handler::ha_start_bulk_insert(); if 0 it means "unknown". */ ulonglong nb_desired_values; /* If an estimation was given to the engine: - use it. - if we already reserved numbers, it means the estimation was not accurate, then we'll reserve 2*AUTO_INC_DEFAULT_NB_ROWS the 2nd time, twice that the 3rd time etc. If no estimation was given, use those increasing defaults from the start, starting from AUTO_INC_DEFAULT_NB_ROWS. Don't go beyond a max to not reserve "way too much" (because reservation means potentially losing unused values). Note that in prelocked mode no estimation is given. */ if ((auto_inc_intervals_count == 0) && (estimation_rows_to_insert > 0)) nb_desired_values= estimation_rows_to_insert; else if ((auto_inc_intervals_count == 0) && (thd->lex->many_values.elements > 0)) { /* For multi-row inserts, if the bulk inserts cannot be started, the handler::estimation_rows_to_insert will not be set. But we still want to reserve the autoinc values. */ nb_desired_values= thd->lex->many_values.elements; } else /* go with the increasing defaults */ { /* avoid overflow in formula, with this if() */ if (auto_inc_intervals_count <= AUTO_INC_DEFAULT_NB_MAX_BITS) { nb_desired_values= AUTO_INC_DEFAULT_NB_ROWS * (1 << auto_inc_intervals_count); set_if_smaller(nb_desired_values, AUTO_INC_DEFAULT_NB_MAX); } else nb_desired_values= AUTO_INC_DEFAULT_NB_MAX; } get_auto_increment(variables->auto_increment_offset, variables->auto_increment_increment, nb_desired_values, &nr, &nb_reserved_values); if (nr == ULONGLONG_MAX) DBUG_RETURN(HA_ERR_AUTOINC_READ_FAILED); // Mark failure /* That rounding below should not be needed when all engines actually respect offset and increment in get_auto_increment(). But they don't so we still do it. Wonder if for the not-first-in-index we should do it. Hope that this rounding didn't push us out of the interval; even if it did we cannot do anything about it (calling the engine again will not help as we inserted no row). */ nr= compute_next_insert_id(nr-1, variables); } if (table->s->next_number_keypart == 0) { /* We must defer the appending until "nr" has been possibly truncated */ append= TRUE; } else { /* For such auto_increment there is no notion of interval, just a singleton. The interval is not even stored in thd->auto_inc_interval_for_cur_row, so we are sure to call the engine for next row. */ DBUG_PRINT("info",("auto_increment: special not-first-in-index")); } } if (unlikely(nr == ULONGLONG_MAX)) DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); DBUG_ASSERT(nr != 0); DBUG_PRINT("info",("auto_increment: %llu nb_reserved_values: %llu", nr, append ? nb_reserved_values : 0)); /* Store field without warning (Warning will be printed by insert) */ { Check_level_instant_set check_level_save(thd, CHECK_FIELD_IGNORE); tmp= table->next_number_field->store((longlong)nr, TRUE); } if (unlikely(tmp)) // Out of range value in store { /* First, test if the query was aborted due to strict mode constraints or new field value greater than maximum integer value: */ if (thd->killed == KILL_BAD_DATA || nr > table->next_number_field->get_max_int_value()) { /* It's better to return an error here than getting a confusing 'duplicate key error' later. */ result= HA_ERR_AUTOINC_ERANGE; } else { /* Field refused this value (overflow) and truncated it, use the result of the truncation (which is going to be inserted); however we try to decrease it to honour auto_increment_* variables. That will shift the left bound of the reserved interval, we don't bother shifting the right bound (anyway any other value from this interval will cause a duplicate key). */ nr= prev_insert_id(table->next_number_field->val_int(), variables); if (unlikely(table->next_number_field->store((longlong)nr, TRUE))) nr= table->next_number_field->val_int(); } } if (append) { auto_inc_interval_for_cur_row.replace(nr, nb_reserved_values, variables->auto_increment_increment); auto_inc_intervals_count++; /* Row-based replication does not need to store intervals in binlog */ if (((WSREP(thd) && wsrep_emulate_bin_log ) || mysql_bin_log.is_open()) && !thd->is_current_stmt_binlog_format_row()) thd->auto_inc_intervals_in_cur_stmt_for_binlog. append(auto_inc_interval_for_cur_row.minimum(), auto_inc_interval_for_cur_row.values(), variables->auto_increment_increment); } /* Record this autogenerated value. If the caller then succeeds to insert this value, it will call record_first_successful_insert_id_in_cur_stmt() which will set first_successful_insert_id_in_cur_stmt if it's not already set. */ insert_id_for_cur_row= nr; if (result) // overflow DBUG_RETURN(result); /* Set next insert id to point to next auto-increment value to be able to handle multi-row statements. */ set_next_insert_id(compute_next_insert_id(nr, variables)); DBUG_RETURN(0); }
0
[ "CWE-416" ]
server
af810407f78b7f792a9bb8c47c8c532eb3b3a758
258,659,387,207,523,960,000,000,000,000,000,000,000
226
MDEV-28098 incorrect key in "dup value" error after long unique reset errkey after using it, so that it wouldn't affect the next error message in the next statement
int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct vmw_private *dev_priv = vmw_priv(dev); struct vmw_user_surface *user_srf; struct vmw_surface *srf; struct vmw_resource *res; struct vmw_resource *tmp; union drm_vmw_gb_surface_create_arg *arg = (union drm_vmw_gb_surface_create_arg *)data; struct drm_vmw_gb_surface_create_req *req = &arg->req; struct drm_vmw_gb_surface_create_rep *rep = &arg->rep; struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; int ret; uint32_t size; uint32_t backup_handle; if (req->multisample_count != 0) return -EINVAL; if (req->mip_levels > DRM_VMW_MAX_MIP_LEVELS) return -EINVAL; if (unlikely(vmw_user_surface_size == 0)) vmw_user_surface_size = ttm_round_pot(sizeof(*user_srf)) + 128; size = vmw_user_surface_size + 128; /* Define a surface based on the parameters. */ ret = vmw_surface_gb_priv_define(dev, size, req->svga3d_flags, req->format, req->drm_surface_flags & drm_vmw_surface_flag_scanout, req->mip_levels, req->multisample_count, req->array_size, req->base_size, &srf); if (unlikely(ret != 0)) return ret; user_srf = container_of(srf, struct vmw_user_surface, srf); if (drm_is_primary_client(file_priv)) user_srf->master = drm_master_get(file_priv->master); ret = ttm_read_lock(&dev_priv->reservation_sem, true); if (unlikely(ret != 0)) return ret; res = &user_srf->srf.res; if (req->buffer_handle != SVGA3D_INVALID_ID) { ret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle, &res->backup, &user_srf->backup_base); if (ret == 0 && res->backup->base.num_pages * PAGE_SIZE < res->backup_size) { DRM_ERROR("Surface backup buffer is too small.\n"); vmw_dmabuf_unreference(&res->backup); ret = -EINVAL; goto out_unlock; } } else if (req->drm_surface_flags & drm_vmw_surface_flag_create_buffer) ret = vmw_user_dmabuf_alloc(dev_priv, tfile, res->backup_size, req->drm_surface_flags & drm_vmw_surface_flag_shareable, &backup_handle, &res->backup, &user_srf->backup_base); if (unlikely(ret != 0)) { vmw_resource_unreference(&res); goto out_unlock; } tmp = vmw_resource_reference(res); ret = ttm_prime_object_init(tfile, res->backup_size, &user_srf->prime, req->drm_surface_flags & drm_vmw_surface_flag_shareable, VMW_RES_SURFACE, &vmw_user_surface_base_release, NULL); if (unlikely(ret != 0)) { vmw_resource_unreference(&tmp); vmw_resource_unreference(&res); goto out_unlock; } rep->handle = user_srf->prime.base.hash.key; rep->backup_size = res->backup_size; if (res->backup) { rep->buffer_map_handle = drm_vma_node_offset_addr(&res->backup->base.vma_node); rep->buffer_size = res->backup->base.num_pages * PAGE_SIZE; rep->buffer_handle = backup_handle; } else { rep->buffer_map_handle = 0; rep->buffer_size = 0; rep->buffer_handle = SVGA3D_INVALID_ID; } vmw_resource_unreference(&res); out_unlock: ttm_read_unlock(&dev_priv->reservation_sem); return ret; }
1
[ "CWE-200" ]
linux
07678eca2cf9c9a18584e546c2b2a0d0c9a3150c
329,068,265,810,383,470,000,000,000,000,000,000,000
111
drm/vmwgfx: Make sure backup_handle is always valid When vmw_gb_surface_define_ioctl() is called with an existing buffer, we end up returning an uninitialized variable in the backup_handle. The fix is to first initialize backup_handle to 0 just to be sure, and second, when a user-provided buffer is found, we will use the req->buffer_handle as the backup_handle. Cc: <[email protected]> Reported-by: Murray McAllister <[email protected]> Signed-off-by: Sinclair Yeh <[email protected]> Reviewed-by: Deepak Rawat <[email protected]>
static int imap_msg_open_new(struct Context *ctx, struct Message *msg, struct Header *hdr) { char tmp[PATH_MAX]; mutt_mktemp(tmp, sizeof(tmp)); msg->fp = mutt_file_fopen(tmp, "w"); if (!msg->fp) { mutt_perror(tmp); return -1; } msg->path = mutt_str_strdup(tmp); return 0; }
0
[ "CWE-78", "CWE-77" ]
neomutt
95e80bf9ff10f68cb6443f760b85df4117cb15eb
208,363,579,858,639,130,000,000,000,000,000,000,000
14
Quote path in imap_subscribe
int get_num_images(char *imgdirpath) { DIR *dir; struct dirent* content; int num_images = 0; /*Reading the input images from given input directory*/ dir = opendir(imgdirpath); if (!dir) { fprintf(stderr, "Could not open Folder %s\n", imgdirpath); return 0; } while ((content = readdir(dir)) != NULL) { if (strcmp(".", content->d_name) == 0 || strcmp("..", content->d_name) == 0) { continue; } num_images++; } closedir(dir); return num_images; }
0
[ "CWE-824" ]
openjpeg
0afbdcf3e6d0d2bd2e16a0c4d513ee3cf86e460d
273,955,909,069,617,230,000,000,000,000,000,000,000
23
Fix segfault in src/bin/jp2/opj_decompress.c due to uninitialized pointer (fixes #1368) (#1369)
bool attemptToParseGenericExpression(ParseContext* parseCtx, const FieldPath& path, const BSONObj& subObj, ProjectionPathASTNode* parent) { if (!Expression::isExpressionName(subObj.firstElementFieldNameStringData())) { return false; } // It must be an expression. verifyComputedFieldsAllowed(parseCtx->policies); const bool isMeta = subObj.firstElementFieldNameStringData() == "$meta"; uassert(31252, "Cannot use expression other than $meta in exclusion projection", !parseCtx->type || *parseCtx->type == ProjectType::kInclusion || isMeta); if (!isMeta) { parseCtx->type = ProjectType::kInclusion; } auto expr = Expression::parseExpression( parseCtx->expCtx.get(), subObj, parseCtx->expCtx->variablesParseState); addNodeAtPath(parent, path, std::make_unique<ExpressionASTNode>(expr)); parseCtx->hasMeta = parseCtx->hasMeta || isMeta; return true; }
0
[ "CWE-732" ]
mongo
cd583b6c4d8aa2364f255992708b9bb54e110cf4
83,619,272,104,887,340,000,000,000,000,000,000,000
26
SERVER-53929 Add stricter parser checks around positional projection
vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, struct VhostUserMsg *msg) { uint16_t vring_idx; switch (msg->request.master) { case VHOST_USER_SET_VRING_KICK: case VHOST_USER_SET_VRING_CALL: case VHOST_USER_SET_VRING_ERR: vring_idx = msg->payload.u64 & VHOST_USER_VRING_IDX_MASK; break; case VHOST_USER_SET_VRING_NUM: case VHOST_USER_SET_VRING_BASE: case VHOST_USER_SET_VRING_ENABLE: vring_idx = msg->payload.state.index; break; case VHOST_USER_SET_VRING_ADDR: vring_idx = msg->payload.addr.index; break; default: return 0; } if (vring_idx >= VHOST_MAX_VRING) { RTE_LOG(ERR, VHOST_CONFIG, "invalid vring index: %u\n", vring_idx); return -1; } if (dev->virtqueue[vring_idx]) return 0; return alloc_vring_queue(dev, vring_idx); }
0
[]
dpdk
612e17cf6d7b2bf05a687d8a9ba7be582a744e50
79,247,182,918,343,010,000,000,000,000,000,000,000
34
vhost: fix possible denial of service on SET_VRING_NUM vhost_user_set_vring_num() performs multiple allocations without checking whether data were previously allocated. It may cause a denial of service because of the memory leaks that happen if a malicious vhost-user master keeps sending VHOST_USER_SET_VRING_NUM request until the slave runs out of memory. This issue has been assigned CVE-2019-14818 Fixes: b0a985d1f340 ("vhost: add dequeue zero copy") Reported-by: Jason Wang <[email protected]> Signed-off-by: Maxime Coquelin <[email protected]>
bool Aggregator_distinct::unique_walk_function(void *element) { memcpy(table->field[0]->ptr, element, tree_key_length); item_sum->add(); return 0; }
0
[ "CWE-120" ]
server
eca207c46293bc72dd8d0d5622153fab4d3fccf1
147,894,728,546,462,080,000,000,000,000,000,000,000
6
MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size. Precision should be kept below DECIMAL_MAX_SCALE for computations. It can be bigger in Item_decimal. I'd fix this too but it changes the existing behaviour so problemmatic to ix.
static int parse_group (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) { group_context_t *gc = NULL; group_state_t state = NONE; ADDRESS *addr = NULL; char *estr = NULL; do { mutt_extract_token (buf, s, 0); if (parse_group_context (&gc, buf, s, data, err) == -1) goto bail; if (data == M_UNGROUP && !mutt_strcasecmp (buf->data, "*")) { if (mutt_group_context_clear (&gc) < 0) goto bail; goto out; } if (!mutt_strcasecmp (buf->data, "-rx")) state = RX; else if (!mutt_strcasecmp (buf->data, "-addr")) state = ADDR; else { switch (state) { case NONE: snprintf (err->data, err->dsize, _("%sgroup: missing -rx or -addr."), data == M_UNGROUP ? "un" : ""); goto bail; case RX: if (data == M_GROUP && mutt_group_context_add_rx (gc, buf->data, REG_ICASE, err) != 0) goto bail; else if (data == M_UNGROUP && mutt_group_context_remove_rx (gc, buf->data) < 0) goto bail; break; case ADDR: if ((addr = mutt_parse_adrlist (NULL, buf->data)) == NULL) goto bail; if (mutt_addrlist_to_idna (addr, &estr)) { snprintf (err->data, err->dsize, _("%sgroup: warning: bad IDN '%s'.\n"), data == 1 ? "un" : "", estr); goto bail; } if (data == M_GROUP) mutt_group_context_add_adrlist (gc, addr); else if (data == M_UNGROUP) mutt_group_context_remove_adrlist (gc, addr); rfc822_free_address (&addr); break; } } } while (MoreArgs (s)); out: mutt_group_context_destroy (&gc); return 0; bail: mutt_group_context_destroy (&gc); return -1; }
0
[ "CWE-668" ]
mutt
6d0624411a979e2e1d76af4dd97d03f47679ea4a
141,544,472,597,941,510,000,000,000,000,000,000,000
69
use a 64-bit random value in temporary filenames. closes #3158
msdos_type_find (GstTypeFind * tf, gpointer unused) { const guint8 *data = gst_type_find_peek (tf, 0, 64); if (data && data[0] == 'M' && data[1] == 'Z' && GST_READ_UINT16_LE (data + 8) == 4) { guint32 pe_offset = GST_READ_UINT32_LE (data + 60); data = gst_type_find_peek (tf, pe_offset, 2); if (data && data[0] == 'P' && data[1] == 'E') { gst_type_find_suggest (tf, GST_TYPE_FIND_NEARLY_CERTAIN, MSDOS_CAPS); } } }
0
[ "CWE-125" ]
gst-plugins-base
2fdccfd64fc609e44e9c4b8eed5bfdc0ab9c9095
149,458,636,014,801,740,000,000,000,000,000,000,000
14
typefind: bounds check windows ico detection Fixes out of bounds read https://bugzilla.gnome.org/show_bug.cgi?id=774902
CImg<T>& object3dtoCImg3d(const bool full_check=true) { return get_object3dtoCImg3d(full_check).move_to(*this); }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
286,880,490,153,680,800,000,000,000,000,000,000,000
3
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
static int tar_set(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, const void *kbuf, const void __user *ubuf) { return user_regset_copyin(&pos, &count, &kbuf, &ubuf, &target->thread.tar, 0, sizeof(u64)); }
0
[ "CWE-119", "CWE-787" ]
linux
c1fa0768a8713b135848f78fd43ffc208d8ded70
272,827,821,376,308,150,000,000,000,000,000,000,000
8
powerpc/tm: Flush TM only if CPU has TM feature Commit cd63f3c ("powerpc/tm: Fix saving of TM SPRs in core dump") added code to access TM SPRs in flush_tmregs_to_thread(). However flush_tmregs_to_thread() does not check if TM feature is available on CPU before trying to access TM SPRs in order to copy live state to thread structures. flush_tmregs_to_thread() is indeed guarded by CONFIG_PPC_TRANSACTIONAL_MEM but it might be the case that kernel was compiled with CONFIG_PPC_TRANSACTIONAL_MEM enabled and ran on a CPU without TM feature available, thus rendering the execution of TM instructions that are treated by the CPU as illegal instructions. The fix is just to add proper checking in flush_tmregs_to_thread() if CPU has the TM feature before accessing any TM-specific resource, returning immediately if TM is no available on the CPU. Adding that checking in flush_tmregs_to_thread() instead of in places where it is called, like in vsr_get() and vsr_set(), is better because avoids the same problem cropping up elsewhere. Cc: [email protected] # v4.13+ Fixes: cd63f3c ("powerpc/tm: Fix saving of TM SPRs in core dump") Signed-off-by: Gustavo Romero <[email protected]> Reviewed-by: Cyril Bur <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
static void memcpy_to_page(struct page *page, size_t offset, const char *from, size_t len) { char *to = kmap_atomic(page); memcpy(to + offset, from, len); kunmap_atomic(to); }
0
[ "CWE-200" ]
linux
b9dc6f65bc5e232d1c05fe34b5daadc7e8bbf1fb
76,939,798,761,602,220,000,000,000,000,000,000,000
6
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]>
coolkey_v1_get_attribute_record_len(const u8 *attr, size_t buf_len) { size_t attribute_len = sizeof(coolkey_attribute_header_t); size_t len = 0; int r; r = coolkey_v1_get_attribute_len(attr, buf_len, &len, 1); if (r < 0) { return buf_len; /* skip to the end, ignore the rest of the record */ } return MIN(buf_len,attribute_len+len); }
0
[ "CWE-415" ]
OpenSC
c246f6f69a749d4f68626b40795a4f69168008f4
10,644,714,771,748,371,000,000,000,000,000,000,000
13
coolkey: Make sure the object ID is unique when filling list Thanks to oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19208
void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx) { unsigned int state; /* updated only when leaving the FSM */ register char *ptr, *end; /* request pointers, to avoid dereferences */ struct buffer *buf; state = msg->msg_state; buf = msg->chn->buf; ptr = buf->p + msg->next; end = buf->p + buf->i; if (unlikely(ptr >= end)) goto http_msg_ood; switch (state) { /* * First, states that are specific to the response only. * We check them first so that request and headers are * closer to each other (accessed more often). */ case HTTP_MSG_RPBEFORE: http_msg_rpbefore: if (likely(HTTP_IS_TOKEN(*ptr))) { /* we have a start of message, but we have to check * first if we need to remove some CRLF. We can only * do this when o=0. */ if (unlikely(ptr != buf->p)) { if (buf->o) goto http_msg_ood; /* Remove empty leading lines, as recommended by RFC2616. */ bi_fast_delete(buf, ptr - buf->p); } msg->sol = 0; msg->sl.st.l = 0; /* used in debug mode */ hdr_idx_init(idx); state = HTTP_MSG_RPVER; goto http_msg_rpver; } if (unlikely(!HTTP_IS_CRLF(*ptr))) goto http_msg_invalid; if (unlikely(*ptr == '\n')) EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore, HTTP_MSG_RPBEFORE); EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore_cr, HTTP_MSG_RPBEFORE_CR); /* stop here */ case HTTP_MSG_RPBEFORE_CR: http_msg_rpbefore_cr: EXPECT_LF_HERE(ptr, http_msg_invalid); EAT_AND_JUMP_OR_RETURN(http_msg_rpbefore, HTTP_MSG_RPBEFORE); /* stop here */ case HTTP_MSG_RPVER: http_msg_rpver: case HTTP_MSG_RPVER_SP: case HTTP_MSG_RPCODE: case HTTP_MSG_RPCODE_SP: case HTTP_MSG_RPREASON: ptr = (char *)http_parse_stsline(msg, state, ptr, end, &msg->next, &msg->msg_state); if (unlikely(!ptr)) return; /* we have a full response and we know that we have either a CR * or an LF at <ptr>. */ hdr_idx_set_start(idx, msg->sl.st.l, *ptr == '\r'); msg->sol = ptr - buf->p; if (likely(*ptr == '\r')) EAT_AND_JUMP_OR_RETURN(http_msg_rpline_end, HTTP_MSG_RPLINE_END); goto http_msg_rpline_end; case HTTP_MSG_RPLINE_END: http_msg_rpline_end: /* msg->sol must point to the first of CR or LF. */ EXPECT_LF_HERE(ptr, http_msg_invalid); EAT_AND_JUMP_OR_RETURN(http_msg_hdr_first, HTTP_MSG_HDR_FIRST); /* stop here */ /* * Second, states that are specific to the request only */ case HTTP_MSG_RQBEFORE: http_msg_rqbefore: if (likely(HTTP_IS_TOKEN(*ptr))) { /* we have a start of message, but we have to check * first if we need to remove some CRLF. We can only * do this when o=0. */ if (likely(ptr != buf->p)) { if (buf->o) goto http_msg_ood; /* Remove empty leading lines, as recommended by RFC2616. */ bi_fast_delete(buf, ptr - buf->p); } msg->sol = 0; msg->sl.rq.l = 0; /* used in debug mode */ state = HTTP_MSG_RQMETH; goto http_msg_rqmeth; } if (unlikely(!HTTP_IS_CRLF(*ptr))) goto http_msg_invalid; if (unlikely(*ptr == '\n')) EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore, HTTP_MSG_RQBEFORE); EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore_cr, HTTP_MSG_RQBEFORE_CR); /* stop here */ case HTTP_MSG_RQBEFORE_CR: http_msg_rqbefore_cr: EXPECT_LF_HERE(ptr, http_msg_invalid); EAT_AND_JUMP_OR_RETURN(http_msg_rqbefore, HTTP_MSG_RQBEFORE); /* stop here */ case HTTP_MSG_RQMETH: http_msg_rqmeth: case HTTP_MSG_RQMETH_SP: case HTTP_MSG_RQURI: case HTTP_MSG_RQURI_SP: case HTTP_MSG_RQVER: ptr = (char *)http_parse_reqline(msg, state, ptr, end, &msg->next, &msg->msg_state); if (unlikely(!ptr)) return; /* we have a full request and we know that we have either a CR * or an LF at <ptr>. */ hdr_idx_set_start(idx, msg->sl.rq.l, *ptr == '\r'); msg->sol = ptr - buf->p; if (likely(*ptr == '\r')) EAT_AND_JUMP_OR_RETURN(http_msg_rqline_end, HTTP_MSG_RQLINE_END); goto http_msg_rqline_end; case HTTP_MSG_RQLINE_END: http_msg_rqline_end: /* check for HTTP/0.9 request : no version information available. * msg->sol must point to the first of CR or LF. */ if (unlikely(msg->sl.rq.v_l == 0)) goto http_msg_last_lf; EXPECT_LF_HERE(ptr, http_msg_invalid); EAT_AND_JUMP_OR_RETURN(http_msg_hdr_first, HTTP_MSG_HDR_FIRST); /* stop here */ /* * Common states below */ case HTTP_MSG_HDR_FIRST: http_msg_hdr_first: msg->sol = ptr - buf->p; if (likely(!HTTP_IS_CRLF(*ptr))) { goto http_msg_hdr_name; } if (likely(*ptr == '\r')) EAT_AND_JUMP_OR_RETURN(http_msg_last_lf, HTTP_MSG_LAST_LF); goto http_msg_last_lf; case HTTP_MSG_HDR_NAME: http_msg_hdr_name: /* assumes msg->sol points to the first char */ if (likely(HTTP_IS_TOKEN(*ptr))) EAT_AND_JUMP_OR_RETURN(http_msg_hdr_name, HTTP_MSG_HDR_NAME); if (likely(*ptr == ':')) EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_sp, HTTP_MSG_HDR_L1_SP); if (likely(msg->err_pos < -1) || *ptr == '\n') goto http_msg_invalid; if (msg->err_pos == -1) /* capture error pointer */ msg->err_pos = ptr - buf->p; /* >= 0 now */ /* and we still accept this non-token character */ EAT_AND_JUMP_OR_RETURN(http_msg_hdr_name, HTTP_MSG_HDR_NAME); case HTTP_MSG_HDR_L1_SP: http_msg_hdr_l1_sp: /* assumes msg->sol points to the first char */ if (likely(HTTP_IS_SPHT(*ptr))) EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_sp, HTTP_MSG_HDR_L1_SP); /* header value can be basically anything except CR/LF */ msg->sov = ptr - buf->p; if (likely(!HTTP_IS_CRLF(*ptr))) { goto http_msg_hdr_val; } if (likely(*ptr == '\r')) EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_lf, HTTP_MSG_HDR_L1_LF); goto http_msg_hdr_l1_lf; case HTTP_MSG_HDR_L1_LF: http_msg_hdr_l1_lf: EXPECT_LF_HERE(ptr, http_msg_invalid); EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l1_lws, HTTP_MSG_HDR_L1_LWS); case HTTP_MSG_HDR_L1_LWS: http_msg_hdr_l1_lws: if (likely(HTTP_IS_SPHT(*ptr))) { /* replace HT,CR,LF with spaces */ for (; buf->p + msg->sov < ptr; msg->sov++) buf->p[msg->sov] = ' '; goto http_msg_hdr_l1_sp; } /* we had a header consisting only in spaces ! */ msg->eol = msg->sov; goto http_msg_complete_header; case HTTP_MSG_HDR_VAL: http_msg_hdr_val: /* assumes msg->sol points to the first char, and msg->sov * points to the first character of the value. */ if (likely(!HTTP_IS_CRLF(*ptr))) EAT_AND_JUMP_OR_RETURN(http_msg_hdr_val, HTTP_MSG_HDR_VAL); msg->eol = ptr - buf->p; /* Note: we could also copy eol into ->eoh so that we have the * real header end in case it ends with lots of LWS, but is this * really needed ? */ if (likely(*ptr == '\r')) EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l2_lf, HTTP_MSG_HDR_L2_LF); goto http_msg_hdr_l2_lf; case HTTP_MSG_HDR_L2_LF: http_msg_hdr_l2_lf: EXPECT_LF_HERE(ptr, http_msg_invalid); EAT_AND_JUMP_OR_RETURN(http_msg_hdr_l2_lws, HTTP_MSG_HDR_L2_LWS); case HTTP_MSG_HDR_L2_LWS: http_msg_hdr_l2_lws: if (unlikely(HTTP_IS_SPHT(*ptr))) { /* LWS: replace HT,CR,LF with spaces */ for (; buf->p + msg->eol < ptr; msg->eol++) buf->p[msg->eol] = ' '; goto http_msg_hdr_val; } http_msg_complete_header: /* * It was a new header, so the last one is finished. * Assumes msg->sol points to the first char, msg->sov points * to the first character of the value and msg->eol to the * first CR or LF so we know how the line ends. We insert last * header into the index. */ if (unlikely(hdr_idx_add(msg->eol - msg->sol, buf->p[msg->eol] == '\r', idx, idx->tail) < 0)) goto http_msg_invalid; msg->sol = ptr - buf->p; if (likely(!HTTP_IS_CRLF(*ptr))) { goto http_msg_hdr_name; } if (likely(*ptr == '\r')) EAT_AND_JUMP_OR_RETURN(http_msg_last_lf, HTTP_MSG_LAST_LF); goto http_msg_last_lf; case HTTP_MSG_LAST_LF: http_msg_last_lf: /* Assumes msg->sol points to the first of either CR or LF */ EXPECT_LF_HERE(ptr, http_msg_invalid); ptr++; msg->sov = msg->next = ptr - buf->p; msg->eoh = msg->sol; msg->sol = 0; msg->msg_state = HTTP_MSG_BODY; return; case HTTP_MSG_ERROR: /* this may only happen if we call http_msg_analyser() twice with an error */ break; #ifdef DEBUG_FULL default: fprintf(stderr, "FIXME !!!! impossible state at %s:%d = %d\n", __FILE__, __LINE__, state); exit(1); #endif } http_msg_ood: /* out of data */ msg->msg_state = state; msg->next = ptr - buf->p; return; http_msg_invalid: /* invalid message */ msg->msg_state = HTTP_MSG_ERROR; msg->next = ptr - buf->p; return; }
0
[]
haproxy
aae75e3279c6c9bd136413a72dafdcd4986bb89a
149,236,183,715,031,890,000,000,000,000,000,000,000
303
BUG/CRITICAL: using HTTP information in tcp-request content may crash the process During normal HTTP request processing, request buffers are realigned if there are less than global.maxrewrite bytes available after them, in order to leave enough room for rewriting headers after the request. This is done in http_wait_for_request(). However, if some HTTP inspection happens during a "tcp-request content" rule, this realignment is not performed. In theory this is not a problem because empty buffers are always aligned and TCP inspection happens at the beginning of a connection. But with HTTP keep-alive, it also happens at the beginning of each subsequent request. So if a second request was pipelined by the client before the first one had a chance to be forwarded, the second request will not be realigned. Then, http_wait_for_request() will not perform such a realignment either because the request was already parsed and marked as such. The consequence of this, is that the rewrite of a sufficient number of such pipelined, unaligned requests may leave less room past the request been processed than the configured reserve, which can lead to a buffer overflow if request processing appends some data past the end of the buffer. A number of conditions are required for the bug to be triggered : - HTTP keep-alive must be enabled ; - HTTP inspection in TCP rules must be used ; - some request appending rules are needed (reqadd, x-forwarded-for) - since empty buffers are always realigned, the client must pipeline enough requests so that the buffer always contains something till the point where there is no more room for rewriting. While such a configuration is quite unlikely to be met (which is confirmed by the bug's lifetime), a few people do use these features together for very specific usages. And more importantly, writing such a configuration and the request to attack it is trivial. A quick workaround consists in forcing keep-alive off by adding "option httpclose" or "option forceclose" in the frontend. Alternatively, disabling HTTP-based TCP inspection rules enough if the application supports it. At first glance, this bug does not look like it could lead to remote code execution, as the overflowing part is controlled by the configuration and not by the user. But some deeper analysis should be performed to confirm this. And anyway, corrupting the process' memory and crashing it is quite trivial. Special thanks go to Yves Lafon from the W3C who reported this bug and deployed significant efforts to collect the relevant data needed to understand it in less than one week. CVE-2013-1912 was assigned to this issue. Note that 1.4 is also affected so the fix must be backported.
static int ip_vs_genl_dump_services(struct sk_buff *skb, struct netlink_callback *cb) { int idx = 0, i; int start = cb->args[0]; struct ip_vs_service *svc; struct net *net = skb_sknet(skb); mutex_lock(&__ip_vs_mutex); for (i = 0; i < IP_VS_SVC_TAB_SIZE; i++) { list_for_each_entry(svc, &ip_vs_svc_table[i], s_list) { if (++idx <= start || !net_eq(svc->net, net)) continue; if (ip_vs_genl_dump_service(skb, svc, cb) < 0) { idx--; goto nla_put_failure; } } } for (i = 0; i < IP_VS_SVC_TAB_SIZE; i++) { list_for_each_entry(svc, &ip_vs_svc_fwm_table[i], f_list) { if (++idx <= start || !net_eq(svc->net, net)) continue; if (ip_vs_genl_dump_service(skb, svc, cb) < 0) { idx--; goto nla_put_failure; } } } nla_put_failure: mutex_unlock(&__ip_vs_mutex); cb->args[0] = idx; return skb->len; }
0
[ "CWE-200" ]
linux
2d8a041b7bfe1097af21441cb77d6af95f4f4680
158,883,018,532,649,500,000,000,000,000,000,000,000
37
ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT) If at least one of CONFIG_IP_VS_PROTO_TCP or CONFIG_IP_VS_PROTO_UDP is not set, __ip_vs_get_timeouts() does not fully initialize the structure that gets copied to userland and that for leaks up to 12 bytes of kernel stack. Add an explicit memset(0) before passing the structure to __ip_vs_get_timeouts() to avoid the info leak. Signed-off-by: Mathias Krause <[email protected]> Cc: Wensong Zhang <[email protected]> Cc: Simon Horman <[email protected]> Cc: Julian Anastasov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
megasas_check_reset_xscale(struct megasas_instance *instance, struct megasas_register_set __iomem *regs) { if ((atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) && (le32_to_cpu(*instance->consumer) == MEGASAS_ADPRESET_INPROG_SIGN)) return 1; return 0; }
0
[ "CWE-476" ]
linux
bcf3b67d16a4c8ffae0aa79de5853435e683945c
228,841,022,162,675,430,000,000,000,000,000,000,000
9
scsi: megaraid_sas: return error when create DMA pool failed when create DMA pool for cmd frames failed, we should return -ENOMEM, instead of 0. In some case in: megasas_init_adapter_fusion() -->megasas_alloc_cmds() -->megasas_create_frame_pool create DMA pool failed, --> megasas_free_cmds() [1] -->megasas_alloc_cmds_fusion() failed, then goto fail_alloc_cmds. -->megasas_free_cmds() [2] we will call megasas_free_cmds twice, [1] will kfree cmd_list, [2] will use cmd_list.it will cause a problem: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = ffffffc000f70000 [00000000] *pgd=0000001fbf893003, *pud=0000001fbf893003, *pmd=0000001fbf894003, *pte=006000006d000707 Internal error: Oops: 96000005 [#1] SMP Modules linked in: CPU: 18 PID: 1 Comm: swapper/0 Not tainted task: ffffffdfb9290000 ti: ffffffdfb923c000 task.ti: ffffffdfb923c000 PC is at megasas_free_cmds+0x30/0x70 LR is at megasas_free_cmds+0x24/0x70 ... Call trace: [<ffffffc0005b779c>] megasas_free_cmds+0x30/0x70 [<ffffffc0005bca74>] megasas_init_adapter_fusion+0x2f4/0x4d8 [<ffffffc0005b926c>] megasas_init_fw+0x2dc/0x760 [<ffffffc0005b9ab0>] megasas_probe_one+0x3c0/0xcd8 [<ffffffc0004a5abc>] local_pci_probe+0x4c/0xb4 [<ffffffc0004a5c40>] pci_device_probe+0x11c/0x14c [<ffffffc00053a5e4>] driver_probe_device+0x1ec/0x430 [<ffffffc00053a92c>] __driver_attach+0xa8/0xb0 [<ffffffc000538178>] bus_for_each_dev+0x74/0xc8 [<ffffffc000539e88>] driver_attach+0x28/0x34 [<ffffffc000539a18>] bus_add_driver+0x16c/0x248 [<ffffffc00053b234>] driver_register+0x6c/0x138 [<ffffffc0004a5350>] __pci_register_driver+0x5c/0x6c [<ffffffc000ce3868>] megasas_init+0xc0/0x1a8 [<ffffffc000082a58>] do_one_initcall+0xe8/0x1ec [<ffffffc000ca7be8>] kernel_init_freeable+0x1c8/0x284 [<ffffffc0008d90b8>] kernel_init+0x1c/0xe4 Signed-off-by: Jason Yan <[email protected]> Acked-by: Sumit Saxena <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
static void auth_server_reconnect_timeout(struct auth_server_connection *conn) { (void)auth_server_connection_connect(conn); }
0
[]
core
a9b135760aea6d1790d447d351c56b78889dac22
196,873,985,221,575,700,000,000,000,000,000,000,000
4
lib-auth: Remove request after abort Otherwise the request will still stay in hash table and get dereferenced when all requests are aborted causing an attempt to access free'd memory. Found by Apollon Oikonomopoulos <[email protected]> Broken in 1a29ed2f96da1be22fa5a4d96c7583aa81b8b060
inline const char* option(const char *const name, const int argc, const char *const *const argv, const char *const _default, const char *const usage=0) { return option(name,argc,argv,_default,usage,false); }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
166,778,377,463,787,140,000,000,000,000,000,000,000
4
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
x509::~x509() { ysArrayDelete(buffer_); }
0
[ "CWE-254" ]
mysql-server
e7061f7e5a96c66cb2e0bf46bec7f6ff35801a69
66,102,226,981,302,070,000,000,000,000,000,000,000
4
Bug #22738607: YASSL FUNCTION X509_NAME_GET_INDEX_BY_NID IS NOT WORKING AS EXPECTED.
flatpak_context_load_metadata (FlatpakContext *context, GKeyFile *metakey, GError **error) { gboolean remove; g_auto(GStrv) groups = NULL; gsize i; if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SHARED, NULL)) { g_auto(GStrv) shares = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SHARED, NULL, error); if (shares == NULL) return FALSE; for (i = 0; shares[i] != NULL; i++) { FlatpakContextShares share; share = flatpak_context_share_from_string (parse_negated (shares[i], &remove), NULL); if (share == 0) g_debug ("Unknown share type %s", shares[i]); else { if (remove) flatpak_context_remove_shares (context, share); else flatpak_context_add_shares (context, share); } } } if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SOCKETS, NULL)) { g_auto(GStrv) sockets = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_SOCKETS, NULL, error); if (sockets == NULL) return FALSE; for (i = 0; sockets[i] != NULL; i++) { FlatpakContextSockets socket = flatpak_context_socket_from_string (parse_negated (sockets[i], &remove), NULL); if (socket == 0) g_debug ("Unknown socket type %s", sockets[i]); else { if (remove) flatpak_context_remove_sockets (context, socket); else flatpak_context_add_sockets (context, socket); } } } if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_DEVICES, NULL)) { g_auto(GStrv) devices = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_DEVICES, NULL, error); if (devices == NULL) return FALSE; for (i = 0; devices[i] != NULL; i++) { FlatpakContextDevices device = flatpak_context_device_from_string (parse_negated (devices[i], &remove), NULL); if (device == 0) g_debug ("Unknown device type %s", devices[i]); else { if (remove) flatpak_context_remove_devices (context, device); else flatpak_context_add_devices (context, device); } } } if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FEATURES, NULL)) { g_auto(GStrv) features = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FEATURES, NULL, error); if (features == NULL) return FALSE; for (i = 0; features[i] != NULL; i++) { FlatpakContextFeatures feature = flatpak_context_feature_from_string (parse_negated (features[i], &remove), NULL); if (feature == 0) g_debug ("Unknown feature type %s", features[i]); else { if (remove) flatpak_context_remove_features (context, feature); else flatpak_context_add_features (context, feature); } } } if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FILESYSTEMS, NULL)) { g_auto(GStrv) filesystems = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_FILESYSTEMS, NULL, error); if (filesystems == NULL) return FALSE; for (i = 0; filesystems[i] != NULL; i++) { const char *fs = parse_negated (filesystems[i], &remove); g_autofree char *filesystem = NULL; FlatpakFilesystemMode mode; if (!flatpak_context_parse_filesystem (fs, &filesystem, &mode, NULL)) g_debug ("Unknown filesystem type %s", filesystems[i]); else { if (remove) flatpak_context_take_filesystem (context, g_steal_pointer (&filesystem), FLATPAK_FILESYSTEM_MODE_NONE); else flatpak_context_take_filesystem (context, g_steal_pointer (&filesystem), mode); } } } if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_PERSISTENT, NULL)) { g_auto(GStrv) persistent = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_PERSISTENT, NULL, error); if (persistent == NULL) return FALSE; for (i = 0; persistent[i] != NULL; i++) flatpak_context_set_persistent (context, persistent[i]); } if (g_key_file_has_group (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY)) { g_auto(GStrv) keys = NULL; gsize keys_count; keys = g_key_file_get_keys (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY, &keys_count, NULL); for (i = 0; i < keys_count; i++) { const char *key = keys[i]; g_autofree char *value = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_SESSION_BUS_POLICY, key, NULL); FlatpakPolicy policy; if (!flatpak_verify_dbus_name (key, error)) return FALSE; policy = flatpak_policy_from_string (value, NULL); if ((int) policy != -1) flatpak_context_set_session_bus_policy (context, key, policy); } } if (g_key_file_has_group (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY)) { g_auto(GStrv) keys = NULL; gsize keys_count; keys = g_key_file_get_keys (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY, &keys_count, NULL); for (i = 0; i < keys_count; i++) { const char *key = keys[i]; g_autofree char *value = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_SYSTEM_BUS_POLICY, key, NULL); FlatpakPolicy policy; if (!flatpak_verify_dbus_name (key, error)) return FALSE; policy = flatpak_policy_from_string (value, NULL); if ((int) policy != -1) flatpak_context_set_system_bus_policy (context, key, policy); } } if (g_key_file_has_group (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT)) { g_auto(GStrv) keys = NULL; gsize keys_count; keys = g_key_file_get_keys (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT, &keys_count, NULL); for (i = 0; i < keys_count; i++) { const char *key = keys[i]; g_autofree char *value = g_key_file_get_string (metakey, FLATPAK_METADATA_GROUP_ENVIRONMENT, key, NULL); flatpak_context_set_env_var (context, key, value); } } /* unset-environment is higher precedence than Environment, so that * we can put unset keys in both places. Old versions of Flatpak will * interpret the empty string as unset; new versions will obey * unset-environment. */ if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_UNSET_ENVIRONMENT, NULL)) { g_auto(GStrv) vars = NULL; gsize vars_count; vars = g_key_file_get_string_list (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METADATA_KEY_UNSET_ENVIRONMENT, &vars_count, error); if (vars == NULL) return FALSE; for (i = 0; i < vars_count; i++) { const char *var = vars[i]; flatpak_context_set_env_var (context, var, NULL); } } groups = g_key_file_get_groups (metakey, NULL); for (i = 0; groups[i] != NULL; i++) { const char *group = groups[i]; const char *subsystem; int j; if (g_str_has_prefix (group, FLATPAK_METADATA_GROUP_PREFIX_POLICY)) { g_auto(GStrv) keys = NULL; subsystem = group + strlen (FLATPAK_METADATA_GROUP_PREFIX_POLICY); keys = g_key_file_get_keys (metakey, group, NULL, NULL); for (j = 0; keys != NULL && keys[j] != NULL; j++) { const char *key = keys[j]; g_autofree char *policy_key = g_strdup_printf ("%s.%s", subsystem, key); g_auto(GStrv) values = NULL; int k; values = g_key_file_get_string_list (metakey, group, key, NULL, NULL); for (k = 0; values != NULL && values[k] != NULL; k++) flatpak_context_apply_generic_policy (context, policy_key, values[k]); } } } return TRUE; }
0
[ "CWE-74" ]
flatpak
4108e022452303093d8b90c838695a0476cb09c7
204,720,100,094,647,120,000,000,000,000,000,000,000
247
context: Add --unset-env option and a corresponding override This follows up from GHSA-4ppf-fxf6-vxg2 to fix missing functionality that I noticed while resolving that vulnerability, but is not required for fixing the vulnerability. Signed-off-by: Simon McVittie <[email protected]>
//! Append two images along specified axis \specialization. CImg<T> get_append(const CImg<T>& img, const char axis='x', const float align=0) const { if (is_empty()) return +img; if (!img) return +*this; return CImgList<T>(*this,img,true).get_append(axis,align);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
1,890,860,671,912,762,700,000,000,000,000,000,000
5
Fix other issues in 'CImg<T>::load_bmp()'.
void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group) { int argc; char *argv_buff[1],**argv; const char *groups[5]; DBUG_ENTER("mysql_read_default_options"); DBUG_PRINT("enter",("file: %s group: %s",filename,group ? group :"NULL")); compile_time_assert(OPT_keep_this_one_last == array_elements(default_options)); argc=1; argv=argv_buff; argv_buff[0]= (char*) "client"; groups[0]= (char*) "client"; groups[1]= (char*) "client-server"; groups[2]= (char*) "client-mariadb"; groups[3]= (char*) group; groups[4]=0; my_load_defaults(filename, groups, &argc, &argv, NULL); if (argc != 1) /* If some default option */ { char **option=argv; while (*++option) { if (my_getopt_is_args_separator(option[0])) /* skip arguments separator */ continue; /* DBUG_PRINT("info",("option: %s",option[0])); */ if (option[0][0] == '-' && option[0][1] == '-') { char *end=strcend(*option,'='); char *opt_arg=0; if (*end) { opt_arg=end+1; *end=0; /* Remove '=' */ } /* Change all '_' in variable name to '-' */ for (end= *option ; *(end= strcend(end,'_')) ; ) *end= '-'; switch (find_type(*option + 2, &option_types, FIND_TYPE_BASIC)) { case OPT_port: if (opt_arg) options->port=atoi(opt_arg); break; case OPT_socket: if (opt_arg) { my_free(options->unix_socket); options->unix_socket=my_strdup(opt_arg,MYF(MY_WME)); } break; case OPT_compress: options->compress=1; options->client_flag|= CLIENT_COMPRESS; break; case OPT_password: if (opt_arg) { my_free(options->password); options->password=my_strdup(opt_arg,MYF(MY_WME)); } break; case OPT_pipe: options->protocol = MYSQL_PROTOCOL_PIPE; break; case OPT_connect_timeout: case OPT_timeout: if (opt_arg) options->connect_timeout=atoi(opt_arg); break; case OPT_user: if (opt_arg) { my_free(options->user); options->user=my_strdup(opt_arg,MYF(MY_WME)); } break; case OPT_init_command: add_init_command(options,opt_arg); break; case OPT_host: if (opt_arg) { my_free(options->host); options->host=my_strdup(opt_arg,MYF(MY_WME)); } break; case OPT_database: if (opt_arg) { my_free(options->db); options->db=my_strdup(opt_arg,MYF(MY_WME)); } break; case OPT_debug: #ifdef MYSQL_CLIENT mysql_debug(opt_arg ? opt_arg : "d:t:o,/tmp/client.trace"); break; #endif case OPT_return_found_rows: options->client_flag|=CLIENT_FOUND_ROWS; break; #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) case OPT_ssl_key: my_free(options->ssl_key); options->ssl_key = my_strdup(opt_arg, MYF(MY_WME)); break; case OPT_ssl_cert: my_free(options->ssl_cert); options->ssl_cert = my_strdup(opt_arg, MYF(MY_WME)); break; case OPT_ssl_ca: my_free(options->ssl_ca); options->ssl_ca = my_strdup(opt_arg, MYF(MY_WME)); break; case OPT_ssl_capath: my_free(options->ssl_capath); options->ssl_capath = my_strdup(opt_arg, MYF(MY_WME)); break; case OPT_ssl_cipher: my_free(options->ssl_cipher); options->ssl_cipher= my_strdup(opt_arg, MYF(MY_WME)); break; #else case OPT_ssl_key: case OPT_ssl_cert: case OPT_ssl_ca: case OPT_ssl_capath: case OPT_ssl_cipher: break; #endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */ case OPT_character_sets_dir: my_free(options->charset_dir); options->charset_dir = my_strdup(opt_arg, MYF(MY_WME)); break; case OPT_default_character_set: my_free(options->charset_name); options->charset_name = my_strdup(opt_arg, MYF(MY_WME)); break; case OPT_interactive_timeout: options->client_flag|= CLIENT_INTERACTIVE; break; case OPT_local_infile: if (!opt_arg || atoi(opt_arg) != 0) options->client_flag|= CLIENT_LOCAL_FILES; else options->client_flag&= ~CLIENT_LOCAL_FILES; break; case OPT_disable_local_infile: options->client_flag&= ~CLIENT_LOCAL_FILES; break; case OPT_max_allowed_packet: if (opt_arg) options->max_allowed_packet= atoi(opt_arg); break; case OPT_protocol: if ((options->protocol= find_type(opt_arg, &sql_protocol_typelib, FIND_TYPE_BASIC)) <= 0) { fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg); exit(1); } break; case OPT_shared_memory_base_name: #ifdef HAVE_SMEM if (options->shared_memory_base_name != def_shared_memory_base_name) my_free(options->shared_memory_base_name); options->shared_memory_base_name=my_strdup(opt_arg,MYF(MY_WME)); #endif break; case OPT_multi_results: options->client_flag|= CLIENT_MULTI_RESULTS; break; case OPT_multi_statements: case OPT_multi_queries: options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS; break; case OPT_secure_auth: options->secure_auth= TRUE; break; case OPT_report_data_truncation: options->report_data_truncation= opt_arg ? test(atoi(opt_arg)) : 1; break; case OPT_plugin_dir: { char buff[FN_REFLEN], buff2[FN_REFLEN]; if (strlen(opt_arg) >= FN_REFLEN) opt_arg[FN_REFLEN]= '\0'; if (my_realpath(buff, opt_arg, 0)) { DBUG_PRINT("warning",("failed to normalize the plugin path: %s", opt_arg)); break; } convert_dirname(buff2, buff, NULL); EXTENSION_SET_STRING(options, plugin_dir, buff2); } break; case OPT_default_auth: EXTENSION_SET_STRING(options, default_auth, opt_arg); break; case OPT_enable_cleartext_plugin: break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); } } } } free_defaults(argv); DBUG_VOID_RETURN; }
0
[]
server
f5369faf5bbfb56b5e945836eb3f7c7ee88b4079
50,205,267,544,689,050,000,000,000,000,000,000,000
213
don't disable SSL when connecting via libmysqld
static int crypto_report_one(struct crypto_alg *alg, struct crypto_user_alg *ualg, struct sk_buff *skb) { strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); strlcpy(ualg->cru_driver_name, alg->cra_driver_name, sizeof(ualg->cru_driver_name)); strlcpy(ualg->cru_module_name, module_name(alg->cra_module), sizeof(ualg->cru_module_name)); ualg->cru_type = 0; ualg->cru_mask = 0; ualg->cru_flags = alg->cra_flags; ualg->cru_refcnt = refcount_read(&alg->cra_refcnt); if (nla_put_u32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority)) goto nla_put_failure; if (alg->cra_flags & CRYPTO_ALG_LARVAL) { struct crypto_report_larval rl; strlcpy(rl.type, "larval", sizeof(rl.type)); if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, sizeof(struct crypto_report_larval), &rl)) goto nla_put_failure; goto out; } if (alg->cra_type && alg->cra_type->report) { if (alg->cra_type->report(skb, alg)) goto nla_put_failure; goto out; } switch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) { case CRYPTO_ALG_TYPE_CIPHER: if (crypto_report_cipher(skb, alg)) goto nla_put_failure; break; case CRYPTO_ALG_TYPE_COMPRESS: if (crypto_report_comp(skb, alg)) goto nla_put_failure; break; case CRYPTO_ALG_TYPE_ACOMPRESS: if (crypto_report_acomp(skb, alg)) goto nla_put_failure; break; case CRYPTO_ALG_TYPE_AKCIPHER: if (crypto_report_akcipher(skb, alg)) goto nla_put_failure; break; case CRYPTO_ALG_TYPE_KPP: if (crypto_report_kpp(skb, alg)) goto nla_put_failure; break; } out: return 0; nla_put_failure: return -EMSGSIZE; }
1
[ "CWE-200" ]
linux
f43f39958beb206b53292801e216d9b8a660f087
113,204,639,660,369,490,000,000,000,000,000,000,000
66
crypto: user - fix leaking uninitialized memory to userspace All bytes of the NETLINK_CRYPTO report structures must be initialized, since they are copied to userspace. The change from strncpy() to strlcpy() broke this. As a minimal fix, change it back. Fixes: 4473710df1f8 ("crypto: user - Prepare for CRYPTO_MAX_ALG_NAME expansion") Cc: <[email protected]> # v4.12+ Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
static int parse_CRowSeekByBookmark(tvbuff_t *tvb, int offset, proto_tree *parent_tree, const char *fmt, ...) { proto_tree *tree; proto_item *item; guint32 num; const char *txt; va_list ap; va_start(ap, fmt); txt = wmem_strdup_vprintf(wmem_packet_scope(), fmt, ap); va_end(ap); tree = proto_tree_add_subtree(parent_tree, tvb, offset, 0, ett_CRowsSeekByBookmark, &item, txt); num = tvb_get_letohl(tvb,offset); proto_tree_add_item(tree, hf_mswsp_crowseekbybookmark_cbookmarks, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; offset = parse_UInt32Array(tvb, offset, tree, num, "abookmark", "abookmarks"); num = tvb_get_letohl(tvb,offset); proto_tree_add_item(tree, hf_mswsp_crowseekbybookmark_maxret, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; offset = parse_UInt32Array(tvb, offset, tree, num, "ascret", "ascret"); proto_item_set_end(item, tvb, offset); return offset; }
0
[ "CWE-770" ]
wireshark
b7a0650e061b5418ab4a8f72c6e4b00317aff623
149,401,735,505,829,700,000,000,000,000,000,000,000
29
MS-WSP: Don't allocate huge amounts of memory. Add a couple of memory allocation sanity checks, one of which fixes #17331.
void WebPImage::decodeChunks(uint32_t filesize) { DataBuf chunkId(5); byte size_buff[WEBP_TAG_SIZE]; bool has_canvas_data = false; #ifdef DEBUG std::cout << "Reading metadata" << std::endl; #endif chunkId.pData_[4] = '\0' ; while ( !io_->eof() && (uint64_t) io_->tell() < filesize) { io_->readOrThrow(chunkId.pData_, WEBP_TAG_SIZE, Exiv2::kerCorruptedMetadata); io_->readOrThrow(size_buff, WEBP_TAG_SIZE, Exiv2::kerCorruptedMetadata); const uint32_t size = Exiv2::getULong(size_buff, littleEndian); enforce(io_->tell() <= filesize, Exiv2::kerCorruptedMetadata); enforce(size <= (filesize - io_->tell()), Exiv2::kerCorruptedMetadata); DataBuf payload(size); if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_VP8X) && !has_canvas_data) { enforce(size >= 10, Exiv2::kerCorruptedMetadata); has_canvas_data = true; byte size_buf[WEBP_TAG_SIZE]; io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); // Fetch width memcpy(&size_buf, &payload.pData_[4], 3); size_buf[3] = 0; pixelWidth_ = Exiv2::getULong(size_buf, littleEndian) + 1; // Fetch height memcpy(&size_buf, &payload.pData_[7], 3); size_buf[3] = 0; pixelHeight_ = Exiv2::getULong(size_buf, littleEndian) + 1; } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_VP8) && !has_canvas_data) { enforce(size >= 10, Exiv2::kerCorruptedMetadata); has_canvas_data = true; io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); byte size_buf[WEBP_TAG_SIZE]; // Fetch width"" memcpy(&size_buf, &payload.pData_[6], 2); size_buf[2] = 0; size_buf[3] = 0; pixelWidth_ = Exiv2::getULong(size_buf, littleEndian) & 0x3fff; // Fetch height memcpy(&size_buf, &payload.pData_[8], 2); size_buf[2] = 0; size_buf[3] = 0; pixelHeight_ = Exiv2::getULong(size_buf, littleEndian) & 0x3fff; } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_VP8L) && !has_canvas_data) { enforce(size >= 5, Exiv2::kerCorruptedMetadata); has_canvas_data = true; byte size_buf_w[2]; byte size_buf_h[3]; io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); // Fetch width memcpy(&size_buf_w, &payload.pData_[1], 2); size_buf_w[1] &= 0x3F; pixelWidth_ = Exiv2::getUShort(size_buf_w, littleEndian) + 1; // Fetch height memcpy(&size_buf_h, &payload.pData_[2], 3); size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3F) << 0x2); size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2); pixelHeight_ = Exiv2::getUShort(size_buf_h, littleEndian) + 1; } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ANMF) && !has_canvas_data) { enforce(size >= 12, Exiv2::kerCorruptedMetadata); has_canvas_data = true; byte size_buf[WEBP_TAG_SIZE]; io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); // Fetch width memcpy(&size_buf, &payload.pData_[6], 3); size_buf[3] = 0; pixelWidth_ = Exiv2::getULong(size_buf, littleEndian) + 1; // Fetch height memcpy(&size_buf, &payload.pData_[9], 3); size_buf[3] = 0; pixelHeight_ = Exiv2::getULong(size_buf, littleEndian) + 1; } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ICCP)) { io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); this->setIccProfile(payload); } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_EXIF)) { io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); // 4 meaningful bytes + 2 padding bytes byte exifLongHeader[] = { 0xFF, 0x01, 0xFF, 0xE1, 0x00, 0x00 }; byte exifShortHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; byte exifTiffLEHeader[] = { 0x49, 0x49, 0x2A }; // "MM*" byte exifTiffBEHeader[] = { 0x4D, 0x4D, 0x00, 0x2A }; // "II\0*" byte* rawExifData = nullptr; long offset = 0; bool s_header = false; bool le_header = false; bool be_header = false; long pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifLongHeader, 4); if (pos == -1) { pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifLongHeader, 6); if (pos != -1) { s_header = true; } } if (pos == -1) { pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifTiffLEHeader, 3); if (pos != -1) { le_header = true; } } if (pos == -1) { pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifTiffBEHeader, 4); if (pos != -1) { be_header = true; } } if (s_header) { offset += 6; } if (be_header || le_header) { offset += 12; } const long sizePayload = payload.size_ + offset; rawExifData = (byte*)malloc(sizePayload); byte sizeBuff[2]; if (s_header) { us2Data(sizeBuff, (uint16_t) (sizePayload - 6), bigEndian); memcpy(rawExifData, (char*)&exifLongHeader, 4); memcpy(rawExifData + 4, (char*)&sizeBuff, 2); } if (be_header || le_header) { us2Data(sizeBuff, (uint16_t) (sizePayload - 6), bigEndian); memcpy(rawExifData, (char*)&exifLongHeader, 4); memcpy(rawExifData + 4, (char*)&sizeBuff, 2); memcpy(rawExifData + 6, (char*)&exifShortHeader, 6); } memcpy(rawExifData + offset, payload.pData_, payload.size_); #ifdef DEBUG std::cout << "Display Hex Dump [size:" << (unsigned long)sizePayload << "]" << std::endl; std::cout << Internal::binaryToHex(rawExifData, sizePayload); #endif if (pos != -1) { XmpData xmpData; ByteOrder bo = ExifParser::decode(exifData_, payload.pData_ + pos, payload.size_ - pos); setByteOrder(bo); } else { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode Exif metadata." << std::endl; #endif exifData_.clear(); } if (rawExifData) free(rawExifData); } else if (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_XMP)) { io_->readOrThrow(payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); xmpPacket_.assign(reinterpret_cast<char*>(payload.pData_), payload.size_); if (xmpPacket_.size() > 0 && XmpParser::decode(xmpData_, xmpPacket_)) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode XMP metadata." << std::endl; #endif } else { #ifdef DEBUG std::cout << "Display Hex Dump [size:" << (unsigned long)payload.size_ << "]" << std::endl; std::cout << Internal::binaryToHex(payload.pData_, payload.size_); #endif } } else { io_->seek(size, BasicIo::cur); } if ( io_->tell() % 2 ) io_->seek(+1, BasicIo::cur); } }
0
[ "CWE-190" ]
exiv2
c73d1e27198a389ce7caf52ac30f8e2120acdafd
40,930,305,355,552,487,000,000,000,000,000,000,000
196
Avoid negative integer overflow when `filesize < io_->tell()`. This fixes #791.
static UINT cliprdr_server_receive_format_data_request(CliprdrServerContext* context, wStream* s, const CLIPRDR_HEADER* header) { CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest; UINT error = CHANNEL_RC_OK; WLog_DBG(TAG, "CliprdrClientFormatDataRequest"); formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST; formatDataRequest.msgFlags = header->msgFlags; formatDataRequest.dataLen = header->dataLen; if ((error = cliprdr_read_format_data_request(s, &formatDataRequest))) return error; context->lastRequestedFormatId = formatDataRequest.requestedFormatId; IFCALLRET(context->ClientFormatDataRequest, error, context, &formatDataRequest); if (error) WLog_ERR(TAG, "ClientFormatDataRequest failed with error %" PRIu32 "!", error); return error; }
0
[]
FreeRDP
8e1a1b407565eb0a48923c796f5b1f69167b3c48
70,493,072,868,483,040,000,000,000,000,000,000,000
21
Fixed cliprdr_server_receive_capabilities Thanks to hac425 CVE-2020-11017, CVE-2020-11018
unsigned char *ndp_msg_opt_tlladdr(struct ndp_msg *msg, int offset) { unsigned char *opt_data = ndp_msg_payload_opts_offset(msg, offset); return &opt_data[2]; }
0
[ "CWE-284" ]
libndp
a4892df306e0532487f1634ba6d4c6d4bb381c7f
301,951,327,038,725,670,000,000,000,000,000,000,000
6
libndp: validate the IPv6 hop limit None of the NDP messages should ever come from a non-local network; as stated in RFC4861's 6.1.1 (RS), 6.1.2 (RA), 7.1.1 (NS), 7.1.2 (NA), and 8.1. (redirect): - The IP Hop Limit field has a value of 255, i.e., the packet could not possibly have been forwarded by a router. This fixes CVE-2016-3698. Reported by: Julien BERNARD <[email protected]> Signed-off-by: Lubomir Rintel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]>
TEST_F(HeaderToMetadataTest, RejectBothCookieHeader) { const std::string config = R"EOF( request_rules: - header: x-something cookie: something-else on_header_present: key: something value: else type: STRING remove: false )EOF"; auto expected = "Cannot specify both header and cookie"; EXPECT_THROW_WITH_MESSAGE(initializeFilter(config), EnvoyException, expected); }
0
[]
envoy
2c60632d41555ec8b3d9ef5246242be637a2db0f
195,784,794,716,294,340,000,000,000,000,000,000,000
15
http: header map security fixes for duplicate headers (#197) Previously header matching did not match on all headers for non-inline headers. This patch changes the default behavior to always logically match on all headers. Multiple individual headers will be logically concatenated with ',' similar to what is done with inline headers. This makes the behavior effectively consistent. This behavior can be temporary reverted by setting the runtime value "envoy.reloadable_features.header_match_on_all_headers" to "false". Targeted fixes have been additionally performed on the following extensions which make them consider all duplicate headers by default as a comma concatenated list: 1) Any extension using CEL matching on headers. 2) The header to metadata filter. 3) The JWT filter. 4) The Lua filter. Like primary header matching used in routing, RBAC, etc. this behavior can be disabled by setting the runtime value "envoy.reloadable_features.header_match_on_all_headers" to false. Finally, the setCopy() header map API previously only set the first header in the case of duplicate non-inline headers. setCopy() now behaves similiarly to the other set*() APIs and replaces all found headers with a single value. This may have had security implications in the extauth filter which uses this API. This behavior can be disabled by setting the runtime value "envoy.reloadable_features.http_set_copy_replace_all_headers" to false. Fixes https://github.com/envoyproxy/envoy-setec/issues/188 Signed-off-by: Matt Klein <[email protected]>
static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ int i,j; for (i=0; i < height; i++) { for (j=0; j < width; j++) { dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11; } src += stride; dst += stride; } }
0
[ "CWE-703", "CWE-189" ]
FFmpeg
454a11a1c9c686c78aa97954306fb63453299760
295,010,812,478,750,270,000,000,000,000,000,000,000
10
avcodec/dsputil: fix signedness in sizeof() comparissions Signed-off-by: Michael Niedermayer <[email protected]>
static int __init cipso_v4_cache_init(void) { u32 iter; cipso_v4_cache = kcalloc(CIPSO_V4_CACHE_BUCKETS, sizeof(struct cipso_v4_map_cache_bkt), GFP_KERNEL); if (!cipso_v4_cache) return -ENOMEM; for (iter = 0; iter < CIPSO_V4_CACHE_BUCKETS; iter++) { spin_lock_init(&cipso_v4_cache[iter].lock); cipso_v4_cache[iter].size = 0; INIT_LIST_HEAD(&cipso_v4_cache[iter].list); } return 0; }
0
[ "CWE-835" ]
linux
40413955ee265a5e42f710940ec78f5450d49149
334,181,974,906,230,360,000,000,000,000,000,000,000
18
Cipso: cipso_v4_optptr enter infinite loop in for(),if((optlen > 0) && (optptr[1] == 0)), enter infinite loop. Test: receive a packet which the ip length > 20 and the first byte of ip option is 0, produce this issue Signed-off-by: yujuan.qi <[email protected]> Acked-by: Paul Moore <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void cancel_att_send_op(void *data) { struct att_send_op *op = data; if (op->destroy) op->destroy(op->user_data); op->user_data = NULL; op->callback = NULL; op->destroy = NULL; }
0
[ "CWE-415" ]
bluez
1cd644db8c23a2f530ddb93cebed7dacc5f5721a
263,389,844,017,891,540,000,000,000,000,000,000,000
11
shared/att: Fix possible crash on disconnect If there are pending request while disconnecting they would be notified but clients may endup being freed in the proccess which will then be calling bt_att_cancel to cancal its requests causing the following trace: Invalid read of size 4 at 0x1D894C: enable_ccc_callback (gatt-client.c:1627) by 0x1D247B: disc_att_send_op (att.c:417) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1D47B7: disconnect_cb (att.c:635) by 0x1E0707: watch_callback (io-glib.c:170) by 0x48E963B: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x48E9AC7: ??? (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x48E9ECF: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.6400.4) by 0x1E0E97: mainloop_run (mainloop-glib.c:79) by 0x1E13B3: mainloop_run_with_signal (mainloop-notify.c:201) by 0x12BC3B: main (main.c:770) Address 0x7d40a28 is 24 bytes inside a block of size 32 free'd at 0x484A2E0: free (vg_replace_malloc.c:540) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1CCC83: queue_destroy (queue.c:73) by 0x1D7DD7: bt_gatt_client_free (gatt-client.c:2209) by 0x16497B: batt_free (battery.c:77) by 0x16497B: batt_remove (battery.c:286) by 0x1A0013: service_remove (service.c:176) by 0x1A9B7B: device_remove_gatt_service (device.c:3691) by 0x1A9B7B: gatt_service_removed (device.c:3805) by 0x1CC90B: queue_foreach (queue.c:220) by 0x1DE27B: notify_service_changed.isra.0.part.0 (gatt-db.c:369) by 0x1DE387: notify_service_changed (gatt-db.c:361) by 0x1DE387: gatt_db_service_destroy (gatt-db.c:385) by 0x1DE3EF: gatt_db_remove_service (gatt-db.c:519) by 0x1D674F: discovery_op_complete (gatt-client.c:388) by 0x1D6877: discover_primary_cb (gatt-client.c:1260) by 0x1E220B: discovery_op_complete (gatt-helpers.c:628) by 0x1E249B: read_by_grp_type_cb (gatt-helpers.c:730) by 0x1D247B: disc_att_send_op (att.c:417) by 0x1CCC17: queue_remove_all (queue.c:354) by 0x1D47B7: disconnect_cb (att.c:635)
decode_legacy_async_masks(const ovs_be32 masks[2], enum ofputil_async_msg_type oam, enum ofp_version version, struct ofputil_async_cfg *dst) { for (int i = 0; i < 2; i++) { bool master = i == 0; const struct ofp14_async_prop *ap = get_ofp14_async_config_prop_by_oam(oam, master); decode_async_mask(masks[i], ap, version, true, dst); } }
0
[ "CWE-772" ]
ovs
77ad4225d125030420d897c873e4734ac708c66b
114,716,826,564,664,530,000,000,000,000,000,000,000
12
ofp-util: Fix memory leaks on error cases in ofputil_decode_group_mod(). Found by libFuzzer. Reported-by: Bhargava Shastry <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Justin Pettit <[email protected]>
f_toupper(typval_T *argvars, typval_T *rettv) { rettv->v_type = VAR_STRING; rettv->vval.v_string = strup_save(tv_get_string(&argvars[0])); }
0
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
61,104,048,082,587,530,000,000,000,000,000,000,000
5
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) { int reg; reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg &= ~DWC3_DCTL_INITU1ENA; dwc3_writel(dwc->regs, DWC3_DCTL, reg); reg &= ~DWC3_DCTL_INITU2ENA; dwc3_writel(dwc->regs, DWC3_DCTL, reg); dwc3_disconnect_gadget(dwc); dwc->gadget.speed = USB_SPEED_UNKNOWN; dwc->setup_packet_pending = false; usb_gadget_set_state(&dwc->gadget, USB_STATE_NOTATTACHED); dwc->connected = false; }
0
[ "CWE-703", "CWE-667", "CWE-189" ]
linux
c91815b596245fd7da349ecc43c8def670d2269e
319,982,004,015,416,400,000,000,000,000,000,000,000
19
usb: dwc3: gadget: never call ->complete() from ->ep_queue() This is a requirement which has always existed but, somehow, wasn't reflected in the documentation and problems weren't found until now when Tuba Yavuz found a possible deadlock happening between dwc3 and f_hid. She described the situation as follows: spin_lock_irqsave(&hidg->write_spinlock, flags); // first acquire /* we our function has been disabled by host */ if (!hidg->req) { free_ep_req(hidg->in_ep, hidg->req); goto try_again; } [...] status = usb_ep_queue(hidg->in_ep, hidg->req, GFP_ATOMIC); => [...] => usb_gadget_giveback_request => f_hidg_req_complete => spin_lock_irqsave(&hidg->write_spinlock, flags); // second acquire Note that this happens because dwc3 would call ->complete() on a failed usb_ep_queue() due to failed Start Transfer command. This is, anyway, a theoretical situation because dwc3 currently uses "No Response Update Transfer" command for Bulk and Interrupt endpoints. It's still good to make this case impossible to happen even if the "No Reponse Update Transfer" command is changed. Reported-by: Tuba Yavuz <[email protected]> Signed-off-by: Felipe Balbi <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static inline void ext4_unlock_group(struct super_block *sb, ext4_group_t group) { spin_unlock(ext4_group_lock_ptr(sb, group));
0
[ "CWE-787" ]
linux
c37e9e013469521d9adb932d17a1795c139b36db
285,795,555,242,245,000,000,000,000,000,000,000,000
5
ext4: add more inode number paranoia checks If there is a directory entry pointing to a system inode (such as a journal inode), complain and declare the file system to be corrupted. Also, if the superblock's first inode number field is too small, refuse to mount the file system. This addresses CVE-2018-10882. https://bugzilla.kernel.org/show_bug.cgi?id=200069 Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
TEST_P(ProtocolIntegrationTest, HeadersWithUnderscoresDropped) { config_helper_.addConfigModifier( [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& hcm) -> void { hcm.mutable_common_http_protocol_options()->set_headers_with_underscores_action( envoy::config::core::v3::HttpProtocolOptions::DROP_HEADER); }); initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); auto response = codec_client_->makeHeaderOnlyRequest( Http::TestRequestHeaderMapImpl{{":method", "GET"}, {":path", "/test/long/url"}, {":scheme", "http"}, {":authority", "host"}, {"foo_bar", "baz"}}); waitForNextUpstreamRequest(); EXPECT_THAT(upstream_request_->headers(), Not(HeaderHasValueRef("foo_bar", "baz"))); upstream_request_->encodeHeaders( Http::TestResponseHeaderMapImpl{{":status", "200"}, {"bar_baz", "fooz"}}, true); response->waitForEndStream(); EXPECT_TRUE(response->complete()); EXPECT_EQ("200", response->headers().getStatusValue()); EXPECT_THAT(response->headers(), HeaderHasValueRef("bar_baz", "fooz")); Stats::Store& stats = test_server_->server().stats(); std::string stat_name = (downstreamProtocol() == Http::CodecClient::Type::HTTP1) ? "http1.dropped_headers_with_underscores" : "http2.dropped_headers_with_underscores"; EXPECT_EQ(1L, TestUtility::findCounter(stats, stat_name)->value()); }
0
[ "CWE-770" ]
envoy
7ca28ff7d46454ae930e193d97b7d08156b1ba59
77,446,756,714,520,110,000,000,000,000,000,000,000
30
[http1] Include request URL in request header size computation, and reject partial headers that exceed configured limits (#145) Signed-off-by: antonio <[email protected]>
static int nbd_send_reply(QIOChannel *ioc, NBDReply *reply, Error **errp) { uint8_t buf[NBD_REPLY_SIZE]; reply->error = system_errno_to_nbd_errno(reply->error); trace_nbd_send_reply(reply->error, reply->handle); /* Reply [ 0 .. 3] magic (NBD_REPLY_MAGIC) [ 4 .. 7] error (0 == no error) [ 7 .. 15] handle */ stl_be_p(buf, NBD_REPLY_MAGIC); stl_be_p(buf + 4, reply->error); stq_be_p(buf + 8, reply->handle); return nbd_write(ioc, buf, sizeof(buf), errp); }
0
[]
qemu
f37708f6b8e0bef0dd85c6aad7fc2062071f8227
267,559,693,629,674,400,000,000,000,000,000,000,000
19
nbd: Implement NBD_OPT_GO on server NBD_OPT_EXPORT_NAME is lousy: per the NBD protocol, any failure requires us to close the connection rather than report an error. Therefore, upstream NBD recently added NBD_OPT_GO as the improved version of the option that does what we want [1], along with NBD_OPT_INFO that returns the same information but does not transition to transmission phase. [1] https://github.com/NetworkBlockDevice/nbd/blob/extension-info/doc/proto.md This is a first cut at the information types, and only passes the same information already available through NBD_OPT_LIST and NBD_OPT_EXPORT_NAME; items like NBD_INFO_BLOCK_SIZE (and thus any use of NBD_REP_ERR_BLOCK_SIZE_REQD) are intentionally left for later patches. Signed-off-by: Eric Blake <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
inline bool LowFirstBitReader::FillBuffer(unsigned int length) { while (m_bitsBuffered < length) { byte b; if (!m_store.Get(b)) return false; m_buffer |= (unsigned long)b << m_bitsBuffered; m_bitsBuffered += 8; } CRYPTOPP_ASSERT(m_bitsBuffered <= sizeof(unsigned long)*8); return true; }
0
[ "CWE-190", "CWE-125" ]
cryptopp
07dbcc3d9644b18e05c1776db2a57fe04d780965
226,949,888,515,903,960,000,000,000,000,000,000,000
13
Add Inflator::BadDistanceErr exception (Issue 414) The improved validation and excpetion clears the Address Sanitizer and Undefined Behavior Sanitizer findings
filter_free (struct backend *b) { struct backend_filter *f = container_of (b, struct backend_filter, backend); f->backend.next->free (f->backend.next); /* Acquiring this lock prevents any filter callbacks from running * simultaneously. */ lock_unload (); debug ("%s: unload", f->name); if (f->filter.unload) f->filter.unload (); if (DO_DLCLOSE) dlclose (f->dl); free (f->filename); unlock_unload (); free (f->name); free (f); }
0
[ "CWE-406" ]
nbdkit
bf0d61883a2f02f4388ec10dc92d4c61c093679e
50,599,633,017,311,950,000,000,000,000,000,000,000
24
server: Fix regression for NBD_OPT_INFO before NBD_OPT_GO Most known NBD clients do not bother with NBD_OPT_INFO (except for clients like 'qemu-nbd --list' that don't ever intend to connect), but go straight to NBD_OPT_GO. However, it's not too hard to hack up qemu to add in an extra client step (whether info on the same name, or more interestingly, info on a different name), as a patch against qemu commit 6f214b30445: | diff --git i/nbd/client.c w/nbd/client.c | index f6733962b49b..425292ac5ea9 100644 | --- i/nbd/client.c | +++ w/nbd/client.c | @@ -1038,6 +1038,14 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc, | * TLS). If it is not available, fall back to | * NBD_OPT_LIST for nicer error messages about a missing | * export, then use NBD_OPT_EXPORT_NAME. */ | + if (getenv ("HACK")) | + info->name[0]++; | + result = nbd_opt_info_or_go(ioc, NBD_OPT_INFO, info, errp); | + if (getenv ("HACK")) | + info->name[0]--; | + if (result < 0) { | + return -EINVAL; | + } | result = nbd_opt_info_or_go(ioc, NBD_OPT_GO, info, errp); | if (result < 0) { | return -EINVAL; This works just fine in 1.14.0, where we call .open only once (so the INFO and GO repeat calls into the same plugin handle), but in 1.14.1 it regressed into causing an assertion failure: we are now calling .open a second time on a connection that is already opened: $ nbdkit -rfv null & $ hacked-qemu-io -f raw -r nbd://localhost -c quit ... nbdkit: null[1]: debug: null: open readonly=1 nbdkit: backend.c:179: backend_open: Assertion `h->handle == NULL' failed. Worse, on the mainline development, we have recently made it possible for plugins to actively report different information for different export names; for example, a plugin may choose to report different answers for .can_write on export A than for export B; but if we share cached handles, then an NBD_OPT_INFO on one export prevents correct answers for NBD_OPT_GO on the second export name. (The HACK envvar in my qemu modifications can be used to demonstrate cross-name requests, which are even less likely in a real client). The solution is to call .close after NBD_OPT_INFO, coupled with enough glue logic to reset cached connection handles back to the state expected by .open. This in turn means factoring out another backend_* function, but also gives us an opportunity to change backend_set_handle to no longer accept NULL. The assertion failure is, to some extent, a possible denial of service attack (one client can force nbdkit to exit by merely sending OPT_INFO before OPT_GO, preventing the next client from connecting), although this is mitigated by using TLS to weed out untrusted clients. Still, the fact that we introduced a potential DoS attack while trying to fix a traffic amplification security bug is not very nice. Sadly, as there are no known clients that easily trigger this mode of operation (OPT_INFO before OPT_GO), there is no easy way to cover this via a testsuite addition. I may end up hacking something into libnbd. Fixes: c05686f957 Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit a6b88b195a959b17524d1c8353fd425d4891dc5f) Conflicts: server/backend.c server/connections.c server/filters.c server/internal.h server/plugins.c No backend.c in the stable branch, and less things to reset, so instead ode that logic into filter_close. Signed-off-by: Eric Blake <[email protected]>
static int mcryptd_hash_import(struct ahash_request *req, const void *in) { struct mcryptd_hash_request_ctx *rctx = ahash_request_ctx(req); return crypto_ahash_import(&rctx->areq, in); }
0
[ "CWE-476", "CWE-284" ]
linux
48a992727d82cb7db076fa15d372178743b1f4cd
293,315,898,233,050,020,000,000,000,000,000,000,000
6
crypto: mcryptd - Check mcryptd algorithm compatibility Algorithms not compatible with mcryptd could be spawned by mcryptd with a direct crypto_alloc_tfm invocation using a "mcryptd(alg)" name construct. This causes mcryptd to crash the kernel if an arbitrary "alg" is incompatible and not intended to be used with mcryptd. It is an issue if AF_ALG tries to spawn mcryptd(alg) to expose it externally. But such algorithms must be used internally and not be exposed. We added a check to enforce that only internal algorithms are allowed with mcryptd at the time mcryptd is spawning an algorithm. Link: http://marc.info/?l=linux-crypto-vger&m=148063683310477&w=2 Cc: [email protected] Reported-by: Mikulas Patocka <[email protected]> Signed-off-by: Tim Chen <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
void TinyGLTF::RemoveImageLoader() { LoadImageData = #ifndef TINYGLTF_NO_STB_IMAGE &tinygltf::LoadImageData; #else nullptr; #endif load_image_user_data_ = nullptr; user_image_loader_ = false; }
0
[ "CWE-20" ]
tinygltf
52ff00a38447f06a17eab1caa2cf0730a119c751
213,650,133,023,257,000,000,000,000,000,000,000,000
11
Do not expand file path since its not necessary for glTF asset path(URI) and for security reason(`wordexp`).
void user_free_preparse(struct key_preparsed_payload *prep) { kfree(prep->payload[0]); }
0
[ "CWE-476" ]
linux
c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81
163,764,149,236,660,200,000,000,000,000,000,000,000
4
KEYS: Remove key_type::match in favour of overriding default by match_preparse A previous patch added a ->match_preparse() method to the key type. This is allowed to override the function called by the iteration algorithm. Therefore, we can just set a default that simply checks for an exact match of the key description with the original criterion data and allow match_preparse to override it as needed. The key_type::match op is then redundant and can be removed, as can the user_match() function. Signed-off-by: David Howells <[email protected]> Acked-by: Vivek Goyal <[email protected]>
virDomainVsockDefFree(virDomainVsockDefPtr vsock) { if (!vsock) return; virObjectUnref(vsock->privateData); virDomainDeviceInfoClear(&vsock->info); VIR_FREE(vsock); }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
123,536,726,254,338,470,000,000,000,000,000,000,000
9
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
static int nested_svm_intercept_ioio(struct vcpu_svm *svm) { unsigned port, size, iopm_len; u16 val, mask; u8 start_bit; u64 gpa; if (!(svm->nested.intercept & (1ULL << INTERCEPT_IOIO_PROT))) return NESTED_EXIT_HOST; port = svm->vmcb->control.exit_info_1 >> 16; size = (svm->vmcb->control.exit_info_1 & SVM_IOIO_SIZE_MASK) >> SVM_IOIO_SIZE_SHIFT; gpa = svm->nested.vmcb_iopm + (port / 8); start_bit = port % 8; iopm_len = (start_bit + size > 8) ? 2 : 1; mask = (0xf >> (4 - size)) << start_bit; val = 0; if (kvm_read_guest(svm->vcpu.kvm, gpa, &val, iopm_len)) return NESTED_EXIT_DONE; return (val & mask) ? NESTED_EXIT_DONE : NESTED_EXIT_HOST; }
0
[]
kvm
854e8bb1aa06c578c2c9145fa6bfe3680ef63b23
135,685,562,829,126,550,000,000,000,000,000,000,000
24
KVM: x86: Check non-canonical addresses upon WRMSR Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is written to certain MSRs. The behavior is "almost" identical for AMD and Intel (ignoring MSRs that are not implemented in either architecture since they would anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if non-canonical address is written on Intel but not on AMD (which ignores the top 32-bits). Accordingly, this patch injects a #GP on the MSRs which behave identically on Intel and AMD. To eliminate the differences between the architecutres, the value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to canonical value before writing instead of injecting a #GP. Some references from Intel and AMD manuals: According to Intel SDM description of WRMSR instruction #GP is expected on WRMSR "If the source register contains a non-canonical address and ECX specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE, IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP." According to AMD manual instruction manual: LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the LSTAR and CSTAR registers. If an RIP written by WRMSR is not in canonical form, a general-protection exception (#GP) occurs." IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the base field must be in canonical form or a #GP fault will occur." IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must be in canonical form." This patch fixes CVE-2014-3610. Cc: [email protected] Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
setrl(isc_ratelimiter_t *rl, unsigned int *rate, unsigned int value) { isc_interval_t interval; uint32_t s, ns; uint32_t pertic; isc_result_t result; if (value == 0) value = 1; if (value == 1) { s = 1; ns = 0; pertic = 1; } else if (value <= 10) { s = 0; ns = 1000000000 / value; pertic = 1; } else { s = 0; ns = (1000000000 / value) * 10; pertic = 10; } isc_interval_set(&interval, s, ns); result = isc_ratelimiter_setinterval(rl, &interval); RUNTIME_CHECK(result == ISC_R_SUCCESS); isc_ratelimiter_setpertic(rl, pertic); *rate = value; }
0
[ "CWE-327" ]
bind9
f09352d20a9d360e50683cd1d2fc52ccedcd77a0
206,409,759,059,663,770,000,000,000,000,000,000,000
31
Update keyfetch_done compute_tag check If in keyfetch_done the compute_tag fails (because for example the algorithm is not supported), don't crash, but instead ignore the key.
static void nfs_writeback_done_common(struct rpc_task *task, void *calldata) { struct nfs_write_data *data = calldata; nfs_writeback_done(task, data); }
0
[]
linux
c7559663e42f4294ffe31fe159da6b6a66b35d61
190,449,883,768,025,400,000,000,000,000,000,000,000
6
NFS: Allow nfs_updatepage to extend a write under additional circumstances Currently nfs_updatepage allows a write to be extended to cover a full page only if we don't have a byte range lock lock on the file... but if we have a write delegation on the file or if we have the whole file locked for writing then we should be allowed to extend the write as well. Signed-off-by: Scott Mayhew <[email protected]> [Trond: fix up call to nfs_have_delegation()] Signed-off-by: Trond Myklebust <[email protected]>
static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 tsval, u32 tsecr, struct tcp_md5sig_key *key, int rst, u8 tclass, u32 label) { const struct tcphdr *th = tcp_hdr(skb); struct tcphdr *t1; struct sk_buff *buff; struct flowi6 fl6; struct net *net = dev_net(skb_dst(skb)->dev); struct sock *ctl_sk = net->ipv6.tcp_sk; unsigned int tot_len = sizeof(struct tcphdr); struct dst_entry *dst; __be32 *topt; if (tsecr) tot_len += TCPOLEN_TSTAMP_ALIGNED; #ifdef CONFIG_TCP_MD5SIG if (key) tot_len += TCPOLEN_MD5SIG_ALIGNED; #endif buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len, GFP_ATOMIC); if (buff == NULL) return; skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len); t1 = (struct tcphdr *) skb_push(buff, tot_len); skb_reset_transport_header(buff); /* Swap the send and the receive. */ memset(t1, 0, sizeof(*t1)); t1->dest = th->source; t1->source = th->dest; t1->doff = tot_len / 4; t1->seq = htonl(seq); t1->ack_seq = htonl(ack); t1->ack = !rst || !th->ack; t1->rst = rst; t1->window = htons(win); topt = (__be32 *)(t1 + 1); if (tsecr) { *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); *topt++ = htonl(tsval); *topt++ = htonl(tsecr); } #ifdef CONFIG_TCP_MD5SIG if (key) { *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); tcp_v6_md5_hash_hdr((__u8 *)topt, key, &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, t1); } #endif memset(&fl6, 0, sizeof(fl6)); fl6.daddr = ipv6_hdr(skb)->saddr; fl6.saddr = ipv6_hdr(skb)->daddr; fl6.flowlabel = label; buff->ip_summed = CHECKSUM_PARTIAL; buff->csum = 0; __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr); fl6.flowi6_proto = IPPROTO_TCP; if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL) fl6.flowi6_oif = inet6_iif(skb); fl6.fl6_dport = t1->dest; fl6.fl6_sport = t1->source; security_skb_classify_flow(skb, flowi6_to_flowi(&fl6)); /* Pass a socket to ip6_dst_lookup either it is for RST * Underlying function will use this to retrieve the network * namespace */ dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL); if (!IS_ERR(dst)) { skb_dst_set(buff, dst); ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass); TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); if (rst) TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); return; } kfree_skb(buff); }
0
[]
linux
7bced397510ab569d31de4c70b39e13355046387
273,601,125,556,727,760,000,000,000,000,000,000,000
95
net_dma: simple removal Per commit "77873803363c net_dma: mark broken" net_dma is no longer used and there is no plan to fix it. This is the mechanical removal of bits in CONFIG_NET_DMA ifdef guards. Reverting the remainder of the net_dma induced changes is deferred to subsequent patches. Marked for stable due to Roman's report of a memory leak in dma_pin_iovec_pages(): https://lkml.org/lkml/2014/9/3/177 Cc: Dave Jiang <[email protected]> Cc: Vinod Koul <[email protected]> Cc: David Whipple <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: <[email protected]> Reported-by: Roman Gushchin <[email protected]> Acked-by: David S. Miller <[email protected]> Signed-off-by: Dan Williams <[email protected]>
static int slab_pad_check(struct kmem_cache *s, struct page *page) { u8 *start; u8 *fault; u8 *end; u8 *pad; int length; int remainder; if (!(s->flags & SLAB_POISON)) return 1; start = page_address(page); length = page_size(page); end = start + length; remainder = length % s->size; if (!remainder) return 1; pad = end - remainder; metadata_access_enable(); fault = memchr_inv(pad, POISON_INUSE, remainder); metadata_access_disable(); if (!fault) return 1; while (end > fault && end[-1] == POISON_INUSE) end--; slab_err(s, page, "Padding overwritten. 0x%p-0x%p @offset=%tu", fault, end - 1, fault - start); print_section(KERN_ERR, "Padding ", pad, remainder); restore_bytes(s, "slab padding", POISON_INUSE, fault, end); return 0; }
0
[]
linux
fd4d9c7d0c71866ec0c2825189ebd2ce35bd95b8
167,592,776,743,216,030,000,000,000,000,000,000,000
35
mm: slub: add missing TID bump in kmem_cache_alloc_bulk() When kmem_cache_alloc_bulk() attempts to allocate N objects from a percpu freelist of length M, and N > M > 0, it will first remove the M elements from the percpu freelist, then call ___slab_alloc() to allocate the next element and repopulate the percpu freelist. ___slab_alloc() can re-enable IRQs via allocate_slab(), so the TID must be bumped before ___slab_alloc() to properly commit the freelist head change. Fix it by unconditionally bumping c->tid when entering the slowpath. Cc: [email protected] Fixes: ebe909e0fdb3 ("slub: improve bulk alloc strategy") Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Item *Item_field::derived_field_transformer_for_where(THD *thd, uchar *arg) { st_select_lex *sel= (st_select_lex *)arg; Item *producing_item= find_producing_item(this, sel); if (producing_item) { Item *producing_clone= producing_item->build_clone(thd); if (producing_clone) producing_clone->marker|= SUBSTITUTION_FL; return producing_clone; } return this; }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
211,760,866,956,483,650,000,000,000,000,000,000,000
13
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.
//! Load a list from a file. /** \param filename Filename to read data from. **/ CImgList<T>& load(const char *const filename) { if (!filename) throw CImgArgumentException(_cimglist_instance "load(): Specified filename is (null).", cimglist_instance); if (!cimg::strncasecmp(filename,"http://",7) || !cimg::strncasecmp(filename,"https://",8)) { CImg<charT> filename_local(256); load(cimg::load_network(filename,filename_local)); std::remove(filename_local); return *this; } const bool is_stdin = *filename=='-' && (!filename[1] || filename[1]=='.'); const char *const ext = cimg::split_filename(filename); const unsigned int omode = cimg::exception_mode(); cimg::exception_mode(0); bool is_loaded = true; try { #ifdef cimglist_load_plugin cimglist_load_plugin(filename); #endif #ifdef cimglist_load_plugin1 cimglist_load_plugin1(filename); #endif #ifdef cimglist_load_plugin2 cimglist_load_plugin2(filename); #endif #ifdef cimglist_load_plugin3 cimglist_load_plugin3(filename); #endif #ifdef cimglist_load_plugin4 cimglist_load_plugin4(filename); #endif #ifdef cimglist_load_plugin5 cimglist_load_plugin5(filename); #endif #ifdef cimglist_load_plugin6 cimglist_load_plugin6(filename); #endif #ifdef cimglist_load_plugin7 cimglist_load_plugin7(filename); #endif #ifdef cimglist_load_plugin8 cimglist_load_plugin8(filename); #endif if (!cimg::strcasecmp(ext,"tif") || !cimg::strcasecmp(ext,"tiff")) load_tiff(filename); else if (!cimg::strcasecmp(ext,"gif")) load_gif_external(filename); else if (!cimg::strcasecmp(ext,"cimg") || !cimg::strcasecmp(ext,"cimgz") || !*ext) load_cimg(filename); else if (!cimg::strcasecmp(ext,"rec") || !cimg::strcasecmp(ext,"par")) load_parrec(filename); else if (!cimg::strcasecmp(ext,"avi") || !cimg::strcasecmp(ext,"mov") || !cimg::strcasecmp(ext,"asf") || !cimg::strcasecmp(ext,"divx") || !cimg::strcasecmp(ext,"flv") || !cimg::strcasecmp(ext,"mpg") || !cimg::strcasecmp(ext,"m1v") || !cimg::strcasecmp(ext,"m2v") || !cimg::strcasecmp(ext,"m4v") || !cimg::strcasecmp(ext,"mjp") || !cimg::strcasecmp(ext,"mp4") || !cimg::strcasecmp(ext,"mkv") || !cimg::strcasecmp(ext,"mpe") || !cimg::strcasecmp(ext,"movie") || !cimg::strcasecmp(ext,"ogm") || !cimg::strcasecmp(ext,"ogg") || !cimg::strcasecmp(ext,"ogv") || !cimg::strcasecmp(ext,"qt") || !cimg::strcasecmp(ext,"rm") || !cimg::strcasecmp(ext,"vob") || !cimg::strcasecmp(ext,"wmv") || !cimg::strcasecmp(ext,"xvid") || !cimg::strcasecmp(ext,"mpeg")) load_video(filename); else if (!cimg::strcasecmp(ext,"gz")) load_gzip_external(filename); else is_loaded = false; } catch (CImgIOException&) { is_loaded = false; } // If nothing loaded, try to guess file format from magic number in file. if (!is_loaded && !is_stdin) { std::FILE *const file = cimg::std_fopen(filename,"rb"); if (!file) { cimg::exception_mode(omode); throw CImgIOException(_cimglist_instance "load(): Failed to open file '%s'.", cimglist_instance, filename); } const char *const f_type = cimg::ftype(file,filename); cimg::fclose(file); is_loaded = true; try { if (!cimg::strcasecmp(f_type,"gif")) load_gif_external(filename); else if (!cimg::strcasecmp(f_type,"tif")) load_tiff(filename); else is_loaded = false; } catch (CImgIOException&) { is_loaded = false; } } // If nothing loaded, try to load file as a single image. if (!is_loaded) { assign(1); try { _data->load(filename); } catch (CImgIOException&) { cimg::exception_mode(omode); throw CImgIOException(_cimglist_instance "load(): Failed to recognize format of file '%s'.", cimglist_instance, filename); }
0
[ "CWE-119", "CWE-787" ]
CImg
ac8003393569aba51048c9d67e1491559877b1d1
102,610,450,481,663,050,000,000,000,000,000,000,000
118
.
type_column_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) { FileData *fdata1; FileData *fdata2; GtkSortType sort_order; int result; gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), NULL, &sort_order); gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); if (file_data_is_dir (fdata1) == file_data_is_dir (fdata2)) { if (file_data_is_dir (fdata1)) { result = strcmp (fdata1->sort_key, fdata2->sort_key); if (sort_order == GTK_SORT_DESCENDING) result = -1 * result; } else { const char *desc1, *desc2; desc1 = g_content_type_get_description (fdata1->content_type); desc2 = g_content_type_get_description (fdata2->content_type); result = strcasecmp (desc1, desc2); if (result == 0) result = strcmp (fdata1->sort_key, fdata2->sort_key); } } else { result = file_data_is_dir (fdata1) ? -1 : 1; if (sort_order == GTK_SORT_DESCENDING) result = -1 * result; } return result; }
0
[ "CWE-22" ]
file-roller
b147281293a8307808475e102a14857055f81631
164,247,607,846,060,900,000,000,000,000,000,000,000
39
libarchive: sanitize filenames before extracting
psutil_users(PyObject *self, PyObject *args) { struct utmpx *ut; PyObject *py_retlist = PyList_New(0); PyObject *py_tuple = NULL; PyObject *py_username = NULL; PyObject *py_tty = NULL; PyObject *py_hostname = NULL; PyObject *py_user_proc = NULL; if (py_retlist == NULL) return NULL; setutxent(); while (NULL != (ut = getutxent())) { if (ut->ut_type == USER_PROCESS) py_user_proc = Py_True; else py_user_proc = Py_False; py_username = PyUnicode_DecodeFSDefault(ut->ut_user); if (! py_username) goto error; py_tty = PyUnicode_DecodeFSDefault(ut->ut_line); if (! py_tty) goto error; py_hostname = PyUnicode_DecodeFSDefault(ut->ut_host); if (! py_hostname) goto error; py_tuple = Py_BuildValue( "(OOOfOi)", py_username, // username py_tty, // tty py_hostname, // hostname (float)ut->ut_tv.tv_sec, // tstamp py_user_proc, // (bool) user process ut->ut_pid // process id ); if (py_tuple == NULL) goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; Py_CLEAR(py_username); Py_CLEAR(py_tty); Py_CLEAR(py_hostname); Py_CLEAR(py_tuple); } endutxent(); return py_retlist; error: Py_XDECREF(py_username); Py_XDECREF(py_tty); Py_XDECREF(py_hostname); Py_XDECREF(py_tuple); Py_DECREF(py_retlist); if (ut != NULL) endutxent(); return NULL; }
0
[ "CWE-415" ]
psutil
7d512c8e4442a896d56505be3e78f1156f443465
145,212,562,570,391,380,000,000,000,000,000,000,000
59
Use Py_CLEAR instead of Py_DECREF to also set the variable to NULL (#1616) These files contain loops that convert system data into python objects and during the process they create objects and dereference their refcounts after they have been added to the resulting list. However, in case of errors during the creation of those python objects, the refcount to previously allocated objects is dropped again with Py_XDECREF, which should be a no-op in case the paramater is NULL. Even so, in most of these loops the variables pointing to the objects are never set to NULL, even after Py_DECREF is called at the end of the loop iteration. This means, after the first iteration, if an error occurs those python objects will get their refcount dropped two times, resulting in a possible double-free.
QPDF::getTrailer() { return this->trailer; }
0
[ "CWE-399", "CWE-835" ]
qpdf
701b518d5c56a1449825a3a37a716c58e05e1c3e
189,994,187,751,056,060,000,000,000,000,000,000,000
4
Detect recursion loops resolving objects (fixes #51) During parsing of an object, sometimes parts of the object have to be resolved. An example is stream lengths. If such an object directly or indirectly points to the object being parsed, it can cause an infinite loop. Guard against all cases of re-entrant resolution of objects.
SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode) { struct path path; int error; unsigned int lookup_flags = LOOKUP_FOLLOW; retry: error = user_path_at(dfd, filename, lookup_flags, &path); if (!error) { error = chmod_common(&path, mode); path_put(&path); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; goto retry; } } return error; }
0
[ "CWE-17" ]
linux
eee5cc2702929fd41cce28058dc6d6717f723f87
140,735,655,341,633,740,000,000,000,000,000,000,000
17
get rid of s_files and files_lock The only thing we need it for is alt-sysrq-r (emergency remount r/o) and these days we can do just as well without going through the list of files. Signed-off-by: Al Viro <[email protected]>
const EVP_CIPHER *EVP_aes_128_wrap_pad(void) { return &aes_128_wrap_pad; }
0
[ "CWE-125" ]
openssl
2198b3a55de681e1f3c23edb0586afe13f438051
158,986,163,617,956,180,000,000,000,000,000,000,000
4
crypto/evp: harden AEAD ciphers. Originally a crash in 32-bit build was reported CHACHA20-POLY1305 cipher. The crash is triggered by truncated packet and is result of excessive hashing to the edge of accessible memory. Since hash operation is read-only it is not considered to be exploitable beyond a DoS condition. Other ciphers were hardened. Thanks to Robert Święcki for report. CVE-2017-3731 Reviewed-by: Rich Salz <[email protected]>
nautilus_file_mark_desktop_file_trusted (GFile *file, GtkWindow *parent_window, NautilusOpCallback done_callback, gpointer done_callback_data) { MarkTrustedJob *job; job = op_job_new (MarkTrustedJob, parent_window); job->file = g_object_ref (file); job->done_callback = done_callback; job->done_callback_data = done_callback_data; g_io_scheduler_push_job (mark_trusted_job, job, NULL, 0, NULL); }
0
[]
nautilus
ca2fd475297946f163c32dcea897f25da892b89d
245,062,640,522,095,870,000,000,000,000,000,000,000
18
Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if 2009-02-24 Alexander Larsson <[email protected]> * libnautilus-private/nautilus-file-operations.c: * libnautilus-private/nautilus-file-operations.h: Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if there is none as well as makes the file executable. * libnautilus-private/nautilus-mime-actions.c: Use nautilus_file_mark_desktop_file_trusted() instead of just setting the permissions. svn path=/trunk/; revision=15006
fetch_name(OnigCodePoint start_code, UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int* rback_num, enum REF_NUM* num_type, int is_ref) { int r, sign; int digit_count; OnigCodePoint end_code; OnigCodePoint c = 0; OnigEncoding enc = env->enc; UChar *name_end; UChar *pnum_head; UChar *p = *src; *rback_num = 0; end_code = get_name_end_code_point(start_code); digit_count = 0; name_end = end; pnum_head = *src; r = 0; *num_type = IS_NOT_NUM; sign = 1; if (PEND) { return ONIGERR_EMPTY_GROUP_NAME; } else { PFETCH_S(c); if (c == end_code) return ONIGERR_EMPTY_GROUP_NAME; if (IS_CODE_DIGIT_ASCII(enc, c)) { if (is_ref == TRUE) *num_type = IS_ABS_NUM; else { r = ONIGERR_INVALID_GROUP_NAME; } digit_count++; } else if (c == '-') { if (is_ref == TRUE) { *num_type = IS_REL_NUM; sign = -1; pnum_head = p; } else { r = ONIGERR_INVALID_GROUP_NAME; } } else if (c == '+') { if (is_ref == TRUE) { *num_type = IS_REL_NUM; sign = 1; pnum_head = p; } else { r = ONIGERR_INVALID_GROUP_NAME; } } else if (!ONIGENC_IS_CODE_WORD(enc, c)) { r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } } if (r == 0) { while (!PEND) { name_end = p; PFETCH_S(c); if (c == end_code || c == ')') { if (*num_type != IS_NOT_NUM && digit_count == 0) r = ONIGERR_INVALID_GROUP_NAME; break; } if (*num_type != IS_NOT_NUM) { if (IS_CODE_DIGIT_ASCII(enc, c)) { digit_count++; } else { if (!ONIGENC_IS_CODE_WORD(enc, c)) r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; else r = ONIGERR_INVALID_GROUP_NAME; *num_type = IS_NOT_NUM; } } else { if (!ONIGENC_IS_CODE_WORD(enc, c)) { r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } } } if (c != end_code) { r = ONIGERR_INVALID_GROUP_NAME; goto err; } if (*num_type != IS_NOT_NUM) { *rback_num = scan_number(&pnum_head, name_end, enc); if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER; else if (*rback_num == 0) { if (*num_type == IS_REL_NUM) { r = ONIGERR_INVALID_GROUP_NAME; goto err; } } *rback_num *= sign; } *rname_end = name_end; *src = p; return 0; } else { while (!PEND) { name_end = p; PFETCH_S(c); if (c == end_code || c == ')') break; } if (PEND) name_end = end; err: onig_scan_env_set_error_string(env, r, *src, name_end); return r; } }
0
[ "CWE-125" ]
oniguruma
aa0188eaedc056dca8374ac03d0177429b495515
129,586,619,532,779,240,000,000,000,000,000,000,000
131
fix #163: heap-buffer-overflow in gb18030_mbc_enc_len
static inline void aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask) { struct file *file = iocb->poll.file; aio_complete(iocb, mangle_poll(mask), 0); fput(file); }
1
[ "CWE-416" ]
linux
84c4e1f89fefe70554da0ab33be72c9be7994379
322,014,618,578,786,600,000,000,000,000,000,000,000
7
aio: simplify - and fix - fget/fput for io_submit() Al Viro root-caused a race where the IOCB_CMD_POLL handling of fget/fput() could cause us to access the file pointer after it had already been freed: "In more details - normally IOCB_CMD_POLL handling looks so: 1) io_submit(2) allocates aio_kiocb instance and passes it to aio_poll() 2) aio_poll() resolves the descriptor to struct file by req->file = fget(iocb->aio_fildes) 3) aio_poll() sets ->woken to false and raises ->ki_refcnt of that aio_kiocb to 2 (bumps by 1, that is). 4) aio_poll() calls vfs_poll(). After sanity checks (basically, "poll_wait() had been called and only once") it locks the queue. That's what the extra reference to iocb had been for - we know we can safely access it. 5) With queue locked, we check if ->woken has already been set to true (by aio_poll_wake()) and, if it had been, we unlock the queue, drop a reference to aio_kiocb and bugger off - at that point it's a responsibility to aio_poll_wake() and the stuff called/scheduled by it. That code will drop the reference to file in req->file, along with the other reference to our aio_kiocb. 6) otherwise, we see whether we need to wait. If we do, we unlock the queue, drop one reference to aio_kiocb and go away - eventual wakeup (or cancel) will deal with the reference to file and with the other reference to aio_kiocb 7) otherwise we remove ourselves from waitqueue (still under the queue lock), so that wakeup won't get us. No async activity will be happening, so we can safely drop req->file and iocb ourselves. If wakeup happens while we are in vfs_poll(), we are fine - aio_kiocb won't get freed under us, so we can do all the checks and locking safely. And we don't touch ->file if we detect that case. However, vfs_poll() most certainly *does* touch the file it had been given. So wakeup coming while we are still in ->poll() might end up doing fput() on that file. That case is not too rare, and usually we are saved by the still present reference from descriptor table - that fput() is not the final one. But if another thread closes that descriptor right after our fget() and wakeup does happen before ->poll() returns, we are in trouble - final fput() done while we are in the middle of a method: Al also wrote a patch to take an extra reference to the file descriptor to fix this, but I instead suggested we just streamline the whole file pointer handling by submit_io() so that the generic aio submission code simply keeps the file pointer around until the aio has completed. Fixes: bfe4037e722e ("aio: implement IOCB_CMD_POLL") Acked-by: Al Viro <[email protected]> Reported-by: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
static void nodeDestruct(struct SaveNode* node) { TR_ASSERT(node != NULL); if (node->sorted != NULL) { tr_free(node->sorted->val.l.vals); tr_free(node->sorted); } }
0
[ "CWE-416", "CWE-284" ]
transmission
2123adf8e5e1c2b48791f9d22fc8c747e974180e
16,756,064,529,771,620,000,000,000,000,000,000,000
10
CVE-2018-10756: Fix heap-use-after-free in tr_variantWalk In libtransmission/variant.c, function tr_variantWalk, when the variant stack is reallocated, a pointer to the previously allocated memory region is kept. This address is later accessed (heap use-after-free) while walking back down the stack, causing the application to crash. The application can be any application which uses libtransmission, such as transmission-daemon, transmission-gtk, transmission-show, etc. Reported-by: Tom Richards <[email protected]>
qf_entry_on_or_before_pos(qfline_T *qfp, pos_T *pos, int linewise) { if (linewise) return qfp->qf_lnum <= pos->lnum; else return (qfp->qf_lnum < pos->lnum || (qfp->qf_lnum == pos->lnum && qfp->qf_col <= pos->col)); }
0
[ "CWE-416" ]
vim
4f1b083be43f351bc107541e7b0c9655a5d2c0bb
241,560,439,186,835,030,000,000,000,000,000,000,000
8
patch 9.0.0322: crash when no errors and 'quickfixtextfunc' is set Problem: Crash when no errors and 'quickfixtextfunc' is set. Solution: Do not handle errors if there aren't any.
ExpressionConstant::ExpressionConstant(ExpressionContext* const expCtx, const Value& value) : Expression(expCtx), _value(value) {}
0
[]
mongo
1772b9a0393b55e6a280a35e8f0a1f75c014f301
151,230,381,282,102,800,000,000,000,000,000,000,000
2
SERVER-49404 Enforce additional checks in $arrayToObject
R_API char *cmd_syscall_dostr(RCore *core, st64 n, ut64 addr) { int i; char str[64]; st64 N = n; int defVector = r_syscall_get_swi (core->anal->syscall); if (defVector > 0) { n = -1; } if (n == -1 || defVector > 0) { n = (int)r_debug_reg_get (core->dbg, "oeax"); if (!n || n == -1) { const char *a0 = r_reg_get_name (core->anal->reg, R_REG_NAME_SN); n = (a0 == NULL)? -1: (int)r_debug_reg_get (core->dbg, a0); } } RSyscallItem *item = r_syscall_get (core->anal->syscall, n, defVector); if (!item) { item = r_syscall_get (core->anal->syscall, N, -1); } if (!item) { return r_str_newf ("%s = unknown ()", syscallNumber (n)); } char *res = r_str_newf ("%s = %s (", syscallNumber (item->num), item->name); // TODO: move this to r_syscall //TODO replace the hardcoded CC with the sdb ones for (i = 0; i < item->args; i++) { // XXX this is a hack to make syscall args work on x86-32 and x86-64 // we need to shift sn first.. which is bad, but needs to be redesigned int regidx = i; if (core->assembler->bits == 32) { regidx++; } ut64 arg = r_debug_arg_get (core->dbg, R_ANAL_CC_TYPE_FASTCALL, regidx); //r_cons_printf ("(%d:0x%"PFMT64x")\n", i, arg); if (item->sargs) { switch (item->sargs[i]) { case 'p': // pointer res = r_str_appendf (res, "0x%08" PFMT64x "", arg); break; case 'i': res = r_str_appendf (res, "%" PFMT64u "", arg); break; case 'z': memset (str, 0, sizeof (str)); r_io_read_at (core->io, arg, (ut8 *)str, sizeof (str) - 1); r_str_filter (str, strlen (str)); res = r_str_appendf (res, "\"%s\"", str); break; case 'Z': { //TODO replace the hardcoded CC with the sdb ones ut64 len = r_debug_arg_get (core->dbg, R_ANAL_CC_TYPE_FASTCALL, i + 2); len = R_MIN (len + 1, sizeof (str) - 1); if (len == 0) { len = 16; // override default } (void)r_io_read_at (core->io, arg, (ut8 *)str, len); str[len] = 0; r_str_filter (str, -1); res = r_str_appendf (res, "\"%s\"", str); } break; default: res = r_str_appendf (res, "0x%08" PFMT64x "", arg); break; } } else { res = r_str_appendf (res, "0x%08" PFMT64x "", arg); } if (i + 1 < item->args) { res = r_str_appendf (res, ", "); } } r_syscall_item_free (item); return r_str_appendf (res, ")"); }
0
[ "CWE-703", "CWE-908" ]
radare2
4d3811681a80f92a53e795f6a64c4b0fc2c8dd22
161,154,302,779,748,400,000,000,000,000,000,000,000
74
Fix segfault in adf (#16230)
init_seconds_var () { SHELL_VAR *v; v = find_variable ("SECONDS"); if (v) { if (legal_number (value_cell(v), &seconds_value_assigned) == 0) seconds_value_assigned = 0; } INIT_DYNAMIC_VAR ("SECONDS", (v ? value_cell (v) : (char *)NULL), get_seconds, assign_seconds); return v; }
0
[]
bash
863d31ae775d56b785dc5b0105b6d251515d81d5
241,643,709,104,589,800,000,000,000,000,000,000,000
13
commit bash-20120224 snapshot
long vt_compat_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct vc_data *vc = tty->driver_data; struct console_font_op op; /* used in multiple places here */ void __user *up = compat_ptr(arg); int perm; /* * To have permissions to do most of the vt ioctls, we either have * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. */ perm = 0; if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) perm = 1; switch (cmd) { /* * these need special handlers for incompatible data structures */ case PIO_FONTX: case GIO_FONTX: return compat_fontx_ioctl(cmd, up, perm, &op); case KDFONTOP: return compat_kdfontop_ioctl(up, perm, &op, vc); case PIO_UNIMAP: case GIO_UNIMAP: return compat_unimap_ioctl(cmd, up, perm, vc); /* * all these treat 'arg' as an integer */ case KIOCSOUND: case KDMKTONE: #ifdef CONFIG_X86 case KDADDIO: case KDDELIO: #endif case KDSETMODE: case KDMAPDISP: case KDUNMAPDISP: case KDSKBMODE: case KDSKBMETA: case KDSKBLED: case KDSETLED: case KDSIGACCEPT: case VT_ACTIVATE: case VT_WAITACTIVE: case VT_RELDISP: case VT_DISALLOCATE: case VT_RESIZE: case VT_RESIZEX: return vt_ioctl(tty, cmd, arg); /* * the rest has a compatible data structure behind arg, * but we have to convert it to a proper 64 bit pointer. */ default: return vt_ioctl(tty, cmd, (unsigned long)up); } }
1
[ "CWE-662" ]
linux
90bfdeef83f1d6c696039b6a917190dcbbad3220
233,679,579,024,077,900,000,000,000,000,000,000,000
64
tty: make FONTX ioctl use the tty pointer they were actually passed Some of the font tty ioctl's always used the current foreground VC for their operations. Don't do that then. This fixes a data race on fg_console. Side note: both Michael Ellerman and Jiri Slaby point out that all these ioctls are deprecated, and should probably have been removed long ago, and everything seems to be using the KDFONTOP ioctl instead. In fact, Michael points out that it looks like busybox's loadfont program seems to have switched over to using KDFONTOP exactly _because_ of this bug (ahem.. 12 years ago ;-). Reported-by: Minh Yuan <[email protected]> Acked-by: Michael Ellerman <[email protected]> Acked-by: Jiri Slaby <[email protected]> Cc: Greg KH <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void Ogg::XiphComment::setTitle(const String &s) { addField("TITLE", s); }
0
[ "CWE-20" ]
taglib
ab8a0ee8937256311e649a88e8ddd7c7f870ad59
93,927,347,279,499,470,000,000,000,000,000,000,000
4
Don't store the output of ByteVector::toUInt() in int, use uint instead
static void blkif_notify_work(struct xen_blkif *blkif) { blkif->waiting_reqs = 1; wake_up(&blkif->wq); }
0
[ "CWE-20" ]
linux-2.6
604c499cbbcc3d5fe5fb8d53306aa0fae1990109
269,281,090,711,466,660,000,000,000,000,000,000,000
5
xen/blkback: Check device permissions before allowing OP_DISCARD We need to make sure that the device is not RO or that the request is not past the number of sectors we want to issue the DISCARD operation for. This fixes CVE-2013-2140. Cc: [email protected] Acked-by: Jan Beulich <[email protected]> Acked-by: Ian Campbell <[email protected]> [v1: Made it pr_warn instead of pr_debug] Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
static int wcd9335_power_on_reset(struct wcd9335_codec *wcd) { struct device *dev = wcd->dev; int ret; ret = regulator_bulk_enable(WCD9335_MAX_SUPPLY, wcd->supplies); if (ret) { dev_err(dev, "Failed to get supplies: err = %d\n", ret); return ret; } /* * For WCD9335, it takes about 600us for the Vout_A and * Vout_D to be ready after BUCK_SIDO is powered up. * SYS_RST_N shouldn't be pulled high during this time * Toggle the reset line to make sure the reset pulse is * correctly applied */ usleep_range(600, 650); gpio_direction_output(wcd->reset_gpio, 0); msleep(20); gpio_set_value(wcd->reset_gpio, 1); msleep(20); return 0; }
0
[]
sound
a54988113985ca22e414e132054f234fc8a92604
168,387,294,240,835,430,000,000,000,000,000,000,000
27
wcd9335: fix a incorrect use of kstrndup() In wcd9335_codec_enable_dec(), 'widget_name' is allocated by kstrndup(). However, according to doc: "Note: Use kmemdup_nul() instead if the size is known exactly." So we should use kmemdup_nul() here instead of kstrndup(). Signed-off-by: Gen Zhang <[email protected]> Signed-off-by: Mark Brown <[email protected]>
routerid_handler(vector_t *strvec) { FREE_PTR(global_data->router_id); global_data->router_id = set_value(strvec); }
0
[ "CWE-200" ]
keepalived
c6247a9ef2c7b33244ab1d3aa5d629ec49f0a067
12,361,284,622,102,704,000,000,000,000,000,000,000
5
Add command line and configuration option to set umask Issue #1048 identified that files created by keepalived are created with mode 0666. This commit changes the default to 0644, and also allows the umask to be specified in the configuration or as a command line option. Signed-off-by: Quentin Armitage <[email protected]>
void BrotliContext::finalizeOutput(Buffer::Instance& output_buffer) { const size_t n_output = chunk_size_ - avail_out_; if (n_output > 0) { output_buffer.add(static_cast<void*>(chunk_ptr_.get()), n_output); } }
0
[]
envoy
cb4ef0b09200c720dfdb07e097092dd105450343
205,759,119,083,072,850,000,000,000,000,000,000,000
6
decompressors: stop decompressing upon excessive compression ratio (#733) Signed-off-by: Dmitry Rozhkov <[email protected]> Co-authored-by: Ryan Hamilton <[email protected]> Signed-off-by: Matt Klein <[email protected]> Signed-off-by: Pradeep Rao <[email protected]>
dict_continue(i_ctx_t *i_ctx_p) { os_ptr op = osp; es_ptr obj = esp - 2; int index = esp->value.intval; push(2); /* make room for key and value */ if ((index = dict_next(obj, index, op - 1)) >= 0) { /* continue */ esp->value.intval = index; esp += 2; *esp = obj[1]; return o_push_estack; } else { /* done */ pop(2); /* undo push */ esp -= 4; /* pop mark, object, proc, index */ return o_pop_estack; } }
0
[]
ghostpdl
d683d1e6450d74619e6277efeebfc222d9a5cb91
149,028,499,025,906,720,000,000,000,000,000,000,000
18
Bug 700585: Obliterate "superexec". We don't need it, nor do any known apps. We were under the impression that the Windows driver 'PScript5.dll' used superexec, but after testing with our extensive suite of PostScript file, and analysis of the PScript5 "Adobe CoolType ProcSet, it does not appear that this operator is needed anymore. Get rid of superexec and all of the references to it, since it is a potential security hole.
void write( const char* key, double value ) { char buf[128]; writeScalar( key, fs::doubleToString( buf, value, true )); }
0
[ "CWE-787" ]
opencv
f42d5399aac80d371b17d689851406669c9b9111
208,864,686,175,284,300,000,000,000,000,000,000,000
5
core(persistence): add more checks for implementation limitations
archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid) { struct zip *zip = (struct zip *)a->format->data; int64_t file_size, current_offset; const char *p; int i, tail; /* If someone has already bid more than 32, then avoid trashing the look-ahead buffers with a seek. */ if (best_bid > 32) return (-1); file_size = __archive_read_seek(a, 0, SEEK_END); if (file_size <= 0) return 0; /* Search last 16k of file for end-of-central-directory * record (which starts with PK\005\006) */ tail = (int)zipmin(1024 * 16, file_size); current_offset = __archive_read_seek(a, -tail, SEEK_END); if (current_offset < 0) return 0; if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL) return 0; /* Boyer-Moore search backwards from the end, since we want * to match the last EOCD in the file (there can be more than * one if there is an uncompressed Zip archive as a member * within this Zip archive). */ for (i = tail - 22; i > 0;) { switch (p[i]) { case 'P': if (memcmp(p + i, "PK\005\006", 4) == 0) { int ret = read_eocd(zip, p + i, current_offset + i); /* Zip64 EOCD locator precedes * regular EOCD if present. */ if (i >= 20 && memcmp(p + i - 20, "PK\006\007", 4) == 0) { int ret_zip64 = read_zip64_eocd(a, zip, p + i - 20); if (ret_zip64 > ret) ret = ret_zip64; } return (ret); } i -= 4; break; case 'K': i -= 1; break; case 005: i -= 2; break; case 006: i -= 3; break; default: i -= 4; break; } } return 0; }
0
[ "CWE-399", "CWE-401" ]
libarchive
ba641f73f3d758d9032b3f0e5597a9c6e593a505
263,956,172,867,565,700,000,000,000,000,000,000,000
53
Fix typo in preprocessor macro in archive_read_format_zip_cleanup() Frees lzma_stream on cleanup() Fixes #1165
QString Utils::String::fromStdString(const std::string &str) { return QString::fromUtf8(str.c_str()); }
0
[ "CWE-20", "CWE-79" ]
qBittorrent
6ca3e4f094da0a0017cb2d483ec1db6176bb0b16
331,742,689,370,953,760,000,000,000,000,000,000,000
4
Add Utils::String::toHtmlEscaped
CNF_AddSources(void) { NTP_Source *source; unsigned int i; for (i = 0; i < ARR_GetSize(ntp_sources); i++) { source = (NTP_Source *)ARR_GetElement(ntp_sources, i); NSR_AddSourceByName(source->params.name, source->params.port, source->pool, source->type, &source->params.params); Free(source->params.name); } ARR_SetSize(ntp_sources, 0); }
0
[ "CWE-59" ]
chrony
e18903a6b56341481a2e08469c0602010bf7bfe3
328,444,299,528,211,920,000,000,000,000,000,000,000
14
switch to new util file functions Replace all fopen(), rename(), and unlink() calls with the new util functions.
static void cqspi_configure_cs_and_sizes(struct spi_nor *nor) { struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_st *cqspi = f_pdata->cqspi; void __iomem *iobase = cqspi->iobase; unsigned int reg; /* configure page size and block size. */ reg = readl(iobase + CQSPI_REG_SIZE); reg &= ~(CQSPI_REG_SIZE_PAGE_MASK << CQSPI_REG_SIZE_PAGE_LSB); reg &= ~(CQSPI_REG_SIZE_BLOCK_MASK << CQSPI_REG_SIZE_BLOCK_LSB); reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK; reg |= (nor->page_size << CQSPI_REG_SIZE_PAGE_LSB); reg |= (ilog2(nor->mtd.erasesize) << CQSPI_REG_SIZE_BLOCK_LSB); reg |= (nor->addr_width - 1); writel(reg, iobase + CQSPI_REG_SIZE); /* configure the chip select */ cqspi_chipselect(nor); /* Store the new configuration of the controller */ cqspi->current_page_size = nor->page_size; cqspi->current_erase_size = nor->mtd.erasesize; cqspi->current_addr_width = nor->addr_width; }
0
[ "CWE-119", "CWE-787" ]
linux
193e87143c290ec16838f5368adc0e0bc94eb931
10,595,996,626,378,274,000,000,000,000,000,000,000
25
mtd: spi-nor: Off by one in cqspi_setup_flash() There are CQSPI_MAX_CHIPSELECT elements in the ->f_pdata array so the > should be >=. Fixes: 140623410536 ('mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller') Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Cyrille Pitchen <[email protected]>
static struct nft_rule_blob *nf_tables_chain_alloc_rules(unsigned int size) { struct nft_rule_blob *blob; /* size must include room for the last rule */ if (size < offsetof(struct nft_rule_dp, data)) return NULL; size += sizeof(struct nft_rule_blob) + sizeof(struct nft_rules_old); if (size > INT_MAX) return NULL; blob = kvmalloc(size, GFP_KERNEL_ACCOUNT); if (!blob) return NULL; blob->size = 0; nft_last_rule(blob, blob->data); return blob; }
0
[]
net
520778042ccca019f3ffa136dd0ca565c486cedd
218,585,782,921,130,780,000,000,000,000,000,000,000
21
netfilter: nf_tables: disallow non-stateful expression in sets earlier Since 3e135cd499bf ("netfilter: nft_dynset: dynamic stateful expression instantiation"), it is possible to attach stateful expressions to set elements. cd5125d8f518 ("netfilter: nf_tables: split set destruction in deactivate and destroy phase") introduces conditional destruction on the object to accomodate transaction semantics. nft_expr_init() calls expr->ops->init() first, then check for NFT_STATEFUL_EXPR, this stills allows to initialize a non-stateful lookup expressions which points to a set, which might lead to UAF since the set is not properly detached from the set->binding for this case. Anyway, this combination is non-sense from nf_tables perspective. This patch fixes this problem by checking for NFT_STATEFUL_EXPR before expr->ops->init() is called. The reporter provides a KASAN splat and a poc reproducer (similar to those autogenerated by syzbot to report use-after-free errors). It is unknown to me if they are using syzbot or if they use similar automated tool to locate the bug that they are reporting. For the record, this is the KASAN splat. [ 85.431824] ================================================================== [ 85.432901] BUG: KASAN: use-after-free in nf_tables_bind_set+0x81b/0xa20 [ 85.433825] Write of size 8 at addr ffff8880286f0e98 by task poc/776 [ 85.434756] [ 85.434999] CPU: 1 PID: 776 Comm: poc Tainted: G W 5.18.0+ #2 [ 85.436023] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 Fixes: 0b2d8a7b638b ("netfilter: nf_tables: add helper functions for expression handling") Reported-and-tested-by: Aaron Adams <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
static void rfx_write_message_channels(RFX_CONTEXT* context, wStream* s) { Stream_Write_UINT16(s, WBT_CHANNELS); /* BlockT.blockType (2 bytes) */ Stream_Write_UINT32(s, 12); /* BlockT.blockLen (4 bytes) */ Stream_Write_UINT8(s, 1); /* numChannels (1 byte) */ Stream_Write_UINT8(s, 0); /* Channel.channelId (1 byte) */ Stream_Write_UINT16(s, context->width); /* Channel.width (2 bytes) */ Stream_Write_UINT16(s, context->height); /* Channel.height (2 bytes) */ }
0
[ "CWE-125" ]
FreeRDP
3a06ce058f690b7fc1edad2f352c453376c2ebfe
205,057,604,651,420,170,000,000,000,000,000,000,000
9
Fixed oob read in rfx_process_message_tileset Check input data length Thanks to hac425 CVE-2020-11043
void sqlite3WindowFunctions(void){ static FuncDef aWindowFuncs[] = { WINDOWFUNCX(row_number, 0, 0), WINDOWFUNCX(dense_rank, 0, 0), WINDOWFUNCX(rank, 0, 0), WINDOWFUNCALL(percent_rank, 0, 0), WINDOWFUNCALL(cume_dist, 0, 0), WINDOWFUNCALL(ntile, 1, 0), WINDOWFUNCALL(last_value, 1, 0), WINDOWFUNCALL(nth_value, 2, 0), WINDOWFUNCALL(first_value, 1, 0), WINDOWFUNCNOOP(lead, 1, 0), WINDOWFUNCNOOP(lead, 2, 0), WINDOWFUNCNOOP(lead, 3, 0), WINDOWFUNCNOOP(lag, 1, 0), WINDOWFUNCNOOP(lag, 2, 0), WINDOWFUNCNOOP(lag, 3, 0), }; sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs)); }
0
[ "CWE-476" ]
sqlite
75e95e1fcd52d3ec8282edb75ac8cd0814095d54
298,507,056,624,946,600,000,000,000,000,000,000,000
20
When processing constant integer values in ORDER BY clauses of window definitions (see check-in [7e4809eadfe99ebf]) be sure to fully disable the constant value to avoid an invalid pointer dereference if the expression is ever duplicated. This fixes a crash report from Yongheng and Rui. FossilOrigin-Name: 1ca0bd982ab1183bbafce0d260e4dceda5eb766ed2e7793374a88d1ae0bdd2ca
void sort_directory(struct dir *dir) { struct dir_ent *cur, *l1, *l2, *next; int len1, len2, stride = 1; if(dir->dir_count < 2) return; /* * We can consider our linked-list to be made up of stride length * sublists. Eacn iteration around this loop merges adjacent * stride length sublists into larger 2*stride sublists. We stop * when stride becomes equal to the entire list. * * Initially stride = 1 (by definition a sublist of 1 is sorted), and * these 1 element sublists are merged into 2 element sublists, which * are then merged into 4 element sublists and so on. */ do { l2 = dir->dirs; /* head of current linked list */ cur = NULL; /* empty output list */ /* * Iterate through the linked list, merging adjacent sublists. * On each interation l2 points to the next sublist pair to be * merged (if there's only one sublist left this is simply added * to the output list) */ while(l2) { l1 = l2; for(len1 = 0; l2 && len1 < stride; len1 ++, l2 = l2->next); len2 = stride; /* * l1 points to first sublist. * l2 points to second sublist. * Merge them onto the output list */ while(len1 && l2 && len2) { if(strcmp(l1->name, l2->name) <= 0) { next = l1; l1 = l1->next; len1 --; } else { next = l2; l2 = l2->next; len2 --; } if(cur) { cur->next = next; cur = next; } else dir->dirs = cur = next; } /* * One sublist is now empty, copy the other one onto the * output list */ for(; len1; len1 --, l1 = l1->next) { if(cur) { cur->next = l1; cur = l1; } else dir->dirs = cur = l1; } for(; l2 && len2; len2 --, l2 = l2->next) { if(cur) { cur->next = l2; cur = l2; } else dir->dirs = cur = l2; } } cur->next = NULL; stride = stride << 1; } while(stride < dir->dir_count); }
0
[ "CWE-200", "CWE-59", "CWE-22" ]
squashfs-tools
e0485802ec72996c20026da320650d8362f555bd
195,677,670,004,602,400,000,000,000,000,000,000,000
78
Unsquashfs: additional write outside destination directory exploit fix An issue on github (https://github.com/plougher/squashfs-tools/issues/72) showed how some specially crafted Squashfs filesystems containing invalid file names (with '/' and '..') can cause Unsquashfs to write files outside of the destination directory. Since then it has been shown that specially crafted Squashfs filesystems that contain a symbolic link pointing outside of the destination directory, coupled with an identically named file within the same directory, can cause Unsquashfs to write files outside of the destination directory. Specifically the symbolic link produces a pathname pointing outside of the destination directory, which is then followed when writing the duplicate identically named file within the directory. This commit fixes this exploit by explictly checking for duplicate filenames within a directory. As directories in v2.1, v3.x, and v4.0 filesystems are sorted, this is achieved by checking for consecutively identical filenames. Additionally directories are checked to ensure they are sorted, to avoid attempts to evade the duplicate check. Version 1.x and 2.0 filesystems (where the directories were unsorted) are sorted and then the above duplicate filename check is applied. Signed-off-by: Phillip Lougher <[email protected]>