func
stringlengths
0
484k
target
int64
0
1
cwe
listlengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
void msetGenericCommand(client *c, int nx) { int j; if ((c->argc % 2) == 0) { addReplyError(c,"wrong number of arguments for MSET"); return; } /* Handle the NX flag. The MSETNX semantic is to return zero and don't * set anything if at least one key already exists. */ if (nx) { for (j = 1; j < c->argc; j += 2) { if (lookupKeyWrite(c->db,c->argv[j]) != NULL) { addReply(c, shared.czero); return; } } } for (j = 1; j < c->argc; j += 2) { c->argv[j+1] = tryObjectEncoding(c->argv[j+1]); setKey(c,c->db,c->argv[j],c->argv[j+1]); notifyKeyspaceEvent(NOTIFY_STRING,"set",c->argv[j],c->db->id); } server.dirty += (c->argc-1)/2; addReply(c, nx ? shared.cone : shared.ok); }
0
[ "CWE-190" ]
redis
92e3b1802f72ca0c5b0bde97f01d9b57a758d85c
3,273,439,207,418,615,700,000,000,000,000,000,000
27
Fix integer overflow in STRALGO LCS (CVE-2021-29477) An integer overflow bug in Redis version 6.0 or newer could be exploited using the STRALGO LCS command to corrupt the heap and potentially result with remote code execution. (cherry picked from commit f0c5f920d0f88bd8aa376a2c05af4902789d1ef9)
static int process_command(MYSQL_THD thd, LEX_CSTRING event_command, my_bool consume_event) { LEX_CSTRING abort_ret_command= { C_STRING_WITH_LEN("ABORT_RET") }; if (!my_charset_latin1.coll->strnncoll(&my_charset_latin1, (const uchar *)event_command.str, event_command.length, (const uchar *)abort_ret_command.str, abort_ret_command.length, 0)) { int ret_code = (int)THDVAR(thd, abort_value); const char *err_message = (const char *)THDVAR(thd, abort_message); LEX_CSTRING status = { C_STRING_WITH_LEN("EVENT-ORDER-ABORT") }; LEX_CSTRING order_cstr; lex_cstring_set(&order_cstr, (const char *)THDVAR(thd, event_order_check)); /* Do not replace order string yet. */ if (consume_event) { memmove((char *) order_cstr.str, (void *) status.str, status.length + 1); THDVAR(thd, abort_value)= 1; THDVAR(thd, abort_message)= 0; } if (err_message) { my_message(ER_AUDIT_API_ABORT, err_message, MYF(0)); THDVAR(thd, event_order_check)= (char *)order_cstr.str; } return ret_code; } return 0; }
0
[]
mysql-server
914590c737dab0e3e7d9f023aef4c704a443ed7f
175,176,651,494,259,860,000,000,000,000,000,000,000
40
Bug#24493829 SETTING THE NULL_AUDIT_EVENT_RECORD CAUSES SEGMENTATION FAULT Post-push fix. Memory leak fixed (reported by Valgrind).
static bool kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, gfn_t gfn) { struct kvm_arch_async_pf arch; arch.token = alloc_apf_token(vcpu); arch.gfn = gfn; arch.direct_map = vcpu->arch.mmu->direct_map; arch.cr3 = vcpu->arch.mmu->get_guest_pgd(vcpu); return kvm_setup_async_pf(vcpu, cr2_or_gpa, kvm_vcpu_gfn_to_hva(vcpu, gfn), &arch); }
0
[ "CWE-476" ]
linux
9f46c187e2e680ecd9de7983e4d081c3391acc76
266,152,863,711,183,070,000,000,000,000,000,000,000
13
KVM: x86/mmu: fix NULL pointer dereference on guest INVPCID With shadow paging enabled, the INVPCID instruction results in a call to kvm_mmu_invpcid_gva. If INVPCID is executed with CR0.PG=0, the invlpg callback is not set and the result is a NULL pointer dereference. Fix it trivially by checking for mmu->invlpg before every call. There are other possibilities: - check for CR0.PG, because KVM (like all Intel processors after P5) flushes guest TLB on CR0.PG changes so that INVPCID/INVLPG are a nop with paging disabled - check for EFER.LMA, because KVM syncs and flushes when switching MMU contexts outside of 64-bit mode All of these are tricky, go for the simple solution. This is CVE-2022-1789. Reported-by: Yongkang Jia <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
PHP_METHOD(Phar, convertToExecutable) { char *ext = NULL; int is_data; size_t ext_len = 0; php_uint32 flags; zend_object *ret; /* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */ zend_long format = 9021976, method = 9021976; PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) { return; } if (PHAR_G(readonly)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out executable phar archive, phar is read-only"); return; } switch (format) { case 9021976: case PHAR_FORMAT_SAME: /* null is converted to 0 */ /* by default, use the existing format */ if (phar_obj->archive->is_tar) { format = PHAR_FORMAT_TAR; } else if (phar_obj->archive->is_zip) { format = PHAR_FORMAT_ZIP; } else { format = PHAR_FORMAT_PHAR; } break; case PHAR_FORMAT_PHAR: case PHAR_FORMAT_TAR: case PHAR_FORMAT_ZIP: break; default: zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP"); return; } switch (method) { case 9021976: flags = phar_obj->archive->flags & PHAR_FILE_COMPRESSION_MASK; break; case 0: flags = PHAR_FILE_COMPRESSED_NONE; break; case PHAR_ENT_COMPRESSED_GZ: if (format == PHAR_FORMAT_ZIP) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot compress entire archive with gzip, zip archives do not support whole-archive compression"); return; } if (!PHAR_G(has_zlib)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot compress entire archive with gzip, enable ext/zlib in php.ini"); return; } flags = PHAR_FILE_COMPRESSED_GZ; break; case PHAR_ENT_COMPRESSED_BZ2: if (format == PHAR_FORMAT_ZIP) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot compress entire archive with bz2, zip archives do not support whole-archive compression"); return; } if (!PHAR_G(has_bz2)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot compress entire archive with bz2, enable ext/bz2 in php.ini"); return; } flags = PHAR_FILE_COMPRESSED_BZ2; break; default: zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2"); return; } is_data = phar_obj->archive->is_data; phar_obj->archive->is_data = 0; ret = phar_convert_to_other(phar_obj->archive, format, ext, flags); phar_obj->archive->is_data = is_data; if (ret) { ZVAL_OBJ(return_value, ret); } else { RETURN_NULL(); } }
0
[ "CWE-20" ]
php-src
1e9b175204e3286d64dfd6c9f09151c31b5e099a
38,477,760,376,438,534,000,000,000,000,000,000,000
97
Fix bug #71860: Require valid paths for phar filenames
copy_text_attr( int off, char_u *buf, int len, int attr) { int i; mch_memmove(ScreenLines + off, buf, (size_t)len); if (enc_utf8) vim_memset(ScreenLinesUC + off, 0, sizeof(u8char_T) * (size_t)len); for (i = 0; i < len; ++i) ScreenAttrs[off + i] = attr; }
0
[ "CWE-122" ]
vim
826bfe4bbd7594188e3d74d2539d9707b1c6a14b
290,830,325,325,424,480,000,000,000,000,000,000,000
14
patch 8.2.3487: illegal memory access if buffer name is very long Problem: Illegal memory access if buffer name is very long. Solution: Make sure not to go over the end of the buffer.
static inline void expire_data_free(struct expire_data *data) { if (!data) return; safe_close(data->dev_autofs_fd); safe_close(data->ioctl_fd); free(data); }
0
[ "CWE-362" ]
systemd
e7d54bf58789545a9eb0b3964233defa0b007318
4,369,431,581,797,274,600,000,000,000,000,000,000
8
automount: ack automount requests even when already mounted (#5916) If a process accesses an autofs filesystem while systemd is in the middle of starting the mount unit on top of it, it is possible for the autofs_ptype_missing_direct request from the kernel to be received after the mount unit has been fully started: systemd forks and execs mount ... ... access autofs, blocks mount exits ... systemd receives SIGCHLD ... ... kernel sends request systemd receives request ... systemd needs to respond to this request, otherwise the kernel will continue to block access to the mount point.
virDomainDelIOThread(virDomainPtr domain, unsigned int iothread_id, unsigned int flags) { virConnectPtr conn; VIR_DOMAIN_DEBUG(domain, "iothread_id=%u, flags=%x", iothread_id, flags); virResetLastError(); virCheckDomainReturn(domain, -1); virCheckReadOnlyGoto(domain->conn->flags, error); virCheckNonZeroArgGoto(iothread_id, error); conn = domain->conn; if (conn->driver->domainDelIOThread) { int ret; ret = conn->driver->domainDelIOThread(domain, iothread_id, flags); if (ret < 0) goto error; return ret; } virReportUnsupportedError(); error: virDispatchError(domain->conn); return -1; }
0
[ "CWE-254" ]
libvirt
506e9d6c2d4baaf580d489fff0690c0ff2ff588f
172,478,135,843,154,140,000,000,000,000,000,000,000
30
virDomainGetTime: Deny on RO connections We have a policy that if API may end up talking to a guest agent it should require RW connection. We don't obey the rule in virDomainGetTime(). Signed-off-by: Michal Privoznik <[email protected]>
DocumentSourceLookUp::DocumentSourceLookUp(NamespaceString fromNs, std::string as, std::vector<BSONObj> pipeline, BSONObj letVariables, const boost::intrusive_ptr<ExpressionContext>& expCtx) : DocumentSourceLookUp(fromNs, as, expCtx) { // '_resolvedPipeline' will first be initialized by the constructor delegated to within this // constructor's initializer list. It will be populated with view pipeline prefix if 'fromNs' // represents a view. We append the user 'pipeline' to the end of '_resolvedPipeline' to ensure // any view prefix is not overwritten. _resolvedPipeline.insert(_resolvedPipeline.end(), pipeline.begin(), pipeline.end()); _userPipeline = std::move(pipeline); _cache.emplace(internalDocumentSourceLookupCacheSizeBytes.load()); for (auto&& varElem : letVariables) { const auto varName = varElem.fieldNameStringData(); Variables::uassertValidNameForUserWrite(varName); _letVariables.emplace_back( varName.toString(), Expression::parseOperand(expCtx, varElem, expCtx->variablesParseState), _variablesParseState.defineVariable(varName)); } initializeResolvedIntrospectionPipeline(); }
0
[ "CWE-416" ]
mongo
d6133a3a5464fac202f512b0310dfeb200c126f9
128,616,807,683,523,480,000,000,000,000,000,000,000
28
SERVER-43350 $lookup with no local default or user-specified collation should explicitly set the simple collation on the foreign expression context
static int b43_validate_chipaccess(struct b43_wldev *dev) { u32 v, backup0, backup4; backup0 = b43_shm_read32(dev, B43_SHM_SHARED, 0); backup4 = b43_shm_read32(dev, B43_SHM_SHARED, 4); /* Check for read/write and endianness problems. */ b43_shm_write32(dev, B43_SHM_SHARED, 0, 0x55AAAA55); if (b43_shm_read32(dev, B43_SHM_SHARED, 0) != 0x55AAAA55) goto error; b43_shm_write32(dev, B43_SHM_SHARED, 0, 0xAA5555AA); if (b43_shm_read32(dev, B43_SHM_SHARED, 0) != 0xAA5555AA) goto error; /* Check if unaligned 32bit SHM_SHARED access works properly. * However, don't bail out on failure, because it's noncritical. */ b43_shm_write16(dev, B43_SHM_SHARED, 0, 0x1122); b43_shm_write16(dev, B43_SHM_SHARED, 2, 0x3344); b43_shm_write16(dev, B43_SHM_SHARED, 4, 0x5566); b43_shm_write16(dev, B43_SHM_SHARED, 6, 0x7788); if (b43_shm_read32(dev, B43_SHM_SHARED, 2) != 0x55663344) b43warn(dev->wl, "Unaligned 32bit SHM read access is broken\n"); b43_shm_write32(dev, B43_SHM_SHARED, 2, 0xAABBCCDD); if (b43_shm_read16(dev, B43_SHM_SHARED, 0) != 0x1122 || b43_shm_read16(dev, B43_SHM_SHARED, 2) != 0xCCDD || b43_shm_read16(dev, B43_SHM_SHARED, 4) != 0xAABB || b43_shm_read16(dev, B43_SHM_SHARED, 6) != 0x7788) b43warn(dev->wl, "Unaligned 32bit SHM write access is broken\n"); b43_shm_write32(dev, B43_SHM_SHARED, 0, backup0); b43_shm_write32(dev, B43_SHM_SHARED, 4, backup4); if ((dev->dev->core_rev >= 3) && (dev->dev->core_rev <= 10)) { /* The 32bit register shadows the two 16bit registers * with update sideeffects. Validate this. */ b43_write16(dev, B43_MMIO_TSF_CFP_START, 0xAAAA); b43_write32(dev, B43_MMIO_TSF_CFP_START, 0xCCCCBBBB); if (b43_read16(dev, B43_MMIO_TSF_CFP_START_LOW) != 0xBBBB) goto error; if (b43_read16(dev, B43_MMIO_TSF_CFP_START_HIGH) != 0xCCCC) goto error; } b43_write32(dev, B43_MMIO_TSF_CFP_START, 0); v = b43_read32(dev, B43_MMIO_MACCTL); v |= B43_MACCTL_GMODE; if (v != (B43_MACCTL_GMODE | B43_MACCTL_IHR_ENABLED)) goto error; return 0; error: b43err(dev->wl, "Failed to validate the chipaccess\n"); return -ENODEV; }
0
[ "CWE-134" ]
wireless
9538cbaab6e8b8046039b4b2eb6c9d614dc782bd
15,118,307,960,996,430,000,000,000,000,000,000,000
55
b43: stop format string leaking into error msgs The module parameter "fwpostfix" is userspace controllable, unfiltered, and is used to define the firmware filename. b43_do_request_fw() populates ctx->errors[] on error, containing the firmware filename. b43err() parses its arguments as a format string. For systems with b43 hardware, this could lead to a uid-0 to ring-0 escalation. CVE-2013-2852 Signed-off-by: Kees Cook <[email protected]> Cc: [email protected] Signed-off-by: John W. Linville <[email protected]>
static word32 SetBitString16Bit(word16 val, byte* output) { word32 idx; int len; byte lastByte; byte unusedBits = 0; if ((val >> 8) != 0) { len = 2; lastByte = (byte)(val >> 8); } else { len = 1; lastByte = (byte)val; } while (((lastByte >> unusedBits) & 0x01) == 0x00) unusedBits++; idx = SetBitString(len, unusedBits, output); output[idx++] = (byte)val; if (len > 1) output[idx++] = (byte)(val >> 8); return idx; }
0
[ "CWE-125", "CWE-345" ]
wolfssl
f93083be72a3b3d956b52a7ec13f307a27b6e093
319,595,743,258,333,050,000,000,000,000,000,000,000
26
OCSP: improve handling of OCSP no check extension
GF_Err gf_isom_set_visual_color_info(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, u32 colour_type, u16 colour_primaries, u16 transfer_characteristics, u16 matrix_coefficients, Bool full_range_flag, u8 *icc_data, u32 icc_size) { GF_Err e; GF_TrackBox *trak; GF_SampleEntryBox *entry; GF_SampleDescriptionBox *stsd; GF_ColourInformationBox *clr=NULL; e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return GF_BAD_PARAM; stsd = trak->Media->information->sampleTable->SampleDescription; if (!stsd) return movie->LastError = GF_ISOM_INVALID_FILE; if (!StreamDescriptionIndex || StreamDescriptionIndex > gf_list_count(stsd->child_boxes)) { return movie->LastError = GF_BAD_PARAM; } entry = (GF_SampleEntryBox *)gf_list_get(stsd->child_boxes, StreamDescriptionIndex - 1); //no support for generic sample entries (eg, no MPEG4 descriptor) if (entry == NULL) return GF_BAD_PARAM; if (!movie->keep_utc) trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); if (entry->internal_type != GF_ISOM_SAMPLE_ENTRY_VIDEO) return GF_OK; clr = (GF_ColourInformationBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_COLR); if (!colour_type) { if (clr) gf_isom_box_del_parent(&entry->child_boxes, (GF_Box *)clr); return GF_OK; } if (!clr) { clr = (GF_ColourInformationBox*)gf_isom_box_new_parent(&entry->child_boxes, GF_ISOM_BOX_TYPE_COLR); if (!clr) return GF_OUT_OF_MEM; } clr->colour_type = colour_type; clr->colour_primaries = colour_primaries; clr->transfer_characteristics = transfer_characteristics; clr->matrix_coefficients = matrix_coefficients; clr->full_range_flag = full_range_flag; if (clr->opaque) gf_free(clr->opaque); clr->opaque = NULL; clr->opaque_size = 0; if ((colour_type==GF_ISOM_SUBTYPE_RICC) || (colour_type==GF_ISOM_SUBTYPE_PROF)) { clr->opaque_size = icc_data ? icc_size : 0; if (clr->opaque_size) { clr->opaque = gf_malloc(sizeof(char)*clr->opaque_size); if (!clr->opaque) return GF_OUT_OF_MEM; memcpy(clr->opaque, icc_data, sizeof(char)*clr->opaque_size); } } return GF_OK; }
0
[ "CWE-476" ]
gpac
ebfa346eff05049718f7b80041093b4c5581c24e
115,063,983,844,803,200,000,000,000,000,000,000,000
53
fixed #1706
void SQLiteDBInstance::init() { primary_ = false; openOptimized(db_); }
0
[ "CWE-77", "CWE-295" ]
osquery
c3f9a3dae22d43ed3b4f6a403cbf89da4cba7c3c
205,561,467,745,950,050,000,000,000,000,000,000,000
4
Merge pull request from GHSA-4g56-2482-x7q8 * Proposed fix for attach tables vulnerability * Add authorizer to ATC tables and cleanups - Add unit test for authorizer function
NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info, SEC_DESC **ppdesc) { SMB_STRUCT_STAT sbuf; SMB_ACL_T posix_acl = NULL; struct pai_val *pal; *ppdesc = NULL; DEBUG(10,("posix_fget_nt_acl: called for file %s\n", fsp->fsp_name )); /* can it happen that fsp_name == NULL ? */ if (fsp->is_directory || fsp->fh->fd == -1) { return posix_get_nt_acl(fsp->conn, fsp->fsp_name, security_info, ppdesc); } /* Get the stat struct for the owner info. */ if(SMB_VFS_FSTAT(fsp, &sbuf) != 0) { return map_nt_error_from_unix(errno); } /* Get the ACL from the fd. */ posix_acl = SMB_VFS_SYS_ACL_GET_FD(fsp); pal = fload_inherited_info(fsp); return posix_get_nt_acl_common(fsp->conn, fsp->fsp_name, &sbuf, pal, posix_acl, NULL, security_info, ppdesc); }
0
[ "CWE-264" ]
samba
d6c28913f3109d1327a3d1369b6eafd3874b2dca
3,526,075,031,887,491,500,000,000,000,000,000,000
30
Bug 6488: acl_group_override() call in posix acls references an uninitialized variable. (cherry picked from commit f92195e3a1baaddda47a5d496f9488c8445b41ad)
GF_Err txtc_box_size(GF_Box *s) { GF_TextConfigBox *ptr = (GF_TextConfigBox *)s; if (ptr->config) ptr->size += strlen(ptr->config); ptr->size++; return GF_OK;
0
[ "CWE-787" ]
gpac
388ecce75d05e11fc8496aa4857b91245007d26e
169,374,128,788,365,450,000,000,000,000,000,000,000
8
fixed #1587
void set_ndpi_flow_malloc(void *(*__ndpi_flow_malloc)(size_t size)) { _ndpi_flow_malloc = __ndpi_flow_malloc; }
0
[ "CWE-416", "CWE-787" ]
nDPI
6a9f5e4f7c3fd5ddab3e6727b071904d76773952
40,894,725,048,518,080,000,000,000,000,000,000,000
3
Fixed use after free caused by dangling pointer * This fix also improved RCE Injection detection Signed-off-by: Toni Uhlig <[email protected]>
static void wait_for_snapshot_creation(struct btrfs_root *root) { while (true) { int ret; ret = btrfs_start_write_no_snapshoting(root); if (ret) break; wait_on_atomic_t(&root->will_be_snapshoted, wait_snapshoting_atomic_t, TASK_UNINTERRUPTIBLE); } }
0
[ "CWE-200" ]
linux
0305cd5f7fca85dae392b9ba85b116896eb7c1c7
172,943,824,282,263,470,000,000,000,000,000,000,000
13
Btrfs: fix truncation of compressed and inlined extents When truncating a file to a smaller size which consists of an inline extent that is compressed, we did not discard (or made unusable) the data between the new file size and the old file size, wasting metadata space and allowing for the truncated data to be leaked and the data corruption/loss mentioned below. We were also not correctly decrementing the number of bytes used by the inode, we were setting it to zero, giving a wrong report for callers of the stat(2) syscall. The fsck tool also reported an error about a mismatch between the nbytes of the file versus the real space used by the file. Now because we weren't discarding the truncated region of the file, it was possible for a caller of the clone ioctl to actually read the data that was truncated, allowing for a security breach without requiring root access to the system, using only standard filesystem operations. The scenario is the following: 1) User A creates a file which consists of an inline and compressed extent with a size of 2000 bytes - the file is not accessible to any other users (no read, write or execution permission for anyone else); 2) The user truncates the file to a size of 1000 bytes; 3) User A makes the file world readable; 4) User B creates a file consisting of an inline extent of 2000 bytes; 5) User B issues a clone operation from user A's file into its own file (using a length argument of 0, clone the whole range); 6) User B now gets to see the 1000 bytes that user A truncated from its file before it made its file world readbale. User B also lost the bytes in the range [1000, 2000[ bytes from its own file, but that might be ok if his/her intention was reading stale data from user A that was never supposed to be public. Note that this contrasts with the case where we truncate a file from 2000 bytes to 1000 bytes and then truncate it back from 1000 to 2000 bytes. In this case reading any byte from the range [1000, 2000[ will return a value of 0x00, instead of the original data. This problem exists since the clone ioctl was added and happens both with and without my recent data loss and file corruption fixes for the clone ioctl (patch "Btrfs: fix file corruption and data loss after cloning inline extents"). So fix this by truncating the compressed inline extents as we do for the non-compressed case, which involves decompressing, if the data isn't already in the page cache, compressing the truncated version of the extent, writing the compressed content into the inline extent and then truncate it. The following test case for fstests reproduces the problem. In order for the test to pass both this fix and my previous fix for the clone ioctl that forbids cloning a smaller inline extent into a larger one, which is titled "Btrfs: fix file corruption and data loss after cloning inline extents", are needed. Without that other fix the test fails in a different way that does not leak the truncated data, instead part of destination file gets replaced with zeroes (because the destination file has a larger inline extent than the source). seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" tmp=/tmp/$$ status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { rm -f $tmp.* } # get standard environment, filters and checks . ./common/rc . ./common/filter # real QA test starts here _need_to_be_root _supported_fs btrfs _supported_os Linux _require_scratch _require_cloner rm -f $seqres.full _scratch_mkfs >>$seqres.full 2>&1 _scratch_mount "-o compress" # Create our test files. File foo is going to be the source of a clone operation # and consists of a single inline extent with an uncompressed size of 512 bytes, # while file bar consists of a single inline extent with an uncompressed size of # 256 bytes. For our test's purpose, it's important that file bar has an inline # extent with a size smaller than foo's inline extent. $XFS_IO_PROG -f -c "pwrite -S 0xa1 0 128" \ -c "pwrite -S 0x2a 128 384" \ $SCRATCH_MNT/foo | _filter_xfs_io $XFS_IO_PROG -f -c "pwrite -S 0xbb 0 256" $SCRATCH_MNT/bar | _filter_xfs_io # Now durably persist all metadata and data. We do this to make sure that we get # on disk an inline extent with a size of 512 bytes for file foo. sync # Now truncate our file foo to a smaller size. Because it consists of a # compressed and inline extent, btrfs did not shrink the inline extent to the # new size (if the extent was not compressed, btrfs would shrink it to 128 # bytes), it only updates the inode's i_size to 128 bytes. $XFS_IO_PROG -c "truncate 128" $SCRATCH_MNT/foo # Now clone foo's inline extent into bar. # This clone operation should fail with errno EOPNOTSUPP because the source # file consists only of an inline extent and the file's size is smaller than # the inline extent of the destination (128 bytes < 256 bytes). However the # clone ioctl was not prepared to deal with a file that has a size smaller # than the size of its inline extent (something that happens only for compressed # inline extents), resulting in copying the full inline extent from the source # file into the destination file. # # Note that btrfs' clone operation for inline extents consists of removing the # inline extent from the destination inode and copy the inline extent from the # source inode into the destination inode, meaning that if the destination # inode's inline extent is larger (N bytes) than the source inode's inline # extent (M bytes), some bytes (N - M bytes) will be lost from the destination # file. Btrfs could copy the source inline extent's data into the destination's # inline extent so that we would not lose any data, but that's currently not # done due to the complexity that would be needed to deal with such cases # (specially when one or both extents are compressed), returning EOPNOTSUPP, as # it's normally not a very common case to clone very small files (only case # where we get inline extents) and copying inline extents does not save any # space (unlike for normal, non-inlined extents). $CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar # Now because the above clone operation used to succeed, and due to foo's inline # extent not being shinked by the truncate operation, our file bar got the whole # inline extent copied from foo, making us lose the last 128 bytes from bar # which got replaced by the bytes in range [128, 256[ from foo before foo was # truncated - in other words, data loss from bar and being able to read old and # stale data from foo that should not be possible to read anymore through normal # filesystem operations. Contrast with the case where we truncate a file from a # size N to a smaller size M, truncate it back to size N and then read the range # [M, N[, we should always get the value 0x00 for all the bytes in that range. # We expected the clone operation to fail with errno EOPNOTSUPP and therefore # not modify our file's bar data/metadata. So its content should be 256 bytes # long with all bytes having the value 0xbb. # # Without the btrfs bug fix, the clone operation succeeded and resulted in # leaking truncated data from foo, the bytes that belonged to its range # [128, 256[, and losing data from bar in that same range. So reading the # file gave us the following content: # # 0000000 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 # * # 0000200 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a # * # 0000400 echo "File bar's content after the clone operation:" od -t x1 $SCRATCH_MNT/bar # Also because the foo's inline extent was not shrunk by the truncate # operation, btrfs' fsck, which is run by the fstests framework everytime a # test completes, failed reporting the following error: # # root 5 inode 257 errors 400, nbytes wrong status=0 exit Cc: [email protected] Signed-off-by: Filipe Manana <[email protected]>
check_LEARN(const struct ofpact_learn *a, const struct ofpact_check_params *cp) { return learn_check(a, cp->match); }
0
[ "CWE-416" ]
ovs
77cccc74deede443e8b9102299efc869a52b65b2
252,446,886,058,440,000,000,000,000,000,000,000,000
5
ofp-actions: Fix use-after-free while decoding RAW_ENCAP. While decoding RAW_ENCAP action, decode_ed_prop() might re-allocate ofpbuf if there is no enough space left. However, function 'decode_NXAST_RAW_ENCAP' continues to use old pointer to 'encap' structure leading to write-after-free and incorrect decoding. ==3549105==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600000011a at pc 0x0000005f6cc6 bp 0x7ffc3a2d4410 sp 0x7ffc3a2d4408 WRITE of size 2 at 0x60600000011a thread T0 #0 0x5f6cc5 in decode_NXAST_RAW_ENCAP lib/ofp-actions.c:4461:20 #1 0x5f0551 in ofpact_decode ./lib/ofp-actions.inc2:4777:16 #2 0x5ed17c in ofpacts_decode lib/ofp-actions.c:7752:21 #3 0x5eba9a in ofpacts_pull_openflow_actions__ lib/ofp-actions.c:7791:13 #4 0x5eb9fc in ofpacts_pull_openflow_actions lib/ofp-actions.c:7835:12 #5 0x64bb8b in ofputil_decode_packet_out lib/ofp-packet.c:1113:17 #6 0x65b6f4 in ofp_print_packet_out lib/ofp-print.c:148:13 #7 0x659e3f in ofp_to_string__ lib/ofp-print.c:1029:16 #8 0x659b24 in ofp_to_string lib/ofp-print.c:1244:21 #9 0x65a28c in ofp_print lib/ofp-print.c:1288:28 #10 0x540d11 in ofctl_ofp_parse utilities/ovs-ofctl.c:2814:9 #11 0x564228 in ovs_cmdl_run_command__ lib/command-line.c:247:17 #12 0x56408a in ovs_cmdl_run_command lib/command-line.c:278:5 #13 0x5391ae in main utilities/ovs-ofctl.c:179:9 #14 0x7f6911ce9081 in __libc_start_main (/lib64/libc.so.6+0x27081) #15 0x461fed in _start (utilities/ovs-ofctl+0x461fed) Fix that by getting a new pointer before using. Credit to OSS-Fuzz. Fuzzer regression test will fail only with AddressSanitizer enabled. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27851 Fixes: f839892a206a ("OF support and translation of generic encap and decap") Acked-by: William Tu <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
xfs_getbmap_format(void **ap, struct getbmapx *bmv, int *full) { struct getbmap __user *base = *ap; /* copy only getbmap portion (not getbmapx) */ if (copy_to_user(base, bmv, sizeof(struct getbmap))) return XFS_ERROR(EFAULT); *ap += sizeof(struct getbmap); return 0; }
0
[ "CWE-200" ]
linux-2.6
af24ee9ea8d532e16883251a6684dfa1be8eec29
117,086,212,977,187,900,000,000,000,000,000,000,000
11
xfs: zero proper structure size for geometry calls Commit 493f3358cb289ccf716c5a14fa5bb52ab75943e5 added this call to xfs_fs_geometry() in order to avoid passing kernel stack data back to user space: + memset(geo, 0, sizeof(*geo)); Unfortunately, one of the callers of that function passes the address of a smaller data type, cast to fit the type that xfs_fs_geometry() requires. As a result, this can happen: Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: f87aca93 Pid: 262, comm: xfs_fsr Not tainted 2.6.38-rc6-493f3358cb2+ #1 Call Trace: [<c12991ac>] ? panic+0x50/0x150 [<c102ed71>] ? __stack_chk_fail+0x10/0x18 [<f87aca93>] ? xfs_ioc_fsgeometry_v1+0x56/0x5d [xfs] Fix this by fixing that one caller to pass the right type and then copy out the subset it is interested in. Note: This patch is an alternative to one originally proposed by Eric Sandeen. Reported-by: Jeffrey Hundstad <[email protected]> Signed-off-by: Alex Elder <[email protected]> Reviewed-by: Eric Sandeen <[email protected]> Tested-by: Jeffrey Hundstad <[email protected]>
for (p = head; p; ) { next_node = p->next; Free(p); p = next_node; }
0
[ "CWE-189" ]
chrony
7712455d9aa33d0db0945effaa07e900b85987b1
298,735,337,718,626,400,000,000,000,000,000,000,000
5
Fix buffer overflow when processing crafted command packets When the length of the REQ_SUBNETS_ACCESSED, REQ_CLIENT_ACCESSES command requests and the RPY_SUBNETS_ACCESSED, RPY_CLIENT_ACCESSES, RPY_CLIENT_ACCESSES_BY_INDEX, RPY_MANUAL_LIST command replies is calculated, the number of items stored in the packet is not validated. A crafted command request/reply can be used to crash the server/client. Only clients allowed by cmdallow (by default only localhost) can crash the server. With chrony versions 1.25 and 1.26 this bug has a smaller security impact as the server requires the clients to be authenticated in order to process the subnet and client accesses commands. In 1.27 and 1.28, however, the invalid calculated length is included also in the authentication check which may cause another crash.
static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms) { jpc_siz_t *siz = &ms->parms.siz; int compno; int tileno; jpc_dec_tile_t *tile; jpc_dec_tcomp_t *tcomp; int htileno; int vtileno; jpc_dec_cmpt_t *cmpt; size_t size; dec->xstart = siz->xoff; dec->ystart = siz->yoff; dec->xend = siz->width; dec->yend = siz->height; dec->tilewidth = siz->tilewidth; dec->tileheight = siz->tileheight; dec->tilexoff = siz->tilexoff; dec->tileyoff = siz->tileyoff; dec->numcomps = siz->numcomps; if (!(dec->cp = jpc_dec_cp_create(dec->numcomps))) { return -1; } if (!(dec->cmpts = jas_alloc2(dec->numcomps, sizeof(jpc_dec_cmpt_t)))) { return -1; } for (compno = 0, cmpt = dec->cmpts; compno < dec->numcomps; ++compno, ++cmpt) { cmpt->prec = siz->comps[compno].prec; cmpt->sgnd = siz->comps[compno].sgnd; cmpt->hstep = siz->comps[compno].hsamp; cmpt->vstep = siz->comps[compno].vsamp; cmpt->width = JPC_CEILDIV(dec->xend, cmpt->hstep) - JPC_CEILDIV(dec->xstart, cmpt->hstep); cmpt->height = JPC_CEILDIV(dec->yend, cmpt->vstep) - JPC_CEILDIV(dec->ystart, cmpt->vstep); cmpt->hsubstep = 0; cmpt->vsubstep = 0; } dec->image = 0; dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth); dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight); if (!jas_safe_size_mul(dec->numhtiles, dec->numvtiles, &size)) { return -1; } dec->numtiles = size; JAS_DBGLOG(10, ("numtiles = %d; numhtiles = %d; numvtiles = %d;\n", dec->numtiles, dec->numhtiles, dec->numvtiles)); if (!(dec->tiles = jas_alloc2(dec->numtiles, sizeof(jpc_dec_tile_t)))) { return -1; } for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno, ++tile) { htileno = tileno % dec->numhtiles; vtileno = tileno / dec->numhtiles; tile->realmode = 0; tile->state = JPC_TILE_INIT; tile->xstart = JAS_MAX(dec->tilexoff + htileno * dec->tilewidth, dec->xstart); tile->ystart = JAS_MAX(dec->tileyoff + vtileno * dec->tileheight, dec->ystart); tile->xend = JAS_MIN(dec->tilexoff + (htileno + 1) * dec->tilewidth, dec->xend); tile->yend = JAS_MIN(dec->tileyoff + (vtileno + 1) * dec->tileheight, dec->yend); tile->numparts = 0; tile->partno = 0; tile->pkthdrstream = 0; tile->pkthdrstreampos = 0; tile->pptstab = 0; tile->cp = 0; tile->pi = 0; if (!(tile->tcomps = jas_alloc2(dec->numcomps, sizeof(jpc_dec_tcomp_t)))) { return -1; } for (compno = 0, cmpt = dec->cmpts, tcomp = tile->tcomps; compno < dec->numcomps; ++compno, ++cmpt, ++tcomp) { tcomp->rlvls = 0; tcomp->numrlvls = 0; tcomp->data = 0; tcomp->xstart = JPC_CEILDIV(tile->xstart, cmpt->hstep); tcomp->ystart = JPC_CEILDIV(tile->ystart, cmpt->vstep); tcomp->xend = JPC_CEILDIV(tile->xend, cmpt->hstep); tcomp->yend = JPC_CEILDIV(tile->yend, cmpt->vstep); tcomp->tsfb = 0; } } dec->pkthdrstreams = 0; /* We should expect to encounter other main header marker segments or an SOT marker segment next. */ dec->state = JPC_MH; return 0; }
1
[ "CWE-20", "CWE-399" ]
jasper
ba2b9d000660313af7b692542afbd374c5685865
115,562,972,089,464,580,000,000,000,000,000,000,000
103
Ensure that not all tiles lie outside the image area.
char *qemu_mac_strdup_printf(const uint8_t *macaddr) { return g_strdup_printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]); }
0
[ "CWE-190" ]
qemu
25c01bd19d0e4b66f357618aeefda1ef7a41e21a
197,054,384,551,309,840,000,000,000,000,000,000,000
6
net: drop too large packet early We try to detect and drop too large packet (>INT_MAX) in 1592a9947036 ("net: ignore packet size greater than INT_MAX") during packet delivering. Unfortunately, this is not sufficient as we may hit another integer overflow when trying to queue such large packet in qemu_net_queue_append_iov(): - size of the allocation may overflow on 32bit - packet->size is integer which may overflow even on 64bit Fixing this by moving the check to qemu_sendv_packet_async() which is the entrance of all networking codes and reduce the limit to NET_BUFSIZE to be more conservative. This works since: - For the callers that call qemu_sendv_packet_async() directly, they only care about if zero is returned to determine whether to prevent the source from producing more packets. A callback will be triggered if peer can accept more then source could be enabled. This is usually used by high speed networking implementation like virtio-net or netmap. - For the callers that call qemu_sendv_packet() that calls qemu_sendv_packet_async() indirectly, they often ignore the return value. In this case qemu will just the drop packets if peer can't receive. Qemu will copy the packet if it was queued. So it was safe for both kinds of the callers to assume the packet was sent. Since we move the check from qemu_deliver_packet_iov() to qemu_sendv_packet_async(), it would be safer to make qemu_deliver_packet_iov() static to prevent any external user in the future. This is a revised patch of CVE-2018-17963. Cc: [email protected] Cc: Li Qiang <[email protected]> Fixes: 1592a9947036 ("net: ignore packet size greater than INT_MAX") Reported-by: Li Qiang <[email protected]> Reviewed-by: Li Qiang <[email protected]> Signed-off-by: Jason Wang <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
dump_job_history(cupsd_job_t *job) /* I - Job */ { int i, /* Looping var */ oldsize; /* Current MaxLogSize */ struct tm *date; /* Date/time value */ cupsd_joblog_t *message; /* Current message */ char temp[2048], /* Log message */ *ptr, /* Pointer into log message */ start[256], /* Start time */ end[256]; /* End time */ cupsd_printer_t *printer; /* Printer for job */ /* * See if we have anything to dump... */ if (!job->history) return; /* * Disable log rotation temporarily... */ oldsize = MaxLogSize; MaxLogSize = 0; /* * Copy the debug messages to the log... */ message = (cupsd_joblog_t *)cupsArrayFirst(job->history); date = localtime(&(message->time)); strftime(start, sizeof(start), "%X", date); message = (cupsd_joblog_t *)cupsArrayLast(job->history); date = localtime(&(message->time)); strftime(end, sizeof(end), "%X", date); snprintf(temp, sizeof(temp), "[Job %d] The following messages were recorded from %s to %s", job->id, start, end); cupsdWriteErrorLog(CUPSD_LOG_DEBUG, temp); for (message = (cupsd_joblog_t *)cupsArrayFirst(job->history); message; message = (cupsd_joblog_t *)cupsArrayNext(job->history)) cupsdWriteErrorLog(CUPSD_LOG_DEBUG, message->message); snprintf(temp, sizeof(temp), "[Job %d] End of messages", job->id); cupsdWriteErrorLog(CUPSD_LOG_DEBUG, temp); /* * Log the printer state values... */ if ((printer = job->printer) == NULL) printer = cupsdFindDest(job->dest); if (printer) { snprintf(temp, sizeof(temp), "[Job %d] printer-state=%d(%s)", job->id, printer->state, printer->state == IPP_PRINTER_IDLE ? "idle" : printer->state == IPP_PRINTER_PROCESSING ? "processing" : "stopped"); cupsdWriteErrorLog(CUPSD_LOG_DEBUG, temp); snprintf(temp, sizeof(temp), "[Job %d] printer-state-message=\"%s\"", job->id, printer->state_message); cupsdWriteErrorLog(CUPSD_LOG_DEBUG, temp); snprintf(temp, sizeof(temp), "[Job %d] printer-state-reasons=", job->id); ptr = temp + strlen(temp); if (printer->num_reasons == 0) strlcpy(ptr, "none", sizeof(temp) - (size_t)(ptr - temp)); else { for (i = 0; i < printer->num_reasons && ptr < (temp + sizeof(temp) - 2); i ++) { if (i) *ptr++ = ','; strlcpy(ptr, printer->reasons[i], sizeof(temp) - (size_t)(ptr - temp)); ptr += strlen(ptr); } } cupsdWriteErrorLog(CUPSD_LOG_DEBUG, temp); } /* * Restore log file rotation... */ MaxLogSize = oldsize; /* * Free all messages... */ free_job_history(job); }
0
[]
cups
d47f6aec436e0e9df6554436e391471097686ecc
130,525,624,792,789,130,000,000,000,000,000,000,000
104
Fix local privilege escalation to root and sandbox bypasses in scheduler (rdar://37836779, rdar://37836995, rdar://37837252, rdar://37837581)
static size_t tcp_opt_stats_get_size(void) { return nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_BUSY */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_RWND_LIMITED */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_SNDBUF_LIMITED */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_DATA_SEGS_OUT */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_TOTAL_RETRANS */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_PACING_RATE */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_DELIVERY_RATE */ nla_total_size(sizeof(u32)) + /* TCP_NLA_SND_CWND */ nla_total_size(sizeof(u32)) + /* TCP_NLA_REORDERING */ nla_total_size(sizeof(u32)) + /* TCP_NLA_MIN_RTT */ nla_total_size(sizeof(u8)) + /* TCP_NLA_RECUR_RETRANS */ nla_total_size(sizeof(u8)) + /* TCP_NLA_DELIVERY_RATE_APP_LMT */ nla_total_size(sizeof(u32)) + /* TCP_NLA_SNDQ_SIZE */ nla_total_size(sizeof(u8)) + /* TCP_NLA_CA_STATE */ nla_total_size(sizeof(u32)) + /* TCP_NLA_SND_SSTHRESH */ nla_total_size(sizeof(u32)) + /* TCP_NLA_DELIVERED */ nla_total_size(sizeof(u32)) + /* TCP_NLA_DELIVERED_CE */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_BYTES_SENT */ nla_total_size_64bit(sizeof(u64)) + /* TCP_NLA_BYTES_RETRANS */ nla_total_size(sizeof(u32)) + /* TCP_NLA_DSACK_DUPS */ nla_total_size(sizeof(u32)) + /* TCP_NLA_REORD_SEEN */ nla_total_size(sizeof(u32)) + /* TCP_NLA_SRTT */ 0; }
0
[ "CWE-190" ]
net
3b4929f65b0d8249f19a50245cd88ed1a2f78cff
202,867,945,699,192,570,000,000,000,000,000,000,000
27
tcp: limit payload size of sacked skbs Jonathan Looney reported that TCP can trigger the following crash in tcp_shifted_skb() : BUG_ON(tcp_skb_pcount(skb) < pcount); This can happen if the remote peer has advertized the smallest MSS that linux TCP accepts : 48 An skb can hold 17 fragments, and each fragment can hold 32KB on x86, or 64KB on PowerPC. This means that the 16bit witdh of TCP_SKB_CB(skb)->tcp_gso_segs can overflow. Note that tcp_sendmsg() builds skbs with less than 64KB of payload, so this problem needs SACK to be enabled. SACK blocks allow TCP to coalesce multiple skbs in the retransmit queue, thus filling the 17 fragments to maximal capacity. CVE-2019-11477 -- u16 overflow of TCP_SKB_CB(skb)->tcp_gso_segs Fixes: 832d11c5cd07 ("tcp: Try to restore large SKBs while SACK processing") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Jonathan Looney <[email protected]> Acked-by: Neal Cardwell <[email protected]> Reviewed-by: Tyler Hicks <[email protected]> Cc: Yuchung Cheng <[email protected]> Cc: Bruce Curtis <[email protected]> Cc: Jonathan Lemon <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void cmp_item_row::store_value(Item *item) { DBUG_ENTER("cmp_item_row::store_value"); DBUG_ASSERT(comparators); DBUG_ASSERT(n == item->cols()); item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) { DBUG_ASSERT(comparators[i]); comparators[i]->store_value(item->element_index(i)); item->null_value|= item->element_index(i)->null_value; } DBUG_VOID_RETURN; }
0
[ "CWE-617" ]
server
807945f2eb5fa22e6f233cc17b85a2e141efe2c8
272,196,356,212,565,970,000,000,000,000,000,000,000
15
MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order... When doing condition pushdown from HAVING into WHERE, Item_equal::create_pushable_equalities() calls item->set_extraction_flag(IMMUTABLE_FL) for constant items. Then, Item::cleanup_excluding_immutables_processor() checks for this flag to see if it should call item->cleanup() or leave the item as-is. The failure happens when a constant item has a non-constant one inside it, like: (tbl.col=0 AND impossible_cond) item->walk(cleanup_excluding_immutables_processor) works in a bottom-up way so it 1. will call Item_func_eq(tbl.col=0)->cleanup() 2. will not call Item_cond_and->cleanup (as the AND is constant) This creates an item tree where a fixed Item has an un-fixed Item inside it which eventually causes an assertion failure. Fixed by introducing this rule: instead of just calling item->set_extraction_flag(IMMUTABLE_FL); we call Item::walk() to set the flag for all sub-items of the item.
void Item_trigger_field::setup_field(THD *thd, TABLE *table, GRANT_INFO *table_grant_info) { /* It is too early to mark fields used here, because before execution of statement that will invoke trigger other statements may use same TABLE object, so all such mark-up will be wiped out. So instead we do it in Table_triggers_list::mark_fields_used() method which is called during execution of these statements. */ enum_column_usage saved_column_usage= thd->column_usage; thd->column_usage= want_privilege == SELECT_ACL ? COLUMNS_READ : COLUMNS_WRITE; /* Try to find field by its name and if it will be found set field_idx properly. */ (void)find_field_in_table(thd, table, field_name.str, field_name.length, 0, &field_idx); thd->column_usage= saved_column_usage; triggers= table->triggers; table_grants= table_grant_info; }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
223,337,564,203,049,700,000,000,000,000,000,000,000
23
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.
BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) { int lastBorder; /* Seek left */ int leftLimit, rightLimit; int i; int restoreAlphaBleding; if (border < 0 || color < 0) { /* Refuse to fill to a non-solid border */ return; } if (!im->trueColor) { if (color > (im->colorsTotal - 1) || border > (im->colorsTotal - 1)) { return; } } leftLimit = (-1); restoreAlphaBleding = im->alphaBlendingFlag; im->alphaBlendingFlag = 0; if (x >= im->sx) { x = im->sx - 1; } else if (x < 0) { x = 0; } if (y >= im->sy) { y = im->sy - 1; } else if (y < 0) { y = 0; } for (i = x; (i >= 0); i--) { if (gdImageGetPixel (im, i, y) == border) { break; } gdImageSetPixel (im, i, y, color); leftLimit = i; } if (leftLimit == (-1)) { im->alphaBlendingFlag = restoreAlphaBleding; return; } /* Seek right */ rightLimit = x; for (i = (x + 1); (i < im->sx); i++) { if (gdImageGetPixel (im, i, y) == border) { break; } gdImageSetPixel (im, i, y, color); rightLimit = i; } /* Look at lines above and below and start paints */ /* Above */ if (y > 0) { lastBorder = 1; for (i = leftLimit; (i <= rightLimit); i++) { int c; c = gdImageGetPixel (im, i, y - 1); if (lastBorder) { if ((c != border) && (c != color)) { gdImageFillToBorder (im, i, y - 1, border, color); lastBorder = 0; } } else if ((c == border) || (c == color)) { lastBorder = 1; } } } /* Below */ if (y < ((im->sy) - 1)) { lastBorder = 1; for (i = leftLimit; (i <= rightLimit); i++) { int c = gdImageGetPixel (im, i, y + 1); if (lastBorder) { if ((c != border) && (c != color)) { gdImageFillToBorder (im, i, y + 1, border, color); lastBorder = 0; } } else if ((c == border) || (c == color)) { lastBorder = 1; } } } im->alphaBlendingFlag = restoreAlphaBleding; }
0
[ "CWE-476" ]
libgd
a93eac0e843148dc2d631c3ba80af17e9c8c860f
232,491,452,677,774,230,000,000,000,000,000,000,000
89
Fix potential NULL pointer dereference in gdImageClone()
//! Cumulate image values, optionally along specified axis \newinstance. CImg<Tlong> get_cumulate(const char axis=0) const { return CImg<Tlong>(*this,false).cumulate(axis);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
178,340,254,598,177,400,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
static int r_cmd_java_get_class_names_from_input (const char *input, char **class_name, ut32 *class_name_len, char **new_class_name, ut32 *new_class_name_len) { const char *p = input; ut32 cmd_sz = input && *input ? strlen (input) : 0; int res = false; if (!class_name || *class_name) { return res; } else if (!new_class_name || *new_class_name) { return res; } else if (!new_class_name_len || !class_name_len) { return res; } *new_class_name = NULL; *class_name_len = 0; if (p && *p && cmd_sz > 1) { const char *end; p = r_cmd_java_consumetok (p, ' ', cmd_sz); end = p && *p ? r_cmd_java_strtok (p, ' ', -1) : NULL; if (p && end && p != end) { *class_name_len = end - p + 1; *class_name = malloc (*class_name_len); snprintf (*class_name, *class_name_len, "%s", p ); cmd_sz = *class_name_len - 1 < cmd_sz ? cmd_sz - *class_name_len : 0; } if (*class_name && cmd_sz > 0) { p = r_cmd_java_consumetok (end+1, ' ', cmd_sz); end = p && *p ? r_cmd_java_strtok (p, ' ', -1) : NULL; if (!end && p && *p) { end = p + cmd_sz; } if (p && end && p != end) { *new_class_name_len = end - p + 1; *new_class_name = malloc (*new_class_name_len); snprintf (*new_class_name, *new_class_name_len, "%s", p ); res = true; } } } return res; }
0
[ "CWE-703", "CWE-193" ]
radare2
ced0223c7a1b3b5344af315715cd28fe7c0d9ebc
139,353,614,437,738,530,000,000,000,000,000,000,000
47
Fix unmatched array length in core_java.c (issue #16304) (#16313)
static INLINE void write_pixel_8(BYTE* _buf, BYTE _pix) { *_buf = _pix; }
0
[ "CWE-787" ]
FreeRDP
7b1d4b49391b4512402840431757703a96946820
197,399,087,384,697,700,000,000,000,000,000,000,000
4
Fix CVE-2020-11524: out of bounds access in interleaved Thanks to Sunglin and HuanGMz from Knownsec 404
static my_bool get_view_structure(char *table, char* db) { MYSQL_RES *table_res; MYSQL_ROW row; MYSQL_FIELD *field; char *result_table, *opt_quoted_table; char table_buff[NAME_LEN*2+3]; char table_buff2[NAME_LEN*2+3]; char query[QUERY_LENGTH]; FILE *sql_file= md_result_file; DBUG_ENTER("get_view_structure"); if (opt_no_create_info) /* Don't write table creation info */ DBUG_RETURN(0); verbose_msg("-- Retrieving view structure for table %s...\n", table); #ifdef NOT_REALLY_USED_YET dynstr_append_checked(&insert_pat, "SET SQL_QUOTE_SHOW_CREATE="); dynstr_append_checked(&insert_pat, (opt_quoted || opt_keywords)? "1":"0"); #endif result_table= quote_name(table, table_buff, 1); opt_quoted_table= quote_name(table, table_buff2, 0); if (switch_character_set_results(mysql, "binary")) DBUG_RETURN(1); my_snprintf(query, sizeof(query), "SHOW CREATE TABLE %s", result_table); if (mysql_query_with_error_report(mysql, &table_res, query)) { switch_character_set_results(mysql, default_charset); DBUG_RETURN(0); } /* Check if this is a view */ field= mysql_fetch_field_direct(table_res, 0); if (strcmp(field->name, "View") != 0) { mysql_free_result(table_res); switch_character_set_results(mysql, default_charset); verbose_msg("-- It's base table, skipped\n"); DBUG_RETURN(0); } /* If requested, open separate .sql file for this view */ if (path) { if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) { mysql_free_result(table_res); DBUG_RETURN(1); } write_header(sql_file, db); } print_comment(sql_file, 0, "\n--\n-- Final view structure for view %s\n--\n\n", fix_for_comment(result_table)); /* Table might not exist if this view was dumped with --tab. */ fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table); if (opt_drop) { fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", opt_quoted_table); check_io(sql_file); } my_snprintf(query, sizeof(query), "SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE, " " CHARACTER_SET_CLIENT, COLLATION_CONNECTION " "FROM information_schema.views " "WHERE table_name=\"%s\" AND table_schema=\"%s\"", table, db); if (mysql_query(mysql, query)) { /* Use the raw output from SHOW CREATE TABLE if information_schema query fails. */ row= mysql_fetch_row(table_res); fprintf(sql_file, "/*!50001 %s */;\n", row[1]); check_io(sql_file); mysql_free_result(table_res); } else { char *ptr; ulong *lengths; char search_buf[256], replace_buf[256]; ulong search_len, replace_len; DYNAMIC_STRING ds_view; /* Save the result of SHOW CREATE TABLE in ds_view */ row= mysql_fetch_row(table_res); lengths= mysql_fetch_lengths(table_res); init_dynamic_string_checked(&ds_view, row[1], lengths[1] + 1, 1024); mysql_free_result(table_res); /* Get the result from "select ... information_schema" */ if (!(table_res= mysql_store_result(mysql)) || !(row= mysql_fetch_row(table_res))) { if (table_res) mysql_free_result(table_res); dynstr_free(&ds_view); DB_error(mysql, "when trying to save the result of SHOW CREATE TABLE in ds_view."); DBUG_RETURN(1); } lengths= mysql_fetch_lengths(table_res); /* "WITH %s CHECK OPTION" is available from 5.0.2 Surround it with !50002 comments */ if (strcmp(row[0], "NONE")) { ptr= search_buf; search_len= (ulong)(strxmov(ptr, "WITH ", row[0], " CHECK OPTION", NullS) - ptr); ptr= replace_buf; replace_len=(ulong)(strxmov(ptr, "*/\n/*!50002 WITH ", row[0], " CHECK OPTION", NullS) - ptr); replace(&ds_view, search_buf, search_len, replace_buf, replace_len); } /* "DEFINER=%s SQL SECURITY %s" is available from 5.0.13 Surround it with !50013 comments */ { size_t user_name_len; char user_name_str[USERNAME_LENGTH + 1]; char quoted_user_name_str[USERNAME_LENGTH * 2 + 3]; size_t host_name_len; char host_name_str[HOSTNAME_LENGTH + 1]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; parse_user(row[1], lengths[1], user_name_str, &user_name_len, host_name_str, &host_name_len); ptr= search_buf; search_len= (ulong)(strxmov(ptr, "DEFINER=", quote_name(user_name_str, quoted_user_name_str, FALSE), "@", quote_name(host_name_str, quoted_host_name_str, FALSE), " SQL SECURITY ", row[2], NullS) - ptr); ptr= replace_buf; replace_len= (ulong)(strxmov(ptr, "*/\n/*!50013 DEFINER=", quote_name(user_name_str, quoted_user_name_str, FALSE), "@", quote_name(host_name_str, quoted_host_name_str, FALSE), " SQL SECURITY ", row[2], " */\n/*!50001", NullS) - ptr); replace(&ds_view, search_buf, search_len, replace_buf, replace_len); } /* Dump view structure to file */ fprintf(sql_file, "/*!50001 SET @saved_cs_client = @@character_set_client */;\n" "/*!50001 SET @saved_cs_results = @@character_set_results */;\n" "/*!50001 SET @saved_col_connection = @@collation_connection */;\n" "/*!50001 SET character_set_client = %s */;\n" "/*!50001 SET character_set_results = %s */;\n" "/*!50001 SET collation_connection = %s */;\n" "/*!50001 %s */;\n" "/*!50001 SET character_set_client = @saved_cs_client */;\n" "/*!50001 SET character_set_results = @saved_cs_results */;\n" "/*!50001 SET collation_connection = @saved_col_connection */;\n", (const char *) row[3], (const char *) row[3], (const char *) row[4], (const char *) ds_view.str); check_io(sql_file); mysql_free_result(table_res); dynstr_free(&ds_view); } if (switch_character_set_results(mysql, default_charset)) DBUG_RETURN(1); /* If a separate .sql file was opened, close it now */ if (sql_file != md_result_file) { fputs("\n", sql_file); write_footer(sql_file); my_fclose(sql_file, MYF(MY_WME)); } DBUG_RETURN(0); }
0
[]
server
5a43a31ee81bc181eeb5ef2bf0704befa6e0594d
153,441,934,677,864,600,000,000,000,000,000,000,000
199
mysqldump: comments and identifiers with new lines don't let identifiers with new lines to break a comment
void imap_make_date (char *buf, time_t timestamp) { struct tm* tm = localtime (&timestamp); time_t tz = mutt_local_tz (timestamp); tz /= 60; snprintf (buf, IMAP_DATELEN, "%02d-%s-%d %02d:%02d:%02d %+03d%02d", tm->tm_mday, Months[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec, (int) tz / 60, (int) abs ((int) tz) % 60); }
0
[ "CWE-125" ]
mutt
7c4779ac24d2fb68a2a47b58c7904118f40965d5
72,256,094,177,985,870,000,000,000,000,000,000,000
12
Fix seqset iterator when it ends in a comma. If the seqset ended with a comma, the substr_end marker would be just before the trailing nul. In the next call, the loop to skip the marker would iterate right past the end of string too. The fix is simple: place the substr_end marker and skip past it immediately.
ParseOnOff(act, var) struct action *act; int *var; { register int num = -1; char **args = act->args; if (args[1] == 0) { if (strcmp(args[0], "on") == 0) num = 1; else if (strcmp(args[0], "off") == 0) num = 0; } if (num < 0) { Msg(0, "%s: %s: invalid argument. Give 'on' or 'off'", rc_name, comms[act->nr].name); return -1; } *var = num; return 0; }
0
[]
screen
c5db181b6e017cfccb8d7842ce140e59294d9f62
312,842,623,350,495,800,000,000,000,000,000,000,000
22
ansi: add support for xterm OSC 11 It allows for getting and setting the background color. Notably, Vim uses OSC 11 to learn whether it's running on a light or dark colored terminal and choose a color scheme accordingly. Tested with gnome-terminal and xterm. When called with "?" argument the current background color is returned: $ echo -ne "\e]11;?\e\\" $ 11;rgb:2323/2727/2929 Signed-off-by: Lubomir Rintel <[email protected]> (cherry picked from commit 7059bff20a28778f9d3acf81cad07b1388d02309) Signed-off-by: Amadeusz Sławiński <[email protected]
int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, const SSL_CIPHER * const *bp) { long l; l=(*ap)->id-(*bp)->id; if (l == 0L) return(0); else return((l > 0)?1:-1); }
0
[]
openssl
ee2ffc279417f15fef3b1073c7dc81a908991516
291,721,560,562,615,520,000,000,000,000,000,000,000
11
Add Next Protocol Negotiation.
dns_reset_correctness_checks(void) { strmap_free(dns_wildcard_response_count, _tor_free); dns_wildcard_response_count = NULL; n_wildcard_requests = 0; if (dns_wildcard_list) { SMARTLIST_FOREACH(dns_wildcard_list, char *, cp, tor_free(cp)); smartlist_clear(dns_wildcard_list); } if (dns_wildcarded_test_address_list) { SMARTLIST_FOREACH(dns_wildcarded_test_address_list, char *, cp, tor_free(cp)); smartlist_clear(dns_wildcarded_test_address_list); } dns_wildcard_one_notice_given = dns_wildcard_notice_given = dns_wildcarded_test_address_notice_given = dns_is_completely_invalid = 0; }
0
[ "CWE-399" ]
tor
62637fa22405278758febb1743da9af562524d4c
173,444,390,388,208,170,000,000,000,000,000,000,000
19
Avoid hard (impossible?)-to-trigger double-free in dns_resolve() Fixes 6480; fix on 0.2.0.1-alpha; based on pseudonymous patch.
static int core_cmd0_wrapper(void *core, const char *cmd) { return r_core_cmd0 ((RCore *)core, cmd); }
0
[ "CWE-78" ]
radare2
dd739f5a45b3af3d1f65f00fe19af1dbfec7aea7
210,062,131,782,986,500,000,000,000,000,000,000,000
3
Fix #14990 - multiple quoted command parsing issue ##core > "?e hello""?e world" hello world" > "?e hello";"?e world" hello world
cmsBool IsTypeSupported(cmsTagDescriptor* TagDescriptor, cmsTagTypeSignature Type) { cmsUInt32Number i, nMaxTypes; nMaxTypes = TagDescriptor->nSupportedTypes; if (nMaxTypes >= MAX_TYPES_IN_LCMS_PLUGIN) nMaxTypes = MAX_TYPES_IN_LCMS_PLUGIN; for (i=0; i < nMaxTypes; i++) { if (Type == TagDescriptor ->SupportedTypes[i]) return TRUE; } return FALSE; }
0
[]
Little-CMS
d2d902b9a03583ae482c782b2f243f7e5268a47d
173,734,046,224,090,500,000,000,000,000,000,000,000
14
>Changes from Richard Hughes
h_trunc(VALUE h, VALUE *fr) { VALUE rh; if (wholenum_p(h)) { rh = to_integer(h); *fr = INT2FIX(0); } else { rh = f_idiv(h, INT2FIX(1)); *fr = f_mod(h, INT2FIX(1)); *fr = f_quo(*fr, INT2FIX(24)); } return rh; }
0
[]
date
3959accef8da5c128f8a8e2fd54e932a4fb253b0
275,941,076,348,877,500,000,000,000,000,000,000,000
15
Add length limit option for methods that parses date strings `Date.parse` now raises an ArgumentError when a given date string is longer than 128. You can configure the limit by giving `limit` keyword arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`, the limit is disabled. Not only `Date.parse` but also the following methods are changed. * Date._parse * Date.parse * DateTime.parse * Date._iso8601 * Date.iso8601 * DateTime.iso8601 * Date._rfc3339 * Date.rfc3339 * DateTime.rfc3339 * Date._xmlschema * Date.xmlschema * DateTime.xmlschema * Date._rfc2822 * Date.rfc2822 * DateTime.rfc2822 * Date._rfc822 * Date.rfc822 * DateTime.rfc822 * Date._jisx0301 * Date.jisx0301 * DateTime.jisx0301
static inline void SetPixelBackgoundColor(const Image *restrict image, Quantum *restrict pixel) { register ssize_t i; for (i=0; i < (ssize_t) GetPixelChannels(image); i++) pixel[i]=0; pixel[image->channel_map[RedPixelChannel].offset]= ClampToQuantum(image->background_color.red); pixel[image->channel_map[GreenPixelChannel].offset]= ClampToQuantum(image->background_color.green); pixel[image->channel_map[BluePixelChannel].offset]= ClampToQuantum(image->background_color.blue); if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait) pixel[image->channel_map[BlackPixelChannel].offset]= ClampToQuantum(image->background_color.black); if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait) pixel[image->channel_map[AlphaPixelChannel].offset]= image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha : ClampToQuantum(image->background_color.alpha); }
0
[ "CWE-119", "CWE-787" ]
ImageMagick
450bd716ed3b9186dd10f9e60f630a3d9eeea2a4
265,621,998,759,265,980,000,000,000,000,000,000,000
22
void module_register(void) { plugin_register_complex_config("snmp", csnmp_config); plugin_register_init("snmp", csnmp_init); plugin_register_shutdown("snmp", csnmp_shutdown); } /* void module_register */
0
[ "CWE-415" ]
collectd
d16c24542b2f96a194d43a73c2e5778822b9cb47
160,052,342,584,243,180,000,000,000,000,000,000,000
5
snmp plugin: Fix double free of request PDU snmp_sess_synch_response() always frees request PDU, in both case of request error and success. If error condition occurs inside of `while (status == 0)` loop, double free of `req` happens. Issue: #2291 Signed-off-by: Florian Forster <[email protected]>
dissect_usb_vid_descriptor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { int offset = 0; guint8 descriptor_len; guint8 descriptor_type; gint bytes_available; usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data; tvbuff_t *desc_tvb; descriptor_len = tvb_get_guint8(tvb, offset); descriptor_type = tvb_get_guint8(tvb, offset+1); bytes_available = tvb_captured_length_remaining(tvb, offset); desc_tvb = tvb_new_subset(tvb, 0, bytes_available, descriptor_len); if (descriptor_type == CS_ENDPOINT) { offset = dissect_usb_video_endpoint_descriptor(tree, desc_tvb, descriptor_len); } else if (descriptor_type == CS_INTERFACE) { if (usb_conv_info && usb_conv_info->interfaceSubclass == SC_VIDEOCONTROL) { offset = dissect_usb_video_control_interface_descriptor(tree, desc_tvb, descriptor_len, pinfo, usb_conv_info); } else if (usb_conv_info && usb_conv_info->interfaceSubclass == SC_VIDEOSTREAMING) { offset = dissect_usb_video_streaming_interface_descriptor(tree, desc_tvb, descriptor_len); } } /* else not something we recognize, just return offset = 0 */ return offset; }
0
[ "CWE-476" ]
wireshark
2cb5985bf47bdc8bea78d28483ed224abdd33dc6
152,033,379,640,860,750,000,000,000,000,000,000,000
39
Make class "type" for USB conversations. USB dissectors can't assume that only their class type has been passed around in the conversation. Make explicit check that class type expected matches the dissector and stop/prevent dissection if there isn't a match. Bug: 12356 Change-Id: Ib23973a4ebd0fbb51952ffc118daf95e3389a209 Reviewed-on: https://code.wireshark.org/review/15212 Petri-Dish: Michael Mann <[email protected]> Reviewed-by: Martin Kaiser <[email protected]> Petri-Dish: Martin Kaiser <[email protected]> Tested-by: Petri Dish Buildbot <[email protected]> Reviewed-by: Michael Mann <[email protected]>
static size_t copy_page_to_iter_iovec(struct page *page, size_t offset, size_t bytes, struct iov_iter *i) { size_t skip, copy, left, wanted; const struct iovec *iov; char __user *buf; void *kaddr, *from; if (unlikely(bytes > i->count)) bytes = i->count; if (unlikely(!bytes)) return 0; might_fault(); wanted = bytes; iov = i->iov; skip = i->iov_offset; buf = iov->iov_base + skip; copy = min(bytes, iov->iov_len - skip); if (IS_ENABLED(CONFIG_HIGHMEM) && !fault_in_writeable(buf, copy)) { kaddr = kmap_atomic(page); from = kaddr + offset; /* first chunk, usually the only one */ left = copyout(buf, from, copy); copy -= left; skip += copy; from += copy; bytes -= copy; while (unlikely(!left && bytes)) { iov++; buf = iov->iov_base; copy = min(bytes, iov->iov_len); left = copyout(buf, from, copy); copy -= left; skip = copy; from += copy; bytes -= copy; } if (likely(!bytes)) { kunmap_atomic(kaddr); goto done; } offset = from - kaddr; buf += copy; kunmap_atomic(kaddr); copy = min(bytes, iov->iov_len - skip); } /* Too bad - revert to non-atomic kmap */ kaddr = kmap(page); from = kaddr + offset; left = copyout(buf, from, copy); copy -= left; skip += copy; from += copy; bytes -= copy; while (unlikely(!left && bytes)) { iov++; buf = iov->iov_base; copy = min(bytes, iov->iov_len); left = copyout(buf, from, copy); copy -= left; skip = copy; from += copy; bytes -= copy; } kunmap(page); done: if (skip == iov->iov_len) { iov++; skip = 0; } i->count -= wanted - bytes; i->nr_segs -= iov - i->iov; i->iov = iov; i->iov_offset = skip; return wanted - bytes; }
0
[ "CWE-665", "CWE-284" ]
linux
9d2231c5d74e13b2a0546fee6737ee4446017903
315,907,889,209,691,620,000,000,000,000,000,000,000
83
lib/iov_iter: initialize "flags" in new pipe_buffer The functions copy_page_to_iter_pipe() and push_pipe() can both allocate a new pipe_buffer, but the "flags" member initializer is missing. Fixes: 241699cd72a8 ("new iov_iter flavour: pipe-backed") To: Alexander Viro <[email protected]> To: [email protected] To: [email protected] Cc: [email protected] Signed-off-by: Max Kellermann <[email protected]> Signed-off-by: Al Viro <[email protected]>
static void ttxt_parse_text_style(GF_TXTIn *ctx, GF_XMLNode *n, GF_StyleRecord *style) { u32 i=0; GF_XMLAttribute *att; memset(style, 0, sizeof(GF_StyleRecord)); style->fontID = 1; style->font_size = ctx->fontsize ; style->text_color = 0xFFFFFFFF; while ( (att=(GF_XMLAttribute *)gf_list_enum(n->attributes, &i))) { if (!stricmp(att->name, "fromChar")) style->startCharOffset = atoi(att->value); else if (!stricmp(att->name, "toChar")) style->endCharOffset = atoi(att->value); else if (!stricmp(att->name, "fontID")) style->fontID = atoi(att->value); else if (!stricmp(att->name, "fontSize")) style->font_size = atoi(att->value); else if (!stricmp(att->name, "color")) style->text_color = ttxt_get_color(att->value); else if (!stricmp(att->name, "styles")) { if (strstr(att->value, "Bold")) style->style_flags |= GF_TXT_STYLE_BOLD; if (strstr(att->value, "Italic")) style->style_flags |= GF_TXT_STYLE_ITALIC; if (strstr(att->value, "Underlined")) style->style_flags |= GF_TXT_STYLE_UNDERLINED; if (strstr(att->value, "Strikethrough")) style->style_flags |= GF_TXT_STYLE_STRIKETHROUGH; } } }
0
[ "CWE-276" ]
gpac
96699aabae042f8f55cf8a85fa5758e3db752bae
93,201,553,777,739,340,000,000,000,000,000,000,000
23
fixed #2061
static void __init report_hugepages(void) { struct hstate *h; for_each_hstate(h) { char buf[32]; string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32); pr_info("HugeTLB registered %s page size, pre-allocated %ld pages\n", buf, h->free_huge_pages); } }
0
[ "CWE-703" ]
linux
5af10dfd0afc559bb4b0f7e3e8227a1578333995
76,713,146,662,103,630,000,000,000,000,000,000,000
12
userfaultfd: hugetlbfs: remove superfluous page unlock in VM_SHARED case huge_add_to_page_cache->add_to_page_cache implicitly unlocks the page before returning in case of errors. The error returned was -EEXIST by running UFFDIO_COPY on a non-hole offset of a VM_SHARED hugetlbfs mapping. It was an userland bug that triggered it and the kernel must cope with it returning -EEXIST from ioctl(UFFDIO_COPY) as expected. page dumped because: VM_BUG_ON_PAGE(!PageLocked(page)) kernel BUG at mm/filemap.c:964! invalid opcode: 0000 [#1] SMP CPU: 1 PID: 22582 Comm: qemu-system-x86 Not tainted 4.11.11-300.fc26.x86_64 #1 RIP: unlock_page+0x4a/0x50 Call Trace: hugetlb_mcopy_atomic_pte+0xc0/0x320 mcopy_atomic+0x96f/0xbe0 userfaultfd_ioctl+0x218/0xe90 do_vfs_ioctl+0xa5/0x600 SyS_ioctl+0x79/0x90 entry_SYSCALL_64_fastpath+0x1a/0xa9 Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Andrea Arcangeli <[email protected]> Tested-by: Maxime Coquelin <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Cc: "Dr. David Alan Gilbert" <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Alexey Perevalov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
map_possibly_volatile_file_to_real (GFile *volatile_file, GCancellable *cancellable, GError **error) { GFile *real_file = NULL; GFileInfo *info = NULL; info = g_file_query_info (volatile_file, G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK "," G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE "," G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error); if (info == NULL) { return NULL; } else { gboolean is_volatile; is_volatile = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE); if (is_volatile) { const gchar *target; target = g_file_info_get_symlink_target (info); real_file = g_file_resolve_relative_path (volatile_file, target); } } g_object_unref (info); if (real_file == NULL) { real_file = g_object_ref (volatile_file); } return real_file; }
0
[ "CWE-20" ]
nautilus
1630f53481f445ada0a455e9979236d31a8d3bb0
256,453,946,291,234,550,000,000,000,000,000,000,000
42
mime-actions: use file metadata for trusting desktop files Currently we only trust desktop files that have the executable bit set, and don't replace the displayed icon or the displayed name until it's trusted, which prevents for running random programs by a malicious desktop file. However, the executable permission is preserved if the desktop file comes from a compressed file. To prevent this, add a metadata::trusted metadata to the file once the user acknowledges the file as trusted. This adds metadata to the file, which cannot be added unless it has access to the computer. Also remove the SHEBANG "trusted" content we were putting inside the desktop file, since that doesn't add more security since it can come with the file itself. https://bugzilla.gnome.org/show_bug.cgi?id=777991
ParserCallbacks::handleObject(QPDFObjectHandle obj) { std::cout << obj.getTypeName() << ": "; if (obj.isInlineImage()) { std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl; } else { std::cout << obj.unparse() << std::endl; } }
0
[ "CWE-125" ]
qpdf
1868a10f8b06631362618bfc85ca8646da4b4b71
181,411,742,704,969,940,000,000,000,000,000,000,000
12
Replace all atoi calls with QUtil::string_to_int The latter catches underflow/overflow.
_asn1_set_value_m (asn1_node node, void *value, unsigned int len) { if (node == NULL) return node; if (node->value) { if (node->value != node->small_value) free (node->value); node->value = NULL; node->value_len = 0; } if (!len) return node; node->value = value; node->value_len = len; return node; }
0
[ "CWE-119" ]
libtasn1
4d4f992826a4962790ecd0cce6fbba4a415ce149
163,799,251,541,281,270,000,000,000,000,000,000,000
21
increased size of LTOSTR_MAX_SIZE to account for sign and null byte This address an overflow found by Hanno Böck in DER decoding.
template<typename tc> CImg<T>& draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity, const unsigned int pattern) { cimg::unused(pattern); if (is_empty()) return *this; if (!color) throw CImgArgumentException(_cimg_instance "draw_circle(): Specified color is (null).", cimg_instance); if (radius<0 || x0 - radius>=width() || y0 + radius<0 || y0 - radius>=height()) return *this; if (!radius) return draw_point(x0,y0,color,opacity); draw_point(x0 - radius,y0,color,opacity).draw_point(x0 + radius,y0,color,opacity). draw_point(x0,y0 - radius,color,opacity).draw_point(x0,y0 + radius,color,opacity); if (radius==1) return *this; for (int f = 1 - radius, ddFx = 0, ddFy = -(radius<<1), x = 0, y = radius; x<y; ) { if (f>=0) { f+=(ddFy+=2); --y; } ++x; ++(f+=(ddFx+=2)); if (x!=y + 1) { const int x1 = x0 - y, x2 = x0 + y, y1 = y0 - x, y2 = y0 + x, x3 = x0 - x, x4 = x0 + x, y3 = y0 - y, y4 = y0 + y; draw_point(x1,y1,color,opacity).draw_point(x1,y2,color,opacity). draw_point(x2,y1,color,opacity).draw_point(x2,y2,color,opacity); if (x!=y) draw_point(x3,y3,color,opacity).draw_point(x4,y4,color,opacity). draw_point(x4,y3,color,opacity).draw_point(x3,y4,color,opacity); } } return *this;
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
320,503,849,278,587,560,000,000,000,000,000,000,000
29
Fix other issues in 'CImg<T>::load_bmp()'.
cmsBool Type_Chromaticity_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems) { cmsCIExyYTRIPLE* chrm = (cmsCIExyYTRIPLE*) Ptr; if (!_cmsWriteUInt16Number(io, 3)) return FALSE; // nChannels if (!_cmsWriteUInt16Number(io, 0)) return FALSE; // Table if (!SaveOneChromaticity(chrm -> Red.x, chrm -> Red.y, io)) return FALSE; if (!SaveOneChromaticity(chrm -> Green.x, chrm -> Green.y, io)) return FALSE; if (!SaveOneChromaticity(chrm -> Blue.x, chrm -> Blue.y, io)) return FALSE; return TRUE; cmsUNUSED_PARAMETER(nItems); cmsUNUSED_PARAMETER(self); }
0
[]
Little-CMS
41d222df1bc6188131a8f46c32eab0a4d4cdf1b6
123,451,573,353,150,140,000,000,000,000,000,000,000
16
Memory squeezing fix: lcms2 cmsPipeline construction When creating a new pipeline, lcms would often try to allocate a stage and pass it to cmsPipelineInsertStage without checking whether the allocation succeeded. cmsPipelineInsertStage would then assert (or crash) if it had not. The fix here is to change cmsPipelineInsertStage to check and return an error value. All calling code is then checked to test this return value and cope.
void nntp_acache_free(struct NntpData *nntp_data) { for (int i = 0; i < NNTP_ACACHE_LEN; i++) { if (nntp_data->acache[i].path) { unlink(nntp_data->acache[i].path); FREE(&nntp_data->acache[i].path); } } }
0
[ "CWE-119", "CWE-787" ]
neomutt
6296f7153f0c9d5e5cd3aaf08f9731e56621bdd3
90,427,714,026,124,780,000,000,000,000,000,000,000
11
Set length modifiers for group and desc nntp_add_group parses a line controlled by the connected nntp server. Restrict the maximum lengths read into the stack buffers group, and desc.
static void test_bug31669() { int rc; static char buff[LARGE_BUFFER_SIZE+1]; #ifndef EMBEDDED_LIBRARY static char user[OLD_USERNAME_CHAR_LENGTH+1]; static char db[NAME_CHAR_LEN+1]; static char query[LARGE_BUFFER_SIZE*2]; #endif MYSQL* conn; DBUG_ENTER("test_bug31669"); myheader("test_bug31669"); conn= client_connect(0, MYSQL_PROTOCOL_TCP, 0); rc= mysql_change_user(conn, NULL, NULL, NULL); DIE_UNLESS(rc); rc= mysql_change_user(conn, "", "", ""); DIE_UNLESS(rc); memset(buff, 'a', sizeof(buff) - 1); buff[sizeof(buff) - 1]= 0; mysql_close(conn); conn= client_connect(0, MYSQL_PROTOCOL_TCP, 0); rc= mysql_change_user(conn, buff, buff, buff); DIE_UNLESS(rc); rc = mysql_change_user(conn, opt_user, opt_password, current_db); DIE_UNLESS(!rc); #ifndef EMBEDDED_LIBRARY memset(db, 'a', sizeof(db)); db[NAME_CHAR_LEN]= 0; strxmov(query, "CREATE DATABASE IF NOT EXISTS ", db, NullS); rc= mysql_query(conn, query); myquery(rc); memset(user, 'b', sizeof(user)); user[OLD_USERNAME_CHAR_LENGTH]= 0; memset(buff, 'c', sizeof(buff)); buff[LARGE_BUFFER_SIZE]= 0; strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'%' IDENTIFIED BY " "'", buff, "' WITH GRANT OPTION", NullS); rc= mysql_query(conn, query); myquery(rc); strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'localhost' IDENTIFIED BY " "'", buff, "' WITH GRANT OPTION", NullS); rc= mysql_query(conn, query); myquery(rc); rc= mysql_query(conn, "FLUSH PRIVILEGES"); myquery(rc); rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(!rc); user[OLD_USERNAME_CHAR_LENGTH-1]= 'a'; rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(rc); user[OLD_USERNAME_CHAR_LENGTH-1]= 'b'; buff[LARGE_BUFFER_SIZE-1]= 'd'; rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(rc); buff[LARGE_BUFFER_SIZE-1]= 'c'; db[NAME_CHAR_LEN-1]= 'e'; rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(rc); mysql_close(conn); conn= client_connect(0, MYSQL_PROTOCOL_TCP, 0); db[NAME_CHAR_LEN-1]= 'a'; rc= mysql_change_user(conn, user, buff, db); DIE_UNLESS(!rc); rc= mysql_change_user(conn, user + 1, buff + 1, db + 1); DIE_UNLESS(rc); rc = mysql_change_user(conn, opt_user, opt_password, current_db); DIE_UNLESS(!rc); strxmov(query, "DROP DATABASE ", db, NullS); rc= mysql_query(conn, query); myquery(rc); strxmov(query, "DELETE FROM mysql.user WHERE User='", user, "'", NullS); rc= mysql_query(conn, query); myquery(rc); DIE_UNLESS(mysql_affected_rows(conn) == 2); #endif mysql_close(conn); DBUG_VOID_RETURN; }
0
[ "CWE-416" ]
server
eef21014898d61e77890359d6546d4985d829ef6
211,791,975,116,003,600,000,000,000,000,000,000,000
102
MDEV-11933 Wrong usage of linked list in mysql_prune_stmt_list mysql_prune_stmt_list() was walking the list following element->next pointers, but inside the loop it was invoking list_add(element) that modified element->next. So, mysql_prune_stmt_list() failed to visit and reset all elements, and some of them were left with pointers to invalid MYSQL.
stack_slot_is_boxed_value (ILStackDesc *value) { return (value->stype & BOXED_MASK) == BOXED_MASK; }
0
[ "CWE-20" ]
mono
4905ef1130feb26c3150b28b97e4a96752e0d399
287,702,354,452,249,350,000,000,000,000,000,000,000
4
Handle invalid instantiation of generic methods. * verify.c: Add new function to internal verifier API to check method instantiations. * reflection.c (mono_reflection_bind_generic_method_parameters): Check the instantiation before returning it. Fixes #655847
static int __dm_get_module_param_int(int *module_param, int min, int max) { int param = ACCESS_ONCE(*module_param); int modified_param = 0; bool modified = true; if (param < min) modified_param = min; else if (param > max) modified_param = max; else modified = false; if (modified) { (void)cmpxchg(module_param, param, modified_param); param = modified_param; } return param; }
0
[ "CWE-362" ]
linux
b9a41d21dceadf8104812626ef85dc56ee8a60ed
304,310,015,574,038,850,000,000,000,000,000,000,000
20
dm: fix race between dm_get_from_kobject() and __dm_destroy() The following BUG_ON was hit when testing repeat creation and removal of DM devices: kernel BUG at drivers/md/dm.c:2919! CPU: 7 PID: 750 Comm: systemd-udevd Not tainted 4.1.44 Call Trace: [<ffffffff81649e8b>] dm_get_from_kobject+0x34/0x3a [<ffffffff81650ef1>] dm_attr_show+0x2b/0x5e [<ffffffff817b46d1>] ? mutex_lock+0x26/0x44 [<ffffffff811df7f5>] sysfs_kf_seq_show+0x83/0xcf [<ffffffff811de257>] kernfs_seq_show+0x23/0x25 [<ffffffff81199118>] seq_read+0x16f/0x325 [<ffffffff811de994>] kernfs_fop_read+0x3a/0x13f [<ffffffff8117b625>] __vfs_read+0x26/0x9d [<ffffffff8130eb59>] ? security_file_permission+0x3c/0x44 [<ffffffff8117bdb8>] ? rw_verify_area+0x83/0xd9 [<ffffffff8117be9d>] vfs_read+0x8f/0xcf [<ffffffff81193e34>] ? __fdget_pos+0x12/0x41 [<ffffffff8117c686>] SyS_read+0x4b/0x76 [<ffffffff817b606e>] system_call_fastpath+0x12/0x71 The bug can be easily triggered, if an extra delay (e.g. 10ms) is added between the test of DMF_FREEING & DMF_DELETING and dm_get() in dm_get_from_kobject(). To fix it, we need to ensure the test of DMF_FREEING & DMF_DELETING and dm_get() are done in an atomic way, so _minor_lock is used. The other callers of dm_get() have also been checked to be OK: some callers invoke dm_get() under _minor_lock, some callers invoke it under _hash_lock, and dm_start_request() invoke it after increasing md->open_count. Cc: [email protected] Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
ISOMChannel *isor_create_channel(ISOMReader *read, GF_FilterPid *pid, u32 track, u32 item_id, Bool force_no_extractors) { ISOMChannel *ch; const GF_PropertyValue *p; s64 ts_shift; if (!read->mov) return NULL; GF_SAFEALLOC(ch, ISOMChannel); if (!ch) { return NULL; } ch->owner = read; ch->pid = pid; ch->to_init = GF_TRUE; gf_list_add(read->channels, ch); ch->track = track; ch->item_id = item_id; ch->nalu_extract_mode = 0; ch->track_id = gf_isom_get_track_id(read->mov, ch->track); switch (gf_isom_get_media_type(ch->owner->mov, ch->track)) { case GF_ISOM_MEDIA_OCR: ch->streamType = GF_STREAM_OCR; break; case GF_ISOM_MEDIA_SCENE: ch->streamType = GF_STREAM_SCENE; break; case GF_ISOM_MEDIA_VISUAL: case GF_ISOM_MEDIA_AUXV: case GF_ISOM_MEDIA_PICT: gf_isom_get_reference(ch->owner->mov, ch->track, GF_ISOM_REF_BASE, 1, &ch->base_track); //use base track only if avc/svc or hevc/lhvc. If avc+lhvc we need different rules if ( gf_isom_get_avc_svc_type(ch->owner->mov, ch->base_track, 1) == GF_ISOM_AVCTYPE_AVC_ONLY) { if ( gf_isom_get_hevc_lhvc_type(ch->owner->mov, ch->track, 1) >= GF_ISOM_HEVCTYPE_HEVC_ONLY) { ch->base_track=0; } } ch->next_track = 0; /*in scalable mode add SPS/PPS in-band*/ if (ch->base_track) ch->nalu_extract_mode = GF_ISOM_NALU_EXTRACT_INBAND_PS_FLAG /*| GF_ISOM_NALU_EXTRACT_ANNEXB_FLAG*/; break; } if (!read->noedit) { ch->ts_offset = 0; ch->has_edit_list = gf_isom_get_edit_list_type(ch->owner->mov, ch->track, &ch->ts_offset) ? GF_TRUE : GF_FALSE; if (!ch->has_edit_list && ch->ts_offset) { //if >0 this is a hold, we signal positive delay //if <0 this is a skip, we signal negative delay gf_filter_pid_set_property(pid, GF_PROP_PID_DELAY, &PROP_LONGSINT( ch->ts_offset) ); } } else ch->has_edit_list = GF_FALSE; ch->has_rap = (gf_isom_has_sync_points(ch->owner->mov, ch->track)==1) ? GF_TRUE : GF_FALSE; gf_filter_pid_set_property(pid, GF_PROP_PID_HAS_SYNC, &PROP_BOOL(ch->has_rap) ); //some fragmented files do not advertize a sync sample table (legal) so we need to update as soon as we fetch a fragment //to see if we are all-intra (as detected here) or not if (!ch->has_rap && ch->owner->frag_type) ch->check_has_rap = GF_TRUE; ch->timescale = gf_isom_get_media_timescale(ch->owner->mov, ch->track); ts_shift = gf_isom_get_cts_to_dts_shift(ch->owner->mov, ch->track); if (ts_shift) { gf_filter_pid_set_property(pid, GF_PROP_PID_CTS_SHIFT, &PROP_UINT((u32) ts_shift) ); } if (!track || !gf_isom_is_track_encrypted(read->mov, track)) { if (force_no_extractors) { ch->nalu_extract_mode = GF_ISOM_NALU_EXTRACT_LAYER_ONLY; } else { switch (read->smode) { case MP4DMX_SPLIT_EXTRACTORS: ch->nalu_extract_mode = GF_ISOM_NALU_EXTRACT_INSPECT | GF_ISOM_NALU_EXTRACT_TILE_ONLY; break; case MP4DMX_SPLIT: ch->nalu_extract_mode = GF_ISOM_NALU_EXTRACT_LAYER_ONLY | GF_ISOM_NALU_EXTRACT_TILE_ONLY; break; default: break; } } if (ch->nalu_extract_mode) { gf_isom_set_nalu_extract_mode(ch->owner->mov, ch->track, ch->nalu_extract_mode); } return ch; } if (ch->owner->nocrypt) { ch->is_encrypted = GF_FALSE; return ch; } ch->is_encrypted = GF_TRUE; p = gf_filter_pid_get_property(pid, GF_PROP_PID_STREAM_TYPE); if (p) gf_filter_pid_set_property(pid, GF_PROP_PID_ORIG_STREAM_TYPE, &PROP_UINT(p->value.uint) ); gf_filter_pid_set_property(pid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_ENCRYPTED) ); isor_set_crypt_config(ch); if (ch->nalu_extract_mode) { if (ch->is_encrypted) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[IsoMedia] using sample NAL rewrite with encryption is not yet supported, patch welcome\n")); } else { gf_isom_set_nalu_extract_mode(ch->owner->mov, ch->track, ch->nalu_extract_mode); } } return ch; }
0
[ "CWE-787" ]
gpac
da37ec8582266983d0ec4b7550ec907401ec441e
174,630,733,473,694,600,000,000,000,000,000,000,000
109
fixed crashes for very long path - cf #1908
dissect_kafka_write_txn_markers_response_partition(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, kafka_api_version_t api_version _U_) { guint32 partition_id; kafka_error_t partition_error_code; proto_item *subti; proto_tree *subtree; subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_kafka_partition, &subti, "Partition"); partition_id = tvb_get_ntohl(tvb, offset); proto_tree_add_item(subtree, hf_kafka_partition_id, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; partition_error_code = (kafka_error_t) tvb_get_ntohs(tvb, offset); proto_tree_add_item(subtree, hf_kafka_error, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_item_set_end(subti, tvb, offset); if (partition_error_code == 0) { proto_item_append_text(subti, " (ID=%u", partition_id); } else { proto_item_append_text(subti, " (ID=%u, Error=%s)", partition_id, kafka_error_to_str(partition_error_code)); } return offset; }
0
[ "CWE-401" ]
wireshark
f4374967bbf9c12746b8ec3cd54dddada9dd353e
244,896,122,418,356,400,000,000,000,000,000,000,000
29
Kafka: Limit our decompression size. Don't assume that the Internet has our best interests at heart when it gives us the size of our decompression buffer. Assign an arbitrary limit of 50 MB. This fixes #16739 in that it takes care of ** (process:17681): WARNING **: 20:03:07.440: Dissector bug, protocol Kafka, in packet 31: ../epan/proto.c:7043: failed assertion "end >= fi->start" which is different from the original error output. It looks like *that* might have taken care of in one of the other recent Kafka bug fixes. The decompression routines return a success or failure status. Use gbooleans instead of ints for that.
ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) { struct ext4_group_desc *desc; struct ext4_sb_info *sbi = EXT4_SB(sb); struct buffer_head *bh = NULL; ext4_fsblk_t bitmap_blk; int err; desc = ext4_get_group_desc(sb, block_group, NULL); if (!desc) return ERR_PTR(-EFSCORRUPTED); bitmap_blk = ext4_inode_bitmap(sb, desc); if ((bitmap_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) || (bitmap_blk >= ext4_blocks_count(sbi->s_es))) { ext4_error(sb, "Invalid inode bitmap blk %llu in " "block_group %u", bitmap_blk, block_group); ext4_mark_group_bitmap_corrupted(sb, block_group, EXT4_GROUP_INFO_IBITMAP_CORRUPT); return ERR_PTR(-EFSCORRUPTED); } bh = sb_getblk(sb, bitmap_blk); if (unlikely(!bh)) { ext4_error(sb, "Cannot read inode bitmap - " "block_group = %u, inode_bitmap = %llu", block_group, bitmap_blk); return ERR_PTR(-ENOMEM); } if (bitmap_uptodate(bh)) goto verify; lock_buffer(bh); if (bitmap_uptodate(bh)) { unlock_buffer(bh); goto verify; } ext4_lock_group(sb, block_group); if (ext4_has_group_desc_csum(sb) && (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT))) { if (block_group == 0) { ext4_unlock_group(sb, block_group); unlock_buffer(bh); ext4_error(sb, "Inode bitmap for bg 0 marked " "uninitialized"); err = -EFSCORRUPTED; goto out; } memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8); ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, bh->b_data); set_bitmap_uptodate(bh); set_buffer_uptodate(bh); set_buffer_verified(bh); ext4_unlock_group(sb, block_group); unlock_buffer(bh); return bh; } ext4_unlock_group(sb, block_group); if (buffer_uptodate(bh)) { /* * if not uninit if bh is uptodate, * bitmap is also uptodate */ set_bitmap_uptodate(bh); unlock_buffer(bh); goto verify; } /* * submit the buffer_head for reading */ trace_ext4_load_inode_bitmap(sb, block_group); bh->b_end_io = ext4_end_bitmap_read; get_bh(bh); submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh); wait_on_buffer(bh); if (!buffer_uptodate(bh)) { put_bh(bh); ext4_error(sb, "Cannot read inode bitmap - " "block_group = %u, inode_bitmap = %llu", block_group, bitmap_blk); ext4_mark_group_bitmap_corrupted(sb, block_group, EXT4_GROUP_INFO_IBITMAP_CORRUPT); return ERR_PTR(-EIO); } verify: err = ext4_validate_inode_bitmap(sb, desc, block_group, bh); if (err) goto out; return bh; out: put_bh(bh); return ERR_PTR(err); }
0
[ "CWE-416" ]
linux
8844618d8aa7a9973e7b527d038a2a589665002c
37,148,280,367,883,950,000,000,000,000,000,000,000
96
ext4: only look at the bg_flags field if it is valid The bg_flags field in the block group descripts is only valid if the uninit_bg or metadata_csum feature is enabled. We were not consistently looking at this field; fix this. Also block group #0 must never have uninitialized allocation bitmaps, or need to be zeroed, since that's where the root inode, and other special inodes are set up. Check for these conditions and mark the file system as corrupted if they are detected. This addresses CVE-2018-10876. https://bugzilla.kernel.org/show_bug.cgi?id=199403 Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
static MemTxResult memory_region_dispatch_read1(struct uc_struct *uc, MemoryRegion *mr, hwaddr addr, uint64_t *pval, unsigned size, MemTxAttrs attrs) { *pval = 0; if (mr->ops->read) { return access_with_adjusted_size(uc, addr, pval, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_read_accessor, mr, attrs); } else { return access_with_adjusted_size(uc, addr, pval, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_read_with_attrs_accessor, mr, attrs); } }
0
[ "CWE-476" ]
unicorn
3d3deac5e6d38602b689c4fef5dac004f07a2e63
161,371,635,617,569,320,000,000,000,000,000,000,000
22
Fix crash when mapping a big memory and calling uc_close
virDomainMemoryTargetDefFormat(virBufferPtr buf, virDomainMemoryDefPtr def) { virBufferAddLit(buf, "<target>\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "<size unit='KiB'>%llu</size>\n", def->size); if (def->targetNode >= 0) virBufferAsprintf(buf, "<node>%d</node>\n", def->targetNode); if (def->labelsize) { virBufferAddLit(buf, "<label>\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "<size unit='KiB'>%llu</size>\n", def->labelsize); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</label>\n"); } if (def->readonly) virBufferAddLit(buf, "<readonly/>\n"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</target>\n"); }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
8,434,923,567,052,682,000,000,000,000,000,000,000
22
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 ssize_t aac_show_flags(struct device *cdev, struct device_attribute *attr, char *buf) { int len = 0; struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata; if (nblank(dprintk(x))) len = snprintf(buf, PAGE_SIZE, "dprintk\n"); #ifdef AAC_DETAILED_STATUS_INFO len += snprintf(buf + len, PAGE_SIZE - len, "AAC_DETAILED_STATUS_INFO\n"); #endif if (dev->raw_io_interface && dev->raw_io_64) len += snprintf(buf + len, PAGE_SIZE - len, "SAI_READ_CAPACITY_16\n"); if (dev->jbod) len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n"); if (dev->supplement_adapter_info.SupportedOptions2 & AAC_OPTION_POWER_MANAGEMENT) len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_POWER_MANAGEMENT\n"); if (dev->msi) len += snprintf(buf + len, PAGE_SIZE - len, "PCI_HAS_MSI\n"); return len; }
0
[ "CWE-284", "CWE-264" ]
linux
f856567b930dfcdbc3323261bf77240ccdde01f5
285,652,115,612,620,400,000,000,000,000,000,000,000
25
aacraid: missing capable() check in compat ioctl In commit d496f94d22d1 ('[SCSI] aacraid: fix security weakness') we added a check on CAP_SYS_RAWIO to the ioctl. The compat ioctls need the check as well. Signed-off-by: Dan Carpenter <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
proto_registrar_get_id_byname(const char *field_name) { header_field_info *hfinfo; hfinfo = proto_registrar_get_byname(field_name); if (!hfinfo) return -1; return hfinfo->id; }
0
[ "CWE-401" ]
wireshark
a9fc769d7bb4b491efb61c699d57c9f35269d871
30,412,639,169,571,620,000,000,000,000,000,000,000
11
epan: Fix a memory leak. Make sure _proto_tree_add_bits_ret_val allocates a bits array using the packet scope, otherwise we leak memory. Fixes #17032.
GF_Err audio_sample_entry_AddBox(GF_Box *s, GF_Box *a) { GF_UnknownBox *wave = NULL; Bool drop_wave=GF_FALSE; GF_MPEGAudioSampleEntryBox *ptr = (GF_MPEGAudioSampleEntryBox *)s; switch (a->type) { case GF_ISOM_BOX_TYPE_ESDS: if (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr) ptr->esd = (GF_ESDBox *)a; ptr->is_qtff = 0; break; case GF_ISOM_BOX_TYPE_SINF: gf_list_add(ptr->protections, a); break; case GF_ISOM_BOX_TYPE_DAMR: case GF_ISOM_BOX_TYPE_DEVC: case GF_ISOM_BOX_TYPE_DQCP: case GF_ISOM_BOX_TYPE_DSMV: ptr->cfg_3gpp = (GF_3GPPConfigBox *) a; /*for 3GP config, remember sample entry type in config*/ ptr->cfg_3gpp->cfg.type = ptr->type; ptr->is_qtff = 0; break; case GF_ISOM_BOX_TYPE_DOPS: ptr->cfg_opus = (GF_OpusSpecificBox *)a; ptr->is_qtff = 0; break; case GF_ISOM_BOX_TYPE_DAC3: ptr->cfg_ac3 = (GF_AC3ConfigBox *) a; ptr->is_qtff = 0; break; case GF_ISOM_BOX_TYPE_DEC3: ptr->cfg_ac3 = (GF_AC3ConfigBox *) a; ptr->is_qtff = 0; break; case GF_ISOM_BOX_TYPE_MHA1: case GF_ISOM_BOX_TYPE_MHA2: case GF_ISOM_BOX_TYPE_MHM1: case GF_ISOM_BOX_TYPE_MHM2: ptr->cfg_mha = (GF_MHAConfigBox *) a; ptr->is_qtff = 0; break; case GF_ISOM_BOX_TYPE_UNKNOWN: wave = (GF_UnknownBox *)a; /*HACK for QT files: get the esds box from the track*/ if (s->type == GF_ISOM_BOX_TYPE_MP4A) { if (ptr->esd) ERROR_ON_DUPLICATED_BOX(a, ptr) //wave subboxes may have been properly parsed if ((wave->original_4cc == GF_QT_BOX_TYPE_WAVE) && gf_list_count(wave->other_boxes)) { u32 i; for (i =0; i<gf_list_count(wave->other_boxes); i++) { GF_Box *inner_box = (GF_Box *)gf_list_get(wave->other_boxes, i); if (inner_box->type == GF_ISOM_BOX_TYPE_ESDS) { ptr->esd = (GF_ESDBox *)inner_box; if (ptr->is_qtff & 1<<16) { gf_list_rem(a->other_boxes, i); drop_wave=GF_TRUE; } } } if (drop_wave) { gf_isom_box_del(a); ptr->is_qtff = 0; return GF_OK; } ptr->is_qtff = 2; return gf_isom_box_add_default(s, a); } gf_isom_box_del(a); return GF_ISOM_INVALID_MEDIA; } ptr->is_qtff &= ~(1<<16); if ((wave->original_4cc == GF_QT_BOX_TYPE_WAVE) && gf_list_count(wave->other_boxes)) { ptr->is_qtff = 2; } return gf_isom_box_add_default(s, a); case GF_QT_BOX_TYPE_WAVE: { u32 subtype = 0; GF_Box **cfg_ptr = NULL; if (s->type == GF_ISOM_BOX_TYPE_MP4A) { cfg_ptr = (GF_Box **) &ptr->esd; subtype = GF_ISOM_BOX_TYPE_ESDS; } else if (s->type == GF_ISOM_BOX_TYPE_AC3) { cfg_ptr = (GF_Box **) &ptr->cfg_ac3; subtype = GF_ISOM_BOX_TYPE_DAC3; } else if (s->type == GF_ISOM_BOX_TYPE_EC3) { cfg_ptr = (GF_Box **) &ptr->cfg_ac3; subtype = GF_ISOM_BOX_TYPE_DEC3; } else if (s->type == GF_ISOM_BOX_TYPE_OPUS) { cfg_ptr = (GF_Box **) &ptr->cfg_opus; subtype = GF_ISOM_BOX_TYPE_DOPS; } else if ((s->type == GF_ISOM_BOX_TYPE_MHA1) || (s->type == GF_ISOM_BOX_TYPE_MHA2)) { cfg_ptr = (GF_Box **) &ptr->cfg_mha; subtype = GF_ISOM_BOX_TYPE_MHAC; } if (cfg_ptr) { if (*cfg_ptr) ERROR_ON_DUPLICATED_BOX(a, ptr) //wave subboxes may have been properly parsed if (gf_list_count(a->other_boxes)) { u32 i; for (i =0; i<gf_list_count(a->other_boxes); i++) { GF_Box *inner_box = (GF_Box *)gf_list_get(a->other_boxes, i); if (inner_box->type == subtype) { *cfg_ptr = inner_box; if (ptr->is_qtff & 1<<16) { gf_list_rem(a->other_boxes, i); drop_wave=GF_TRUE; } break; } } if (drop_wave) { gf_isom_box_del(a); ptr->is_qtff = 0; return GF_OK; } ptr->is_qtff = 2; return gf_isom_box_add_default(s, a); } } } ptr->is_qtff = 2; return gf_isom_box_add_default(s, a); default: return gf_isom_box_add_default(s, a); } return GF_OK; }
0
[ "CWE-416" ]
gpac
6063b1a011c3f80cee25daade18154e15e4c058c
95,516,106,651,523,030,000,000,000,000,000,000,000
140
fix UAF in audio_sample_entry_Read (#1440)
zlog_backtrace_sigsafe(int priority, void *program_counter) { #ifdef HAVE_STACK_TRACE static const char pclabel[] = "Program counter: "; void *array[20]; int size; char buf[100]; char *s; #define LOC s,buf+sizeof(buf)-s #ifdef HAVE_GLIBC_BACKTRACE if (((size = backtrace(array,sizeof(array)/sizeof(array[0]))) <= 0) || ((size_t)size > sizeof(array)/sizeof(array[0]))) return; #define DUMP(FD) { \ if (program_counter) \ { \ write(FD, pclabel, sizeof(pclabel)-1); \ backtrace_symbols_fd(&program_counter, 1, FD); \ } \ write(FD, buf, s-buf); \ backtrace_symbols_fd(array, size, FD); \ } #elif defined(HAVE_PRINTSTACK) #define DUMP(FD) { \ if (program_counter) \ write((FD), pclabel, sizeof(pclabel)-1); \ write((FD), buf, s-buf); \ printstack((FD)); \ } #endif /* HAVE_GLIBC_BACKTRACE, HAVE_PRINTSTACK */ s = buf; s = str_append(LOC,"Backtrace for "); s = num_append(LOC,size); s = str_append(LOC," stack frames:\n"); if ((logfile_fd >= 0) || ((logfile_fd = open_crashlog()) >= 0)) DUMP(logfile_fd) if (!zlog_default) DUMP(STDERR_FILENO) else { if (priority <= zlog_default->maxlvl[ZLOG_DEST_STDOUT]) DUMP(STDOUT_FILENO) /* Remove trailing '\n' for monitor and syslog */ *--s = '\0'; if (priority <= zlog_default->maxlvl[ZLOG_DEST_MONITOR]) vty_log_fixed(buf,s-buf); if (priority <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG]) syslog_sigsafe(priority|zlog_default->facility,buf,s-buf); { int i; /* Just print the function addresses. */ for (i = 0; i < size; i++) { s = buf; s = str_append(LOC,"[bt "); s = num_append(LOC,i); s = str_append(LOC,"] 0x"); s = hex_append(LOC,(u_long)(array[i])); *s = '\0'; if (priority <= zlog_default->maxlvl[ZLOG_DEST_MONITOR]) vty_log_fixed(buf,s-buf); if (priority <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG]) syslog_sigsafe(priority|zlog_default->facility,buf,s-buf); } } } #undef DUMP #undef LOC #endif /* HAVE_STRACK_TRACE */ }
0
[ "CWE-125" ]
frr
6d58272b4cf96f0daa846210dd2104877900f921
43,763,755,969,644,070,000,000,000,000,000,000,000
74
[bgpd] cleanup, compact and consolidate capability parsing code 2007-07-26 Paul Jakma <[email protected]> * (general) Clean up and compact capability parsing slightly. Consolidate validation of length and logging of generic TLV, and memcpy of capability data, thus removing such from cap specifc code (not always present or correct). * bgp_open.h: Add structures for the generic capability TLV header and for the data formats of the various specific capabilities we support. Hence remove the badly named, or else misdefined, struct capability. * bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data. Do the length checks *before* memcpy()'ing based on that length (stored capability - should have been validated anyway on input, but..). (bgp_afi_safi_valid_indices) new function to validate (afi,safi) which is about to be used as index into arrays, consolidates several instances of same, at least one of which appeared to be incomplete.. (bgp_capability_mp) Much condensed. (bgp_capability_orf_entry) New, process one ORF entry (bgp_capability_orf) Condensed. Fixed to process all ORF entries. (bgp_capability_restart) Condensed, and fixed to use a cap-specific type, rather than abusing capability_mp. (struct message capcode_str) added to aid generic logging. (size_t cap_minsizes[]) added to aid generic validation of capability length field. (bgp_capability_parse) Generic logging and validation of TLV consolidated here. Code compacted as much as possible. * bgp_packet.c: (bgp_open_receive) Capability parsers now use streams, so no more need here to manually fudge the input stream getp. (bgp_capability_msg_parse) use struct capability_mp_data. Validate lengths /before/ memcpy. Use bgp_afi_safi_valid_indices. (bgp_capability_receive) Exported for use by test harness. * bgp_vty.c: (bgp_show_summary) fix conversion warning (bgp_show_peer) ditto * bgp_debug.h: Fix storage 'extern' after type 'const'. * lib/log.c: (mes_lookup) warning about code not being in same-number array slot should be debug, not warning. E.g. BGP has several discontigious number spaces, allocating from different parts of a space is not uncommon (e.g. IANA assigned versus vendor-assigned code points in some number space).
static void int_dsa_free(EVP_PKEY *pkey) { DSA_free(pkey->pkey.dsa); }
0
[]
openssl
ab4a81f69ec88d06c9d8de15326b9296d7f498ed
117,067,201,981,857,200,000,000,000,000,000,000,000
4
Remove broken DSA private key workarounds. Remove old code that handled various invalid DSA formats in ancient software. This also fixes a double free bug when parsing malformed DSA private keys. Thanks to Adam Langley (Google/BoringSSL) for discovering this bug using libFuzzer. CVE-2016-0705 Reviewed-by: Emilia Käsper <[email protected]>
mrb_obj_new(mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *argv) { mrb_value obj; mrb_sym mid; obj = mrb_instance_alloc(mrb, mrb_obj_value(c)); mid = MRB_SYM(initialize); if (!mrb_func_basic_p(mrb, obj, mid, mrb_bob_init)) { mrb_funcall_argv(mrb, obj, mid, argc, argv); } return obj; }
0
[ "CWE-476", "CWE-190" ]
mruby
f5e10c5a79a17939af763b1dcf5232ce47e24a34
236,232,793,862,147,420,000,000,000,000,000,000,000
12
proc.c: add `mrb_state` argument to `mrb_proc_copy()`. The function may invoke the garbage collection and it requires `mrb_state` to run.
static int em_pushf(struct x86_emulate_ctxt *ctxt) { ctxt->src.val = (unsigned long)ctxt->eflags & ~EFLG_VM; return em_push(ctxt); }
0
[ "CWE-362", "CWE-269" ]
linux
f3747379accba8e95d70cec0eae0582c8c182050
76,692,213,862,729,490,000,000,000,000,000,000,000
5
KVM: x86: SYSENTER emulation is broken SYSENTER emulation is broken in several ways: 1. It misses the case of 16-bit code segments completely (CVE-2015-0239). 2. MSR_IA32_SYSENTER_CS is checked in 64-bit mode incorrectly (bits 0 and 1 can still be set without causing #GP). 3. MSR_IA32_SYSENTER_EIP and MSR_IA32_SYSENTER_ESP are not masked in legacy-mode. 4. There is some unneeded code. Fix it. Cc: [email protected] Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
gst_mpegts_section_get_pmt (GstMpegtsSection * section) { g_return_val_if_fail (section->section_type == GST_MPEGTS_SECTION_PMT, NULL); g_return_val_if_fail (section->cached_parsed || section->data, NULL); if (!section->cached_parsed) section->cached_parsed = __common_section_checks (section, 16, _parse_pmt, (GDestroyNotify) _gst_mpegts_pmt_free); return (const GstMpegtsPMT *) section->cached_parsed; }
0
[ "CWE-125" ]
gst-plugins-bad
d58f668ece8795bddb3316832e1848c7b7cf38ac
84,158,605,378,063,430,000,000,000,000,000,000,000
12
mpegtssection: Add more section size checks The smallest section ever needs to be at least 3 bytes (i.e. just the short header). Non-short headers need to be at least 11 bytes long (3 for the minimum header, 5 for the non-short header, and 4 for the CRC). https://bugzilla.gnome.org/show_bug.cgi?id=775048
get_description (NautilusFile *file) { const char *mime_type; char *description; g_assert (NAUTILUS_IS_FILE (file)); mime_type = eel_ref_str_peek (file->details->mime_type); if (eel_str_is_empty (mime_type)) { return NULL; } if (g_content_type_is_unknown (mime_type) && nautilus_file_is_executable (file)) { return g_strdup (_("program")); } description = g_content_type_get_description (mime_type); if (!eel_str_is_empty (description)) { return description; } return g_strdup (mime_type); }
0
[]
nautilus
7632a3e13874a2c5e8988428ca913620a25df983
210,341,012,493,341,630,000,000,000,000,000,000,000
24
Check for trusted desktop file launchers. 2009-02-24 Alexander Larsson <[email protected]> * libnautilus-private/nautilus-directory-async.c: Check for trusted desktop file launchers. * libnautilus-private/nautilus-file-private.h: * libnautilus-private/nautilus-file.c: * libnautilus-private/nautilus-file.h: Add nautilus_file_is_trusted_link. Allow unsetting of custom display name. * libnautilus-private/nautilus-mime-actions.c: Display dialog when trying to launch a non-trusted desktop file. svn path=/trunk/; revision=15003
static int uevent_filter(struct kset *kset, struct kobject *kobj) { struct kobj_type *ktype = get_ktype(kobj); if (ktype == &slab_ktype) return 1; return 0;
0
[ "CWE-189" ]
linux
f8bd2258e2d520dff28c855658bd24bdafb5102d
77,367,650,739,680,030,000,000,000,000,000,000,000
8
remove div_long_long_rem x86 is the only arch right now, which provides an optimized for div_long_long_rem and it has the downside that one has to be very careful that the divide doesn't overflow. The API is a little akward, as the arguments for the unsigned divide are signed. The signed version also doesn't handle a negative divisor and produces worse code on 64bit archs. There is little incentive to keep this API alive, so this converts the few users to the new API. Signed-off-by: Roman Zippel <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: john stultz <[email protected]> Cc: Christoph Lameter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax) { unsigned int err = 0; /* Always make any pending restarted system calls return -EINTR */ current_thread_info()->restart_block.fn = do_no_restart_syscall; #define COPY(x) err |= __get_user(regs->x, &sc->x) #define COPY_SEG(seg) \ { unsigned short tmp; \ err |= __get_user(tmp, &sc->seg); \ regs->seg = tmp; } #define COPY_SEG_STRICT(seg) \ { unsigned short tmp; \ err |= __get_user(tmp, &sc->seg); \ regs->seg = tmp|3; } #define GET_SEG(seg) \ { unsigned short tmp; \ err |= __get_user(tmp, &sc->seg); \ loadsegment(seg,tmp); } #define FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_RF | \ X86_EFLAGS_OF | X86_EFLAGS_DF | \ X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \ X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF) GET_SEG(gs); COPY_SEG(fs); COPY_SEG(es); COPY_SEG(ds); COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); COPY(dx); COPY(cx); COPY(ip); COPY_SEG_STRICT(cs); COPY_SEG_STRICT(ss); { unsigned int tmpflags; err |= __get_user(tmpflags, &sc->flags); regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); regs->orig_ax = -1; /* disable syscall checks */ } { struct _fpstate __user * buf; err |= __get_user(buf, &sc->fpstate); if (buf) { if (!access_ok(VERIFY_READ, buf, sizeof(*buf))) goto badframe; err |= restore_i387(buf); } else { struct task_struct *me = current; if (used_math()) { clear_fpu(me); clear_used_math(); } } } err |= __get_user(*peax, &sc->ax); return err; badframe: return 1; }
0
[ "CWE-399" ]
linux-2.6
e40cd10ccff3d9fbffd57b93780bee4b7b9bff51
171,660,535,001,939,200,000,000,000,000,000,000,000
73
x86: clear DF before calling signal handler The Linux kernel currently does not clear the direction flag before calling a signal handler, whereas the x86/x86-64 ABI requires that. Linux had this behavior/bug forever, but this becomes a real problem with gcc version 4.3, which assumes that the direction flag is correctly cleared at the entry of a function. This patches changes the setup_frame() functions to clear the direction before entering the signal handler. Signed-off-by: Aurelien Jarno <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: H. Peter Anvin <[email protected]>
static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr) { return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); }
1
[ "CWE-119" ]
linux
1be7107fbe18eed3e319a6c3e83c78254b693acb
272,689,751,564,048,220,000,000,000,000,000,000,000
4
mm: larger stack guard gap, between vmas Stack guard page is a useful feature to reduce a risk of stack smashing into a different mapping. We have been using a single page gap which is sufficient to prevent having stack adjacent to a different mapping. But this seems to be insufficient in the light of the stack usage in userspace. E.g. glibc uses as large as 64kB alloca() in many commonly used functions. Others use constructs liks gid_t buffer[NGROUPS_MAX] which is 256kB or stack strings with MAX_ARG_STRLEN. This will become especially dangerous for suid binaries and the default no limit for the stack size limit because those applications can be tricked to consume a large portion of the stack and a single glibc call could jump over the guard page. These attacks are not theoretical, unfortunatelly. Make those attacks less probable by increasing the stack guard gap to 1MB (on systems with 4k pages; but make it depend on the page size because systems with larger base pages might cap stack allocations in the PAGE_SIZE units) which should cover larger alloca() and VLA stack allocations. It is obviously not a full fix because the problem is somehow inherent, but it should reduce attack space a lot. One could argue that the gap size should be configurable from userspace, but that can be done later when somebody finds that the new 1MB is wrong for some special case applications. For now, add a kernel command line option (stack_guard_gap) to specify the stack gap size (in page units). Implementation wise, first delete all the old code for stack guard page: because although we could get away with accounting one extra page in a stack vma, accounting a larger gap can break userspace - case in point, a program run with "ulimit -S -v 20000" failed when the 1MB gap was counted for RLIMIT_AS; similar problems could come with RLIMIT_MLOCK and strict non-overcommit mode. Instead of keeping gap inside the stack vma, maintain the stack guard gap as a gap between vmas: using vm_start_gap() in place of vm_start (or vm_end_gap() in place of vm_end if VM_GROWSUP) in just those few places which need to respect the gap - mainly arch_get_unmapped_area(), and and the vma tree's subtree_gap support for that. Original-patch-by: Oleg Nesterov <[email protected]> Original-patch-by: Michal Hocko <[email protected]> Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Michal Hocko <[email protected]> Tested-by: Helge Deller <[email protected]> # parisc Signed-off-by: Linus Torvalds <[email protected]>
static double Hamming(const double x, const ResizeFilter *magick_unused(resize_filter)) { /* Offset cosine window function: .54 + .46 cos(pi x). */ const double cosine = cos((double) (MagickPI*x)); magick_unreferenced(resize_filter); return(0.54+0.46*cosine); }
0
[ "CWE-369" ]
ImageMagick
43539e67a47d2f8de832d33a5b26dc2a7a12294f
53,845,134,636,121,740,000,000,000,000,000,000,000
11
https://github.com/ImageMagick/ImageMagick/issues/1718
int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { int i; uint8_t *row; VncDisplay *vd = vs->vd; row = vnc_server_fb_ptr(vd, x, y); for (i = 0; i < h; i++) { vs->write_pixels(vs, row, w * VNC_SERVER_FB_BYTES); row += vnc_server_fb_stride(vd); } return 1; }
0
[ "CWE-125" ]
qemu
bea60dd7679364493a0d7f5b54316c767cf894ef
7,145,876,035,282,111,000,000,000,000,000,000,000
13
ui/vnc: fix potential memory corruption issues this patch makes the VNC server work correctly if the server surface and the guest surface have different sizes. Basically the server surface is adjusted to not exceed VNC_MAX_WIDTH x VNC_MAX_HEIGHT and additionally the width is rounded up to multiple of VNC_DIRTY_PIXELS_PER_BIT. If we have a resolution whose width is not dividable by VNC_DIRTY_PIXELS_PER_BIT we now get a small black bar on the right of the screen. If the surface is too big to fit the limits only the upper left area is shown. On top of that this fixes 2 memory corruption issues: The first was actually discovered during playing around with a Windows 7 vServer. During resolution change in Windows 7 it happens sometimes that Windows changes to an intermediate resolution where server_stride % cmp_bytes != 0 (in vnc_refresh_server_surface). This happens only if width % VNC_DIRTY_PIXELS_PER_BIT != 0. The second is a theoretical issue, but is maybe exploitable by the guest. If for some reason the guest surface size is bigger than VNC_MAX_WIDTH x VNC_MAX_HEIGHT we end up in severe corruption since this limit is nowhere enforced. Signed-off-by: Peter Lieven <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
MagickExport MagickBooleanType GetImageMedian(const Image *image,double *median, ExceptionInfo *exception) { ChannelStatistics *channel_statistics; assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); channel_statistics=GetImageStatistics(image,exception); if (channel_statistics == (ChannelStatistics *) NULL) return(MagickFalse); *median=channel_statistics[CompositePixelChannel].median; channel_statistics=(ChannelStatistics *) RelinquishMagickMemory( channel_statistics); return(MagickTrue); }
0
[]
ImageMagick
4717744e4bb27de8ea978e51c6d5bcddf62ffe49
262,913,597,767,768,180,000,000,000,000,000,000,000
18
https://github.com/ImageMagick/ImageMagick/issues/3332
static int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d) { #ifndef WOLFSSL_SMALL_STACK fp_int q[1]; #else fp_int *q; #endif fp_word w; fp_digit t; int ix; /* cannot divide by zero */ if (b == 0) { return FP_VAL; } /* quick outs */ if (b == 1 || fp_iszero(a) == FP_YES) { if (d != NULL) { *d = 0; } if (c != NULL) { fp_copy(a, c); } return FP_OKAY; } /* power of two ? */ if (s_is_power_of_two(b, &ix) == FP_YES) { if (d != NULL) { *d = a->dp[0] & ((((fp_digit)1)<<ix) - 1); } if (c != NULL) { fp_div_2d(a, ix, c, NULL); } return FP_OKAY; } #ifdef WOLFSSL_SMALL_STACK q = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT); if (q == NULL) return FP_MEM; #endif fp_init(q); if (c != NULL) { q->used = a->used; q->sign = a->sign; } w = 0; for (ix = a->used - 1; ix >= 0; ix--) { w = (w << ((fp_word)DIGIT_BIT)) | ((fp_word)a->dp[ix]); if (w >= b) { t = (fp_digit)(w / b); w -= ((fp_word)t) * ((fp_word)b); } else { t = 0; } if (c != NULL) q->dp[ix] = (fp_digit)t; } if (d != NULL) { *d = (fp_digit)w; } if (c != NULL) { fp_clamp(q); fp_copy(q, c); } #ifdef WOLFSSL_SMALL_STACK XFREE(q, NULL, DYNAMIC_TYPE_BIGINT); #endif return FP_OKAY; }
0
[ "CWE-326", "CWE-203" ]
wolfssl
1de07da61f0c8e9926dcbd68119f73230dae283f
178,406,316,226,351,600,000,000,000,000,000,000,000
79
Constant time EC map to affine for private operations For fast math, use a constant time modular inverse when mapping to affine when operation involves a private key - key gen, calc shared secret, sign.
inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) { return t0.type | (t1.type << 4) | (t2.type << 8) | (t3.type << 12) | (t4.type << 16) | (t5.type << 20) | (t6.type << 24) | (t7.type << 28) | (t8.type << 32) | (t9.type << 36) | (t10.type << 40) | (t11.type << 44) | (t12.type << 48) | (t13.type << 52) | (t14.type << 56); }
0
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
123,879,026,586,532,870,000,000,000,000,000,000,000
6
Fix segfault on complex pointer formatting (#642)
mrb_full_gc(mrb_state *mrb) { mrb_gc *gc = &mrb->gc; if (gc->disabled) return; GC_INVOKE_TIME_REPORT("mrb_full_gc()"); GC_TIME_START; if (is_generational(gc)) { /* clear all the old objects back to young */ clear_all_old(mrb, gc); gc->full = TRUE; } else if (gc->state != MRB_GC_STATE_ROOT) { /* finish half baked GC cycle */ incremental_gc_until(mrb, gc, MRB_GC_STATE_ROOT); } incremental_gc_until(mrb, gc, MRB_GC_STATE_ROOT); gc->threshold = (gc->live_after_mark/100) * gc->interval_ratio; if (is_generational(gc)) { gc->majorgc_old_threshold = gc->live_after_mark/100 * DEFAULT_MAJOR_GC_INC_RATIO; gc->full = FALSE; } GC_TIME_STOP_AND_REPORT; }
0
[ "CWE-416" ]
mruby
5c114c91d4ff31859fcd84cf8bf349b737b90d99
244,861,931,565,271,940,000,000,000,000,000,000,000
29
Clear unused stack region that may refer freed objects; fix #3596
tty_add(struct tty *tty, const char *buf, size_t len) { struct client *c = tty->client; if (tty->flags & TTY_BLOCK) { tty->discarded += len; return; } evbuffer_add(tty->out, buf, len); log_debug("%s: %.*s", c->name, (int)len, buf); c->written += len; if (tty_log_fd != -1) write(tty_log_fd, buf, len); if (tty->flags & TTY_STARTED) event_add(&tty->event_out, NULL); }
0
[]
src
b32e1d34e10a0da806823f57f02a4ae6e93d756e
269,105,004,637,307,350,000,000,000,000,000,000,000
18
evbuffer_new and bufferevent_new can both fail (when malloc fails) and return NULL. GitHub issue 1547.
xmlParseName(xmlParserCtxtPtr ctxt) { const xmlChar *in; const xmlChar *ret; int count = 0; GROW; #ifdef DEBUG nbParseName++; #endif /* * Accelerator for simple ASCII names */ in = ctxt->input->cur; if (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || (*in == '_') || (*in == ':')) { in++; while (((*in >= 0x61) && (*in <= 0x7A)) || ((*in >= 0x41) && (*in <= 0x5A)) || ((*in >= 0x30) && (*in <= 0x39)) || (*in == '_') || (*in == '-') || (*in == ':') || (*in == '.')) in++; if ((*in > 0) && (*in < 0x80)) { count = in - ctxt->input->cur; if ((count > XML_MAX_NAME_LENGTH) && ((ctxt->options & XML_PARSE_HUGE) == 0)) { xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name"); return(NULL); } ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); ctxt->input->cur = in; ctxt->nbChars += count; ctxt->input->col += count; if (ret == NULL) xmlErrMemory(ctxt, NULL); return(ret); } } /* accelerator for special cases */ return(xmlParseNameComplex(ctxt)); }
0
[ "CWE-119" ]
libxml2
6a36fbe3b3e001a8a840b5c1fdd81cefc9947f0d
206,100,726,279,295,000,000,000,000,000,000,000,000
44
Fix potential out of bound access
template<typename tf> static CImg<floatT> cylinder3d(CImgList<tf>& primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24) { primitives.assign(); if (!subdivisions) return CImg<floatT>(); CImgList<floatT> vertices(2,1,3,1,1, 0.,0.,0., 0.,0.,size_z); for (float delta = 360.0f/subdivisions, angle = 0; angle<360; angle+=delta) { const float a = (float)(angle*cimg::PI/180); CImg<floatT>::vector((float)(radius*std::cos(a)),(float)(radius*std::sin(a)),0.0f).move_to(vertices); CImg<floatT>::vector((float)(radius*std::cos(a)),(float)(radius*std::sin(a)),size_z).move_to(vertices); } const unsigned int nbr = (vertices._width - 2)/2; for (unsigned int p = 0; p<nbr; ++p) { const unsigned int curr = 2 + 2*p, next = 2 + (2*((p + 1)%nbr)); CImg<tf>::vector(0,next,curr).move_to(primitives); CImg<tf>::vector(1,curr + 1,next + 1).move_to(primitives); CImg<tf>::vector(curr,next,next + 1,curr + 1).move_to(primitives); } return vertices>'x';
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
174,716,708,711,060,170,000,000,000,000,000,000,000
21
Fix other issues in 'CImg<T>::load_bmp()'.
asmlinkage void vmread_error(unsigned long field, bool fault) { if (fault) kvm_spurious_fault(); else vmx_insn_failed("kvm: vmread failed: field=%lx\n", field); }
0
[ "CWE-787" ]
linux
04c4f2ee3f68c9a4bf1653d15f1a9a435ae33f7a
49,335,649,640,441,615,000,000,000,000,000,000,000
7
KVM: VMX: Don't use vcpu->run->internal.ndata as an array index __vmx_handle_exit() uses vcpu->run->internal.ndata as an index for an array access. Since vcpu->run is (can be) mapped to a user address space with a writer permission, the 'ndata' could be updated by the user process at anytime (the user process can set it to outside the bounds of the array). So, it is not safe that __vmx_handle_exit() uses the 'ndata' that way. Fixes: 1aa561b1a4c0 ("kvm: x86: Add "last CPU" to some KVM_EXIT information") Signed-off-by: Reiji Watanabe <[email protected]> Reviewed-by: Jim Mattson <[email protected]> Message-Id: <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
xps_parse_path_figure(fz_context *doc, fz_path *path, fz_xml *root, int stroking) { fz_xml *node; char *is_closed_att; char *start_point_att; char *is_filled_att; int is_closed = 0; int is_filled = 1; float start_x = 0; float start_y = 0; int skipped_stroke = 0; is_closed_att = fz_xml_att(root, "IsClosed"); start_point_att = fz_xml_att(root, "StartPoint"); is_filled_att = fz_xml_att(root, "IsFilled"); if (is_closed_att) is_closed = !strcmp(is_closed_att, "true"); if (is_filled_att) is_filled = !strcmp(is_filled_att, "true"); if (start_point_att) xps_parse_point(start_point_att, &start_x, &start_y); if (!stroking && !is_filled) /* not filled, when filling */ return; fz_moveto(doc, path, start_x, start_y); for (node = fz_xml_down(root); node; node = fz_xml_next(node)) { if (!strcmp(fz_xml_tag(node), "ArcSegment")) xps_parse_arc_segment(doc, path, node, stroking, &skipped_stroke); if (!strcmp(fz_xml_tag(node), "PolyBezierSegment")) xps_parse_poly_bezier_segment(doc, path, node, stroking, &skipped_stroke); if (!strcmp(fz_xml_tag(node), "PolyLineSegment")) xps_parse_poly_line_segment(doc, path, node, stroking, &skipped_stroke); if (!strcmp(fz_xml_tag(node), "PolyQuadraticBezierSegment")) xps_parse_poly_quadratic_bezier_segment(doc, path, node, stroking, &skipped_stroke); } if (is_closed) { if (stroking && skipped_stroke) fz_lineto(doc, path, start_x, start_y); /* we've skipped using fz_moveto... */ else fz_closepath(doc, path); /* no skipped segments, safe to closepath properly */ } }
0
[ "CWE-119" ]
mupdf
60dabde18d7fe12b19da8b509bdfee9cc886aafc
107,684,148,209,888,260,000,000,000,000,000,000,000
51
Bug 694957: fix stack buffer overflow in xps_parse_color xps_parse_color happily reads more than FZ_MAX_COLORS values out of a ContextColor array which overflows the passed in samples array. Limiting the number of allowed samples to FZ_MAX_COLORS and make sure to use that constant for all callers fixes the problem. Thanks to Jean-Jamil Khalifé for reporting and investigating the issue and providing a sample exploit file.
static ssize_t sec_write(struct Curl_easy *data, struct connectdata *conn, curl_socket_t fd, const char *buffer, size_t length) { ssize_t tx = 0, len = conn->buffer_size; if(len <= 0) len = length; while(length) { if(length < (size_t)len) len = length; do_sec_send(data, conn, fd, buffer, curlx_sztosi(len)); length -= len; buffer += len; tx += len; } return tx; }
0
[]
curl
6ecdf5136b52af747e7bda08db9a748256b1cd09
221,242,498,229,170,550,000,000,000,000,000,000,000
18
krb5: return error properly on decode errors Bug: https://curl.se/docs/CVE-2022-32208.html CVE-2022-32208 Reported-by: Harry Sintonen Closes #9051
void subs_box_del(GF_Box *s) { GF_SubSampleInformationBox *ptr = (GF_SubSampleInformationBox *)s; if (ptr == NULL) return; while (gf_list_count(ptr->Samples)) { GF_SubSampleInfoEntry *pSamp; pSamp = (GF_SubSampleInfoEntry*)gf_list_get(ptr->Samples, 0); while (gf_list_count(pSamp->SubSamples)) { GF_SubSampleEntry *pSubSamp; pSubSamp = (GF_SubSampleEntry*) gf_list_get(pSamp->SubSamples, 0); gf_free(pSubSamp); gf_list_rem(pSamp->SubSamples, 0); } gf_list_del(pSamp->SubSamples); gf_free(pSamp); gf_list_rem(ptr->Samples, 0); } gf_list_del(ptr->Samples); gf_free(ptr); }
0
[ "CWE-787" ]
gpac
77510778516803b7f7402d7423c6d6bef50254c3
117,732,759,449,507,350,000,000,000,000,000,000,000
21
fixed #2255
int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, int cpu_id) { struct ring_buffer_per_cpu *cpu_buffer; unsigned long nr_pages; int cpu, err; /* * Always succeed at resizing a non-existent buffer: */ if (!buffer) return 0; /* Make sure the requested buffer exists */ if (cpu_id != RING_BUFFER_ALL_CPUS && !cpumask_test_cpu(cpu_id, buffer->cpumask)) return 0; nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE); /* we need a minimum of two pages */ if (nr_pages < 2) nr_pages = 2; /* prevent another thread from changing buffer sizes */ mutex_lock(&buffer->mutex); if (cpu_id == RING_BUFFER_ALL_CPUS) { /* * Don't succeed if resizing is disabled, as a reader might be * manipulating the ring buffer and is expecting a sane state while * this is true. */ for_each_buffer_cpu(buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; if (atomic_read(&cpu_buffer->resize_disabled)) { err = -EBUSY; goto out_err_unlock; } } /* calculate the pages to update */ for_each_buffer_cpu(buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; cpu_buffer->nr_pages_to_update = nr_pages - cpu_buffer->nr_pages; /* * nothing more to do for removing pages or no update */ if (cpu_buffer->nr_pages_to_update <= 0) continue; /* * to add pages, make sure all new pages can be * allocated without receiving ENOMEM */ INIT_LIST_HEAD(&cpu_buffer->new_pages); if (__rb_allocate_pages(cpu_buffer, cpu_buffer->nr_pages_to_update, &cpu_buffer->new_pages)) { /* not enough memory for new pages */ err = -ENOMEM; goto out_err; } } get_online_cpus(); /* * Fire off all the required work handlers * We can't schedule on offline CPUs, but it's not necessary * since we can change their buffer sizes without any race. */ for_each_buffer_cpu(buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; if (!cpu_buffer->nr_pages_to_update) continue; /* Can't run something on an offline CPU. */ if (!cpu_online(cpu)) { rb_update_pages(cpu_buffer); cpu_buffer->nr_pages_to_update = 0; } else { schedule_work_on(cpu, &cpu_buffer->update_pages_work); } } /* wait for all the updates to complete */ for_each_buffer_cpu(buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; if (!cpu_buffer->nr_pages_to_update) continue; if (cpu_online(cpu)) wait_for_completion(&cpu_buffer->update_done); cpu_buffer->nr_pages_to_update = 0; } put_online_cpus(); } else { cpu_buffer = buffer->buffers[cpu_id]; if (nr_pages == cpu_buffer->nr_pages) goto out; /* * Don't succeed if resizing is disabled, as a reader might be * manipulating the ring buffer and is expecting a sane state while * this is true. */ if (atomic_read(&cpu_buffer->resize_disabled)) { err = -EBUSY; goto out_err_unlock; } cpu_buffer->nr_pages_to_update = nr_pages - cpu_buffer->nr_pages; INIT_LIST_HEAD(&cpu_buffer->new_pages); if (cpu_buffer->nr_pages_to_update > 0 && __rb_allocate_pages(cpu_buffer, cpu_buffer->nr_pages_to_update, &cpu_buffer->new_pages)) { err = -ENOMEM; goto out_err; } get_online_cpus(); /* Can't run something on an offline CPU. */ if (!cpu_online(cpu_id)) rb_update_pages(cpu_buffer); else { schedule_work_on(cpu_id, &cpu_buffer->update_pages_work); wait_for_completion(&cpu_buffer->update_done); } cpu_buffer->nr_pages_to_update = 0; put_online_cpus(); } out: /* * The ring buffer resize can happen with the ring buffer * enabled, so that the update disturbs the tracing as little * as possible. But if the buffer is disabled, we do not need * to worry about that, and we can take the time to verify * that the buffer is not corrupt. */ if (atomic_read(&buffer->record_disabled)) { atomic_inc(&buffer->record_disabled); /* * Even though the buffer was disabled, we must make sure * that it is truly disabled before calling rb_check_pages. * There could have been a race between checking * record_disable and incrementing it. */ synchronize_rcu(); for_each_buffer_cpu(buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; rb_check_pages(cpu_buffer); } atomic_dec(&buffer->record_disabled); } mutex_unlock(&buffer->mutex); return 0; out_err: for_each_buffer_cpu(buffer, cpu) { struct buffer_page *bpage, *tmp; cpu_buffer = buffer->buffers[cpu]; cpu_buffer->nr_pages_to_update = 0; if (list_empty(&cpu_buffer->new_pages)) continue; list_for_each_entry_safe(bpage, tmp, &cpu_buffer->new_pages, list) { list_del_init(&bpage->list); free_buffer_page(bpage); } } out_err_unlock: mutex_unlock(&buffer->mutex); return err; }
0
[ "CWE-835" ]
linux
67f0d6d9883c13174669f88adac4f0ee656cc16a
206,367,687,837,773,370,000,000,000,000,000,000,000
188
tracing: Fix bug in rb_per_cpu_empty() that might cause deadloop. The "rb_per_cpu_empty()" misinterpret the condition (as not-empty) when "head_page" and "commit_page" of "struct ring_buffer_per_cpu" points to the same buffer page, whose "buffer_data_page" is empty and "read" field is non-zero. An error scenario could be constructed as followed (kernel perspective): 1. All pages in the buffer has been accessed by reader(s) so that all of them will have non-zero "read" field. 2. Read and clear all buffer pages so that "rb_num_of_entries()" will return 0 rendering there's no more data to read. It is also required that the "read_page", "commit_page" and "tail_page" points to the same page, while "head_page" is the next page of them. 3. Invoke "ring_buffer_lock_reserve()" with large enough "length" so that it shot pass the end of current tail buffer page. Now the "head_page", "commit_page" and "tail_page" points to the same page. 4. Discard current event with "ring_buffer_discard_commit()", so that "head_page", "commit_page" and "tail_page" points to a page whose buffer data page is now empty. When the error scenario has been constructed, "tracing_read_pipe" will be trapped inside a deadloop: "trace_empty()" returns 0 since "rb_per_cpu_empty()" returns 0 when it hits the CPU containing such constructed ring buffer. Then "trace_find_next_entry_inc()" always return NULL since "rb_num_of_entries()" reports there's no more entry to read. Finally "trace_seq_to_user()" returns "-EBUSY" spanking "tracing_read_pipe" back to the start of the "waitagain" loop. I've also written a proof-of-concept script to construct the scenario and trigger the bug automatically, you can use it to trace and validate my reasoning above: https://github.com/aegistudio/RingBufferDetonator.git Tests has been carried out on linux kernel 5.14-rc2 (2734d6c1b1a089fb593ef6a23d4b70903526fe0c), my fixed version of kernel (for testing whether my update fixes the bug) and some older kernels (for range of affected kernels). Test result is also attached to the proof-of-concept repository. Link: https://lore.kernel.org/linux-trace-devel/YPaNxsIlb2yjSi5Y@aegistudio/ Link: https://lore.kernel.org/linux-trace-devel/YPgrN85WL9VyrZ55@aegistudio Cc: [email protected] Fixes: bf41a158cacba ("ring-buffer: make reentrant") Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Haoran Luo <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
SYSCALL_DEFINE0(restart_syscall) { struct restart_block *restart = &current->restart_block; return restart->fn(restart); }
0
[ "CWE-119", "CWE-787" ]
linux
4ea77014af0d6205b05503d1c7aac6eace11d473
252,598,219,600,036,780,000,000,000,000,000,000,000
5
kernel/signal.c: avoid undefined behaviour in kill_something_info When running kill(72057458746458112, 0) in userspace I hit the following issue. UBSAN: Undefined behaviour in kernel/signal.c:1462:11 negation of -2147483648 cannot be represented in type 'int': CPU: 226 PID: 9849 Comm: test Tainted: G B ---- ------- 3.10.0-327.53.58.70.x86_64_ubsan+ #116 Hardware name: Huawei Technologies Co., Ltd. RH8100 V3/BC61PBIA, BIOS BLHSV028 11/11/2014 Call Trace: dump_stack+0x19/0x1b ubsan_epilogue+0xd/0x50 __ubsan_handle_negate_overflow+0x109/0x14e SYSC_kill+0x43e/0x4d0 SyS_kill+0xe/0x10 system_call_fastpath+0x16/0x1b Add code to avoid the UBSAN detection. [[email protected]: tweak comment] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: zhongjiang <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Xishi Qiu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void nfnl_unlock(__u8 subsys_id) { mutex_unlock(&table[subsys_id].mutex); }
0
[ "CWE-264" ]
net
90f62cf30a78721641e08737bda787552428061e
170,009,301,528,980,720,000,000,000,000,000,000,000
4
net: Use netlink_ns_capable to verify the permisions of netlink messages It is possible by passing a netlink socket to a more privileged executable and then to fool that executable into writing to the socket data that happens to be valid netlink message to do something that privileged executable did not intend to do. To keep this from happening replace bare capable and ns_capable calls with netlink_capable, netlink_net_calls and netlink_ns_capable calls. Which act the same as the previous calls except they verify that the opener of the socket had the desired permissions as well. Reported-by: Andy Lutomirski <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int packet_notifier(struct notifier_block *this, unsigned long msg, void *ptr) { struct sock *sk; struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net *net = dev_net(dev); rcu_read_lock(); sk_for_each_rcu(sk, &net->packet.sklist) { struct packet_sock *po = pkt_sk(sk); switch (msg) { case NETDEV_UNREGISTER: if (po->mclist) packet_dev_mclist_delete(dev, &po->mclist); fallthrough; case NETDEV_DOWN: if (dev->ifindex == po->ifindex) { spin_lock(&po->bind_lock); if (po->running) { __unregister_prot_hook(sk, false); sk->sk_err = ENETDOWN; if (!sock_flag(sk, SOCK_DEAD)) sk_error_report(sk); } if (msg == NETDEV_UNREGISTER) { packet_cached_dev_reset(po); WRITE_ONCE(po->ifindex, -1); dev_put_track(po->prot_hook.dev, &po->prot_hook.dev_tracker); po->prot_hook.dev = NULL; } spin_unlock(&po->bind_lock); } break; case NETDEV_UP: if (dev->ifindex == po->ifindex) { spin_lock(&po->bind_lock); if (po->num) register_prot_hook(sk); spin_unlock(&po->bind_lock); } break; } } rcu_read_unlock(); return NOTIFY_DONE; }
0
[]
linux
c700525fcc06b05adfea78039de02628af79e07a
132,948,355,924,978,080,000,000,000,000,000,000,000
49
net/packet: fix slab-out-of-bounds access in packet_recvmsg() syzbot found that when an AF_PACKET socket is using PACKET_COPY_THRESH and mmap operations, tpacket_rcv() is queueing skbs with garbage in skb->cb[], triggering a too big copy [1] Presumably, users of af_packet using mmap() already gets correct metadata from the mapped buffer, we can simply make sure to clear 12 bytes that might be copied to user space later. BUG: KASAN: stack-out-of-bounds in memcpy include/linux/fortify-string.h:225 [inline] BUG: KASAN: stack-out-of-bounds in packet_recvmsg+0x56c/0x1150 net/packet/af_packet.c:3489 Write of size 165 at addr ffffc9000385fb78 by task syz-executor233/3631 CPU: 0 PID: 3631 Comm: syz-executor233 Not tainted 5.17.0-rc7-syzkaller-02396-g0b3660695e80 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xf/0x336 mm/kasan/report.c:255 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 check_region_inline mm/kasan/generic.c:183 [inline] kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189 memcpy+0x39/0x60 mm/kasan/shadow.c:66 memcpy include/linux/fortify-string.h:225 [inline] packet_recvmsg+0x56c/0x1150 net/packet/af_packet.c:3489 sock_recvmsg_nosec net/socket.c:948 [inline] sock_recvmsg net/socket.c:966 [inline] sock_recvmsg net/socket.c:962 [inline] ____sys_recvmsg+0x2c4/0x600 net/socket.c:2632 ___sys_recvmsg+0x127/0x200 net/socket.c:2674 __sys_recvmsg+0xe2/0x1a0 net/socket.c:2704 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fdfd5954c29 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 41 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffcf8e71e48 EFLAGS: 00000246 ORIG_RAX: 000000000000002f RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fdfd5954c29 RDX: 0000000000000000 RSI: 0000000020000500 RDI: 0000000000000005 RBP: 0000000000000000 R08: 000000000000000d R09: 000000000000000d R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffcf8e71e60 R13: 00000000000f4240 R14: 000000000000c1ff R15: 00007ffcf8e71e54 </TASK> addr ffffc9000385fb78 is located in stack of task syz-executor233/3631 at offset 32 in frame: ____sys_recvmsg+0x0/0x600 include/linux/uio.h:246 this frame has 1 object: [32, 160) 'addr' Memory state around the buggy address: ffffc9000385fa80: 00 04 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 ffffc9000385fb00: 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 >ffffc9000385fb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f3 ^ ffffc9000385fc00: f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 f1 ffffc9000385fc80: f1 f1 f1 00 f2 f2 f2 00 f2 f2 f2 00 00 00 00 00 ================================================================== Fixes: 0fb375fb9b93 ("[AF_PACKET]: Allow for > 8 byte hardware addresses.") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: syzbot <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
getsize_application_api( disk_estimates_t *est, int nb_level, int *levels, backup_support_option_t *bsu) { dle_t *dle = est->dle; int pipeinfd[2], pipeoutfd[2], pipeerrfd[2]; pid_t dumppid; off_t size = (off_t)-1; FILE *dumpout; FILE *dumperr; char *line = NULL; char *cmd = NULL; char *cmdline; guint i; int j; GPtrArray *argv_ptr = g_ptr_array_new(); char *newoptstr = NULL; off_t size1, size2; times_t start_time; char *qdisk = quote_string(dle->disk); char *qamdevice = quote_string(dle->device); amwait_t wait_status; char levelstr[NUM_STR_SIZE]; GSList *scriptlist; script_t *script; char *errmsg = NULL; estimate_t estimate; estimatelist_t el; cmd = vstralloc(APPLICATION_DIR, "/", dle->program, NULL); g_ptr_array_add(argv_ptr, stralloc(dle->program)); g_ptr_array_add(argv_ptr, stralloc("estimate")); if (bsu->message_line == 1) { g_ptr_array_add(argv_ptr, stralloc("--message")); g_ptr_array_add(argv_ptr, stralloc("line")); } if (g_options->config && bsu->config == 1) { g_ptr_array_add(argv_ptr, stralloc("--config")); g_ptr_array_add(argv_ptr, stralloc(g_options->config)); } if (g_options->hostname && bsu->host == 1) { g_ptr_array_add(argv_ptr, stralloc("--host")); g_ptr_array_add(argv_ptr, stralloc(g_options->hostname)); } g_ptr_array_add(argv_ptr, stralloc("--device")); g_ptr_array_add(argv_ptr, stralloc(dle->device)); if (dle->disk && bsu->disk == 1) { g_ptr_array_add(argv_ptr, stralloc("--disk")); g_ptr_array_add(argv_ptr, stralloc(dle->disk)); } for (j=0; j < nb_level; j++) { g_ptr_array_add(argv_ptr, stralloc("--level")); g_snprintf(levelstr,SIZEOF(levelstr),"%d", levels[j]); g_ptr_array_add(argv_ptr, stralloc(levelstr)); } /* find the first in ES_CLIENT and ES_CALCSIZE */ estimate = ES_CLIENT; for (el = dle->estimatelist; el != NULL; el = el->next) { estimate = (estimate_t)GPOINTER_TO_INT(el->data); if ((estimate == ES_CLIENT && bsu->client_estimate) || (estimate == ES_CALCSIZE && bsu->calcsize)) break; estimate = ES_CLIENT; } if (estimate == ES_CALCSIZE && bsu->calcsize) { g_ptr_array_add(argv_ptr, stralloc("--calcsize")); } application_property_add_to_argv(argv_ptr, dle, bsu, g_options->features); for (scriptlist = dle->scriptlist; scriptlist != NULL; scriptlist = scriptlist->next) { script = (script_t *)scriptlist->data; if (script->result && script->result->proplist) { property_add_to_argv(argv_ptr, script->result->proplist); } } g_ptr_array_add(argv_ptr, NULL); cmdline = stralloc(cmd); for(i = 1; i < argv_ptr->len-1; i++) cmdline = vstrextend(&cmdline, " ", (char *)g_ptr_array_index(argv_ptr, i), NULL); dbprintf("running: \"%s\"\n", cmdline); amfree(cmdline); if (pipe(pipeerrfd) < 0) { errmsg = vstrallocf(_("getsize_application_api could not create data pipes: %s"), strerror(errno)); goto common_exit; } if (pipe(pipeinfd) < 0) { errmsg = vstrallocf(_("getsize_application_api could not create data pipes: %s"), strerror(errno)); goto common_exit; } if (pipe(pipeoutfd) < 0) { errmsg = vstrallocf(_("getsize_application_api could not create data pipes: %s"), strerror(errno)); goto common_exit; } start_time = curclock(); switch(dumppid = fork()) { case -1: size = (off_t)-1; goto common_exit; default: break; /* parent */ case 0: dup2(pipeinfd[0], 0); dup2(pipeoutfd[1], 1); dup2(pipeerrfd[1], 2); aclose(pipeinfd[1]); aclose(pipeoutfd[0]); aclose(pipeerrfd[0]); safe_fd(-1, 0); execve(cmd, (char **)argv_ptr->pdata, safe_env()); error(_("exec %s failed: %s"), cmd, strerror(errno)); /*NOTREACHED*/ } amfree(newoptstr); aclose(pipeinfd[0]); aclose(pipeoutfd[1]); aclose(pipeerrfd[1]); aclose(pipeinfd[1]); dumpout = fdopen(pipeoutfd[0],"r"); if (!dumpout) { error(_("Can't fdopen: %s"), strerror(errno)); /*NOTREACHED*/ } for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { long long size1_ = (long long)0; long long size2_ = (long long)0; int level = 0; if (line[0] == '\0') continue; dbprintf("%s\n", line); if (strncmp(line,"ERROR ", 6) == 0) { char *errmsg, *qerrmsg; errmsg = stralloc(line+6); qerrmsg = quote_string(errmsg); dbprintf(_("errmsg is %s\n"), errmsg); g_printf(_("%s %d ERROR %s\n"), est->qamname, levels[0], qerrmsg); amfree(qerrmsg); continue; } i = sscanf(line, "%d %lld %lld", &level, &size1_, &size2_); if (i != 3) { i = sscanf(line, "%lld %lld", &size1_, &size2_); level = levels[0]; if (i != 2) { char *errmsg, *qerrmsg; errmsg = vstrallocf(_("bad line %s"), line); qerrmsg = quote_string(errmsg); dbprintf(_("errmsg is %s\n"), errmsg); g_printf(_("%s %d ERROR %s\n"), est->qamname, levels[0], qerrmsg); amfree(qerrmsg); continue; } } size1 = (off_t)size1_; size2 = (off_t)size2_; if (size1 <= 0 || size2 <=0) size = -1; else if (size1 * size2 > 0) size = size1 * size2; dbprintf(_("estimate size for %s level %d: %lld KB\n"), qamdevice, level, (long long)size); g_printf("%s %d SIZE %lld\n", est->qamname, level, (long long)size); } amfree(line); dumperr = fdopen(pipeerrfd[0],"r"); if (!dumperr) { error(_("Can't fdopen: %s"), strerror(errno)); /*NOTREACHED*/ } while ((line = agets(dumperr)) != NULL) { if (strlen(line) > 0) { char *err = g_strdup_printf(_("Application '%s': %s"), dle->program, line); char *qerr = quote_string(err); for (j=0; j < nb_level; j++) { fprintf(stdout, "%s %d ERROR %s\n", est->qamname, levels[j], qerr); } dbprintf("ERROR %s", qerr); amfree(err); amfree(qerr); } amfree(line); } dbprintf(".....\n"); if (nb_level == 1) { dbprintf(_("estimate time for %s level %d: %s\n"), qamdevice, levels[0], walltime_str(timessub(curclock(), start_time))); } else { dbprintf(_("estimate time for %s all level: %s\n"), qamdevice, walltime_str(timessub(curclock(), start_time))); } kill(-dumppid, SIGTERM); dbprintf(_("waiting for %s \"%s\" child\n"), cmd, qdisk); waitpid(dumppid, &wait_status, 0); if (WIFSIGNALED(wait_status)) { errmsg = vstrallocf(_("%s terminated with signal %d: see %s"), cmd, WTERMSIG(wait_status), dbfn()); } else if (WIFEXITED(wait_status)) { if (WEXITSTATUS(wait_status) != 0) { errmsg = vstrallocf(_("%s exited with status %d: see %s"), cmd, WEXITSTATUS(wait_status), dbfn()); } else { /* Normal exit */ } } else { errmsg = vstrallocf(_("%s got bad exit: see %s"), cmd, dbfn()); } dbprintf(_("after %s %s wait\n"), cmd, qdisk); afclose(dumpout); afclose(dumperr); common_exit: amfree(cmd); g_ptr_array_free_full(argv_ptr); amfree(newoptstr); amfree(qdisk); amfree(qamdevice); if (errmsg) { char *qerrmsg = quote_string(errmsg); dbprintf(_("errmsg is %s\n"), errmsg); for (j=0; j < nb_level; j++) { g_printf(_("%s %d ERROR %s\n"), est->qamname, levels[j], qerrmsg); } amfree(errmsg); amfree(qerrmsg); } return size; }
0
[ "CWE-264" ]
amanda
4bf5b9b356848da98560ffbb3a07a9cb5c4ea6d7
232,886,613,264,353,140,000,000,000,000,000,000,000
260
* Add a /etc/amanda-security.conf file git-svn-id: https://svn.code.sf.net/p/amanda/code/amanda/branches/3_3@6486 a8d146d6-cc15-0410-8900-af154a0219e0
RAW_PUTCHAR(c) int c; { ASSERT(display); #ifdef FONT # ifdef UTF8 if (D_encoding == UTF8) { c = (c & 255) | (unsigned char)D_rend.font << 8 | (unsigned char)D_rend.fontx << 16; # ifdef DW_CHARS if (D_mbcs) { c = D_mbcs; if (D_x == D_width) D_x += D_AM ? 1 : -1; D_mbcs = 0; } else if (utf8_isdouble(c)) { D_mbcs = c; D_x++; return; } # endif if (c < 32) { AddCStr2(D_CS0, '0'); AddChar(c + 0x5f); AddCStr(D_CE0); goto addedutf8; } if (c < 0x80) { if (D_xtable && D_xtable[(int)(unsigned char)D_rend.font] && D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]) AddStr(D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]); else AddChar(c); } else AddUtf8(c); goto addedutf8; } # endif # ifdef DW_CHARS if (is_dw_font(D_rend.font)) { int t = c; if (D_mbcs == 0) { D_mbcs = c; D_x++; return; } D_x--; if (D_x == D_width - 1) D_x += D_AM ? 1 : -1; c = D_mbcs; D_mbcs = t; } # endif # if defined(ENCODINGS) && defined(DW_CHARS) if (D_encoding) c = PrepareEncodedChar(c); # endif # ifdef DW_CHARS kanjiloop: # endif if (D_xtable && D_xtable[(int)(unsigned char)D_rend.font] && D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]) AddStr(D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]); else AddChar(D_rend.font != '0' ? c : D_c0_tab[(int)(unsigned char)c]); #else /* FONT */ AddChar(c); #endif /* FONT */ #ifdef UTF8 addedutf8: #endif if (++D_x >= D_width) { if (D_AM == 0) D_x = D_width - 1; else if (!D_CLP || D_x > D_width) { D_x -= D_width; if (D_y < D_height-1 && D_y != D_bot) D_y++; } } #ifdef DW_CHARS if (D_mbcs) { c = D_mbcs; D_mbcs = 0; goto kanjiloop; } #endif }
0
[]
screen
c5db181b6e017cfccb8d7842ce140e59294d9f62
33,784,156,018,607,585,000,000,000,000,000,000,000
99
ansi: add support for xterm OSC 11 It allows for getting and setting the background color. Notably, Vim uses OSC 11 to learn whether it's running on a light or dark colored terminal and choose a color scheme accordingly. Tested with gnome-terminal and xterm. When called with "?" argument the current background color is returned: $ echo -ne "\e]11;?\e\\" $ 11;rgb:2323/2727/2929 Signed-off-by: Lubomir Rintel <[email protected]> (cherry picked from commit 7059bff20a28778f9d3acf81cad07b1388d02309) Signed-off-by: Amadeusz Sławiński <[email protected]
struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, __be16 dport, int dif) { return __udp6_lib_lookup(net, saddr, sport, daddr, dport, dif, &udp_table); }
0
[ "CWE-20" ]
net
bceaa90240b6019ed73b49965eac7d167610be69
48,813,594,024,600,120,000,000,000,000,000,000,000
5
inet: prevent leakage of uninitialized memory to user in recv syscalls Only update *addr_len when we actually fill in sockaddr, otherwise we can return uninitialized memory from the stack to the caller in the recvfrom, recvmmsg and recvmsg syscalls. Drop the the (addr_len == NULL) checks because we only get called with a valid addr_len pointer either from sock_common_recvmsg or inet_recvmsg. If a blocking read waits on a socket which is concurrently shut down we now return zero and set msg_msgnamelen to 0. Reported-by: mpb <[email protected]> Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void WebPImage::readMetadata() { if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError()); IoCloser closer(*io_); // Ensure that this is the correct image type if (!isWebPType(*io_, true)) { if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData); throw Error(kerNotAJpeg); } clearMetadata(); byte data[12]; DataBuf chunkId(5); chunkId.pData_[4] = '\0' ; io_->read(data, WEBP_TAG_SIZE * 3); const uint32_t filesize = Exiv2::getULong(data + WEBP_TAG_SIZE, littleEndian) + 8; enforce(filesize <= io_->size(), Exiv2::kerCorruptedMetadata); WebPImage::decodeChunks(filesize); } // WebPImage::readMetadata
1
[ "CWE-190" ]
exiv2
c73d1e27198a389ce7caf52ac30f8e2120acdafd
160,787,766,558,744,150,000,000,000,000,000,000,000
22
Avoid negative integer overflow when `filesize < io_->tell()`. This fixes #791.
bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option) { bool res; SELECT_LEX *select_lex = &lex->select_lex; DBUG_ENTER("handle_select"); MYSQL_SELECT_START(thd->query()); if (select_lex->master_unit()->is_union() || select_lex->master_unit()->fake_select_lex) res= mysql_union(thd, lex, result, &lex->unit, setup_tables_done_option); else { SELECT_LEX_UNIT *unit= &lex->unit; unit->set_limit(unit->global_parameters()); /* 'options' of mysql_select will be set in JOIN, as far as JOIN for every PS/SP execution new, we will not need reset this flag if setup_tables_done_option changed for next rexecution */ res= mysql_select(thd, select_lex->table_list.first, select_lex->with_wild, select_lex->item_list, select_lex->where, select_lex->order_list.elements + select_lex->group_list.elements, select_lex->order_list.first, select_lex->group_list.first, select_lex->having, lex->proc_list.first, select_lex->options | thd->variables.option_bits | setup_tables_done_option, result, unit, select_lex); } DBUG_PRINT("info",("res: %d report_error: %d", res, thd->is_error())); res|= thd->is_error(); if (unlikely(res)) result->abort_result_set(); if (thd->killed == ABORT_QUERY) { /* If LIMIT ROWS EXAMINED interrupted query execution, issue a warning, continue with normal processing and produce an incomplete query result. */ bool saved_abort_on_warning= thd->abort_on_warning; thd->abort_on_warning= false; push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT, ER_THD(thd, ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT), thd->accessed_rows_and_keys, thd->lex->limit_rows_examined->val_uint()); thd->abort_on_warning= saved_abort_on_warning; thd->reset_killed(); } /* Disable LIMIT ROWS EXAMINED after query execution. */ thd->lex->limit_rows_examined_cnt= ULONGLONG_MAX; MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows); DBUG_RETURN(res); }
0
[ "CWE-89" ]
server
5ba77222e9fe7af8ff403816b5338b18b342053c
306,961,298,427,324,150,000,000,000,000,000,000,000
61
MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view if the view has algorithm=temptable it is not updatable, so DEFAULT() for its fields is meaningless, and thus it's NULL or 0/'' for NOT NULL columns.
static void virtio_net_tx_complete(NetClientState *nc, ssize_t len) { VirtIONet *n = qemu_get_nic_opaque(nc); VirtIONetQueue *q = virtio_net_get_subqueue(nc); VirtIODevice *vdev = VIRTIO_DEVICE(n); virtqueue_push(q->tx_vq, &q->async_tx.elem, 0); virtio_notify(vdev, q->tx_vq); q->async_tx.elem.out_num = q->async_tx.len = 0; virtio_queue_set_notification(q->tx_vq, 1); virtio_net_flush_tx(q); }
0
[ "CWE-119" ]
qemu
98f93ddd84800f207889491e0b5d851386b459cf
37,432,523,511,765,000,000,000,000,000,000,000,000
14
virtio-net: out-of-bounds buffer write on load CVE-2013-4149 QEMU 1.3.0 out-of-bounds buffer write in virtio_net_load()@hw/net/virtio-net.c > } else if (n->mac_table.in_use) { > uint8_t *buf = g_malloc0(n->mac_table.in_use); We are allocating buffer of size n->mac_table.in_use > qemu_get_buffer(f, buf, n->mac_table.in_use * ETH_ALEN); and read to the n->mac_table.in_use size buffer n->mac_table.in_use * ETH_ALEN bytes, corrupting memory. If adversary controls state then memory written there is controlled by adversary. Reviewed-by: Michael Roth <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Juan Quintela <[email protected]>
static int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c) { return fp_div_d(a, b, NULL, c); }
0
[ "CWE-326", "CWE-203" ]
wolfssl
1de07da61f0c8e9926dcbd68119f73230dae283f
194,016,163,872,571,560,000,000,000,000,000,000,000
4
Constant time EC map to affine for private operations For fast math, use a constant time modular inverse when mapping to affine when operation involves a private key - key gen, calc shared secret, sign.
xfs_ioc_inumbers( struct xfs_mount *mp, unsigned int cmd, struct xfs_inumbers_req __user *arg) { struct xfs_bulk_ireq hdr; struct xfs_ibulk breq = { .mp = mp, }; int error; if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (xfs_is_shutdown(mp)) return -EIO; if (copy_from_user(&hdr, &arg->hdr, sizeof(hdr))) return -EFAULT; error = xfs_bulk_ireq_setup(mp, &hdr, &breq, arg->inumbers); if (error == -ECANCELED) goto out_teardown; if (error < 0) return error; error = xfs_inumbers(&breq, xfs_inumbers_fmt); if (error) return error; out_teardown: xfs_bulk_ireq_teardown(&hdr, &breq); if (copy_to_user(&arg->hdr, &hdr, sizeof(hdr))) return -EFAULT; return 0; }
0
[ "CWE-125" ]
linux
983d8e60f50806f90534cc5373d0ce867e5aaf79
297,512,556,692,573,750,000,000,000,000,000,000,000
37
xfs: map unwritten blocks in XFS_IOC_{ALLOC,FREE}SP just like fallocate The old ALLOCSP/FREESP ioctls in XFS can be used to preallocate space at the end of files, just like fallocate and RESVSP. Make the behavior consistent with the other ioctls. Reported-by: Kirill Tkhai <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Eric Sandeen <[email protected]>
static const char *ctxload_probe_data(const u8 *probe_data, u32 size, GF_FilterProbeScore *score) { const char *mime_type = NULL; char *dst = NULL; u8 *res; /* check gzip magic header */ if ((size>2) && (probe_data[0] == 0x1f) && (probe_data[1] == 0x8b)) { *score = GF_FPROBE_EXT_MATCH; return "btz|bt.gz|xmt.gz|xmtz|wrl.gz|x3dv.gz|x3dvz|x3d.gz|x3dz"; } res = gf_utf_get_utf8_string_from_bom((char *)probe_data, size, &dst); if (res) probe_data = res; //strip all spaces and \r\n while (probe_data[0] && strchr("\n\r\t ", (char) probe_data[0])) probe_data ++; //for XML, strip doctype, <?xml and comments while (1) { if (!strncmp(probe_data, "<!DOCTYPE", 9)) { probe_data = strchr(probe_data, '>'); if (!probe_data) goto exit; probe_data++; while (probe_data[0] && strchr("\n\r\t ", (char) probe_data[0])) probe_data ++; } //for XML, strip xml header else if (!strncmp(probe_data, "<?xml", 5)) { probe_data = strstr(probe_data, "?>"); if (!probe_data) goto exit; probe_data += 2; while (probe_data[0] && strchr("\n\r\t ", (char) probe_data[0])) probe_data ++; } else if (!strncmp(probe_data, "<!--", 4)) { probe_data = strstr(probe_data, "-->"); if (!probe_data) goto exit; probe_data += 3; while (probe_data[0] && strchr("\n\r\t ", (char) probe_data[0])) probe_data ++; } else { break; } } //probe_data is now the first element of the document, if XML //we should refin by getting the xmlns attribute value rather than searching for its value... if (!strncmp(probe_data, "<XMT-A", strlen("<XMT-A")) || strstr(probe_data, "urn:mpeg:mpeg4:xmta:schema:2002") ) { mime_type = "application/x-xmt"; } else if (strstr(probe_data, "<X3D") || strstr(probe_data, "http://www.web3d.org/specifications/x3d-3.0.xsd") ) { mime_type = "model/x3d+xml"; } else if (strstr(probe_data, "<saf") || strstr(probe_data, "urn:mpeg:mpeg4:SAF:2005") || strstr(probe_data, "urn:mpeg:mpeg4:LASeR:2005") ) { mime_type = "application/x-LASeR+xml"; } else if (!strncmp(probe_data, "<DIMSStream", strlen("<DIMSStream") ) ) { mime_type = "application/dims"; } else if (!strncmp(probe_data, "<svg", 4) || strstr(probe_data, "http://www.w3.org/2000/svg") ) { mime_type = "image/svg+xml"; } else if (!strncmp(probe_data, "<widget", strlen("<widget") ) ) { mime_type = "application/widget"; } else if (!strncmp(probe_data, "<NHNTStream", strlen("<NHNTStream") ) ) { mime_type = "application/x-nhml"; } else if (!strncmp(probe_data, "<TextStream", strlen("<TextStream") ) ) { mime_type = "text/ttxt"; } else if (!strncmp(probe_data, "<text3GTrack", strlen("<text3GTrack") ) ) { mime_type = "quicktime/text"; } //BT/VRML with no doc header else { //get first keyword while (1) { //strip all spaces and \r\n while (probe_data[0] && strchr("\n\r\t ", (char) probe_data[0])) probe_data ++; //VRML / XRDV files if (!strncmp(probe_data, "#VRML V2.0", strlen("#VRML V2.0"))) { mime_type = "model/vrml"; goto exit; } if (!strncmp(probe_data, "#X3D V3.0", strlen("#X3D V3.0"))) { mime_type = "model/x3d+vrml"; goto exit; } //skip comment lines and some specific X3D keyword (we want to fetch a group if ((probe_data[0] != '#') && strncmp(probe_data, "PROFILE", strlen("PROFILE")) && strncmp(probe_data, "COMPONENT", strlen("COMPONENT")) && strncmp(probe_data, "META", strlen("META")) && strncmp(probe_data, "IMPORT", strlen("IMPORT")) && strncmp(probe_data, "EXPORT", strlen("EXPORT")) ) { break; } //skip line and go one probe_data = strchr(probe_data, '\n'); if (!probe_data) goto exit; } if (!strncmp(probe_data, "InitialObjectDescriptor", strlen("InitialObjectDescriptor")) || !strncmp(probe_data, "EXTERNPROTO", strlen("EXTERNPROTO")) || !strncmp(probe_data, "PROTO", strlen("PROTO")) || !strncmp(probe_data, "Group", strlen("Group")) || !strncmp(probe_data, "OrderedGroup", strlen("OrderedGroup")) || !strncmp(probe_data, "Layer2D", strlen("Layer2D")) || !strncmp(probe_data, "Layer3D", strlen("Layer3D")) ) { if (strstr(probe_data, "children")) mime_type = "application/x-bt"; } } exit: if (dst) gf_free(dst); if (mime_type) { *score = GF_FPROBE_MAYBE_SUPPORTED; return mime_type; } *score = GF_FPROBE_NOT_SUPPORTED; return NULL; }
1
[ "CWE-276" ]
gpac
96699aabae042f8f55cf8a85fa5758e3db752bae
53,395,394,904,337,960,000,000,000,000,000,000,000
134
fixed #2061
static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result, u16 flags) { struct l2cap_conf_rsp *rsp = data; void *ptr = rsp->data; BT_DBG("chan %p", chan); rsp->scid = cpu_to_le16(chan->dcid); rsp->result = cpu_to_le16(result); rsp->flags = cpu_to_le16(flags); return ptr - data; }
0
[ "CWE-787" ]
linux
e860d2c904d1a9f38a24eb44c9f34b8f915a6ea3
87,779,188,529,018,020,000,000,000,000,000,000,000
14
Bluetooth: Properly check L2CAP config option output buffer length Validate the output buffer length for L2CAP config requests and responses to avoid overflowing the stack buffer used for building the option blocks. Cc: [email protected] Signed-off-by: Ben Seri <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void ext4_da_page_release_reservation(struct page *page, unsigned long offset) { int to_release = 0; struct buffer_head *head, *bh; unsigned int curr_off = 0; head = page_buffers(page); bh = head; do { unsigned int next_off = curr_off + bh->b_size; if ((offset <= curr_off) && (buffer_delay(bh))) { to_release++; clear_buffer_delay(bh); } curr_off = next_off; } while ((bh = bh->b_this_page) != head); ext4_da_release_space(page->mapping->host, to_release); }
0
[ "CWE-399" ]
linux-2.6
06a279d636734da32bb62dd2f7b0ade666f65d7c
34,636,291,986,542,837,000,000,000,000,000,000,000
20
ext4: only use i_size_high for regular files Directories are not allowed to be bigger than 2GB, so don't use i_size_high for anything other than regular files. E2fsck should complain about these inodes, but the simplest thing to do for the kernel is to only use i_size_high for regular files. This prevents an intentially corrupted filesystem from causing the kernel to burn a huge amount of CPU and issuing error messages such as: EXT4-fs warning (device loop0): ext4_block_to_path: block 135090028 > max Thanks to David Maciejak from Fortinet's FortiGuard Global Security Research Team for reporting this issue. http://bugzilla.kernel.org/show_bug.cgi?id=12375 Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: [email protected]
span_renderer_fini (cairo_abstract_span_renderer_t *_r, cairo_int_status_t status) { cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *) _r; TRACE ((stderr, "%s\n", __FUNCTION__)); if (likely (status == CAIRO_INT_STATUS_SUCCESS)) { if (r->base.finish) r->base.finish (r); } if (likely (status == CAIRO_INT_STATUS_SUCCESS && r->bpp == 0)) { const cairo_composite_rectangles_t *composite = r->composite; pixman_image_composite32 (r->op, r->src, r->mask, to_pixman_image (composite->surface), composite->unbounded.x + r->u.mask.src_x, composite->unbounded.y + r->u.mask.src_y, 0, 0, composite->unbounded.x, composite->unbounded.y, composite->unbounded.width, composite->unbounded.height); } if (r->src) pixman_image_unref (r->src); if (r->mask) pixman_image_unref (r->mask); }
0
[]
cairo
03a820b173ed1fdef6ff14b4468f5dbc02ff59be
51,142,016,846,399,070,000,000,000,000,000,000,000
30
Fix mask usage in image-compositor
static inline int open_to_namei_flags(int flag) { if ((flag+1) & O_ACCMODE) flag++; return flag; }
0
[ "CWE-120" ]
linux-2.6
d70b67c8bc72ee23b55381bd6a884f4796692f77
134,781,373,985,387,470,000,000,000,000,000,000,000
6
[patch] vfs: fix lookup on deleted directory Lookup can install a child dentry for a deleted directory. This keeps the directory dentry alive, and the inode pinned in the cache and on disk, even after all external references have gone away. This isn't a big problem normally, since memory pressure or umount will clear out the directory dentry and its children, releasing the inode. But for UBIFS this causes problems because its orphan area can overflow. Fix this by returning ENOENT for all lookups on a S_DEAD directory before creating a child dentry. Thanks to Zoltan Sogor for noticing this while testing UBIFS, and Artem for the excellent analysis of the problem and testing. Reported-by: Artem Bityutskiy <[email protected]> Tested-by: Artem Bityutskiy <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Signed-off-by: Al Viro <[email protected]>
server_add_char(struct xrdp_mod* mod, int font, int charactor, int offset, int baseline, int width, int height, char* data) { struct xrdp_font_char fi; fi.offset = offset; fi.baseline = baseline; fi.width = width; fi.height = height; fi.incby = 0; fi.data = data; return libxrdp_orders_send_font(((struct xrdp_wm*)mod->wm)->session, &fi, font, charactor); }
0
[]
xrdp
d8f9e8310dac362bb9578763d1024178f94f4ecc
1,603,172,997,808,457,800,000,000,000,000,000,000
15
move temp files from /tmp to /tmp/.xrdp