project
stringclasses
788 values
commit_id
stringlengths
6
81
CVE ID
stringlengths
13
16
CWE ID
stringclasses
126 values
func
stringlengths
14
482k
vul
int8
0
1
openssl
fa57f74a3941db6b2efb2f43c6add914ec83db20
NOT_APPLICABLE
NOT_APPLICABLE
static int check_policy(X509_STORE_CTX *ctx) { int ret; ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain, ctx->param->policies, ctx->param->flags); if (ret == 0) { X509err(X509_F_CHECK_POLICY, ERR_R_MALLOC_FAILURE); return 0; } /* Invalid or inconsistent extensions */ if (ret == -1) { /* * Locate certificates with bad extensions and notify callback. */ X509 *x; int i; for (i = 1; i < sk_X509_num(ctx->chain); i++) { x = sk_X509_value(ctx->chain, i); if (!(x->ex_flags & EXFLAG_INVALID_POLICY)) continue; ctx->current_cert = x; ctx->error = X509_V_ERR_INVALID_POLICY_EXTENSION; ret = ctx->verify_cb(0, ctx); } return 1; } if (ret == -2) { ctx->current_cert = NULL; ctx->error = X509_V_ERR_NO_EXPLICIT_POLICY; return ctx->verify_cb(0, ctx); } if (ctx->param->flags & X509_V_FLAG_NOTIFY_POLICY) { ctx->current_cert = NULL; ctx->error = X509_V_OK; if (!ctx->verify_cb(2, ctx)) return 0; } return 1; }
0
linux
1e38da300e1e395a15048b0af1e5305bd91402f6
NOT_APPLICABLE
NOT_APPLICABLE
static void timerfd_show(struct seq_file *m, struct file *file) { struct timerfd_ctx *ctx = file->private_data; struct itimerspec t; spin_lock_irq(&ctx->wqh.lock); t.it_value = ktime_to_timespec(timerfd_get_remaining(ctx)); t.it_interval = ktime_to_timespec(ctx->tintv); spin_unlock_irq(&ctx->wqh.lock); seq_printf(m, "clockid: %d\n" "ticks: %llu\n" "settime flags: 0%o\n" "it_value: (%llu, %llu)\n" "it_interval: (%llu, %llu)\n", ctx->clockid, (unsigned long long)ctx->ticks, ctx->settime_flags, (unsigned long long)t.it_value.tv_sec, (unsigned long long)t.it_value.tv_nsec, (unsigned long long)t.it_interval.tv_sec, (unsigned long long)t.it_interval.tv_nsec); }
0
u-boot
8f8c04bf1ebbd2f72f1643e7ad9617dafa6e5409
NOT_APPLICABLE
NOT_APPLICABLE
static int do_i2c_write(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { uint chip; uint devaddr, length; uint alen; u_char *memaddr; int ret; #if CONFIG_IS_ENABLED(DM_I2C) struct udevice *dev; struct dm_i2c_chip *i2c_chip; #endif if ((argc < 5) || (argc > 6)) return cmd_usage(cmdtp); /* * memaddr is the address where to store things in memory */ memaddr = (u_char *)hextoul(argv[1], NULL); /* * I2C chip address */ chip = hextoul(argv[2], NULL); /* * I2C data address within the chip. This can be 1 or * 2 bytes long. Some day it might be 3 bytes long :-). */ devaddr = hextoul(argv[3], NULL); alen = get_alen(argv[3], DEFAULT_ADDR_LEN); if (alen > 3) return cmd_usage(cmdtp); /* * Length is the number of bytes. */ length = hextoul(argv[4], NULL); #if CONFIG_IS_ENABLED(DM_I2C) ret = i2c_get_cur_bus_chip(chip, &dev); if (!ret && alen != -1) ret = i2c_set_chip_offset_len(dev, alen); if (ret) return i2c_report_err(ret, I2C_ERR_WRITE); i2c_chip = dev_get_parent_plat(dev); if (!i2c_chip) return i2c_report_err(ret, I2C_ERR_WRITE); #endif if (argc == 6 && !strcmp(argv[5], "-s")) { /* * Write all bytes in a single I2C transaction. If the target * device is an EEPROM, it is your responsibility to not cross * a page boundary. No write delay upon completion, take this * into account if linking commands. */ #if CONFIG_IS_ENABLED(DM_I2C) i2c_chip->flags &= ~DM_I2C_CHIP_WR_ADDRESS; ret = dm_i2c_write(dev, devaddr, memaddr, length); #else ret = i2c_write(chip, devaddr, alen, memaddr, length); #endif if (ret) return i2c_report_err(ret, I2C_ERR_WRITE); } else { /* * Repeated addressing - perform <length> separate * write transactions of one byte each */ while (length-- > 0) { #if CONFIG_IS_ENABLED(DM_I2C) i2c_chip->flags |= DM_I2C_CHIP_WR_ADDRESS; ret = dm_i2c_write(dev, devaddr++, memaddr++, 1); #else ret = i2c_write(chip, devaddr++, alen, memaddr++, 1); #endif if (ret) return i2c_report_err(ret, I2C_ERR_WRITE); /* * No write delay with FRAM devices. */ #if !defined(CONFIG_SYS_I2C_FRAM) udelay(11000); #endif } } return 0; }
0
php
1291d6bbee93b6109eb07e8f7916ff1b7fcc13e1
NOT_APPLICABLE
NOT_APPLICABLE
PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC) /* {{{ */ { php_stream *stream = NULL; switch (opt_err) { case 1: /*send an email */ if (!php_mail(opt, "PHP error_log message", message, headers, NULL TSRMLS_CC)) { return FAILURE; } break; case 2: /*send to an address */ php_error_docref(NULL TSRMLS_CC, E_WARNING, "TCP/IP option not available!"); return FAILURE; break; case 3: /*save to a file */ stream = php_stream_open_wrapper(opt, "a", IGNORE_URL_WIN | REPORT_ERRORS, NULL); if (!stream) { return FAILURE; } php_stream_write(stream, message, message_len); php_stream_close(stream); break; case 4: /* send to SAPI */ if (sapi_module.log_message) { sapi_module.log_message(message TSRMLS_CC); } else { return FAILURE; } break; default: php_log_err(message TSRMLS_CC); break; } return SUCCESS; } /* }}} */
0
Android
cc274e2abe8b2a6698a5c47d8aa4bb45f1f9538d
CVE-2016-2464
CWE-20
const CuePoint* Cues::GetFirst() const { if (m_cue_points == NULL) return NULL; if (m_count == 0) return NULL; #if 0 LoadCuePoint(); //init cues const size_t count = m_count + m_preload_count; if (count == 0) //weird return NULL; #endif CuePoint* const* const pp = m_cue_points; assert(pp); CuePoint* const pCP = pp[0]; assert(pCP); assert(pCP->GetTimeCode() >= 0); return pCP; }
1
guile
245608911698adb3472803856019bdd5670b6614
NOT_APPLICABLE
NOT_APPLICABLE
SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, 0, (), "Return the name of the current working directory.") #define FUNC_NAME s_scm_getcwd { char *rv; size_t size = 100; char *wd; SCM result; wd = scm_malloc (size); while ((rv = getcwd (wd, size)) == 0 && errno == ERANGE) { free (wd); size *= 2; wd = scm_malloc (size); } if (rv == 0) { int save_errno = errno; free (wd); errno = save_errno; SCM_SYSERROR; } /* On Windows, convert backslashes in current directory to forward slashes. */ scm_i_mirror_backslashes (wd); result = scm_from_locale_stringn (wd, strlen (wd)); free (wd); return result; }
0
savannah
83a95bd8c8561875b948cadd417c653dbe7ef2e2
NOT_APPLICABLE
NOT_APPLICABLE
cwexec (kwset_t kwset, char const *text, size_t len, struct kwsmatch *kwsmatch) { struct trie * const *next; struct trie const *trie; struct trie const *accept; char const *beg, *lim, *mch, *lmch; unsigned char c; unsigned char const *delta; int d; char const *end, *qlim; struct tree const *tree; char const *trans; #ifdef lint accept = NULL; #endif /* Initialize register copies and look for easy ways out. */ if (len < kwset->mind) return -1; next = kwset->next; delta = kwset->delta; trans = kwset->trans; lim = text + len; end = text; if ((d = kwset->mind) != 0) mch = NULL; else { mch = text, accept = kwset->trie; goto match; } if (len >= 4 * kwset->mind) qlim = lim - 4 * kwset->mind; else qlim = NULL; while (lim - end >= d) { if (qlim && end <= qlim) { end += d - 1; while ((d = delta[c = *end]) && end < qlim) { end += d; end += delta[U(*end)]; end += delta[U(*end)]; } ++end; } else d = delta[c = (end += d)[-1]]; if (d) continue; beg = end - 1; trie = next[c]; if (trie->accepting) { mch = beg; accept = trie; } d = trie->shift; while (beg > text) { unsigned char uc = *--beg; c = trans ? trans[uc] : uc; tree = trie->links; while (tree && c != tree->label) if (c < tree->label) tree = tree->llink; else tree = tree->rlink; if (tree) { trie = tree->trie; if (trie->accepting) { mch = beg; accept = trie; } } else break; d = trie->shift; } if (mch) goto match; } return -1; match: /* Given a known match, find the longest possible match anchored at or before its starting point. This is nearly a verbatim copy of the preceding main search loops. */ if (lim - mch > kwset->maxd) lim = mch + kwset->maxd; lmch = 0; d = 1; while (lim - end >= d) { if ((d = delta[c = (end += d)[-1]]) != 0) continue; beg = end - 1; if (!(trie = next[c])) { d = 1; continue; } if (trie->accepting && beg <= mch) { lmch = beg; accept = trie; } d = trie->shift; while (beg > text) { unsigned char uc = *--beg; c = trans ? trans[uc] : uc; tree = trie->links; while (tree && c != tree->label) if (c < tree->label) tree = tree->llink; else tree = tree->rlink; if (tree) { trie = tree->trie; if (trie->accepting && beg <= mch) { lmch = beg; accept = trie; } } else break; d = trie->shift; } if (lmch) { mch = lmch; goto match; } if (!d) d = 1; } kwsmatch->index = accept->accepting / 2; kwsmatch->offset[0] = mch - text; kwsmatch->size[0] = accept->depth; return mch - text; }
0
Chrome
c0c8978849ac57e4ecd613ddc8ff7852a2054734
CVE-2018-6057
CWE-732
PlatformSensorWin::PlatformSensorWin( mojom::SensorType type, mojo::ScopedSharedBufferMapping mapping, PlatformSensorProvider* provider, scoped_refptr<base::SingleThreadTaskRunner> sensor_thread_runner, std::unique_ptr<PlatformSensorReaderWin> sensor_reader) : PlatformSensor(type, std::move(mapping), provider), sensor_thread_runner_(sensor_thread_runner), sensor_reader_(sensor_reader.release()), weak_factory_(this) { DCHECK(sensor_reader_); sensor_reader_->SetClient(this); }
1
linux
bc0c4d1e176eeb614dc8734fc3ace34292771f11
NOT_APPLICABLE
NOT_APPLICABLE
static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { struct madvise_walk_private *private = walk->private; struct mmu_gather *tlb = private->tlb; bool pageout = private->pageout; struct mm_struct *mm = tlb->mm; struct vm_area_struct *vma = walk->vma; pte_t *orig_pte, *pte, ptent; spinlock_t *ptl; struct page *page = NULL; LIST_HEAD(page_list); if (fatal_signal_pending(current)) return -EINTR; #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (pmd_trans_huge(*pmd)) { pmd_t orig_pmd; unsigned long next = pmd_addr_end(addr, end); tlb_change_page_size(tlb, HPAGE_PMD_SIZE); ptl = pmd_trans_huge_lock(pmd, vma); if (!ptl) return 0; orig_pmd = *pmd; if (is_huge_zero_pmd(orig_pmd)) goto huge_unlock; if (unlikely(!pmd_present(orig_pmd))) { VM_BUG_ON(thp_migration_supported() && !is_pmd_migration_entry(orig_pmd)); goto huge_unlock; } page = pmd_page(orig_pmd); /* Do not interfere with other mappings of this page */ if (page_mapcount(page) != 1) goto huge_unlock; if (next - addr != HPAGE_PMD_SIZE) { int err; get_page(page); spin_unlock(ptl); lock_page(page); err = split_huge_page(page); unlock_page(page); put_page(page); if (!err) goto regular_page; return 0; } if (pmd_young(orig_pmd)) { pmdp_invalidate(vma, addr, pmd); orig_pmd = pmd_mkold(orig_pmd); set_pmd_at(mm, addr, pmd, orig_pmd); tlb_remove_pmd_tlb_entry(tlb, pmd, addr); } ClearPageReferenced(page); test_and_clear_page_young(page); if (pageout) { if (!isolate_lru_page(page)) { if (PageUnevictable(page)) putback_lru_page(page); else list_add(&page->lru, &page_list); } } else deactivate_page(page); huge_unlock: spin_unlock(ptl); if (pageout) reclaim_pages(&page_list); return 0; } if (pmd_trans_unstable(pmd)) return 0; regular_page: #endif tlb_change_page_size(tlb, PAGE_SIZE); orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); flush_tlb_batched_pending(mm); arch_enter_lazy_mmu_mode(); for (; addr < end; pte++, addr += PAGE_SIZE) { ptent = *pte; if (pte_none(ptent)) continue; if (!pte_present(ptent)) continue; page = vm_normal_page(vma, addr, ptent); if (!page) continue; /* * Creating a THP page is expensive so split it only if we * are sure it's worth. Split it if we are only owner. */ if (PageTransCompound(page)) { if (page_mapcount(page) != 1) break; get_page(page); if (!trylock_page(page)) { put_page(page); break; } pte_unmap_unlock(orig_pte, ptl); if (split_huge_page(page)) { unlock_page(page); put_page(page); pte_offset_map_lock(mm, pmd, addr, &ptl); break; } unlock_page(page); put_page(page); pte = pte_offset_map_lock(mm, pmd, addr, &ptl); pte--; addr -= PAGE_SIZE; continue; } /* Do not interfere with other mappings of this page */ if (page_mapcount(page) != 1) continue; VM_BUG_ON_PAGE(PageTransCompound(page), page); if (pte_young(ptent)) { ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); ptent = pte_mkold(ptent); set_pte_at(mm, addr, pte, ptent); tlb_remove_tlb_entry(tlb, pte, addr); } /* * We are deactivating a page for accelerating reclaiming. * VM couldn't reclaim the page unless we clear PG_young. * As a side effect, it makes confuse idle-page tracking * because they will miss recent referenced history. */ ClearPageReferenced(page); test_and_clear_page_young(page); if (pageout) { if (!isolate_lru_page(page)) { if (PageUnevictable(page)) putback_lru_page(page); else list_add(&page->lru, &page_list); } } else deactivate_page(page); } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); if (pageout) reclaim_pages(&page_list); cond_resched(); return 0; }
0
ImageMagick
edc7d3035883ddca8413e4fe7689aa2e579ef04a
NOT_APPLICABLE
NOT_APPLICABLE
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length,const char *magick_restrict format,...) { ssize_t n; va_list operands; va_start(operands,format); n=FormatLocaleStringList(string,length,format,operands); va_end(operands); return(n); }
0
openssl
1b4a8df38fc9ab3c089ca5765075ee53ec5bd66a
NOT_APPLICABLE
NOT_APPLICABLE
static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *group, ECPARAMETERS *param) { int ok = 0; size_t len = 0; ECPARAMETERS *ret = NULL; BIGNUM *tmp = NULL; unsigned char *buffer = NULL; const EC_POINT *point = NULL; point_conversion_form_t form; if ((tmp = BN_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } if (param == NULL) { if ((ret = ECPARAMETERS_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } } else ret = param; /* set the version (always one) */ ret->version = (long)0x1; /* set the fieldID */ if (!ec_asn1_group2fieldid(group, ret->fieldID)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } /* set the curve */ if (!ec_asn1_group2curve(group, ret->curve)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } /* set the base point */ if ((point = EC_GROUP_get0_generator(group)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, EC_R_UNDEFINED_GENERATOR); goto err; } form = EC_GROUP_get_point_conversion_form(group); len = EC_POINT_point2oct(group, point, form, NULL, len, NULL); if (len == 0) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } if ((buffer = OPENSSL_malloc(len)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_POINT_point2oct(group, point, form, buffer, len, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } if (ret->base == NULL && (ret->base = ASN1_OCTET_STRING_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_OCTET_STRING_set(ret->base, buffer, len)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } /* set the order */ if (!EC_GROUP_get_order(group, tmp, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } ret->order = BN_to_ASN1_INTEGER(tmp, ret->order); if (ret->order == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } /* set the cofactor (optional) */ if (EC_GROUP_get_cofactor(group, tmp, NULL)) { ret->cofactor = BN_to_ASN1_INTEGER(tmp, ret->cofactor); if (ret->cofactor == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } } ok = 1; err:if (!ok) { if (ret && !param) ECPARAMETERS_free(ret); ret = NULL; } if (tmp) BN_free(tmp); if (buffer) OPENSSL_free(buffer); return (ret); }
0
linux
4a9d46a9fe14401f21df69cea97c62396d5fb053
NOT_APPLICABLE
NOT_APPLICABLE
int bnxt_re_query_gid(struct ib_device *ibdev, u8 port_num, int index, union ib_gid *gid) { struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev); int rc = 0; /* Ignore port_num */ memset(gid, 0, sizeof(*gid)); rc = bnxt_qplib_get_sgid(&rdev->qplib_res, &rdev->qplib_res.sgid_tbl, index, (struct bnxt_qplib_gid *)gid); return rc; }
0
linux
5233252fce714053f0151680933571a2da9cbfb4
NOT_APPLICABLE
NOT_APPLICABLE
int __init sco_init(void) { int err; BUILD_BUG_ON(sizeof(struct sockaddr_sco) > sizeof(struct sockaddr)); err = proto_register(&sco_proto, 0); if (err < 0) return err; err = bt_sock_register(BTPROTO_SCO, &sco_sock_family_ops); if (err < 0) { BT_ERR("SCO socket registration failed"); goto error; } err = bt_procfs_init(&init_net, "sco", &sco_sk_list, NULL); if (err < 0) { BT_ERR("Failed to create SCO proc file"); bt_sock_unregister(BTPROTO_SCO); goto error; } BT_INFO("SCO socket layer initialized"); hci_register_cb(&sco_cb); if (IS_ERR_OR_NULL(bt_debugfs)) return 0; sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs, NULL, &sco_debugfs_fops); return 0; error: proto_unregister(&sco_proto); return err; }
0
EternalTerminal
900348bb8bc96e1c7ba4888ac8480f643c43d3c3
NOT_APPLICABLE
NOT_APPLICABLE
el::Configurations LogHandler::setupLogHandler(int *argc, char ***argv) { // easylogging parse verbose arguments, see [Application Arguments] // in https://github.com/muflihun/easyloggingpp/blob/master/README.md START_EASYLOGGINGPP(*argc, *argv); // Easylogging configurations el::Configurations defaultConf; defaultConf.setToDefault(); // doc says %thread_name, but %thread is the right one defaultConf.setGlobally(el::ConfigurationType::Format, "[%level %datetime %thread %fbase:%line] %msg"); defaultConf.setGlobally(el::ConfigurationType::Enabled, "true"); defaultConf.setGlobally(el::ConfigurationType::SubsecondPrecision, "3"); defaultConf.setGlobally(el::ConfigurationType::PerformanceTracking, "false"); defaultConf.setGlobally(el::ConfigurationType::LogFlushThreshold, "1"); defaultConf.set(el::Level::Verbose, el::ConfigurationType::Format, "[%levshort%vlevel %datetime %thread %fbase:%line] %msg"); return defaultConf; }
0
libXrender
9362c7ddd1af3b168953d0737877bc52d79c94f4
NOT_APPLICABLE
NOT_APPLICABLE
XRenderDepthCheckErrorHandler (Display *dpy, XErrorEvent *evt) { if (evt->request_code == X_CreatePixmap && evt->error_code == BadValue) { DepthCheckPtr d; _XLockMutex(_Xglobal_lock); for (d = depthChecks; d; d = d->next) if (d->dpy == dpy) { if ((long) (evt->serial - d->serial) >= 0) d->missing |= DEPTH_MASK(evt->resourceid); break; } _XUnlockMutex (_Xglobal_lock); } return 0; }
0
qemu
940973ae0b45c9b6817bab8e4cf4df99a9ef83d7
NOT_APPLICABLE
NOT_APPLICABLE
static void ide_trim_bh_cb(void *opaque) { TrimAIOCB *iocb = opaque; iocb->common.cb(iocb->common.opaque, iocb->ret); qemu_bh_delete(iocb->bh); iocb->bh = NULL; qemu_aio_release(iocb); }
0
mod_auth_openidc
03e6bfb446f4e3f27c003d30d6a433e5dd8e2b3d
NOT_APPLICABLE
NOT_APPLICABLE
static int oidc_handle_logout_request(request_rec *r, oidc_cfg *c, oidc_session_t *session, const char *url) { oidc_debug(r, "enter (url=%s)", url); /* if there's no remote_user then there's no (stored) session to kill */ if (session->remote_user != NULL) oidc_revoke_tokens(r, c, session); /* * remove session state (cq. cache entry and cookie) * always clear the session cookie because the cookie may be not sent (but still in the browser) * due to SameSite policies */ oidc_session_kill(r, session); /* see if this is the OP calling us */ if (oidc_is_front_channel_logout(url)) { /* set recommended cache control headers */ oidc_util_hdr_err_out_add(r, OIDC_HTTP_HDR_CACHE_CONTROL, "no-cache, no-store"); oidc_util_hdr_err_out_add(r, OIDC_HTTP_HDR_PRAGMA, "no-cache"); oidc_util_hdr_err_out_add(r, OIDC_HTTP_HDR_P3P, "CAO PSA OUR"); oidc_util_hdr_err_out_add(r, OIDC_HTTP_HDR_EXPIRES, "0"); oidc_util_hdr_err_out_add(r, OIDC_HTTP_HDR_X_FRAME_OPTIONS, "DENY"); /* see if this is PF-PA style logout in which case we return a transparent pixel */ const char *accept = oidc_util_hdr_in_accept_get(r); if ((apr_strnatcmp(url, OIDC_IMG_STYLE_LOGOUT_PARAM_VALUE) == 0) || ((accept) && strstr(accept, OIDC_CONTENT_TYPE_IMAGE_PNG))) { return oidc_util_http_send(r, (const char*) &oidc_transparent_pixel, sizeof(oidc_transparent_pixel), OIDC_CONTENT_TYPE_IMAGE_PNG, OK); } /* standard HTTP based logout: should be called in an iframe from the OP */ return oidc_util_html_send(r, "Logged Out", NULL, NULL, "<p>Logged Out</p>", OK); } /* see if we don't need to go somewhere special after killing the session locally */ if (url == NULL) return oidc_util_html_send(r, "Logged Out", NULL, NULL, "<p>Logged Out</p>", OK); /* send the user to the specified where-to-go-after-logout URL */ oidc_util_hdr_out_location_set(r, url); return HTTP_MOVED_TEMPORARILY; }
0
linux
ea3d7209ca01da209cda6f0dea8be9cc4b7a933b
NOT_APPLICABLE
NOT_APPLICABLE
static void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw, struct ext4_inode_info *ei) { __u32 csum; if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != cpu_to_le32(EXT4_OS_LINUX) || !ext4_has_metadata_csum(inode->i_sb)) return; csum = ext4_inode_csum(inode, raw, ei); raw->i_checksum_lo = cpu_to_le16(csum & 0xFFFF); if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE && EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) raw->i_checksum_hi = cpu_to_le16(csum >> 16); }
0
Chrome
58feadc64d191d834b68b8218eea4ba12b052b96
NOT_APPLICABLE
NOT_APPLICABLE
bool QuotaThreadTask::RunOnTargetThreadAsync() { RunOnTargetThread(); return true; }
0
radare2
a7ce29647fcb38386d7439696375e16e093d6acb
NOT_APPLICABLE
NOT_APPLICABLE
R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, int kind, int mode, PJ *pj) { RList *list = r_anal_var_list (anal, fcn, kind); RAnalVar *var; RListIter *iter; if (!pj && mode == 'j') { return; } if (mode == 'j') { pj_a (pj); } if (!list) { if (mode == 'j') { pj_end (pj); } return; } //s- at the end of the loop if (mode == '*' && !r_list_empty (list)) { anal->cb_printf ("s 0x%" PFMT64x "\n", fcn->addr); } r_list_sort (list, (RListComparator) var_comparator); r_list_foreach (list, iter, var) { if (var->kind != kind) { continue; } switch (mode) { case '*': // we can't express all type info here :( if (kind == R_ANAL_VAR_KIND_REG) { // registers RRegItem *i = r_reg_index_get (anal->reg, var->delta); if (!i) { eprintf ("Register not found"); break; } anal->cb_printf ("\"afv%c %s %s %s\"\n", kind, i->name, var->name, var->type); } else { int delta = kind == R_ANAL_VAR_KIND_BPV ? var->delta + fcn->bp_off : var->delta; anal->cb_printf ("\"afv%c %d %s %s\"\n", kind, delta, var->name, var->type); } break; case 'j': switch (var->kind) { case R_ANAL_VAR_KIND_BPV: { st64 delta = (st64)var->delta + fcn->bp_off; pj_o (pj); pj_ks (pj, "name", var->name); if (var->isarg) { pj_ks (pj, "kind", "arg"); } else { pj_ks (pj, "kind", "var"); } pj_ks (pj, "type", var->type); pj_k (pj, "ref"); pj_o (pj); pj_ks (pj, "base", anal->reg->name[R_REG_NAME_BP]); pj_kN (pj, "offset", delta); pj_end (pj); pj_end (pj); } break; case R_ANAL_VAR_KIND_REG: { RRegItem *i = r_reg_index_get (anal->reg, var->delta); if (!i) { eprintf ("Register not found"); break; } pj_o (pj); pj_ks (pj, "name", var->name); pj_ks (pj, "kind", "reg"); pj_ks (pj, "type", var->type); pj_ks (pj, "ref", i->name); pj_end (pj); } break; case R_ANAL_VAR_KIND_SPV: { st64 delta = (st64)var->delta + fcn->maxstack; pj_o (pj); pj_ks (pj, "name", var->name); if (var->isarg) { pj_ks (pj, "kind", "arg"); } else { pj_ks (pj, "kind", "var"); } pj_ks (pj, "type", var->type); pj_k (pj, "ref"); pj_o (pj); pj_ks (pj, "base", anal->reg->name[R_REG_NAME_SP]); pj_kN (pj, "offset", delta); pj_end (pj); pj_end (pj); } break; } break; default: switch (kind) { case R_ANAL_VAR_KIND_BPV: { int delta = var->delta + fcn->bp_off; if (var->isarg) { anal->cb_printf ("arg %s %s @ %s+0x%x\n", var->type, var->name, anal->reg->name[R_REG_NAME_BP], delta); } else { char sign = (-var->delta <= fcn->bp_off) ? '+' : '-'; anal->cb_printf ("var %s %s @ %s%c0x%x\n", var->type, var->name, anal->reg->name[R_REG_NAME_BP], sign, R_ABS (delta)); } } break; case R_ANAL_VAR_KIND_REG: { RRegItem *i = r_reg_index_get (anal->reg, var->delta); if (!i) { eprintf ("Register not found"); break; } anal->cb_printf ("arg %s %s @ %s\n", var->type, var->name, i->name); } break; case R_ANAL_VAR_KIND_SPV: { int delta = fcn->maxstack + var->delta; if (!var->isarg) { char sign = (-var->delta <= fcn->maxstack) ? '+' : '-'; anal->cb_printf ("var %s %s @ %s%c0x%x\n", var->type, var->name, anal->reg->name[R_REG_NAME_SP], sign, R_ABS (delta)); } else { anal->cb_printf ("arg %s %s @ %s+0x%x\n", var->type, var->name, anal->reg->name[R_REG_NAME_SP], delta); } } break; } } } if (mode == '*' && !r_list_empty (list)) { anal->cb_printf ("s-\n"); } if (mode == 'j') { pj_end (pj); } r_list_free (list); }
0
Chrome
7da6c3419fd172405bcece1ae4ec6ec8316cd345
NOT_APPLICABLE
NOT_APPLICABLE
void RenderWidgetHostImpl::OnUnlockMouse() { const bool was_mouse_locked = !pending_mouse_lock_request_ && IsMouseLocked(); RejectMouseLockOrUnlockIfNecessary(); if (was_mouse_locked) is_last_unlocked_by_target_ = true; }
0
radare2
eb7deb281df54771fb8ecf5890dc325a7d22d3e2
NOT_APPLICABLE
NOT_APPLICABLE
static int check_pe32_bytes(const ut8 *buf, ut64 length) { unsigned int idx; if (!buf || length <= 0x3d) { return false; } idx = (buf[0x3c] | (buf[0x3d]<<8)); if (length > idx + 0x18 + 2) { if (!memcmp (buf, "MZ", 2) && !memcmp (buf+idx, "PE", 2) && !memcmp (buf+idx+0x18, "\x0b\x01", 2)) { return true; } } return false; }
0
linux
e6838a29ecb484c97e4efef9429643b9851fba6e
NOT_APPLICABLE
NOT_APPLICABLE
nfsd_svc(int nrservs, struct net *net) { int error; bool nfsd_up_before; struct nfsd_net *nn = net_generic(net, nfsd_net_id); mutex_lock(&nfsd_mutex); dprintk("nfsd: creating service\n"); nrservs = max(nrservs, 0); nrservs = min(nrservs, NFSD_MAXSERVS); error = 0; if (nrservs == 0 && nn->nfsd_serv == NULL) goto out; error = nfsd_create_serv(net); if (error) goto out; nfsd_up_before = nn->nfsd_net_up; error = nfsd_startup_net(nrservs, net); if (error) goto out_destroy; error = nn->nfsd_serv->sv_ops->svo_setup(nn->nfsd_serv, NULL, nrservs); if (error) goto out_shutdown; /* We are holding a reference to nn->nfsd_serv which * we don't want to count in the return value, * so subtract 1 */ error = nn->nfsd_serv->sv_nrthreads - 1; out_shutdown: if (error < 0 && !nfsd_up_before) nfsd_shutdown_net(net); out_destroy: nfsd_destroy(net); /* Release server */ out: mutex_unlock(&nfsd_mutex); return error; }
0
linux
952fc18ef9ec707ebdc16c0786ec360295e5ff15
NOT_APPLICABLE
NOT_APPLICABLE
void ext4_resize_end(struct super_block *sb) { clear_bit_unlock(EXT4_RESIZING, &EXT4_SB(sb)->s_resize_flags); smp_mb__after_clear_bit(); }
0
Chrome
5a2de6455f565783c73e53eae2c8b953e7d48520
NOT_APPLICABLE
NOT_APPLICABLE
static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint) { int x, y; gdk_window_get_origin(window, &x, &y); return clientPoint + IntSize(x, y); }
0
stb
5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40
CVE-2021-28021
CWE-787
static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static const unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; }
1
Chrome
5a2de6455f565783c73e53eae2c8b953e7d48520
NOT_APPLICABLE
NOT_APPLICABLE
void webkit_web_view_load_html_string(WebKitWebView* webView, const gchar* content, const gchar* baseUri) { g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); g_return_if_fail(content); webkit_web_view_load_string(webView, content, NULL, NULL, baseUri); }
0
linux
34fad54c2537f7c99d07375e50cb30aa3c23bd83
NOT_APPLICABLE
NOT_APPLICABLE
static inline size_t flow_keys_hash_length(const struct flow_keys *flow) { size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs); BUILD_BUG_ON((sizeof(*flow) - FLOW_KEYS_HASH_OFFSET) % sizeof(u32)); BUILD_BUG_ON(offsetof(typeof(*flow), addrs) != sizeof(*flow) - sizeof(flow->addrs)); switch (flow->control.addr_type) { case FLOW_DISSECTOR_KEY_IPV4_ADDRS: diff -= sizeof(flow->addrs.v4addrs); break; case FLOW_DISSECTOR_KEY_IPV6_ADDRS: diff -= sizeof(flow->addrs.v6addrs); break; case FLOW_DISSECTOR_KEY_TIPC_ADDRS: diff -= sizeof(flow->addrs.tipcaddrs); break; } return (sizeof(*flow) - diff) / sizeof(u32); }
0
mapserver
3a10f6b829297dae63492a8c63385044bc6953ed
NOT_APPLICABLE
NOT_APPLICABLE
void msPostGISFreeLayerInfo(layerObj *layer) { msPostGISLayerInfo *layerinfo = NULL; layerinfo = (msPostGISLayerInfo*)layer->layerinfo; if ( layerinfo->sql ) free(layerinfo->sql); if ( layerinfo->uid ) free(layerinfo->uid); if ( layerinfo->srid ) free(layerinfo->srid); if ( layerinfo->geomcolumn ) free(layerinfo->geomcolumn); if ( layerinfo->fromsource ) free(layerinfo->fromsource); if ( layerinfo->pgresult ) PQclear(layerinfo->pgresult); if ( layerinfo->pgconn ) msConnPoolRelease(layer, layerinfo->pgconn); free(layerinfo); layer->layerinfo = NULL; }
0
httpd
4cc27823899e070268b906ca677ee838d07cf67a
NOT_APPLICABLE
NOT_APPLICABLE
static const char *start_cond_section(cmd_parms *cmd, void *mconfig, const char *arg) { const char *endp = ap_strrchr_c(arg, '>'); int result, not = (arg[0] == '!'); test_cond_section_fn testfn = (test_cond_section_fn)cmd->info; const char *arg1; if (endp == NULL) { return unclosed_directive(cmd); } arg = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg); if (not) { arg++; } arg1 = ap_getword_conf(cmd->temp_pool, &arg); if (!arg1[0]) { return missing_container_arg(cmd); } result = testfn(cmd, arg1); if ((!not && result) || (not && !result)) { ap_directive_t *parent = NULL; ap_directive_t *current = NULL; const char *retval; retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd, &current, &parent, cmd->cmd->name); *(ap_directive_t **)mconfig = current; return retval; } else { *(ap_directive_t **)mconfig = NULL; return ap_soak_end_container(cmd, cmd->cmd->name); } }
0
linux
96b340406724d87e4621284ebac5e059d67b2194
NOT_APPLICABLE
NOT_APPLICABLE
fst_init_dma(struct fst_card_info *card) { /* * This is only required for the PLX 9054 */ if (card->family == FST_FAMILY_TXU) { pci_set_master(card->device); outl(0x00020441, card->pci_conf + DMAMODE0); outl(0x00020441, card->pci_conf + DMAMODE1); outl(0x0, card->pci_conf + DMATHR); } }
0
linux
ea2bc483ff5caada7c4aa0d5fbf87d3a6590273d
NOT_APPLICABLE
NOT_APPLICABLE
static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len, char __user *optval, int __user *optlen) { sctp_assoc_t id; struct sctp_bind_addr *bp; struct sctp_association *asoc; struct list_head *pos, *temp; struct sctp_sockaddr_entry *addr; rwlock_t *addr_lock; int cnt = 0; if (len != sizeof(sctp_assoc_t)) return -EINVAL; if (copy_from_user(&id, optval, sizeof(sctp_assoc_t))) return -EFAULT; /* * For UDP-style sockets, id specifies the association to query. * If the id field is set to the value '0' then the locally bound * addresses are returned without regard to any particular * association. */ if (0 == id) { bp = &sctp_sk(sk)->ep->base.bind_addr; addr_lock = &sctp_sk(sk)->ep->base.addr_lock; } else { asoc = sctp_id2assoc(sk, id); if (!asoc) return -EINVAL; bp = &asoc->base.bind_addr; addr_lock = &asoc->base.addr_lock; } sctp_read_lock(addr_lock); /* If the endpoint is bound to 0.0.0.0 or ::0, count the valid * addresses from the global local address list. */ if (sctp_list_single_entry(&bp->address_list)) { addr = list_entry(bp->address_list.next, struct sctp_sockaddr_entry, list); if (sctp_is_any(&addr->a)) { list_for_each_safe(pos, temp, &sctp_local_addr_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); if ((PF_INET == sk->sk_family) && (AF_INET6 == addr->a.sa.sa_family)) continue; cnt++; } } else { cnt = 1; } goto done; } list_for_each(pos, &bp->address_list) { cnt ++; } done: sctp_read_unlock(addr_lock); return cnt; }
0
Chrome
d10065ae8b87f4eefe50d756f9c3464832c40bcf
NOT_APPLICABLE
NOT_APPLICABLE
void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { observers_.RemoveObserver(observer); }
0
linux
a23325b2e583556eae88ed3f764e457786bf4df6
NOT_APPLICABLE
NOT_APPLICABLE
AcpiNsLocal ( ACPI_OBJECT_TYPE Type) { ACPI_FUNCTION_TRACE (NsLocal); if (!AcpiUtValidObjectType (Type)) { /* Type code out of range */ ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type)); return_UINT32 (ACPI_NS_NORMAL); } return_UINT32 (AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); }
0
linux
1f1ea6c2d9d8c0be9ec56454b05315273b5de8ce
NOT_APPLICABLE
NOT_APPLICABLE
static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) { int status = 0; time->tv_sec = 0; time->tv_nsec = 0; if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) return -EIO; if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { status = decode_attr_time(xdr, time); if (status == 0) status = NFS_ATTR_FATTR_CTIME; bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; } dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); return status; }
0
linux
ded89912156b1a47d940a0c954c43afbabd0c42c
NOT_APPLICABLE
NOT_APPLICABLE
brcmf_notify_roaming_status(struct brcmf_if *ifp, const struct brcmf_event_msg *e, void *data) { struct brcmf_cfg80211_info *cfg = ifp->drvr->config; u32 event = e->event_code; u32 status = e->status; if (event == BRCMF_E_ROAM && status == BRCMF_E_STATUS_SUCCESS) { if (test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state)) brcmf_bss_roaming_done(cfg, ifp->ndev, e); else brcmf_bss_connect_done(cfg, ifp->ndev, e, true); } return 0; }
0
zfs
99aa4d2b4fd12c6bef62d02ffd1b375ddd42fcf4
NOT_APPLICABLE
NOT_APPLICABLE
get_linux_shareopts_cb(const char *key, const char *value, void *cookie) { char **plinux_opts = (char **)cookie; /* host-specific options, these are taken care of elsewhere */ if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 || strcmp(key, "sec") == 0) return (SA_OK); if (strcmp(key, "anon") == 0) key = "anonuid"; if (strcmp(key, "root_mapping") == 0) { (void) add_linux_shareopt(plinux_opts, "root_squash", NULL); key = "anonuid"; } if (strcmp(key, "nosub") == 0) key = "subtree_check"; if (strcmp(key, "insecure") != 0 && strcmp(key, "secure") != 0 && strcmp(key, "async") != 0 && strcmp(key, "sync") != 0 && strcmp(key, "no_wdelay") != 0 && strcmp(key, "wdelay") != 0 && strcmp(key, "nohide") != 0 && strcmp(key, "hide") != 0 && strcmp(key, "crossmnt") != 0 && strcmp(key, "no_subtree_check") != 0 && strcmp(key, "subtree_check") != 0 && strcmp(key, "insecure_locks") != 0 && strcmp(key, "secure_locks") != 0 && strcmp(key, "no_auth_nlm") != 0 && strcmp(key, "auth_nlm") != 0 && strcmp(key, "no_acl") != 0 && strcmp(key, "mountpoint") != 0 && strcmp(key, "mp") != 0 && strcmp(key, "fsuid") != 0 && strcmp(key, "refer") != 0 && strcmp(key, "replicas") != 0 && strcmp(key, "root_squash") != 0 && strcmp(key, "no_root_squash") != 0 && strcmp(key, "all_squash") != 0 && strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 && strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) { return (SA_SYNTAX_ERR); } (void) add_linux_shareopt(plinux_opts, key, value); return (SA_OK); }
0
WavPack
070ef6f138956d9ea9612e69586152339dbefe51
NOT_APPLICABLE
NOT_APPLICABLE
static int add_to_metadata (WavpackContext *wpc, void *data, uint32_t bcount, unsigned char id) { WavpackMetadata *mdp; unsigned char *src = data; while (bcount) { if (wpc->metacount) { uint32_t bc = bcount; mdp = wpc->metadata + wpc->metacount - 1; if (mdp->id == id) { if (wpc->metabytes + bcount > 1000000) bc = 1000000 - wpc->metabytes; mdp->data = realloc (mdp->data, mdp->byte_length + bc); memcpy ((char *) mdp->data + mdp->byte_length, src, bc); mdp->byte_length += bc; wpc->metabytes += bc; bcount -= bc; src += bc; if (wpc->metabytes >= 1000000 && !write_metadata_block (wpc)) return FALSE; } } if (bcount) { wpc->metadata = realloc (wpc->metadata, (wpc->metacount + 1) * sizeof (WavpackMetadata)); mdp = wpc->metadata + wpc->metacount++; mdp->byte_length = 0; mdp->data = NULL; mdp->id = id; } } return TRUE; }
0
linux
6b3a707736301c2128ca85ce85fb13f60b5e350a
NOT_APPLICABLE
NOT_APPLICABLE
int __alloc_bootmem_huge_page(struct hstate *h) { struct huge_bootmem_page *m; int nr_nodes, node; for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { void *addr; addr = memblock_alloc_try_nid_raw( huge_page_size(h), huge_page_size(h), 0, MEMBLOCK_ALLOC_ACCESSIBLE, node); if (addr) { /* * Use the beginning of the huge page to store the * huge_bootmem_page struct (until gather_bootmem * puts them into the mem_map). */ m = addr; goto found; } } return 0; found: BUG_ON(!IS_ALIGNED(virt_to_phys(m), huge_page_size(h))); /* Put them into a private list first because mem_map is not up yet */ INIT_LIST_HEAD(&m->list); list_add(&m->list, &huge_boot_pages); m->hstate = h; return 1; }
0
cyrus-imapd
621f9e41465b521399f691c241181300fab55995
NOT_APPLICABLE
NOT_APPLICABLE
EXPORTED int annotatemore_lookup(const char *mboxname, const char *entry, const char *userid, struct buf *value) { return annotatemore_msg_lookup(mboxname, /*uid*/0, entry, userid, value); }
0
FFmpeg
2a05c8f813de6f2278827734bf8102291e7484aa
NOT_APPLICABLE
NOT_APPLICABLE
static int get_cookies(HTTPContext *s, char **cookies, const char *path, const char *domain) { int ret = 0; char *next, *cookie, *set_cookies = av_strdup(s->cookies), *cset_cookies = set_cookies; if (!set_cookies) return AVERROR(EINVAL); av_dict_free(&s->cookie_dict); *cookies = NULL; while ((cookie = av_strtok(set_cookies, "\n", &next))) { int domain_offset = 0; char *param, *next_param, *cdomain = NULL, *cpath = NULL, *cvalue = NULL; set_cookies = NULL; if (parse_cookie(s, cookie, &s->cookie_dict)) av_log(s, AV_LOG_WARNING, "Unable to parse '%s'\n", cookie); while ((param = av_strtok(cookie, "; ", &next_param))) { if (cookie) { cvalue = av_strdup(param); cookie = NULL; } else if (!av_strncasecmp("path=", param, 5)) { av_free(cpath); cpath = av_strdup(&param[5]); } else if (!av_strncasecmp("domain=", param, 7)) { int leading_dot = (param[7] == '.'); av_free(cdomain); cdomain = av_strdup(&param[7+leading_dot]); } else { } } if (!cdomain) cdomain = av_strdup(domain); if (!cdomain || !cpath || !cvalue) { av_log(s, AV_LOG_WARNING, "Invalid cookie found, no value, path or domain specified\n"); goto done_cookie; } if (av_strncasecmp(path, cpath, strlen(cpath))) goto done_cookie; domain_offset = strlen(domain) - strlen(cdomain); if (domain_offset < 0) goto done_cookie; if (av_strcasecmp(&domain[domain_offset], cdomain)) goto done_cookie; if (!*cookies) { if (!(*cookies = av_strdup(cvalue))) { ret = AVERROR(ENOMEM); goto done_cookie; } } else { char *tmp = *cookies; size_t str_size = strlen(cvalue) + strlen(*cookies) + 3; if (!(*cookies = av_malloc(str_size))) { ret = AVERROR(ENOMEM); goto done_cookie; } snprintf(*cookies, str_size, "%s; %s", tmp, cvalue); av_free(tmp); } done_cookie: av_freep(&cdomain); av_freep(&cpath); av_freep(&cvalue); if (ret < 0) { if (*cookies) av_freep(cookies); av_free(cset_cookies); return ret; } } av_free(cset_cookies); return 0; }
0
linux
1fa2337a315a2448c5434f41e00d56b01a22283c
NOT_APPLICABLE
NOT_APPLICABLE
static int cx24116_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) { struct cx24116_cmd cmd; int ret; dprintk("%s(%d)\n", __func__, tone); if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) { printk(KERN_ERR "%s: Invalid, tone=%d\n", __func__, tone); return -EINVAL; } /* Wait for LNB ready */ ret = cx24116_wait_for_lnb(fe); if (ret != 0) return ret; /* Min delay time after DiSEqC send */ msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ /* Now we set the tone */ cmd.args[0x00] = CMD_SET_TONE; cmd.args[0x01] = 0x00; cmd.args[0x02] = 0x00; switch (tone) { case SEC_TONE_ON: dprintk("%s: setting tone on\n", __func__); cmd.args[0x03] = 0x01; break; case SEC_TONE_OFF: dprintk("%s: setting tone off\n", __func__); cmd.args[0x03] = 0x00; break; } cmd.len = 0x04; /* Min delay time before DiSEqC send */ msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ return cx24116_cmd_execute(fe, &cmd); }
0
php
630f9c33c23639de85c3fd306b209b538b73b4c9
NOT_APPLICABLE
NOT_APPLICABLE
static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen) { size_t i, j; char *str = safe_emalloc(*len, 1, 1); unsigned char *end = *(unsigned char **)p+maxlen; if (end < *p) { efree(str); return NULL; } for (i = 0; i < *len; i++) { if (*p >= end) { efree(str); return NULL; } if (**p != '\\') { str[i] = (char)**p; } else { unsigned char ch = 0; for (j = 0; j < 2; j++) { (*p)++; if (**p >= '0' && **p <= '9') { ch = (ch << 4) + (**p -'0'); } else if (**p >= 'a' && **p <= 'f') { ch = (ch << 4) + (**p -'a'+10); } else if (**p >= 'A' && **p <= 'F') { ch = (ch << 4) + (**p -'A'+10); } else { efree(str); return NULL; } } str[i] = (char)ch; } (*p)++; } str[i] = 0; *len = i; return str; }
0
linux
2b7e8665b4ff51c034c55df3cff76518d1a9ee3a
NOT_APPLICABLE
NOT_APPLICABLE
static inline void rcu_copy_process(struct task_struct *p) { #ifdef CONFIG_PREEMPT_RCU p->rcu_read_lock_nesting = 0; p->rcu_read_unlock_special.s = 0; p->rcu_blocked_node = NULL; INIT_LIST_HEAD(&p->rcu_node_entry); #endif /* #ifdef CONFIG_PREEMPT_RCU */ #ifdef CONFIG_TASKS_RCU p->rcu_tasks_holdout = false; INIT_LIST_HEAD(&p->rcu_tasks_holdout_list); p->rcu_tasks_idle_cpu = -1; #endif /* #ifdef CONFIG_TASKS_RCU */ }
0
gimp
32ae0f83e5748299641cceaabe3f80f1b3afd03e
NOT_APPLICABLE
NOT_APPLICABLE
run (const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals) { static GimpParam values[2]; GimpRunMode run_mode; GimpPDBStatusType status = GIMP_PDB_SUCCESS; gint32 image_ID; gint32 drawable_ID; GimpExportReturn export = GIMP_EXPORT_CANCEL; GError *error = NULL; l_run_mode = run_mode = param[0].data.d_int32; INIT_I18N (); gegl_init (NULL, NULL); *nreturn_vals = 1; *return_vals = values; values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; if (strcmp (name, LOAD_PROC) == 0) { image_ID = load_image (param[1].data.d_string, &error); if (image_ID != -1) { *nreturn_vals = 2; values[1].type = GIMP_PDB_IMAGE; values[1].data.d_image = image_ID; } else { status = GIMP_PDB_EXECUTION_ERROR; } } else if (strcmp (name, SAVE_PROC) == 0) { image_ID = param[1].data.d_int32; drawable_ID = param[2].data.d_int32; /* eventually export the image */ switch (run_mode) { case GIMP_RUN_INTERACTIVE: case GIMP_RUN_WITH_LAST_VALS: gimp_ui_init (PLUG_IN_BINARY, FALSE); export = gimp_export_image (&image_ID, &drawable_ID, "XWD", GIMP_EXPORT_CAN_HANDLE_RGB | GIMP_EXPORT_CAN_HANDLE_GRAY | GIMP_EXPORT_CAN_HANDLE_INDEXED); if (export == GIMP_EXPORT_CANCEL) { values[0].data.d_status = GIMP_PDB_CANCEL; return; } break; default: break; } switch (run_mode) { case GIMP_RUN_INTERACTIVE: case GIMP_RUN_WITH_LAST_VALS: /* No additional data to retrieve */ break; case GIMP_RUN_NONINTERACTIVE: /* Make sure all the arguments are there! */ if (nparams != 5) status = GIMP_PDB_CALLING_ERROR; break; default: break; } if (status == GIMP_PDB_SUCCESS) { if (! save_image (param[3].data.d_string, image_ID, drawable_ID, &error)) { status = GIMP_PDB_EXECUTION_ERROR; } } if (export == GIMP_EXPORT_EXPORT) gimp_image_delete (image_ID); } else { status = GIMP_PDB_CANCEL; } if (status != GIMP_PDB_SUCCESS && error) { *nreturn_vals = 2; values[1].type = GIMP_PDB_STRING; values[1].data.d_string = error->message; } values[0].data.d_status = status; }
0
gerbv
319a8af890e4d0a5c38e6d08f510da8eefc42537
NOT_APPLICABLE
NOT_APPLICABLE
visible_file_name(gchar **file_name, gchar **dir_name, gerbv_layertype_t layer_type, /* -1 for all types */ const gchar *file_extension, const gchar *untitled_file_extension) { unsigned int count = 0; gerbv_fileinfo_t *first_vis_file = NULL; for (int i = 0; i < mainProject->max_files; ++i) { if (mainProject->file[i] && mainProject->file[i]->isVisible && (layer_type == (gerbv_layertype_t)-1 || layer_type == mainProject->file[i]->image->layertype)) { if (first_vis_file == NULL) { first_vis_file = mainProject->file[i]; /* Always directory of first visible file */ if (dir_name) *dir_name = g_path_get_dirname ( first_vis_file->fullPathname); } if (++count == 2 && file_name) { *file_name = g_strdup_printf("%s%s", pgettext("file name", "untitled"), untitled_file_extension); } } } if (count == 1 && file_name) *file_name = g_strdup_printf("%s%s", first_vis_file->name, file_extension); return count; }
0
linux
5c25f65fd1e42685f7ccd80e0621829c105785d9
NOT_APPLICABLE
NOT_APPLICABLE
static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) { struct tun_struct *tun; struct tun_file *tfile = file->private_data; struct net_device *dev; int err; if (tfile->detached) return -EINVAL; dev = __dev_get_by_name(net, ifr->ifr_name); if (dev) { if (ifr->ifr_flags & IFF_TUN_EXCL) return -EBUSY; if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops) tun = netdev_priv(dev); else if ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops) tun = netdev_priv(dev); else return -EINVAL; if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) != !!(tun->flags & IFF_MULTI_QUEUE)) return -EINVAL; if (tun_not_capable(tun)) return -EPERM; err = security_tun_dev_open(tun->security); if (err < 0) return err; err = tun_attach(tun, file, ifr->ifr_flags & IFF_NOFILTER); if (err < 0) return err; if (tun->flags & IFF_MULTI_QUEUE && (tun->numqueues + tun->numdisabled > 1)) { /* One or more queue has already been attached, no need * to initialize the device again. */ return 0; } } else { char *name; unsigned long flags = 0; int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ? MAX_TAP_QUEUES : 1; if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) return -EPERM; err = security_tun_dev_create(); if (err < 0) return err; /* Set dev type */ if (ifr->ifr_flags & IFF_TUN) { /* TUN device */ flags |= IFF_TUN; name = "tun%d"; } else if (ifr->ifr_flags & IFF_TAP) { /* TAP device */ flags |= IFF_TAP; name = "tap%d"; } else return -EINVAL; if (*ifr->ifr_name) name = ifr->ifr_name; dev = alloc_netdev_mqs(sizeof(struct tun_struct), name, NET_NAME_UNKNOWN, tun_setup, queues, queues); if (!dev) return -ENOMEM; err = dev_get_valid_name(net, dev, name); if (err < 0) goto err_free_dev; dev_net_set(dev, net); dev->rtnl_link_ops = &tun_link_ops; dev->ifindex = tfile->ifindex; dev->sysfs_groups[0] = &tun_attr_group; tun = netdev_priv(dev); tun->dev = dev; tun->flags = flags; tun->txflt.count = 0; tun->vnet_hdr_sz = sizeof(struct virtio_net_hdr); tun->align = NET_SKB_PAD; tun->filter_attached = false; tun->sndbuf = tfile->socket.sk->sk_sndbuf; tun->rx_batched = 0; tun->pcpu_stats = netdev_alloc_pcpu_stats(struct tun_pcpu_stats); if (!tun->pcpu_stats) { err = -ENOMEM; goto err_free_dev; } spin_lock_init(&tun->lock); err = security_tun_dev_alloc_security(&tun->security); if (err < 0) goto err_free_stat; tun_net_init(dev); tun_flow_init(tun); dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; dev->features = dev->hw_features | NETIF_F_LLTX; dev->vlan_features = dev->features & ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX); INIT_LIST_HEAD(&tun->disabled); err = tun_attach(tun, file, false); if (err < 0) goto err_free_flow; err = register_netdevice(tun->dev); if (err < 0) goto err_detach; } netif_carrier_on(tun->dev); tun_debug(KERN_INFO, tun, "tun_set_iff\n"); tun->flags = (tun->flags & ~TUN_FEATURES) | (ifr->ifr_flags & TUN_FEATURES); /* Make sure persistent devices do not get stuck in * xoff state. */ if (netif_running(tun->dev)) netif_tx_wake_all_queues(tun->dev); strcpy(ifr->ifr_name, tun->dev->name); return 0; err_detach: tun_detach_all(dev); /* register_netdevice() already called tun_free_netdev() */ goto err_free_dev; err_free_flow: tun_flow_uninit(tun); security_tun_dev_free_security(tun->security); err_free_stat: free_percpu(tun->pcpu_stats); err_free_dev: free_netdev(dev); return err; }
0
mstdlib
db124b8f607dd0a40a9aef2d4d468fad433522a7
NOT_APPLICABLE
NOT_APPLICABLE
M_list_str_t *M_fs_path_componentize_path(const char *path, M_fs_system_t sys_type) { M_list_str_t *list1; M_list_str_t *list2; M_list_str_t *list3; const char *const_temp; const char *const_temp2; size_t len; size_t len2; size_t i; size_t j; sys_type = M_fs_path_get_system_type(sys_type); list1 = M_list_str_split('/', path, M_LIST_STR_NONE, M_FALSE); list3 = M_list_str_create(M_LIST_STR_NONE); len = M_list_str_len(list1); for (i=0; i<len; i++) { const_temp = M_list_str_at(list1, i); if (const_temp == NULL || *const_temp == '\0') { continue; } list2 = M_list_str_split('\\', const_temp, M_LIST_STR_NONE, M_FALSE); len2 = M_list_str_len(list2); for (j=0; j<len2; j++) { const_temp2 = M_list_str_at(list2, j); if (const_temp2 == NULL || *const_temp2 == '\0') { continue; } M_list_str_insert(list3, const_temp2); } M_list_str_destroy(list2); } M_list_str_destroy(list1); if ((sys_type == M_FS_SYSTEM_UNIX && M_fs_path_isabs(path, sys_type)) || (sys_type == M_FS_SYSTEM_WINDOWS && M_fs_path_isunc(path))) { M_list_str_insert_at(list3, "", 0); } return list3; }
0
linux
b4487b93545214a9db8cbf32e86411677b0cca21
NOT_APPLICABLE
NOT_APPLICABLE
static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, void *data) { struct nfs_openres *res = data; struct compound_hdr hdr; int status; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_open(xdr, res); if (status) goto out; status = decode_getfh(xdr, &res->fh); if (status) goto out; if (res->access_request) decode_access(xdr, &res->access_supported, &res->access_result); decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); if (res->lg_res) decode_layoutget(xdr, rqstp, res->lg_res); out: return status; }
0
gnutls
21f89efad7014a5ee0debd4cd3d59e27774b29e6
NOT_APPLICABLE
NOT_APPLICABLE
static void enable_profile_legacy(gnutls_priority_t c) { c->additional_verify_flags &= 0x00ffffff; c->additional_verify_flags |= GNUTLS_PROFILE_TO_VFLAGS(GNUTLS_PROFILE_LEGACY); c->level = GNUTLS_SEC_PARAM_LEGACY; }
0
ImageMagick
c073a7712d82476b5fbee74856c46b88af9c3175
NOT_APPLICABLE
NOT_APPLICABLE
static void TIFFGetProfiles(TIFF *tiff,Image *image,MagickBooleanType ping) { uint32 length; unsigned char *profile; length=0; if (ping == MagickFalse) { #if defined(TIFFTAG_ICCPROFILE) if ((TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) (void) ReadProfile(image,"icc",profile,(ssize_t) length); #endif #if defined(TIFFTAG_PHOTOSHOP) if ((TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) (void) ReadProfile(image,"8bim",profile,(ssize_t) length); #endif #if defined(TIFFTAG_RICHTIFFIPTC) if ((TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) { if (TIFFIsByteSwapped(tiff) != 0) TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length); (void) ReadProfile(image,"iptc",profile,4L*length); } #endif #if defined(TIFFTAG_XMLPACKET) if ((TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) (void) ReadProfile(image,"xmp",profile,(ssize_t) length); #endif if ((TIFFGetField(tiff,34118,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) (void) ReadProfile(image,"tiff:34118",profile,(ssize_t) length); } if ((TIFFGetField(tiff,37724,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) (void) ReadProfile(image,"tiff:37724",profile,(ssize_t) length); }
0
libsass
38f4c3699d06b64128bebc7cf1e8b3125be74dc4
NOT_APPLICABLE
NOT_APPLICABLE
void Inspect::operator()(Keyframe_Rule_Ptr rule) { if (rule->name()) rule->name()->perform(this); if (rule->block()) rule->block()->perform(this); }
0
mosquitto
9097577b49b7fdcf45d30975976dd93808ccc0c4
NOT_APPLICABLE
NOT_APPLICABLE
static void print_usage(void) { printf("mosquitto version %s\n\n", VERSION); printf("mosquitto is an MQTT v3.1.1 broker.\n\n"); printf("Usage: mosquitto [-c config_file] [-d] [-h] [-p port]\n\n"); printf(" -c : specify the broker config file.\n"); printf(" -d : put the broker into the background after starting.\n"); printf(" -h : display this help.\n"); printf(" -p : start the broker listening on the specified port.\n"); printf(" Not recommended in conjunction with the -c option.\n"); printf(" -v : verbose mode - enable all logging types. This overrides\n"); printf(" any logging options given in the config file.\n"); printf("\nSee http://mosquitto.org/ for more information.\n\n"); }
0
linux
412b65d15a7f8a93794653968308fc100f2aa87c
NOT_APPLICABLE
NOT_APPLICABLE
static int hns_xgmac_get_regs_count(void) { return HNS_XGMAC_DUMP_NUM; }
0
linux
397d425dc26da728396e66d392d5dcb8dac30c37
NOT_APPLICABLE
NOT_APPLICABLE
static int link_path_walk(const char *name, struct nameidata *nd) { int err; while (*name=='/') name++; if (!*name) return 0; /* At this point we know we have a real path component. */ for(;;) { u64 hash_len; int type; err = may_lookup(nd); if (err) return err; hash_len = hash_name(name); type = LAST_NORM; if (name[0] == '.') switch (hashlen_len(hash_len)) { case 2: if (name[1] == '.') { type = LAST_DOTDOT; nd->flags |= LOOKUP_JUMPED; } break; case 1: type = LAST_DOT; } if (likely(type == LAST_NORM)) { struct dentry *parent = nd->path.dentry; nd->flags &= ~LOOKUP_JUMPED; if (unlikely(parent->d_flags & DCACHE_OP_HASH)) { struct qstr this = { { .hash_len = hash_len }, .name = name }; err = parent->d_op->d_hash(parent, &this); if (err < 0) return err; hash_len = this.hash_len; name = this.name; } } nd->last.hash_len = hash_len; nd->last.name = name; nd->last_type = type; name += hashlen_len(hash_len); if (!*name) goto OK; /* * If it wasn't NUL, we know it was '/'. Skip that * slash, and continue until no more slashes. */ do { name++; } while (unlikely(*name == '/')); if (unlikely(!*name)) { OK: /* pathname body, done */ if (!nd->depth) return 0; name = nd->stack[nd->depth - 1].name; /* trailing symlink, done */ if (!name) return 0; /* last component of nested symlink */ err = walk_component(nd, WALK_GET | WALK_PUT); } else { err = walk_component(nd, WALK_GET); } if (err < 0) return err; if (err) { const char *s = get_link(nd); if (unlikely(IS_ERR(s))) return PTR_ERR(s); err = 0; if (unlikely(!s)) { /* jumped */ put_link(nd); } else { nd->stack[nd->depth - 1].name = name; name = s; continue; } } if (unlikely(!d_can_lookup(nd->path.dentry))) { if (nd->flags & LOOKUP_RCU) { if (unlazy_walk(nd, NULL, 0)) return -ECHILD; } return -ENOTDIR; } } }
0
linux
d76c68109f37cb85b243a1cf0f40313afd2bae68
NOT_APPLICABLE
NOT_APPLICABLE
static int pcrypt_aead_decrypt(struct aead_request *req) { int err; struct pcrypt_request *preq = aead_request_ctx(req); struct aead_request *creq = pcrypt_request_ctx(preq); struct padata_priv *padata = pcrypt_request_padata(preq); struct crypto_aead *aead = crypto_aead_reqtfm(req); struct pcrypt_aead_ctx *ctx = crypto_aead_ctx(aead); u32 flags = aead_request_flags(req); memset(padata, 0, sizeof(struct padata_priv)); padata->parallel = pcrypt_aead_dec; padata->serial = pcrypt_aead_serial; aead_request_set_tfm(creq, ctx->child); aead_request_set_callback(creq, flags & ~CRYPTO_TFM_REQ_MAY_SLEEP, pcrypt_aead_done, req); aead_request_set_crypt(creq, req->src, req->dst, req->cryptlen, req->iv); aead_request_set_ad(creq, req->assoclen); err = pcrypt_do_parallel(padata, &ctx->cb_cpu, &pdecrypt); if (!err) return -EINPROGRESS; return err; }
0
nbd
741495cb08503fd32a9d22648e63b64390c601f4
NOT_APPLICABLE
NOT_APPLICABLE
ssize_t rawexpwrite(off_t a, char *buf, size_t len, CLIENT *client, int fua) { int fhandle; off_t foffset; size_t maxbytes; ssize_t retval; if(get_filepos(client->export, a, &fhandle, &foffset, &maxbytes)) return -1; if(maxbytes && len > maxbytes) len = maxbytes; DEBUG("(WRITE to fd %d offset %llu len %u fua %d), ", fhandle, (long long unsigned)foffset, (unsigned int)len, fua); myseek(fhandle, foffset); retval = write(fhandle, buf, len); if(client->server->flags & F_SYNC) { fsync(fhandle); } else if (fua) { /* This is where we would do the following * #ifdef USE_SYNC_FILE_RANGE * However, we don't, for the reasons set out below * by Christoph Hellwig <[email protected]> * * [BEGINS] * fdatasync is equivalent to fsync except that it does not flush * non-essential metadata (basically just timestamps in practice), but it * does flush metadata requried to find the data again, e.g. allocation * information and extent maps. sync_file_range does nothing but flush * out pagecache content - it means you basically won't get your data * back in case of a crash if you either: * * a) have a volatile write cache in your disk (e.g. any normal SATA disk) * b) are using a sparse file on a filesystem * c) are using a fallocate-preallocated file on a filesystem * d) use any file on a COW filesystem like btrfs * * e.g. it only does anything useful for you if you do not have a volatile * write cache, and either use a raw block device node, or just overwrite * an already fully allocated (and not preallocated) file on a non-COW * filesystem. * [ENDS] * * What we should do is open a second FD with O_DSYNC set, then write to * that when appropriate. However, with a Linux client, every REQ_FUA * immediately follows a REQ_FLUSH, so fdatasync does not cause performance * problems. * */ #if 0 sync_file_range(fhandle, foffset, len, SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_AFTER); #else fdatasync(fhandle); #endif } return retval; }
0
libmatroska
0a2d3e3644a7453b6513db2f9bc270f77943573f
NOT_APPLICABLE
NOT_APPLICABLE
int64 KaxInternalBlock::GetDataPosition(size_t FrameNumber) { int64 _Result = -1; if (ValueIsSet() && FrameNumber < SizeList.size()) { _Result = FirstFrameLocation; size_t _Idx = 0; while(FrameNumber--) { _Result += SizeList[_Idx++]; } } return _Result; }
0
libtasn1
f435825c0f527a8e52e6ffbc3ad0bc60531d537e
CVE-2016-4008
CWE-399
_asn1_extract_der_octet (asn1_node node, const unsigned char *der, int der_len, unsigned flags) { int len2, len3; int counter, counter_end; int result; len2 = asn1_get_length_der (der, der_len, &len3); if (len2 < -1) return ASN1_DER_ERROR; counter = len3 + 1; DECR_LEN(der_len, len3); if (len2 == -1) counter_end = der_len - 2; else counter_end = der_len; while (counter < counter_end) { DECR_LEN(der_len, 1); len2 = asn1_get_length_der (der + counter, der_len, &len3); if (IS_ERR(len2, flags)) { warn(); return ASN1_DER_ERROR; } if (len2 >= 0) { DECR_LEN(der_len, len2+len3); _asn1_append_value (node, der + counter + len3, len2); } else { /* indefinite */ DECR_LEN(der_len, len3); result = _asn1_extract_der_octet (node, der + counter + len3, der_len, flags); if (result != ASN1_SUCCESS) return result; len2 = 0; } counter += len2 + len3 + 1; } return ASN1_SUCCESS; cleanup: return result; }
1
ImageMagick
a33f7498f9052b50e8fe8c8422a11ba84474cb42
NOT_APPLICABLE
NOT_APPLICABLE
static MagickBooleanType ReadDCMPixels(Image *image,DCMInfo *info, DCMStreamInfo *stream_info,MagickBooleanType first_segment, ExceptionInfo *exception) { int byte, index; MagickBooleanType status; PixelPacket pixel; register ssize_t i, x; register Quantum *q; ssize_t y; /* Convert DCM Medical image to pixel packets. */ byte=0; i=0; status=MagickTrue; (void) ResetMagickMemory(&pixel,0,sizeof(pixel)); for (y=0; y < (ssize_t) image->rows; y++) { q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (Quantum *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { if (info->samples_per_pixel == 1) { int pixel_value; if (info->bytes_per_pixel == 1) pixel_value=info->polarity != MagickFalse ? ((int) info->max_value-ReadDCMByte(stream_info,image)) : ReadDCMByte(stream_info,image); else if ((info->bits_allocated != 12) || (info->significant_bits != 12)) { if (info->signed_data) pixel_value=ReadDCMSignedShort(stream_info,image); else pixel_value=(int) ReadDCMShort(stream_info,image); if (info->polarity != MagickFalse) pixel_value=(int)info->max_value-pixel_value; } else { if ((i & 0x01) != 0) pixel_value=(ReadDCMByte(stream_info,image) << 8) | byte; else { pixel_value=ReadDCMSignedShort(stream_info,image); byte=(int) (pixel_value & 0x0f); pixel_value>>=4; } i++; } if (info->signed_data == 1) pixel_value-=32767; if (info->rescale) { double scaled_value; scaled_value=pixel_value*info->rescale_slope+ info->rescale_intercept; if (info->window_width == 0) { index=(int) scaled_value; } else { double window_max, window_min; window_min=ceil(info->window_center- (info->window_width-1.0)/2.0-0.5); window_max=floor(info->window_center+ (info->window_width-1.0)/2.0+0.5); if (scaled_value <= window_min) index=0; else if (scaled_value > window_max) index=(int) info->max_value; else index=(int) (info->max_value*(((scaled_value- info->window_center-0.5)/(info->window_width-1))+0.5)); } } else { index=pixel_value; } index&=info->mask; index=(int) ConstrainColormapIndex(image,(ssize_t) index,exception); if (first_segment) SetPixelIndex(image,(Quantum) index,q); else SetPixelIndex(image,(Quantum) (((size_t) index) | (((size_t) GetPixelIndex(image,q)) << 8)),q); pixel.red=(unsigned int) image->colormap[index].red; pixel.green=(unsigned int) image->colormap[index].green; pixel.blue=(unsigned int) image->colormap[index].blue; } else { if (info->bytes_per_pixel == 1) { pixel.red=(unsigned int) ReadDCMByte(stream_info,image); pixel.green=(unsigned int) ReadDCMByte(stream_info,image); pixel.blue=(unsigned int) ReadDCMByte(stream_info,image); } else { pixel.red=ReadDCMShort(stream_info,image); pixel.green=ReadDCMShort(stream_info,image); pixel.blue=ReadDCMShort(stream_info,image); } pixel.red&=info->mask; pixel.green&=info->mask; pixel.blue&=info->mask; if (info->scale != (Quantum *) NULL) { if ((MagickSizeType) pixel.red <= GetQuantumRange(info->depth)) pixel.red=info->scale[pixel.red]; if ((MagickSizeType) pixel.green <= GetQuantumRange(info->depth)) pixel.green=info->scale[pixel.green]; if ((MagickSizeType) pixel.blue <= GetQuantumRange(info->depth)) pixel.blue=info->scale[pixel.blue]; } } if (first_segment != MagickFalse) { SetPixelRed(image,(Quantum) pixel.red,q); SetPixelGreen(image,(Quantum) pixel.green,q); SetPixelBlue(image,(Quantum) pixel.blue,q); } else { SetPixelRed(image,(Quantum) (((size_t) pixel.red) | (((size_t) GetPixelRed(image,q)) << 8)),q); SetPixelGreen(image,(Quantum) (((size_t) pixel.green) | (((size_t) GetPixelGreen(image,q)) << 8)),q); SetPixelBlue(image,(Quantum) (((size_t) pixel.blue) | (((size_t) GetPixelBlue(image,q)) << 8)),q); } q+=GetPixelChannels(image); } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } return(status); }
0
qemu
4154c7e03fa55b4cf52509a83d50d6c09d743b77
NOT_APPLICABLE
NOT_APPLICABLE
e1000e_set_fcrtl(E1000ECore *core, int index, uint32_t val) { core->mac[FCRTL] = val & 0x8000FFF8; }
0
matio
a47b7cd3aca70e9a0bddf8146eb4ab0cbd19c2c3
CVE-2019-20052
CWE-401
int SafeMulDims(const matvar_t *matvar, size_t* nelems) { int i; for ( i = 0; i < matvar->rank; i++ ) { if ( !psnip_safe_size_mul(nelems, *nelems, matvar->dims[i]) ) { *nelems = 0; return 1; } } return 0; }
1
qemu
79fa99831debc9782087e834382c577215f2f511
NOT_APPLICABLE
NOT_APPLICABLE
static uint32_t *intel_hda_reg_addr(IntelHDAState *d, const IntelHDAReg *reg) { uint8_t *addr = (void*)d; addr += reg->offset; return (uint32_t*)addr;
0
samba
c116652a3050a8549b722ae8ab5f9a2bf9a33b9f
NOT_APPLICABLE
NOT_APPLICABLE
static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx, const char lenbuf[4], int fd, char **buffer, unsigned int timeout, size_t *p_unread, size_t *len_ret) { /* Size of a WRITEX call (+4 byte len). */ char writeX_header[4 + STANDARD_WRITE_AND_X_HEADER_SIZE]; ssize_t len = smb_len_large(lenbuf); /* Could be a UNIX large writeX. */ ssize_t toread; NTSTATUS status; memcpy(writeX_header, lenbuf, 4); status = read_socket_with_timeout( fd, writeX_header + 4, STANDARD_WRITE_AND_X_HEADER_SIZE, STANDARD_WRITE_AND_X_HEADER_SIZE, timeout, NULL); if (!NT_STATUS_IS_OK(status)) { return status; } /* * Ok - now try and see if this is a possible * valid writeX call. */ if (is_valid_writeX_buffer((uint8_t *)writeX_header)) { /* * If the data offset is beyond what * we've read, drain the extra bytes. */ uint16_t doff = SVAL(writeX_header,smb_vwv11); ssize_t newlen; if (doff > STANDARD_WRITE_AND_X_HEADER_SIZE) { size_t drain = doff - STANDARD_WRITE_AND_X_HEADER_SIZE; if (drain_socket(smbd_server_fd(), drain) != drain) { smb_panic("receive_smb_raw_talloc_partial_read:" " failed to drain pending bytes"); } } else { doff = STANDARD_WRITE_AND_X_HEADER_SIZE; } /* Spoof down the length and null out the bcc. */ set_message_bcc(writeX_header, 0); newlen = smb_len(writeX_header); /* Copy the header we've written. */ *buffer = (char *)TALLOC_MEMDUP(mem_ctx, writeX_header, sizeof(writeX_header)); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)sizeof(writeX_header))); return NT_STATUS_NO_MEMORY; } /* Work out the remaining bytes. */ *p_unread = len - STANDARD_WRITE_AND_X_HEADER_SIZE; *len_ret = newlen + 4; return NT_STATUS_OK; } if (!valid_packet_size(len)) { return NT_STATUS_INVALID_PARAMETER; } /* * Not a valid writeX call. Just do the standard * talloc and return. */ *buffer = TALLOC_ARRAY(mem_ctx, char, len+4); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)len+4)); return NT_STATUS_NO_MEMORY; } /* Copy in what we already read. */ memcpy(*buffer, writeX_header, 4 + STANDARD_WRITE_AND_X_HEADER_SIZE); toread = len - STANDARD_WRITE_AND_X_HEADER_SIZE; if(toread > 0) { status = read_packet_remainder( fd, (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE, timeout, toread); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("receive_smb_raw_talloc_partial_read: %s\n", nt_errstr(status))); return status; } } *len_ret = len + 4; return NT_STATUS_OK; }
0
radare2
04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9
NOT_APPLICABLE
NOT_APPLICABLE
R_API int r_str_unescape(char *buf) { unsigned char ch = 0, ch2 = 0; int err = 0; int i; for (i = 0; buf[i]; i++) { if (buf[i] != '\\') { continue; } int esc_seq_len = 2; switch (buf[i + 1]) { case 'e': buf[i] = 0x1b; break; case '\\': buf[i] = '\\'; break; case 'r': buf[i] = 0x0d; break; case 'n': buf[i] = 0x0a; break; case 'a': buf[i] = 0x07; break; case 'b': buf[i] = 0x08; break; case 't': buf[i] = 0x09; break; case 'v': buf[i] = 0x0b; break; case 'f': buf[i] = 0x0c; break; case 'x': err = ch2 = ch = 0; if (!buf[i + 2] || !buf[i + 3]) { eprintf ("Unexpected end of string.\n"); return 0; } err |= r_hex_to_byte (&ch, buf[i + 2]); err |= r_hex_to_byte (&ch2, buf[i + 3]); if (err) { eprintf ("Error: Non-hexadecimal chars in input.\n"); return 0; // -1? } buf[i] = (ch << 4) + ch2; esc_seq_len = 4; break; default: if (IS_OCTAL (buf[i + 1])) { int num_digits = 1; buf[i] = buf[i + 1] - '0'; if (IS_OCTAL (buf[i + 2])) { num_digits++; buf[i] = (ut8)buf[i] * 8 + (buf[i + 2] - '0'); if (IS_OCTAL (buf[i + 3])) { num_digits++; buf[i] = (ut8)buf[i] * 8 + (buf[i + 3] - '0'); } } esc_seq_len = 1 + num_digits; } else { eprintf ("Error: Unknown escape sequence.\n"); return 0; // -1? } } memmove (buf + i + 1, buf + i + esc_seq_len, strlen (buf + i + esc_seq_len) + 1); } return i; }
0
qemu
c1b886c45dc70f247300f549dce9833f3fa2def5
NOT_APPLICABLE
NOT_APPLICABLE
uint32_t vga_ioport_read(void *opaque, uint32_t addr) { VGACommonState *s = opaque; int val, index; if (vga_ioport_invalid(s, addr)) { val = 0xff; } else { switch(addr) { case VGA_ATT_W: if (s->ar_flip_flop == 0) { val = s->ar_index; } else { val = 0; } break; case VGA_ATT_R: index = s->ar_index & 0x1f; if (index < VGA_ATT_C) { val = s->ar[index]; } else { val = 0; } break; case VGA_MIS_W: val = s->st00; break; case VGA_SEQ_I: val = s->sr_index; break; case VGA_SEQ_D: val = s->sr[s->sr_index]; #ifdef DEBUG_VGA_REG printf("vga: read SR%x = 0x%02x\n", s->sr_index, val); #endif break; case VGA_PEL_IR: val = s->dac_state; break; case VGA_PEL_IW: val = s->dac_write_index; break; case VGA_PEL_D: val = s->palette[s->dac_read_index * 3 + s->dac_sub_index]; if (++s->dac_sub_index == 3) { s->dac_sub_index = 0; s->dac_read_index++; } break; case VGA_FTC_R: val = s->fcr; break; case VGA_MIS_R: val = s->msr; break; case VGA_GFX_I: val = s->gr_index; break; case VGA_GFX_D: val = s->gr[s->gr_index]; #ifdef DEBUG_VGA_REG printf("vga: read GR%x = 0x%02x\n", s->gr_index, val); #endif break; case VGA_CRT_IM: case VGA_CRT_IC: val = s->cr_index; break; case VGA_CRT_DM: case VGA_CRT_DC: val = s->cr[s->cr_index]; #ifdef DEBUG_VGA_REG printf("vga: read CR%x = 0x%02x\n", s->cr_index, val); #endif break; case VGA_IS1_RM: case VGA_IS1_RC: /* just toggle to fool polling */ val = s->st01 = s->retrace(s); s->ar_flip_flop = 0; break; default: val = 0x00; break; } } #if defined(DEBUG_VGA) printf("VGA: read addr=0x%04x data=0x%02x\n", addr, val); #endif return val; }
0
dpdk
97ecc1c85c95c13bc66a87435758e93406c35c48
NOT_APPLICABLE
NOT_APPLICABLE
vhost_flush_enqueue_batch_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, uint64_t *lens, uint16_t *ids) { uint16_t i; uint16_t flags; if (vq->shadow_used_idx) { do_data_copy_enqueue(dev, vq); vhost_flush_enqueue_shadow_packed(dev, vq); } flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq->used_wrap_counter); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { vq->desc_packed[vq->last_used_idx + i].id = ids[i]; vq->desc_packed[vq->last_used_idx + i].len = lens[i]; } rte_smp_wmb(); vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) vq->desc_packed[vq->last_used_idx + i].flags = flags; vhost_log_cache_used_vring(dev, vq, vq->last_used_idx * sizeof(struct vring_packed_desc), sizeof(struct vring_packed_desc) * PACKED_BATCH_SIZE); vhost_log_cache_sync(dev, vq); vq_inc_last_used_packed(vq, PACKED_BATCH_SIZE); }
0
nasm
7c88289e222dc5ef9f53f9e86ecaab1924744b88
NOT_APPLICABLE
NOT_APPLICABLE
static Token *pp_tokline(void) { while (true) { Line *l = istk->expansion; Token *tline = NULL; Token *dtline; /* * Fetch a tokenized line, either from the macro-expansion * buffer or from the input file. */ tline = NULL; while (l && l->finishes) { MMacro *fm = l->finishes; nasm_assert(fm == istk->mstk.mstk); if (!fm->name && fm->in_progress > 1) { /* * This is a macro-end marker for a macro with no * name, which means it's not really a macro at all * but a %rep block, and the `in_progress' field is * more than 1, meaning that we still need to * repeat. (1 means the natural last repetition; 0 * means termination by %exitrep.) We have * therefore expanded up to the %endrep, and must * push the whole block on to the expansion buffer * again. We don't bother to remove the macro-end * marker: we'd only have to generate another one * if we did. */ fm->in_progress--; list_for_each(l, fm->expansion) { Line *ll; nasm_new(ll); ll->next = istk->expansion; ll->first = dup_tlist(l->first, NULL); ll->where = l->where; istk->expansion = ll; } break; } else { MMacro *m = istk->mstk.mstk; /* * Check whether a `%rep' was started and not ended * within this macro expansion. This can happen and * should be detected. It's a fatal error because * I'm too confused to work out how to recover * sensibly from it. */ if (defining) { if (defining->name) nasm_panic("defining with name in expansion"); else if (m->name) nasm_fatal("`%%rep' without `%%endrep' within" " expansion of macro `%s'", m->name); } /* * FIXME: investigate the relationship at this point between * istk->mstk.mstk and fm */ istk->mstk = m->mstk; if (m->name) { /* * This was a real macro call, not a %rep, and * therefore the parameter information needs to * be freed and the iteration count/nesting * depth adjusted. */ if (!--mmacro_deadman.levels) { /* * If all mmacro processing done, * clear all counters and the deadman * message trigger. */ nasm_zero(mmacro_deadman); /* Clear all counters */ } #if 0 if (m->prev) { pop_mmacro(m); fm->in_progress --; } else #endif { nasm_free(m->params); free_tlist(m->iline); nasm_free(m->paramlen); fm->in_progress = 0; m->params = NULL; m->iline = NULL; m->paramlen = NULL; } } if (fm->nolist & NL_LIST) { istk->nolist--; } else if (!istk->nolist) { lfmt->downlevel(LIST_MACRO); } if (fm->nolist & NL_LINE) { istk->noline--; } else if (!istk->noline) { if (fm == src_macro_current()) src_macro_pop(); src_update(l->where); } istk->where = l->where; /* * FIXME It is incorrect to always free_mmacro here. * It leads to usage-after-free. * * https://bugzilla.nasm.us/show_bug.cgi?id=3392414 */ #if 0 else free_mmacro(m); #endif } istk->expansion = l->next; nasm_free(l); return &tok_pop; } do { /* until we get a line we can use */ char *line; if (istk->expansion) { /* from a macro expansion */ Line *l = istk->expansion; istk->expansion = l->next; istk->where = l->where; tline = l->first; nasm_free(l); if (!istk->noline) src_update(istk->where); if (!istk->nolist) { line = detoken(tline, false); lfmt->line(LIST_MACRO, istk->where.lineno, line); nasm_free(line); } } else if ((line = read_line())) { line = prepreproc(line); tline = tokenize(line); nasm_free(line); } else { /* * The current file has ended; work down the istk */ Include *i = istk; Include *is; if (i->fp) fclose(i->fp); if (i->conds) { /* nasm_fatal can't be conditionally suppressed */ nasm_fatal("expected `%%endif' before end of file"); } list_for_each(is, i->next) { if (is->fp) { lfmt->downlevel(LIST_INCLUDE); src_update(is->where); break; } } istk = i->next; nasm_free(i); return &tok_pop; } } while (0); /* * We must expand MMacro parameters and MMacro-local labels * _before_ we plunge into directive processing, to cope * with things like `%define something %1' such as STRUC * uses. Unless we're _defining_ a MMacro, in which case * those tokens should be left alone to go into the * definition; and unless we're in a non-emitting * condition, in which case we don't want to meddle with * anything. */ if (!defining && !(istk->conds && !emitting(istk->conds->state)) && !(istk->mstk.mmac && !istk->mstk.mmac->in_progress)) { tline = expand_mmac_params(tline); } /* * Check the line to see if it's a preprocessor directive. */ if (do_directive(tline, &dtline) == DIRECTIVE_FOUND) { if (dtline) return dtline; } else if (defining) { /* * We're defining a multi-line macro. We emit nothing * at all, and just * shove the tokenized line on to the macro definition. */ MMacro *mmac = defining->dstk.mmac; Line *l; nasm_new(l); l->next = defining->expansion; l->first = tline; l->finishes = NULL; l->where = istk->where; defining->expansion = l; /* * Remember if this mmacro expansion contains %00: * if it does, we will have to handle leading labels * specially. */ if (mmac) { const Token *t; list_for_each(t, tline) { if (!memcmp(t->text.a, "%00", 4)) mmac->capture_label = true; } } } else if (istk->conds && !emitting(istk->conds->state)) { /* * We're in a non-emitting branch of a condition block. * Emit nothing at all, not even a blank line: when we * emerge from the condition we'll give a line-number * directive so we keep our place correctly. */ free_tlist(tline); } else if (istk->mstk.mstk && !istk->mstk.mstk->in_progress) { /* * We're in a %rep block which has been terminated, so * we're walking through to the %endrep without * emitting anything. Emit nothing at all, not even a * blank line: when we emerge from the %rep block we'll * give a line-number directive so we keep our place * correctly. */ free_tlist(tline); } else { tline = expand_smacro(tline); if (!expand_mmacro(tline)) return tline; } } }
0
libpng
8a05766cb74af05c04c53e6c9d60c13fc4d59bf2
NOT_APPLICABLE
NOT_APPLICABLE
png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, png_const_bytep prev_row) { unsigned int bpp = (row_info->pixel_depth + 7) >> 3; png_bytep rp_end = row + bpp; /* Process the first pixel in the row completely (this is the same as 'up' * because there is only one candidate predictor for the first row). */ while (row < rp_end) { int a = *row + *prev_row++; *row++ = (png_byte)a; } /* Remainder */ rp_end = rp_end + (row_info->rowbytes - bpp); while (row < rp_end) { int a, b, c, pa, pb, pc, p; c = *(prev_row - bpp); a = *(row - bpp); b = *prev_row++; p = b - c; pc = a - c; #ifdef PNG_USE_ABS pa = abs(p); pb = abs(pc); pc = abs(p + pc); #else pa = p < 0 ? -p : p; pb = pc < 0 ? -pc : pc; pc = (p + pc) < 0 ? -(p + pc) : p + pc; #endif if (pb < pa) { pa = pb; a = b; } if (pc < pa) a = c; a += *row; *row++ = (png_byte)a; } }
0
Chrome
23803a58e481e464a787e4b2c461af9e62f03905
NOT_APPLICABLE
NOT_APPLICABLE
int size() { return static_cast<int>(files_.size()); }
0
ghostpdl
c9b362ba908ca4b1d7c72663a33229588012d7d9
NOT_APPLICABLE
NOT_APPLICABLE
int epo_strip_copy_rop2(gx_device *dev, const byte *sdata, int sourcex, uint sraster, gx_bitmap_id id, const gx_color_index *scolors, const gx_strip_bitmap *textures, const gx_color_index *tcolors, int x, int y, int width, int height, int phase_x, int phase_y, gs_logical_operation_t lop, uint planar_height) { int code = epo_handle_erase_page(dev); if (code != 0) return code; return dev_proc(dev, strip_copy_rop2)(dev, sdata, sourcex, sraster, id, scolors, textures, tcolors, x, y, width, height, phase_x, phase_y, lop, planar_height); }
0
sound
e4ec8cc8039a7063e24204299b462bd1383184a5
NOT_APPLICABLE
NOT_APPLICABLE
static int snd_timer_register_system(void) { struct snd_timer *timer; struct snd_timer_system_private *priv; int err; err = snd_timer_global_new("system", SNDRV_TIMER_GLOBAL_SYSTEM, &timer); if (err < 0) return err; strcpy(timer->name, "system timer"); timer->hw = snd_timer_system; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) { snd_timer_free(timer); return -ENOMEM; } setup_timer(&priv->tlist, snd_timer_s_function, (unsigned long) timer); timer->private_data = priv; timer->private_free = snd_timer_free_system; return snd_timer_global_register(timer); }
0
file
59e63838913eee47f5c120a6c53d4565af638158
CVE-2014-9652
CWE-119
*/ private int mconvert(struct magic_set *ms, struct magic *m, int flip) { union VALUETYPE *p = &ms->ms_value; uint8_t type; switch (type = cvt_flip(m->type, flip)) { case FILE_BYTE: cvt_8(p, m); return 1; case FILE_SHORT: cvt_16(p, m); return 1; case FILE_LONG: case FILE_DATE: case FILE_LDATE: cvt_32(p, m); return 1; case FILE_QUAD: case FILE_QDATE: case FILE_QLDATE: case FILE_QWDATE: cvt_64(p, m); return 1; case FILE_STRING: case FILE_BESTRING16: case FILE_LESTRING16: { /* Null terminate and eat *trailing* return */ p->s[sizeof(p->s) - 1] = '\0'; return 1; } case FILE_PSTRING: { size_t sz = file_pstring_length_size(m); char *ptr1 = p->s, *ptr2 = ptr1 + sz; size_t len = file_pstring_get_length(m, ptr1); if (len >= sizeof(p->s)) { /* * The size of the pascal string length (sz) * is 1, 2, or 4. We need at least 1 byte for NUL * termination, but we've already truncated the * string by p->s, so we need to deduct sz. */ len = sizeof(p->s) - sz; } while (len--) *ptr1++ = *ptr2++; *ptr1 = '\0'; return 1; } case FILE_BESHORT: p->h = (short)((p->hs[0]<<8)|(p->hs[1])); cvt_16(p, m); return 1; case FILE_BELONG: case FILE_BEDATE: case FILE_BELDATE: p->l = (int32_t) ((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3])); if (type == FILE_BELONG) cvt_32(p, m); return 1; case FILE_BEQUAD: case FILE_BEQDATE: case FILE_BEQLDATE: case FILE_BEQWDATE: p->q = (uint64_t) (((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)| ((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)| ((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)| ((uint64_t)p->hq[6]<<8)|((uint64_t)p->hq[7])); if (type == FILE_BEQUAD) cvt_64(p, m); return 1; case FILE_LESHORT: p->h = (short)((p->hs[1]<<8)|(p->hs[0])); cvt_16(p, m); return 1; case FILE_LELONG: case FILE_LEDATE: case FILE_LELDATE: p->l = (int32_t) ((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0])); if (type == FILE_LELONG) cvt_32(p, m); return 1; case FILE_LEQUAD: case FILE_LEQDATE: case FILE_LEQLDATE: case FILE_LEQWDATE: p->q = (uint64_t) (((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)| ((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)| ((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)| ((uint64_t)p->hq[1]<<8)|((uint64_t)p->hq[0])); if (type == FILE_LEQUAD) cvt_64(p, m); return 1; case FILE_MELONG: case FILE_MEDATE: case FILE_MELDATE: p->l = (int32_t) ((p->hl[1]<<24)|(p->hl[0]<<16)|(p->hl[3]<<8)|(p->hl[2])); if (type == FILE_MELONG) cvt_32(p, m); return 1; case FILE_FLOAT: cvt_float(p, m); return 1; case FILE_BEFLOAT: p->l = ((uint32_t)p->hl[0]<<24)|((uint32_t)p->hl[1]<<16)| ((uint32_t)p->hl[2]<<8) |((uint32_t)p->hl[3]); cvt_float(p, m); return 1; case FILE_LEFLOAT: p->l = ((uint32_t)p->hl[3]<<24)|((uint32_t)p->hl[2]<<16)| ((uint32_t)p->hl[1]<<8) |((uint32_t)p->hl[0]); cvt_float(p, m); return 1; case FILE_DOUBLE: cvt_double(p, m); return 1; case FILE_BEDOUBLE: p->q = ((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)| ((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)| ((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)| ((uint64_t)p->hq[6]<<8) |((uint64_t)p->hq[7]); cvt_double(p, m); return 1; case FILE_LEDOUBLE: p->q = ((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)| ((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)| ((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)| ((uint64_t)p->hq[1]<<8) |((uint64_t)p->hq[0]); cvt_double(p, m); return 1; case FILE_REGEX: case FILE_SEARCH: case FILE_DEFAULT: case FILE_CLEAR: case FILE_NAME: case FILE_USE: return 1; default: file_magerror(ms, "invalid type %d in mconvert()", m->type); return 0;
1
php-src
aa82e99ed8003c01f1ef4f0940e56b85c5b032d4
NOT_APPLICABLE
NOT_APPLICABLE
PHP_FUNCTION(locale_accept_from_http) { UEnumeration *available; char *http_accept = NULL; int http_accept_len; UErrorCode status = 0; int len; char resultLocale[INTL_MAX_LOCALE_LEN+1]; UAcceptResult outResult; if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s", &http_accept, &http_accept_len) == FAILURE) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_accept_from_http: unable to parse input parameters", 0 TSRMLS_CC ); RETURN_FALSE; } if(http_accept_len > ULOC_FULLNAME_CAPACITY) { /* check each fragment, if any bigger than capacity, can't do it due to bug #72533 */ char *start = http_accept; char *end; size_t len; do { end = strchr(start, ','); len = end ? end-start : http_accept_len-(start-http_accept); if(len > ULOC_FULLNAME_CAPACITY) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_accept_from_http: locale string too long", 0 TSRMLS_CC ); RETURN_FALSE; } if(end) { start = end+1; } } while(end != NULL); } available = ures_openAvailableLocales(NULL, &status); INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to retrieve locale list"); len = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN, &outResult, http_accept, available, &status); uenum_close(available); INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to find acceptable locale"); if (len < 0 || outResult == ULOC_ACCEPT_FAILED) { RETURN_FALSE; } RETURN_STRINGL(resultLocale, len, 1); }
0
hylafax
c6cac8d8cd0dbe313689ba77023e12bc5b3027be
NOT_APPLICABLE
NOT_APPLICABLE
FaxModem::initializeDecoder(const Class2Params& params) { setupDecoder(recvFillOrder, params.is2D(), (params.df == DF_2DMMR)); u_int rowpixels = params.pageWidth(); // NB: assume rowpixels <= 4864 tiff_runlen_t runs[2*4864]; // run arrays for cur+ref rows setRuns(runs, runs+4864, rowpixels); setIsECM(false); resetLineCounts(); }
0
Espruino
51380baf17241728b6d48cdb84140b931e3e3cc5
NOT_APPLICABLE
NOT_APPLICABLE
NO_INLINE void jspeSkipBlock() { int brackets = 1; while (lex->tk && brackets) { if (lex->tk == '{') brackets++; else if (lex->tk == '}') { brackets--; if (!brackets) return; } JSP_ASSERT_MATCH(lex->tk); } }
0
linux
88d7d4e4a439f32acc56a6d860e415ee71d3df08
NOT_APPLICABLE
NOT_APPLICABLE
build_path_from_dentry(struct dentry *direntry) { struct dentry *temp; int namelen; int dfsplen; char *full_path; char dirsep; struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); unsigned seq; dirsep = CIFS_DIR_SEP(cifs_sb); if (tcon->Flags & SMB_SHARE_IS_IN_DFS) dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1); else dfsplen = 0; cifs_bp_rename_retry: namelen = dfsplen; seq = read_seqbegin(&rename_lock); rcu_read_lock(); for (temp = direntry; !IS_ROOT(temp);) { namelen += (1 + temp->d_name.len); temp = temp->d_parent; if (temp == NULL) { cERROR(1, "corrupt dentry"); rcu_read_unlock(); return NULL; } } rcu_read_unlock(); full_path = kmalloc(namelen+1, GFP_KERNEL); if (full_path == NULL) return full_path; full_path[namelen] = 0; /* trailing null */ rcu_read_lock(); for (temp = direntry; !IS_ROOT(temp);) { spin_lock(&temp->d_lock); namelen -= 1 + temp->d_name.len; if (namelen < 0) { spin_unlock(&temp->d_lock); break; } else { full_path[namelen] = dirsep; strncpy(full_path + namelen + 1, temp->d_name.name, temp->d_name.len); cFYI(0, "name: %s", full_path + namelen); } spin_unlock(&temp->d_lock); temp = temp->d_parent; if (temp == NULL) { cERROR(1, "corrupt dentry"); rcu_read_unlock(); kfree(full_path); return NULL; } } rcu_read_unlock(); if (namelen != dfsplen || read_seqretry(&rename_lock, seq)) { cFYI(1, "did not end path lookup where expected. namelen=%d " "dfsplen=%d", namelen, dfsplen); /* presumably this is only possible if racing with a rename of one of the parent directories (we can not lock the dentries above us to prevent this, but retrying should be harmless) */ kfree(full_path); goto cifs_bp_rename_retry; } /* DIR_SEP already set for byte 0 / vs \ but not for subsequent slashes in prepath which currently must be entered the right way - not sure if there is an alternative since the '\' is a valid posix character so we can not switch those safely to '/' if any are found in the middle of the prepath */ /* BB test paths to Windows with '/' in the midst of prepath */ if (dfsplen) { strncpy(full_path, tcon->treeName, dfsplen); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { int i; for (i = 0; i < dfsplen; i++) { if (full_path[i] == '\\') full_path[i] = '/'; } } } return full_path; }
0
linux
f8be156be163a052a067306417cd0ff679068c97
NOT_APPLICABLE
NOT_APPLICABLE
static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu) { int ret = -EINTR; int idx = srcu_read_lock(&vcpu->kvm->srcu); if (kvm_arch_vcpu_runnable(vcpu)) { kvm_make_request(KVM_REQ_UNHALT, vcpu); goto out; } if (kvm_cpu_has_pending_timer(vcpu)) goto out; if (signal_pending(current)) goto out; if (kvm_check_request(KVM_REQ_UNBLOCK, vcpu)) goto out; ret = 0; out: srcu_read_unlock(&vcpu->kvm->srcu, idx); return ret; }
0
linux
0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7
NOT_APPLICABLE
NOT_APPLICABLE
int invalidate_inodes(struct super_block *sb, bool kill_dirty) { int busy = 0; struct inode *inode, *next; LIST_HEAD(dispose); spin_lock(&sb->s_inode_list_lock); list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { spin_lock(&inode->i_lock); if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); continue; } if (inode->i_state & I_DIRTY_ALL && !kill_dirty) { spin_unlock(&inode->i_lock); busy = 1; continue; } if (atomic_read(&inode->i_count)) { spin_unlock(&inode->i_lock); busy = 1; continue; } inode->i_state |= I_FREEING; inode_lru_list_del(inode); spin_unlock(&inode->i_lock); list_add(&inode->i_lru, &dispose); } spin_unlock(&sb->s_inode_list_lock); dispose_list(&dispose); return busy; }
0
php-src
863d37ea66d5c960db08d6f4a2cbd2518f0f80d1
NOT_APPLICABLE
NOT_APPLICABLE
void gdImageColorTransparent (gdImagePtr im, int color) { if (color < 0) { return; } if (!im->trueColor) { if((color >= im->colorsTotal)) { return; } /* Make the old transparent color opaque again */ if (im->transparent != -1) { im->alpha[im->transparent] = gdAlphaOpaque; } im->alpha[color] = gdAlphaTransparent; } im->transparent = color; }
0
samba
6ef0e33fe8afa0ebb81652b9d42b42d20efadf04
NOT_APPLICABLE
NOT_APPLICABLE
static NTSTATUS get_null_nt_acl(TALLOC_CTX *mem_ctx, SEC_DESC **ppsd) { size_t sd_size; *ppsd = make_standard_sec_desc( mem_ctx, &global_sid_World, &global_sid_World, NULL, &sd_size); if(!*ppsd) { DEBUG(0,("get_null_nt_acl: Unable to malloc space for security descriptor.\n")); return NT_STATUS_NO_MEMORY; } return NT_STATUS_OK; }
0
FFmpeg
27a99e2c7d450fef15594671eef4465c8a166bd7
NOT_APPLICABLE
NOT_APPLICABLE
static int track_index(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *buf, unsigned size) { int64_t off; int64_t poff; int maxnp=0; AVIOContext pb0, *pb = &pb0; int i; int64_t filesize = avio_size(s->pb); uint64_t n_sb_blocks_tmp; ffio_init_context(pb, buf, size, 0, NULL, NULL, NULL, NULL); ffio_read_varlen(pb); // track_index_len avio_r8(pb); // 'c' n_sb_blocks_tmp = ffio_read_varlen(pb); if (n_sb_blocks_tmp > size / 2) return AVERROR_INVALIDDATA; viv->sb_blocks = av_calloc(n_sb_blocks_tmp, sizeof(*viv->sb_blocks)); if (!viv->sb_blocks) { return AVERROR(ENOMEM); } viv->n_sb_blocks = n_sb_blocks_tmp; off = 0; poff = 0; for (i = 0; i < viv->n_sb_blocks; i++) { uint64_t size_tmp = ffio_read_varlen(pb); uint64_t n_packets_tmp = ffio_read_varlen(pb); if (size_tmp > INT_MAX || n_packets_tmp > INT_MAX) return AVERROR_INVALIDDATA; viv->sb_blocks[i].byte_offset = off; viv->sb_blocks[i].packet_offset = poff; viv->sb_blocks[i].size = size_tmp; viv->sb_blocks[i].n_packets = n_packets_tmp; off += viv->sb_blocks[i].size; poff += viv->sb_blocks[i].n_packets; if (maxnp < viv->sb_blocks[i].n_packets) maxnp = viv->sb_blocks[i].n_packets; } if (filesize > 0 && poff > filesize) return AVERROR_INVALIDDATA; viv->sb_entries = av_calloc(maxnp, sizeof(VIV_SB_entry)); if (!viv->sb_entries) return AVERROR(ENOMEM); return 0; }
0
ImageMagick
f68a98a9d385838a1c73ec960a14102949940a64
NOT_APPLICABLE
NOT_APPLICABLE
static MagickBooleanType ReadPSDChannelRLE(Image *image,const PSDInfo *psd_info, const ssize_t type,MagickOffsetType *sizes,ExceptionInfo *exception) { MagickBooleanType status; size_t length, row_size; ssize_t count, y; unsigned char *compact_pixels, *pixels; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer data is RLE compressed"); row_size=GetPSDRowSize(image); pixels=(unsigned char *) AcquireQuantumMemory(row_size,sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); length=0; for (y=0; y < (ssize_t) image->rows; y++) if ((MagickOffsetType) length < sizes[y]) length=(size_t) sizes[y]; compact_pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels)); if (compact_pixels == (unsigned char *) NULL) { pixels=(unsigned char *) RelinquishMagickMemory(pixels); ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); } (void) ResetMagickMemory(compact_pixels,0,length*sizeof(*compact_pixels)); status=MagickTrue; for (y=0; y < (ssize_t) image->rows; y++) { status=MagickFalse; count=ReadBlob(image,(size_t) sizes[y],compact_pixels); if (count != (ssize_t) sizes[y]) break; count=DecodePSDPixels((size_t) sizes[y],compact_pixels, (ssize_t) (image->depth == 1 ? 123456 : image->depth),row_size,pixels); if (count != (ssize_t) row_size) break; status=ReadPSDChannelPixels(image,psd_info->channels,y,type,pixels, exception); if (status == MagickFalse) break; } compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels); pixels=(unsigned char *) RelinquishMagickMemory(pixels); return(status); }
0
libsolv
fdb9c9c03508990e4583046b590c30d958f272da
NOT_APPLICABLE
NOT_APPLICABLE
repodata_new_handle(Repodata *data) { if (!data->nxattrs) { data->xattrs = solv_calloc_block(1, sizeof(Id *), REPODATA_BLOCK); data->nxattrs = 2; /* -1: SOLVID_META */ } data->xattrs = solv_extend(data->xattrs, data->nxattrs, 1, sizeof(Id *), REPODATA_BLOCK); data->xattrs[data->nxattrs] = 0; return -(data->nxattrs++); }
0
linux
cef31d9af908243421258f1df35a4a644604efbe
NOT_APPLICABLE
NOT_APPLICABLE
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, struct timespec __user *,tp) { const struct k_clock *kc = clockid_to_kclock(which_clock); struct timespec64 kernel_tp; int error; if (!kc) return -EINVAL; error = kc->clock_get(which_clock, &kernel_tp); if (!error && put_timespec64(&kernel_tp, tp)) error = -EFAULT; return error; }
0
libtiff
99b10edde9a0fc28cc0e7b7757aa18ac4c8c225f
CVE-2018-18661
CWE-476
main(int argc, char* argv[]) { uint32 rowsperstrip = (uint32) -1; TIFF *in, *out; uint32 w, h; uint16 samplesperpixel; uint16 bitspersample; uint16 config; uint16 photometric; uint16* red; uint16* green; uint16* blue; tsize_t rowsize; register uint32 row; register tsample_t s; unsigned char *inbuf, *outbuf; char thing[1024]; int c; #if !HAVE_DECL_OPTARG extern int optind; extern char *optarg; #endif in = (TIFF *) NULL; out = (TIFF *) NULL; inbuf = (unsigned char *) NULL; outbuf = (unsigned char *) NULL; while ((c = getopt(argc, argv, "c:r:R:G:B:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case 'R': RED = PCT(atoi(optarg)); break; case 'G': GREEN = PCT(atoi(optarg)); break; case 'B': BLUE = PCT(atoi(optarg)); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 2) usage(); in = TIFFOpen(argv[optind], "r"); if (in == NULL) return (-1); photometric = 0; TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric); if (photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_PALETTE ) { fprintf(stderr, "%s: Bad photometric; can only handle RGB and Palette images.\n", argv[optind]); goto tiff2bw_error; } TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); if (samplesperpixel != 1 && samplesperpixel != 3) { fprintf(stderr, "%s: Bad samples/pixel %u.\n", argv[optind], samplesperpixel); goto tiff2bw_error; } if( photometric == PHOTOMETRIC_RGB && samplesperpixel != 3) { fprintf(stderr, "%s: Bad samples/pixel %u for PHOTOMETRIC_RGB.\n", argv[optind], samplesperpixel); goto tiff2bw_error; } TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); if (bitspersample != 8) { fprintf(stderr, " %s: Sorry, only handle 8-bit samples.\n", argv[optind]); goto tiff2bw_error; } TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) { goto tiff2bw_error; } TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(out, TIFFTAG_IMAGELENGTH, h); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); cpTags(in, out); if (compression != (uint16) -1) { TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_JPEG: TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } } TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); snprintf(thing, sizeof(thing), "B&W version of %s", argv[optind]); TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); TIFFSetField(out, TIFFTAG_SOFTWARE, "tiff2bw"); outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); #define pack(a,b) ((a)<<8 | (b)) switch (pack(photometric, config)) { case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_CONTIG): case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_SEPARATE): TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue); /* * Convert 16-bit colormap to 8-bit (unless it looks * like an old-style 8-bit colormap). */ if (checkcmap(in, 1<<bitspersample, red, green, blue) == 16) { int i; #define CVT(x) (((x) * 255L) / ((1L<<16)-1)) for (i = (1<<bitspersample)-1; i >= 0; i--) { red[i] = CVT(red[i]); green[i] = CVT(green[i]); blue[i] = CVT(blue[i]); } #undef CVT } inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); for (row = 0; row < h; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0) break; compresspalette(outbuf, inbuf, w, red, green, blue); if (TIFFWriteScanline(out, outbuf, row, 0) < 0) break; } break; case pack(PHOTOMETRIC_RGB, PLANARCONFIG_CONTIG): inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); for (row = 0; row < h; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0) break; compresscontig(outbuf, inbuf, w); if (TIFFWriteScanline(out, outbuf, row, 0) < 0) break; } break; case pack(PHOTOMETRIC_RGB, PLANARCONFIG_SEPARATE): rowsize = TIFFScanlineSize(in); inbuf = (unsigned char *)_TIFFmalloc(3*rowsize); for (row = 0; row < h; row++) { for (s = 0; s < 3; s++) if (TIFFReadScanline(in, inbuf+s*rowsize, row, s) < 0) goto tiff2bw_error; compresssep(outbuf, inbuf, inbuf+rowsize, inbuf+2*rowsize, w); if (TIFFWriteScanline(out, outbuf, row, 0) < 0) break; } break; } #undef pack if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); TIFFClose(in); TIFFClose(out); return (0); tiff2bw_error: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); if (out) TIFFClose(out); if (in) TIFFClose(in); return (-1); }
1
linux
8e2d61e0aed2b7c4ecb35844fe07e0b2b762dee4
NOT_APPLICABLE
NOT_APPLICABLE
static void sctp_free_addr_wq(struct net *net) { struct sctp_sockaddr_entry *addrw; struct sctp_sockaddr_entry *temp; spin_lock_bh(&net->sctp.addr_wq_lock); del_timer(&net->sctp.addr_wq_timer); list_for_each_entry_safe(addrw, temp, &net->sctp.addr_waitq, list) { list_del(&addrw->list); kfree(addrw); } spin_unlock_bh(&net->sctp.addr_wq_lock); }
0
FFmpeg
454a11a1c9c686c78aa97954306fb63453299760
NOT_APPLICABLE
NOT_APPLICABLE
static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, int line_size) { int i; /* read the pixels */ for(i=0;i<4;i++) { pixels[0] = av_clip_uint8(block[0]); pixels[1] = av_clip_uint8(block[1]); pixels[2] = av_clip_uint8(block[2]); pixels[3] = av_clip_uint8(block[3]); pixels += line_size; block += 8; } }
0
Chrome
a7d715ae5b654d1f98669fd979a00282a7229044
NOT_APPLICABLE
NOT_APPLICABLE
void WebContentsImpl::SetWasDiscarded(bool was_discarded) { GetFrameTree()->root()->set_was_discarded(); }
0
poppler
89a5367d49b2556a2635dbb6d48d6a6b182a2c6c
NOT_APPLICABLE
NOT_APPLICABLE
void JPXStream::reset() { priv->counter = 0; priv->ccounter = 0; }
0
pure-ftpd
37ad222868e52271905b94afea4fc780d83294b4
NOT_APPLICABLE
NOT_APPLICABLE
static struct passwd *fakegetpwnam(const char * const name) { static struct passwd pwd; (void) name; pwd.pw_name = pwd.pw_gecos = pwd.pw_shell = "ftp"; pwd.pw_passwd = "*"; pwd.pw_uid = (uid_t) 42U; pwd.pw_gid = (gid_t) 42U; pwd.pw_dir = WIN32_ANON_DIR; return &pwd; }
0
server
807945f2eb5fa22e6f233cc17b85a2e141efe2c8
NOT_APPLICABLE
NOT_APPLICABLE
Item_func_if::eval_not_null_tables(void *opt_arg) { if (Item_func::eval_not_null_tables(NULL)) return 1; not_null_tables_cache= (args[1]->not_null_tables() & args[2]->not_null_tables()); return 0; }
0
flatpak
a9107feeb4b8275b78965b36bf21b92d5724699e
NOT_APPLICABLE
NOT_APPLICABLE
flatpak_run_add_x11_args (FlatpakBwrap *bwrap, gboolean allowed) { g_autofree char *x11_socket = NULL; const char *display; /* Always cover /tmp/.X11-unix, that way we never see the host one in case * we have access to the host /tmp. If you request X access we'll put the right * thing in this anyway. */ flatpak_bwrap_add_args (bwrap, "--tmpfs", "/tmp/.X11-unix", NULL); if (!allowed) { flatpak_bwrap_unset_env (bwrap, "DISPLAY"); return; } g_debug ("Allowing x11 access"); display = g_getenv ("DISPLAY"); if (display && display[0] == ':' && g_ascii_isdigit (display[1])) { const char *display_nr = &display[1]; const char *display_nr_end = display_nr; g_autofree char *d = NULL; while (g_ascii_isdigit (*display_nr_end)) display_nr_end++; d = g_strndup (display_nr, display_nr_end - display_nr); x11_socket = g_strdup_printf ("/tmp/.X11-unix/X%s", d); flatpak_bwrap_add_args (bwrap, "--ro-bind", x11_socket, "/tmp/.X11-unix/X99", NULL); flatpak_bwrap_set_env (bwrap, "DISPLAY", ":99.0", TRUE); #ifdef ENABLE_XAUTH g_auto(GLnxTmpfile) xauth_tmpf = { 0, }; if (glnx_open_anonymous_tmpfile (O_RDWR | O_CLOEXEC, &xauth_tmpf, NULL)) { FILE *output = fdopen (xauth_tmpf.fd, "wb"); if (output != NULL) { /* fd is now owned by output, steal it from the tmpfile */ int tmp_fd = dup (glnx_steal_fd (&xauth_tmpf.fd)); if (tmp_fd != -1) { g_autofree char *dest = g_strdup_printf ("/run/user/%d/Xauthority", getuid ()); write_xauth (d, output); flatpak_bwrap_add_args_data_fd (bwrap, "--ro-bind-data", tmp_fd, dest); flatpak_bwrap_set_env (bwrap, "XAUTHORITY", dest, TRUE); } fclose (output); if (tmp_fd != -1) lseek (tmp_fd, 0, SEEK_SET); } } #endif } else { flatpak_bwrap_unset_env (bwrap, "DISPLAY"); } }
0
libplist
32ee5213fe64f1e10ec76c1ee861ee6f233120dd
NOT_APPLICABLE
NOT_APPLICABLE
static void serialize_plist(node_t* node, void* data) { uint64_t *index_val = NULL; struct serialize_s *ser = (struct serialize_s *) data; uint64_t current_index = ser->objects->len; void* val = hash_table_lookup(ser->ref_table, node); if (val) { return; } index_val = (uint64_t *) malloc(sizeof(uint64_t)); assert(index_val != NULL); *index_val = current_index; hash_table_insert(ser->ref_table, node, index_val); ptr_array_add(ser->objects, node); node_iterator_t *ni = node_iterator_create(node->children); node_t *ch; while ((ch = node_iterator_next(ni))) { serialize_plist(ch, data); } node_iterator_destroy(ni); return; }
0
Espruino
bf4416ab9129ee3afd56739ea4e3cd0da5484b6b
NOT_APPLICABLE
NOT_APPLICABLE
JsVar *jspEvaluateModule(JsVar *moduleContents) { assert(jsvIsString(moduleContents) || jsvIsFunction(moduleContents)); if (jsvIsFunction(moduleContents)) { moduleContents = jsvObjectGetChild(moduleContents,JSPARSE_FUNCTION_CODE_NAME,0); if (!jsvIsString(moduleContents)) { jsvUnLock(moduleContents); return 0; } } else jsvLockAgain(moduleContents); JsVar *scope = jsvNewObject(); JsVar *scopeExports = jsvNewObject(); if (!scope || !scopeExports) { // out of mem jsvUnLock3(scope, scopeExports, moduleContents); return 0; } JsVar *exportsName = jsvAddNamedChild(scope, scopeExports, "exports"); jsvUnLock2(scopeExports, jsvAddNamedChild(scope, scope, "module")); JsExecFlags oldExecute = execInfo.execute; JsVar *oldThisVar = execInfo.thisVar; execInfo.thisVar = scopeExports; // set 'this' variable to exports jsvUnLock(jspEvaluateVar(moduleContents, scope, 0)); execInfo.thisVar = oldThisVar; execInfo.execute = oldExecute; // make sure we fully restore state after parsing a module jsvUnLock2(moduleContents, scope); return jsvSkipNameAndUnLock(exportsName); }
0
linux
0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd
NOT_APPLICABLE
NOT_APPLICABLE
static int vfat_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) { struct super_block *sb = dir->i_sb; struct inode *inode; struct fat_slot_info sinfo; struct timespec ts; int err; lock_super(sb); ts = CURRENT_TIME_SEC; err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo); if (err) goto out; dir->i_version++; inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); brelse(sinfo.bh); if (IS_ERR(inode)) { err = PTR_ERR(inode); goto out; } inode->i_version++; inode->i_mtime = inode->i_atime = inode->i_ctime = ts; /* timestamp is already written, so mark_inode_dirty() is unneeded. */ dentry->d_time = dentry->d_parent->d_inode->i_version; d_instantiate(dentry, inode); out: unlock_super(sb); return err; }
0
wayland
5d201df72f3d4f4cb8b8f75f980169b03507da38
NOT_APPLICABLE
NOT_APPLICABLE
_XcursorFindImageToc (XcursorFileHeader *fileHeader, XcursorDim size, int count) { unsigned int toc; XcursorDim thisSize; if (!fileHeader) return 0; for (toc = 0; toc < fileHeader->ntoc; toc++) { if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE) continue; thisSize = fileHeader->tocs[toc].subtype; if (thisSize != size) continue; if (!count) break; count--; } if (toc == fileHeader->ntoc) return -1; return toc; }
0
libtiff
5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3
NOT_APPLICABLE
NOT_APPLICABLE
DECLAREwriteFunc(writeBufferToContigStrips) { uint32 row, rowsperstrip; tstrip_t strip = 0; (void) imagewidth; (void) spp; (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); for (row = 0; row < imagelength; row += rowsperstrip) { uint32 nrows = (row+rowsperstrip > imagelength) ? imagelength-row : rowsperstrip; tsize_t stripsize = TIFFVStripSize(out, nrows); if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); return 0; } buf += stripsize; } return 1; }
0
mongo
c7f14b7be4a1f622fe81ef60f946a5aac17f3d0e
NOT_APPLICABLE
NOT_APPLICABLE
RoleName RoleName::parseFromBSON(const BSONElement& elem) { auto obj = elem.embeddedObjectUserCheck(); std::array<BSONElement, 2> fields; obj.getFields( {AuthorizationManager::ROLE_NAME_FIELD_NAME, AuthorizationManager::ROLE_DB_FIELD_NAME}, &fields); const auto& nameField = fields[0]; uassert(ErrorCodes::BadValue, str::stream() << "user name must contain a string field named: " << AuthorizationManager::ROLE_NAME_FIELD_NAME, nameField.type() == String); const auto& dbField = fields[1]; uassert(ErrorCodes::BadValue, str::stream() << "role name must contain a string field named: " << AuthorizationManager::ROLE_DB_FIELD_NAME, dbField.type() == String); return RoleName(nameField.valueStringData(), dbField.valueStringData()); }
0
linux
67de956ff5dc1d4f321e16cfbd63f5be3b691b43
NOT_APPLICABLE
NOT_APPLICABLE
static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) { struct nci_rf_intf_activated_ntf ntf; __u8 *data = skb->data; int err = NCI_STATUS_OK; ntf.rf_discovery_id = *data++; ntf.rf_interface = *data++; ntf.rf_protocol = *data++; ntf.activation_rf_tech_and_mode = *data++; ntf.max_data_pkt_payload_size = *data++; ntf.initial_num_credits = *data++; ntf.rf_tech_specific_params_len = *data++; pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id); pr_debug("rf_interface 0x%x\n", ntf.rf_interface); pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol); pr_debug("activation_rf_tech_and_mode 0x%x\n", ntf.activation_rf_tech_and_mode); pr_debug("max_data_pkt_payload_size 0x%x\n", ntf.max_data_pkt_payload_size); pr_debug("initial_num_credits 0x%x\n", ntf.initial_num_credits); pr_debug("rf_tech_specific_params_len %d\n", ntf.rf_tech_specific_params_len); if (ntf.rf_tech_specific_params_len > 0) { switch (ntf.activation_rf_tech_and_mode) { case NCI_NFC_A_PASSIVE_POLL_MODE: data = nci_extract_rf_params_nfca_passive_poll(ndev, &(ntf.rf_tech_specific_params.nfca_poll), data); break; case NCI_NFC_B_PASSIVE_POLL_MODE: data = nci_extract_rf_params_nfcb_passive_poll(ndev, &(ntf.rf_tech_specific_params.nfcb_poll), data); break; case NCI_NFC_F_PASSIVE_POLL_MODE: data = nci_extract_rf_params_nfcf_passive_poll(ndev, &(ntf.rf_tech_specific_params.nfcf_poll), data); break; default: pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", ntf.activation_rf_tech_and_mode); err = NCI_STATUS_RF_PROTOCOL_ERROR; goto exit; } } ntf.data_exch_rf_tech_and_mode = *data++; ntf.data_exch_tx_bit_rate = *data++; ntf.data_exch_rx_bit_rate = *data++; ntf.activation_params_len = *data++; pr_debug("data_exch_rf_tech_and_mode 0x%x\n", ntf.data_exch_rf_tech_and_mode); pr_debug("data_exch_tx_bit_rate 0x%x\n", ntf.data_exch_tx_bit_rate); pr_debug("data_exch_rx_bit_rate 0x%x\n", ntf.data_exch_rx_bit_rate); pr_debug("activation_params_len %d\n", ntf.activation_params_len); if (ntf.activation_params_len > 0) { switch (ntf.rf_interface) { case NCI_RF_INTERFACE_ISO_DEP: err = nci_extract_activation_params_iso_dep(ndev, &ntf, data); break; case NCI_RF_INTERFACE_FRAME: /* no activation params */ break; default: pr_err("unsupported rf_interface 0x%x\n", ntf.rf_interface); err = NCI_STATUS_RF_PROTOCOL_ERROR; break; } } exit: if (err == NCI_STATUS_OK) { ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size; ndev->initial_num_credits = ntf.initial_num_credits; /* set the available credits to initial value */ atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); } if (atomic_read(&ndev->state) == NCI_DISCOVERY) { /* A single target was found and activated automatically */ atomic_set(&ndev->state, NCI_POLL_ACTIVE); if (err == NCI_STATUS_OK) nci_target_auto_activated(ndev, &ntf); } else { /* ndev->state == NCI_W4_HOST_SELECT */ /* A selected target was activated, so complete the request */ atomic_set(&ndev->state, NCI_POLL_ACTIVE); nci_req_complete(ndev, err); } }
0