project
stringclasses
791 values
commit_id
stringlengths
6
81
CVE ID
stringlengths
13
16
CWE ID
stringclasses
127 values
func
stringlengths
5
484k
vul
int8
0
1
openssl
1b4a8df38fc9ab3c089ca5765075ee53ec5bd66a
NOT_APPLICABLE
NOT_APPLICABLE
EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len) { EC_KEY *ret; if (in == NULL || *in == NULL) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_PASSED_NULL_PARAMETER); return NULL; } if (a == NULL || *a == NULL) { if ((ret = EC_KEY_new()) == NULL) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_MALLOC_FAILURE); return NULL; } if (a) *a = ret; } else ret = *a; if (!d2i_ECPKParameters(&ret->group, in, len)) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_EC_LIB); return NULL; } return ret; }
0
ceph
f44a8ae8aa27ecef69528db9aec220f12492810e
NOT_APPLICABLE
NOT_APPLICABLE
void RGWInfo_ObjStore_SWIFT::list_slo_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store) { formatter.open_object_section("slo"); formatter.dump_int("max_manifest_segments", config->rgw_max_slo_entries); formatter.close_section(); }
0
libsolv
0077ef29eb46d2e1df2f230fc95a1d9748d49dec
NOT_APPLICABLE
NOT_APPLICABLE
strqueue_init(Strqueue *q) { q->str = 0; q->nstr = 0; }
0
linux
c40f7d74c741a907cfaeb73a7697081881c497d0
NOT_APPLICABLE
NOT_APPLICABLE
static unsigned long task_h_load(struct task_struct *p) { struct cfs_rq *cfs_rq = task_cfs_rq(p); update_cfs_rq_h_load(cfs_rq); return div64_ul(p->se.avg.load_avg * cfs_rq->h_load, cfs_rq_load_avg(cfs_rq) + 1); }
0
linux
9f645bcc566a1e9f921bdae7528a01ced5bc3713
NOT_APPLICABLE
NOT_APPLICABLE
static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task, struct uvesafb_par *par) { int i, err; uvesafb_reset(task); task->t.regs.eax = 0x4f0a; task->t.regs.ebx = 0x0; err = uvesafb_exec(task); if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) { par->pmi_setpal = par->ypan = 0; } else { par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4) + task->t.regs.edi); par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1]; par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2]; pr_info("protected mode interface info at %04x:%04x\n", (u16)task->t.regs.es, (u16)task->t.regs.edi); pr_info("pmi: set display start = %p, set palette = %p\n", par->pmi_start, par->pmi_pal); if (par->pmi_base[3]) { pr_info("pmi: ports ="); for (i = par->pmi_base[3]/2; par->pmi_base[i] != 0xffff; i++) pr_cont(" %x", par->pmi_base[i]); pr_cont("\n"); if (par->pmi_base[i] != 0xffff) { pr_info("can't handle memory requests, pmi disabled\n"); par->ypan = par->pmi_setpal = 0; } } } return 0; }
0
php-src
0d822f6df946764f3f0348b82efae2e1eaa83aa0
NOT_APPLICABLE
NOT_APPLICABLE
PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len) { return _php_math_number_format_ex_len(d, dec, dec_point, dec_point_len, thousand_sep, thousand_sep_len, NULL); }
0
tensorflow
e84c975313e8e8e38bb2ea118196369c45c51378
NOT_APPLICABLE
NOT_APPLICABLE
explicit BoostedTreesCalculateBestGainsPerFeatureOp( OpKernelConstruction* const context) : OpKernel(context) { OP_REQUIRES_OK(context, context->GetAttr("max_splits", &max_splits_)); OP_REQUIRES_OK(context, context->GetAttr("num_features", &num_features_)); }
0
php-src
7cf7148a8f8f4f55fb04de2a517d740bb6253eac
NOT_APPLICABLE
NOT_APPLICABLE
static php_iconv_err_t php_iconv_stream_filter_register_factory(void) { static php_stream_filter_factory filter_factory = { php_iconv_stream_filter_factory_create }; if (FAILURE == php_stream_filter_register_factory( php_iconv_stream_filter_ops.label, &filter_factory)) { return PHP_ICONV_ERR_UNKNOWN; } return PHP_ICONV_ERR_SUCCESS; }
0
Chrome
5925dff83699508b5e2735afb0297dfb310e159d
NOT_APPLICABLE
NOT_APPLICABLE
void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { CrashedPluginHelper(tab, plugin_path); }
0
Chrome
faaa2fd0a05f1622d9a8806da118d4f3b602e707
NOT_APPLICABLE
NOT_APPLICABLE
HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& document) : HTMLElement(tagName, document), SuspendableObject(&document), m_loadTimer(TaskRunnerHelper::get(TaskType::Unthrottled, &document), this, &HTMLMediaElement::loadTimerFired), m_progressEventTimer( TaskRunnerHelper::get(TaskType::Unthrottled, &document), this, &HTMLMediaElement::progressEventTimerFired), m_playbackProgressTimer( TaskRunnerHelper::get(TaskType::Unthrottled, &document), this, &HTMLMediaElement::playbackProgressTimerFired), m_audioTracksTimer( TaskRunnerHelper::get(TaskType::Unthrottled, &document), this, &HTMLMediaElement::audioTracksTimerFired), m_viewportFillDebouncerTimer( TaskRunnerHelper::get(TaskType::Unthrottled, &document), this, &HTMLMediaElement::viewportFillDebouncerTimerFired), m_checkViewportIntersectionTimer( TaskRunnerHelper::get(TaskType::Unthrottled, &document), this, &HTMLMediaElement::checkViewportIntersectionTimerFired), m_playedTimeRanges(), m_asyncEventQueue(GenericEventQueue::create(this)), m_playbackRate(1.0f), m_defaultPlaybackRate(1.0f), m_networkState(kNetworkEmpty), m_readyState(kHaveNothing), m_readyStateMaximum(kHaveNothing), m_volume(1.0f), m_lastSeekTime(0), m_previousProgressTime(std::numeric_limits<double>::max()), m_duration(std::numeric_limits<double>::quiet_NaN()), m_lastTimeUpdateEventWallTime(0), m_lastTimeUpdateEventMediaTime(std::numeric_limits<double>::quiet_NaN()), m_defaultPlaybackStartPosition(0), m_loadState(WaitingForSource), m_deferredLoadState(NotDeferred), m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired), m_webLayer(nullptr), m_displayMode(Unknown), m_officialPlaybackPosition(0), m_officialPlaybackPositionNeedsUpdate(true), m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()), m_pendingActionFlags(0), m_lockedPendingUserGesture(false), m_lockedPendingUserGestureIfCrossOriginExperimentEnabled(true), m_playing(false), m_shouldDelayLoadEvent(false), m_haveFiredLoadedData(false), m_autoplaying(true), m_muted(false), m_paused(true), m_seeking(false), m_sentStalledEvent(false), m_ignorePreloadNone(false), m_textTracksVisible(false), m_shouldPerformAutomaticTrackSelection(true), m_tracksAreReady(true), m_processingPreferenceChange(false), m_playingRemotely(false), m_inOverlayFullscreenVideo(false), m_mostlyFillingViewport(false), m_audioTracks(this, AudioTrackList::create(*this)), m_videoTracks(this, VideoTrackList::create(*this)), m_textTracks(this, nullptr), m_audioSourceNode(nullptr), m_autoplayUmaHelper(AutoplayUmaHelper::create(this)), m_remotePlaybackClient(nullptr), m_autoplayVisibilityObserver(nullptr), m_mediaControls(nullptr) { BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; m_lockedPendingUserGesture = computeLockedPendingUserGesture(document); m_lockedPendingUserGestureIfCrossOriginExperimentEnabled = isDocumentCrossOrigin(document); LocalFrame* frame = document.frame(); if (frame) { m_remotePlaybackClient = frame->loader().client()->createWebRemotePlaybackClient(*this); } setHasCustomStyleCallbacks(); addElementToDocumentMap(this, &document); UseCounter::count(document, UseCounter::HTMLMediaElement); }
0
elog
993bed4923c88593cc6b1186e0d1b9564994a25a
NOT_APPLICABLE
NOT_APPLICABLE
int get_verbose(void) { return _verbose_level; }
0
gpac
bceb03fd2be95097a7b409ea59914f332fb6bc86
NOT_APPLICABLE
NOT_APPLICABLE
void stri_del(GF_Box *s) { GF_SubTrackInformationBox *ptr = (GF_SubTrackInformationBox *)s; if (ptr == NULL) return; if (ptr->attribute_list) gf_free(ptr->attribute_list); gf_free(ptr); }
0
linux
c70422f760c120480fee4de6c38804c72aa26bc1
NOT_APPLICABLE
NOT_APPLICABLE
static void nfs4_free_openowner(struct nfs4_stateowner *so) { struct nfs4_openowner *oo = openowner(so); kmem_cache_free(openowner_slab, oo); }
0
openjpeg
73fdf28342e4594019af26eb6a347a34eceb6296
NOT_APPLICABLE
NOT_APPLICABLE
OPJ_BOOL opj_j2k_end_compress(opj_j2k_t *p_j2k, opj_stream_private_t *p_stream, opj_event_mgr_t * p_manager) { /* customization of the encoding */ if (! opj_j2k_setup_end_compress(p_j2k, p_manager)) { return OPJ_FALSE; } if (! opj_j2k_exec(p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) { return OPJ_FALSE; } return OPJ_TRUE; }
0
njs
6a07c2156a07ef307b6dcf3c2ca8571a5f1af7a6
NOT_APPLICABLE
NOT_APPLICABLE
njs_vm_create(njs_vm_opt_t *options) { njs_mp_t *mp; njs_vm_t *vm; njs_int_t ret; njs_uint_t i; njs_module_t **addons; mp = njs_mp_fast_create(2 * njs_pagesize(), 128, 512, 16); if (njs_slow_path(mp == NULL)) { return NULL; } vm = njs_mp_zalign(mp, sizeof(njs_value_t), sizeof(njs_vm_t)); if (njs_slow_path(vm == NULL)) { return NULL; } vm->mem_pool = mp; ret = njs_regexp_init(vm); if (njs_slow_path(ret != NJS_OK)) { return NULL; } njs_lvlhsh_init(&vm->values_hash); vm->options = *options; if (options->shared != NULL) { vm->shared = options->shared; } else { ret = njs_builtin_objects_create(vm); if (njs_slow_path(ret != NJS_OK)) { return NULL; } } vm->external = options->external; vm->trace.level = NJS_LEVEL_TRACE; vm->trace.size = 2048; vm->trace.data = vm; njs_set_undefined(&vm->retval); if (options->init) { ret = njs_vm_init(vm); if (njs_slow_path(ret != NJS_OK)) { return NULL; } } for (i = 0; njs_modules[i] != NULL; i++) { ret = njs_modules[i]->init(vm); if (njs_slow_path(ret != NJS_OK)) { return NULL; } } if (options->addons != NULL) { addons = options->addons; for (i = 0; addons[i] != NULL; i++) { ret = addons[i]->init(vm); if (njs_slow_path(ret != NJS_OK)) { return NULL; } } } vm->symbol_generator = NJS_SYMBOL_KNOWN_MAX; if (njs_scope_undefined_index(vm, 0) == NJS_INDEX_ERROR) { return NULL; } return vm; }
0
qemu
60253ed1e6ec6d8e5ef2efe7bf755f475dce9956
NOT_APPLICABLE
NOT_APPLICABLE
static void rng_backend_init(Object *obj) { object_property_add_bool(obj, "opened", rng_backend_prop_get_opened, rng_backend_prop_set_opened, NULL); }
0
ruby
1c2ef610358af33f9ded3086aa2d70aac03dcac5
NOT_APPLICABLE
NOT_APPLICABLE
rb_enc_cr_str_copy_for_substr(VALUE dest, VALUE src) { /* this function is designed for copying encoding and coderange * from src to new string "dest" which is made from the part of src. */ str_enc_copy(dest, src); switch (ENC_CODERANGE(src)) { case ENC_CODERANGE_7BIT: ENC_CODERANGE_SET(dest, ENC_CODERANGE_7BIT); break; case ENC_CODERANGE_VALID: if (!rb_enc_asciicompat(STR_ENC_GET(src)) || search_nonascii(RSTRING_PTR(dest), RSTRING_END(dest))) ENC_CODERANGE_SET(dest, ENC_CODERANGE_VALID); else ENC_CODERANGE_SET(dest, ENC_CODERANGE_7BIT); break; default: if (RSTRING_LEN(dest) == 0) { if (!rb_enc_asciicompat(STR_ENC_GET(src))) ENC_CODERANGE_SET(dest, ENC_CODERANGE_VALID); else ENC_CODERANGE_SET(dest, ENC_CODERANGE_7BIT); } break; } }
0
linux
e8d5f92b8d30bb4ade76494490c3c065e12411b1
NOT_APPLICABLE
NOT_APPLICABLE
static void printer_dev_free(struct kref *kref) { struct printer_dev *dev = container_of(kref, struct printer_dev, kref); kfree(dev); }
0
qemu
3251bdcf1c67427d964517053c3d185b46e618e8
NOT_APPLICABLE
NOT_APPLICABLE
static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev) { AHCIPCIState *d = container_of(s, AHCIPCIState, ahci); PCIDevice *pci_dev = (PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE); DPRINTF(0, "lower irq\n"); if (!pci_dev || !msi_enabled(pci_dev)) { qemu_irq_lower(s->irq); } }
0
radare2
d31c4d3cbdbe01ea3ded16a584de94149ecd31d9
NOT_APPLICABLE
NOT_APPLICABLE
R_API int r_bin_file_ref(RBin *bin, RBinFile *a) { RBinObject *o = r_bin_cur_object (bin); if (a && o) { o->referenced--; return true; } return false; }
0
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
NOT_APPLICABLE
NOT_APPLICABLE
Move_Zp2_Point( EXEC_OP_ FT_UShort point, FT_F26Dot6 dx, FT_F26Dot6 dy, FT_Bool touch ) { #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING if ( CUR.face->unpatented_hinting ) { if ( CUR.GS.both_x_axis ) { CUR.zp2.cur[point].x += dx; if ( touch ) CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X; } else { CUR.zp2.cur[point].y += dy; if ( touch ) CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y; } return; } #endif if ( CUR.GS.freeVector.x != 0 ) { CUR.zp2.cur[point].x += dx; if ( touch ) CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X; } if ( CUR.GS.freeVector.y != 0 ) { CUR.zp2.cur[point].y += dy; if ( touch ) CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y; } }
0
linux
70789d7052239992824628db8133de08dc78e593
NOT_APPLICABLE
NOT_APPLICABLE
fq_find(struct net *net, __be32 id, struct in6_addr *src, struct in6_addr *dst) { struct inet_frag_queue *q; struct ip6_create_arg arg; unsigned int hash; arg.id = id; arg.user = IP6_DEFRAG_LOCAL_DELIVER; arg.src = src; arg.dst = dst; read_lock(&ip6_frags.lock); hash = inet6_hash_frag(id, src, dst, ip6_frags.rnd); q = inet_frag_find(&net->ipv6.frags, &ip6_frags, &arg, hash); if (q == NULL) return NULL; return container_of(q, struct frag_queue, q); }
0
linux
beb39db59d14990e401e235faf66a6b9b31240b0
NOT_APPLICABLE
NOT_APPLICABLE
static inline int compute_score2(struct sock *sk, struct net *net, __be32 saddr, __be16 sport, __be32 daddr, unsigned int hnum, int dif) { int score; struct inet_sock *inet; if (!net_eq(sock_net(sk), net) || ipv6_only_sock(sk)) return -1; inet = inet_sk(sk); if (inet->inet_rcv_saddr != daddr || inet->inet_num != hnum) return -1; score = (sk->sk_family == PF_INET) ? 2 : 1; if (inet->inet_daddr) { if (inet->inet_daddr != saddr) return -1; score += 4; } if (inet->inet_dport) { if (inet->inet_dport != sport) return -1; score += 4; } if (sk->sk_bound_dev_if) { if (sk->sk_bound_dev_if != dif) return -1; score += 4; } return score; }
0
linux
f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
NOT_APPLICABLE
NOT_APPLICABLE
mISDN_sock_link(struct mISDN_sock_list *l, struct sock *sk) { write_lock_bh(&l->lock); sk_add_node(sk, &l->head); write_unlock_bh(&l->lock); }
0
CImg
ac8003393569aba51048c9d67e1491559877b1d1
NOT_APPLICABLE
NOT_APPLICABLE
//! Load image from a .cimg[z] file \newinstance static CImg<T> get_load_cimg(std::FILE *const file, const char axis='z', const float align=0) { return CImg<T>().load_cimg(file,axis,align);
0
Chrome
9b04ffd8e7a07e9b2947fe5b71acf85dff38a63f
NOT_APPLICABLE
NOT_APPLICABLE
bool PDFScriptableObject::HasMethod(const pp::Var& name, pp::Var* exception) { return instance_->HasScriptableMethod(name, exception); }
0
ovs
4af6da3b275b764b1afe194df6499b33d2bf4cde
NOT_APPLICABLE
NOT_APPLICABLE
ofputil_decode_bundle_add(const struct ofp_header *oh, struct ofputil_bundle_add_msg *msg, enum ofptype *typep) { struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length)); /* Pull the outer ofp_header. */ enum ofpraw raw = ofpraw_pull_assert(&b); ovs_assert(raw == OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE || raw == OFPRAW_ONFT13_BUNDLE_ADD_MESSAGE); /* Pull the bundle_ctrl header. */ const struct ofp14_bundle_ctrl_msg *m = ofpbuf_pull(&b, sizeof *m); msg->bundle_id = ntohl(m->bundle_id); msg->flags = ntohs(m->flags); /* Pull the inner ofp_header. */ if (b.size < sizeof(struct ofp_header)) { return OFPERR_OFPBFC_MSG_BAD_LEN; } msg->msg = b.data; if (msg->msg->version != oh->version) { return OFPERR_OFPBFC_BAD_VERSION; } size_t inner_len = ntohs(msg->msg->length); if (inner_len < sizeof(struct ofp_header) || inner_len > b.size) { return OFPERR_OFPBFC_MSG_BAD_LEN; } if (msg->msg->xid != oh->xid) { return OFPERR_OFPBFC_MSG_BAD_XID; } /* Reject unbundlable messages. */ enum ofptype type; enum ofperr error = ofptype_decode(&type, msg->msg); if (error) { VLOG_WARN_RL(&bad_ofmsg_rl, "OFPT14_BUNDLE_ADD_MESSAGE contained " "message is unparsable (%s)", ofperr_get_name(error)); return OFPERR_OFPBFC_MSG_UNSUP; /* 'error' would be confusing. */ } if (!ofputil_is_bundlable(type)) { VLOG_WARN_RL(&bad_ofmsg_rl, "%s message not allowed inside " "OFPT14_BUNDLE_ADD_MESSAGE", ofptype_get_name(type)); return OFPERR_OFPBFC_MSG_UNSUP; } if (typep) { *typep = type; } return 0; }
0
ghostscript
b326a71659b7837d3acde954b18bda1a6f5e9498
NOT_APPLICABLE
NOT_APPLICABLE
static int ciedefgvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 4) return_error(gs_error_stackunderflow); op -= 3; for (i=0;i < 4;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } return 0; }
0
xserver
dc777c346d5d452a53b13b917c45f6a1bad2f20b
NOT_APPLICABLE
NOT_APPLICABLE
ProcUngrabServer(ClientPtr client) { REQUEST_SIZE_MATCH(xReq); UngrabServer(client); return Success; }
0
linux
4397f04575c44e1440ec2e49b6302785c95fd2f8
NOT_APPLICABLE
NOT_APPLICABLE
create_trace_option_files(struct trace_array *tr, struct tracer *tracer) { struct trace_option_dentry *topts; struct trace_options *tr_topts; struct tracer_flags *flags; struct tracer_opt *opts; int cnt; int i; if (!tracer) return; flags = tracer->flags; if (!flags || !flags->opts) return; /* * If this is an instance, only create flags for tracers * the instance may have. */ if (!trace_ok_for_array(tracer, tr)) return; for (i = 0; i < tr->nr_topts; i++) { /* Make sure there's no duplicate flags. */ if (WARN_ON_ONCE(tr->topts[i].tracer->flags == tracer->flags)) return; } opts = flags->opts; for (cnt = 0; opts[cnt].name; cnt++) ; topts = kcalloc(cnt + 1, sizeof(*topts), GFP_KERNEL); if (!topts) return; tr_topts = krealloc(tr->topts, sizeof(*tr->topts) * (tr->nr_topts + 1), GFP_KERNEL); if (!tr_topts) { kfree(topts); return; } tr->topts = tr_topts; tr->topts[tr->nr_topts].tracer = tracer; tr->topts[tr->nr_topts].topts = topts; tr->nr_topts++; for (cnt = 0; opts[cnt].name; cnt++) { create_trace_option_file(tr, &topts[cnt], flags, &opts[cnt]); WARN_ONCE(topts[cnt].entry == NULL, "Failed to create trace option: %s", opts[cnt].name); } }
0
ImageMagick
4e81ce8b07219c69a9aeccb0f7f7b927ca6db74c
NOT_APPLICABLE
NOT_APPLICABLE
static Cache GetImagePixelCache(Image *image,const MagickBooleanType clone, ExceptionInfo *exception) { CacheInfo *magick_restrict cache_info; MagickBooleanType destroy, status; static MagickSizeType cpu_throttle = MagickResourceInfinity, cycles = 0, time_limit = 0; static time_t cache_timestamp = 0; status=MagickTrue; if (cpu_throttle == MagickResourceInfinity) cpu_throttle=GetMagickResourceLimit(ThrottleResource); if ((cpu_throttle != 0) && ((cycles++ % 32) == 0)) MagickDelay(cpu_throttle); if (time_limit == 0) { /* Set the expire time in seconds. */ time_limit=GetMagickResourceLimit(TimeResource); cache_timestamp=time((time_t *) NULL); } if ((time_limit != MagickResourceInfinity) && ((MagickSizeType) (time((time_t *) NULL)-cache_timestamp) >= time_limit)) { #if defined(ECANCELED) errno=ECANCELED; #endif ThrowFatalException(ResourceLimitFatalError,"TimeLimitExceeded"); } LockSemaphoreInfo(image->semaphore); assert(image->cache != (Cache) NULL); cache_info=(CacheInfo *) image->cache; destroy=MagickFalse; if ((cache_info->reference_count > 1) || (cache_info->mode == ReadMode)) { LockSemaphoreInfo(cache_info->semaphore); if ((cache_info->reference_count > 1) || (cache_info->mode == ReadMode)) { CacheInfo *clone_info; Image clone_image; /* Clone pixel cache. */ clone_image=(*image); clone_image.semaphore=AllocateSemaphoreInfo(); clone_image.reference_count=1; clone_image.cache=ClonePixelCache(cache_info); clone_info=(CacheInfo *) clone_image.cache; status=OpenPixelCache(&clone_image,IOMode,exception); if (status != MagickFalse) { if (clone != MagickFalse) status=ClonePixelCacheRepository(clone_info,cache_info, exception); if (status != MagickFalse) { if (cache_info->reference_count == 1) cache_info->nexus_info=(NexusInfo **) NULL; destroy=MagickTrue; image->cache=clone_image.cache; } } DestroySemaphoreInfo(&clone_image.semaphore); } UnlockSemaphoreInfo(cache_info->semaphore); } if (destroy != MagickFalse) cache_info=(CacheInfo *) DestroyPixelCache(cache_info); if (status != MagickFalse) { /* Ensure the image matches the pixel cache morphology. */ image->type=UndefinedType; if (ValidatePixelCacheMorphology(image) == MagickFalse) { status=OpenPixelCache(image,IOMode,exception); cache_info=(CacheInfo *) image->cache; if (cache_info->type == DiskCache) (void) ClosePixelCacheOnDisk(cache_info); } } UnlockSemaphoreInfo(image->semaphore); if (status == MagickFalse) return((Cache) NULL); return(image->cache); }
0
linux
51c19bf3d5cfaa66571e4b88ba2a6f6295311101
NOT_APPLICABLE
NOT_APPLICABLE
static void hci_cc_le_set_default_phy(struct hci_dev *hdev, struct sk_buff *skb) { __u8 status = *((__u8 *) skb->data); struct hci_cp_le_set_default_phy *cp; BT_DBG("%s status 0x%2.2x", hdev->name, status); if (status) return; cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_DEFAULT_PHY); if (!cp) return; hci_dev_lock(hdev); hdev->le_tx_def_phys = cp->tx_phys; hdev->le_rx_def_phys = cp->rx_phys; hci_dev_unlock(hdev); }
0
hhvm
08193b7f0cd3910256e00d599f0f3eb2519c44ca
NOT_APPLICABLE
NOT_APPLICABLE
bool HHVM_FUNCTION(mcrypt_module_is_block_algorithm_mode, const String& mode, const String& lib_dir /* = null_string */) { String dir = lib_dir.empty() ? String(MCG(modes_dir)) : lib_dir; return mcrypt_module_is_block_algorithm_mode((char*)mode.data(), (char*)dir.data()) == 1; }
0
ImageMagick
01843366d6a7b96e22ad7bb67f3df7d9fd4d5d74
NOT_APPLICABLE
NOT_APPLICABLE
MagickExport ExceptionType CatchImageException(Image *image) { ExceptionInfo *exception; ExceptionType severity; assert(image != (const Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); exception=AcquireExceptionInfo(); GetImageException(image,exception); CatchException(exception); severity=exception->severity; exception=DestroyExceptionInfo(exception); return(severity); }
0
linux
60a2362f769cf549dc466134efe71c8bf9fbaaba
NOT_APPLICABLE
NOT_APPLICABLE
unsigned int regulator_get_linear_step(struct regulator *regulator) { struct regulator_dev *rdev = regulator->rdev; return rdev->desc->uV_step; }
0
ruby
1c2ef610358af33f9ded3086aa2d70aac03dcac5
NOT_APPLICABLE
NOT_APPLICABLE
rb_enc_str_asciionly_p(VALUE str) { rb_encoding *enc = STR_ENC_GET(str); if (!rb_enc_asciicompat(enc)) return FALSE; else if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) return TRUE; return FALSE; }
0
bpf
c4eb1f403243fc7bbb7de644db8587c03de36da6
NOT_APPLICABLE
NOT_APPLICABLE
static inline bool htab_is_prealloc(const struct bpf_htab *htab) { return !(htab->map.map_flags & BPF_F_NO_PREALLOC); }
0
tor
43414eb98821d3b5c6c65181d7545ce938f82c8e
NOT_APPLICABLE
NOT_APPLICABLE
load_policy_from_option(config_line_t *config, smartlist_t **policy, int assume_action) { int r; addr_policy_list_free(*policy); *policy = NULL; r = parse_addr_policy(config, policy, assume_action); if (r < 0) { return -1; } if (*policy) { SMARTLIST_FOREACH_BEGIN(*policy, addr_policy_t *, n) { /* ports aren't used in these. */ if (n->prt_min > 1 || n->prt_max != 65535) { addr_policy_t newp, *c; memcpy(&newp, n, sizeof(newp)); newp.prt_min = 1; newp.prt_max = 65535; newp.is_canonical = 0; c = addr_policy_get_canonical_entry(&newp); SMARTLIST_REPLACE_CURRENT(*policy, n, c); addr_policy_free(n); } } SMARTLIST_FOREACH_END(n); } return 0; }
0
Chrome
a452fc081f4e81befb97cc911ea2391c61d32926
NOT_APPLICABLE
NOT_APPLICABLE
bool ExecutableAllocator::underMemoryPressure() { MetaAllocator::Statistics statistics = allocator->currentStatistics(); return statistics.bytesAllocated > statistics.bytesReserved / 2; }
0
gnutls
21f89efad7014a5ee0debd4cd3d59e27774b29e6
NOT_APPLICABLE
NOT_APPLICABLE
gnutls_handshake_set_timeout(gnutls_session_t session, unsigned int ms) { if (ms == GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT) ms = DEFAULT_HANDSHAKE_TIMEOUT_MS; if (IS_DTLS(session)) { gnutls_dtls_set_timeouts(session, DTLS_RETRANS_TIMEOUT, ms); return; } session->internals.handshake_timeout_ms = ms; }
0
LibRaw
89d065424f09b788f443734d44857289489ca9e2
NOT_APPLICABLE
NOT_APPLICABLE
void CLASS parse_foveon() { int entries, img=0, off, len, tag, save, i, wide, high, pent, poff[256][2]; char name[64], value[64]; order = 0x4949; /* Little-endian */ fseek (ifp, 36, SEEK_SET); flip = get4(); fseek (ifp, -4, SEEK_END); fseek (ifp, get4(), SEEK_SET); if (get4() != 0x64434553) return; /* SECd */ entries = (get4(),get4()); while (entries--) { off = get4(); len = get4(); tag = get4(); save = ftell(ifp); fseek (ifp, off, SEEK_SET); if (get4() != (0x20434553 | (tag << 24))) return; switch (tag) { case 0x47414d49: /* IMAG */ case 0x32414d49: /* IMA2 */ fseek (ifp, 8, SEEK_CUR); pent = get4(); wide = get4(); high = get4(); if (wide > raw_width && high > raw_height) { switch (pent) { case 5: load_flags = 1; case 6: load_raw = &CLASS foveon_sd_load_raw; break; case 30: load_raw = &CLASS foveon_dp_load_raw; break; default: load_raw = 0; } raw_width = wide; raw_height = high; data_offset = off+28; is_foveon = 1; } fseek (ifp, off+28, SEEK_SET); if (fgetc(ifp) == 0xff && fgetc(ifp) == 0xd8 && thumb_length < len-28) { thumb_offset = off+28; thumb_length = len-28; write_thumb = &CLASS jpeg_thumb; } if (++img == 2 && !thumb_length) { thumb_offset = off+24; thumb_width = wide; thumb_height = high; write_thumb = &CLASS foveon_thumb; } break; case 0x464d4143: /* CAMF */ meta_offset = off+8; meta_length = len-28; break; case 0x504f5250: /* PROP */ pent = (get4(),get4()); fseek (ifp, 12, SEEK_CUR); off += pent*8 + 24; if ((unsigned) pent > 256) pent=256; for (i=0; i < pent*2; i++) ((int *)poff)[i] = off + get4()*2; for (i=0; i < pent; i++) { foveon_gets (poff[i][0], name, 64); foveon_gets (poff[i][1], value, 64); if (!strcmp (name, "ISO")) iso_speed = atoi(value); if (!strcmp (name, "CAMMANUF")) strcpy (make, value); if (!strcmp (name, "CAMMODEL")) strcpy (model, value); if (!strcmp (name, "WB_DESC")) strcpy (model2, value); if (!strcmp (name, "TIME")) timestamp = atoi(value); if (!strcmp (name, "EXPTIME")) shutter = atoi(value) / 1000000.0; if (!strcmp (name, "APERTURE")) aperture = atof(value); if (!strcmp (name, "FLENGTH")) focal_len = atof(value); #ifdef LIBRAW_LIBRARY_BUILD if (!strcmp (name, "FLEQ35MM")) imgdata.lens.makernotes.FocalLengthIn35mmFormat = atof(value); if (!strcmp (name, "LENSARANGE")) { char *sp; imgdata.lens.makernotes.MaxAp4CurFocal = imgdata.lens.makernotes.MinAp4CurFocal = atof(value); sp = strrchr (value, ' '); if (sp) { imgdata.lens.makernotes.MinAp4CurFocal = atof(sp); if (imgdata.lens.makernotes.MaxAp4CurFocal > imgdata.lens.makernotes.MinAp4CurFocal) my_swap (float, imgdata.lens.makernotes.MaxAp4CurFocal, imgdata.lens.makernotes.MinAp4CurFocal); } } if (!strcmp (name, "LENSFRANGE")) { char *sp; imgdata.lens.makernotes.MinFocal = imgdata.lens.makernotes.MaxFocal = atof(value); sp = strrchr (value, ' '); if (sp) { imgdata.lens.makernotes.MaxFocal = atof(sp); if ((imgdata.lens.makernotes.MaxFocal + 0.17f) < imgdata.lens.makernotes.MinFocal) my_swap (float, imgdata.lens.makernotes.MaxFocal, imgdata.lens.makernotes.MinFocal); } } if (!strcmp (name, "LENSMODEL")) { imgdata.lens.makernotes.LensID = atoi(value); if (imgdata.lens.makernotes.LensID) imgdata.lens.makernotes.LensMount = Sigma_X3F; } } #endif } #ifdef LOCALTIME timestamp = mktime (gmtime (&timestamp)); #endif } fseek (ifp, save, SEEK_SET); }
0
quassel
da215fcb9cd3096a3e223c87577d5d4ab8f8518b
CVE-2011-3354
CWE-399
void CtcpParser::packedReply(CoreNetwork *net, const QString &bufname, const QList<QByteArray> &replies) { QList<QByteArray> params; int answerSize = 0; for(int i = 0; i < replies.count(); i++) { answerSize += replies.at(i).size(); } QByteArray quotedReply(answerSize, 0); int nextPos = 0; QByteArray &reply = quotedReply; for(int i = 0; i < replies.count(); i++) { reply = replies.at(i); quotedReply.replace(nextPos, reply.size(), reply); nextPos += reply.size(); } params << net->serverEncode(bufname) << quotedReply; // FIXME user proper event net->putCmd("NOTICE", params); }
1
libxml2
92b9e8c8b3787068565a1820ba575d042f9eec66
NOT_APPLICABLE
NOT_APPLICABLE
xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem) { int ret = 1; xmlElementPtr tst; CHECK_DTD; if (elem == NULL) return(1); #if 0 #ifdef LIBXML_REGEXP_ENABLED /* Build the regexp associated to the content model */ ret = xmlValidBuildContentModel(ctxt, elem); #endif #endif /* No Duplicate Types */ if (elem->etype == XML_ELEMENT_TYPE_MIXED) { xmlElementContentPtr cur, next; const xmlChar *name; cur = elem->content; while (cur != NULL) { if (cur->type != XML_ELEMENT_CONTENT_OR) break; if (cur->c1 == NULL) break; if (cur->c1->type == XML_ELEMENT_CONTENT_ELEMENT) { name = cur->c1->name; next = cur->c2; while (next != NULL) { if (next->type == XML_ELEMENT_CONTENT_ELEMENT) { if ((xmlStrEqual(next->name, name)) && (xmlStrEqual(next->prefix, cur->c1->prefix))) { if (cur->c1->prefix == NULL) { xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, "Definition of %s has duplicate references of %s\n", elem->name, name, NULL); } else { xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, "Definition of %s has duplicate references of %s:%s\n", elem->name, cur->c1->prefix, name); } ret = 0; } break; } if (next->c1 == NULL) break; if (next->c1->type != XML_ELEMENT_CONTENT_ELEMENT) break; if ((xmlStrEqual(next->c1->name, name)) && (xmlStrEqual(next->c1->prefix, cur->c1->prefix))) { if (cur->c1->prefix == NULL) { xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, "Definition of %s has duplicate references to %s\n", elem->name, name, NULL); } else { xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR, "Definition of %s has duplicate references to %s:%s\n", elem->name, cur->c1->prefix, name); } ret = 0; } next = next->c2; } } cur = cur->c2; } } /* VC: Unique Element Type Declaration */ tst = xmlGetDtdElementDesc(doc->intSubset, elem->name); if ((tst != NULL ) && (tst != elem) && ((tst->prefix == elem->prefix) || (xmlStrEqual(tst->prefix, elem->prefix))) && (tst->etype != XML_ELEMENT_TYPE_UNDEFINED)) { xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_ELEM_REDEFINED, "Redefinition of element %s\n", elem->name, NULL, NULL); ret = 0; } tst = xmlGetDtdElementDesc(doc->extSubset, elem->name); if ((tst != NULL ) && (tst != elem) && ((tst->prefix == elem->prefix) || (xmlStrEqual(tst->prefix, elem->prefix))) && (tst->etype != XML_ELEMENT_TYPE_UNDEFINED)) { xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_ELEM_REDEFINED, "Redefinition of element %s\n", elem->name, NULL, NULL); ret = 0; } /* One ID per Element Type * already done when registering the attribute if (xmlScanIDAttributeDecl(ctxt, elem) > 1) { ret = 0; } */ return(ret); }
0
qemu
5311fb805a4403bba024e83886fa0e7572265de4
NOT_APPLICABLE
NOT_APPLICABLE
static uint32_t rtl8139_io_readb(void *opaque, uint8_t addr) { RTL8139State *s = opaque; int ret; switch (addr) { case MAC0 ... MAC0+5: ret = s->phys[addr - MAC0]; break; case MAC0+6 ... MAC0+7: ret = 0; break; case MAR0 ... MAR0+7: ret = s->mult[addr - MAR0]; break; case TxStatus0 ... TxStatus0+4*4-1: ret = rtl8139_TxStatus_TxAddr_read(s, s->TxStatus, TxStatus0, addr, 1); break; case ChipCmd: ret = rtl8139_ChipCmd_read(s); break; case Cfg9346: ret = rtl8139_Cfg9346_read(s); break; case Config0: ret = rtl8139_Config0_read(s); break; case Config1: ret = rtl8139_Config1_read(s); break; case Config3: ret = rtl8139_Config3_read(s); break; case Config4: ret = rtl8139_Config4_read(s); break; case Config5: ret = rtl8139_Config5_read(s); break; case MediaStatus: /* The LinkDown bit of MediaStatus is inverse with link status */ ret = 0xd0 | (~s->BasicModeStatus & 0x04); DPRINTF("MediaStatus read 0x%x\n", ret); break; case HltClk: ret = s->clock_enabled; DPRINTF("HltClk read 0x%x\n", ret); break; case PCIRevisionID: ret = RTL8139_PCI_REVID; DPRINTF("PCI Revision ID read 0x%x\n", ret); break; case TxThresh: ret = s->TxThresh; DPRINTF("C+ TxThresh read(b) val=0x%02x\n", ret); break; case 0x43: /* Part of TxConfig register. Windows driver tries to read it */ ret = s->TxConfig >> 24; DPRINTF("RTL8139C TxConfig at 0x43 read(b) val=0x%02x\n", ret); break; default: DPRINTF("not implemented read(b) addr=0x%x\n", addr); ret = 0; break; } return ret; }
0
linux
ea702b80e0bbb2448e201472127288beb82ca2fe
NOT_APPLICABLE
NOT_APPLICABLE
SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, char *in_buf, int flags) { int rc; struct kvec iov[1]; int resp_buf_type; iov[0].iov_base = in_buf; iov[0].iov_len = get_rfc1002_length(in_buf) + 4; flags |= CIFS_NO_RESP; rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags); cFYI(DBG2, "SendRcvNoRsp flags %d rc %d", flags, rc); return rc; }
0
leptonica
5ee24b398bb67666f6d173763eaaedd9c36fb1e5
NOT_APPLICABLE
NOT_APPLICABLE
pixRemoveUnusedColors(PIX *pixs) { l_int32 i, j, w, h, d, nc, wpls, val, newval, index, zerofound; l_int32 rval, gval, bval; l_uint32 *datas, *lines; l_int32 *histo, *map1, *map2; PIXCMAP *cmap, *cmapd; PROCNAME("pixRemoveUnusedColors"); if (!pixs) return ERROR_INT("pixs not defined", procName, 1); if ((cmap = pixGetColormap(pixs)) == NULL) return 0; d = pixGetDepth(pixs); if (d != 2 && d != 4 && d != 8) return ERROR_INT("d not in {2, 4, 8}", procName, 1); /* Find which indices are actually used */ nc = pixcmapGetCount(cmap); if ((histo = (l_int32 *)LEPT_CALLOC(nc, sizeof(l_int32))) == NULL) return ERROR_INT("histo not made", procName, 1); pixGetDimensions(pixs, &w, &h, NULL); wpls = pixGetWpl(pixs); datas = pixGetData(pixs); for (i = 0; i < h; i++) { lines = datas + i * wpls; for (j = 0; j < w; j++) { switch (d) { case 2: val = GET_DATA_DIBIT(lines, j); break; case 4: val = GET_DATA_QBIT(lines, j); break; case 8: val = GET_DATA_BYTE(lines, j); break; default: LEPT_FREE(histo); return ERROR_INT("switch ran off end!", procName, 1); } if (val >= nc) { L_WARNING("cmap index out of bounds!\n", procName); continue; } histo[val]++; } } /* Check if there are any zeroes. If none, quit. */ zerofound = FALSE; for (i = 0; i < nc; i++) { if (histo[i] == 0) { zerofound = TRUE; break; } } if (!zerofound) { LEPT_FREE(histo); return 0; } /* Generate mapping tables between indices */ map1 = (l_int32 *)LEPT_CALLOC(nc, sizeof(l_int32)); map2 = (l_int32 *)LEPT_CALLOC(nc, sizeof(l_int32)); index = 0; for (i = 0; i < nc; i++) { if (histo[i] != 0) { map1[index] = i; /* get old index from new */ map2[i] = index; /* get new index from old */ index++; } } /* Generate new colormap and attach to pixs */ cmapd = pixcmapCreate(d); for (i = 0; i < index; i++) { pixcmapGetColor(cmap, map1[i], &rval, &gval, &bval); pixcmapAddColor(cmapd, rval, gval, bval); } pixSetColormap(pixs, cmapd); /* Map pixel (index) values to new cmap */ for (i = 0; i < h; i++) { lines = datas + i * wpls; for (j = 0; j < w; j++) { switch (d) { case 2: val = GET_DATA_DIBIT(lines, j); newval = map2[val]; SET_DATA_DIBIT(lines, j, newval); break; case 4: val = GET_DATA_QBIT(lines, j); newval = map2[val]; SET_DATA_QBIT(lines, j, newval); break; case 8: val = GET_DATA_BYTE(lines, j); newval = map2[val]; SET_DATA_BYTE(lines, j, newval); break; default: LEPT_FREE(histo); LEPT_FREE(map1); LEPT_FREE(map2); return ERROR_INT("switch ran off end!", procName, 1); } } } LEPT_FREE(histo); LEPT_FREE(map1); LEPT_FREE(map2); return 0; }
0
linux
a4a5ed2835e8ea042868b7401dced3f517cafa76
NOT_APPLICABLE
NOT_APPLICABLE
bool acpi_queue_hotplug_work(struct work_struct *work) { return queue_work(kacpi_hotplug_wq, work); }
0
Chrome
de485eb849be99305925de2257da3b85325df2fd
NOT_APPLICABLE
NOT_APPLICABLE
aura::Window* Shell::GetTargetRootWindow() { CHECK(HasInstance()); Shell* shell = GetInstance(); if (shell->scoped_target_root_window_) return shell->scoped_target_root_window_; return shell->target_root_window_; }
0
linux
e4f3aa2e1e67bb48dfbaaf1cad59013d5a5bc276
NOT_APPLICABLE
NOT_APPLICABLE
static int cdrom_get_random_writable(struct cdrom_device_info *cdi, struct rwrt_feature_desc *rfd) { struct packet_command cgc; char buffer[24]; int ret; init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ); cgc.cmd[0] = GPCMD_GET_CONFIGURATION; /* often 0x46 */ cgc.cmd[3] = CDF_RWRT; /* often 0x0020 */ cgc.cmd[8] = sizeof(buffer); /* often 0x18 */ cgc.quiet = 1; if ((ret = cdi->ops->generic_packet(cdi, &cgc))) return ret; memcpy(rfd, &buffer[sizeof(struct feature_header)], sizeof (*rfd)); return 0; }
0
Chrome
adca986a53b31b6da4cb22f8e755f6856daea89a
NOT_APPLICABLE
NOT_APPLICABLE
void NavigatorImpl::OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed, const base::TimeTicks& proceed_time) { CHECK(IsBrowserSideNavigationEnabled()); DCHECK(frame_tree_node); NavigationRequest* navigation_request = frame_tree_node->navigation_request(); if (!navigation_request) return; navigation_request->set_navigation_start_time(proceed_time); DCHECK_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, navigation_request->state()); if (proceed) navigation_request->BeginNavigation(); else CancelNavigation(frame_tree_node, true); }
0
qemu
284f191b4abad213aed04cb0458e1600fd18d7c4
NOT_APPLICABLE
NOT_APPLICABLE
static void *pvrdma_map_to_pdir(PCIDevice *pdev, uint64_t pdir_dma, uint32_t nchunks, size_t length) { uint64_t *dir, *tbl; int tbl_idx, dir_idx, addr_idx; void *host_virt = NULL, *curr_page; if (!nchunks) { rdma_error_report("Got nchunks=0"); return NULL; } length = ROUND_UP(length, TARGET_PAGE_SIZE); if (nchunks * TARGET_PAGE_SIZE != length) { rdma_error_report("Invalid nchunks/length (%u, %lu)", nchunks, (unsigned long)length); return NULL; } dir = rdma_pci_dma_map(pdev, pdir_dma, TARGET_PAGE_SIZE); if (!dir) { rdma_error_report("Failed to map to page directory"); return NULL; } tbl = rdma_pci_dma_map(pdev, dir[0], TARGET_PAGE_SIZE); if (!tbl) { rdma_error_report("Failed to map to page table 0"); goto out_unmap_dir; } curr_page = rdma_pci_dma_map(pdev, (dma_addr_t)tbl[0], TARGET_PAGE_SIZE); if (!curr_page) { rdma_error_report("Failed to map the page 0"); goto out_unmap_tbl; } host_virt = mremap(curr_page, 0, length, MREMAP_MAYMOVE); if (host_virt == MAP_FAILED) { host_virt = NULL; rdma_error_report("Failed to remap memory for host_virt"); goto out_unmap_tbl; } trace_pvrdma_map_to_pdir_host_virt(curr_page, host_virt); rdma_pci_dma_unmap(pdev, curr_page, TARGET_PAGE_SIZE); dir_idx = 0; tbl_idx = 1; addr_idx = 1; while (addr_idx < nchunks) { if (tbl_idx == TARGET_PAGE_SIZE / sizeof(uint64_t)) { tbl_idx = 0; dir_idx++; rdma_pci_dma_unmap(pdev, tbl, TARGET_PAGE_SIZE); tbl = rdma_pci_dma_map(pdev, dir[dir_idx], TARGET_PAGE_SIZE); if (!tbl) { rdma_error_report("Failed to map to page table %d", dir_idx); goto out_unmap_host_virt; } } curr_page = rdma_pci_dma_map(pdev, (dma_addr_t)tbl[tbl_idx], TARGET_PAGE_SIZE); if (!curr_page) { rdma_error_report("Failed to map to page %d, dir %d", tbl_idx, dir_idx); goto out_unmap_host_virt; } mremap(curr_page, 0, TARGET_PAGE_SIZE, MREMAP_MAYMOVE | MREMAP_FIXED, host_virt + TARGET_PAGE_SIZE * addr_idx); trace_pvrdma_map_to_pdir_next_page(addr_idx, curr_page, host_virt + TARGET_PAGE_SIZE * addr_idx); rdma_pci_dma_unmap(pdev, curr_page, TARGET_PAGE_SIZE); addr_idx++; tbl_idx++; } goto out_unmap_tbl; out_unmap_host_virt: munmap(host_virt, length); host_virt = NULL; out_unmap_tbl: rdma_pci_dma_unmap(pdev, tbl, TARGET_PAGE_SIZE); out_unmap_dir: rdma_pci_dma_unmap(pdev, dir, TARGET_PAGE_SIZE); return host_virt; }
0
xserver
dc777c346d5d452a53b13b917c45f6a1bad2f20b
NOT_APPLICABLE
NOT_APPLICABLE
ProcGetFontPath(ClientPtr client) { xGetFontPathReply reply; int rc, stringLens, numpaths; unsigned char *bufferStart; /* REQUEST (xReq); */ REQUEST_SIZE_MATCH(xReq); rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart); if (rc != Success) return rc; reply = (xGetFontPathReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = bytes_to_int32(stringLens + numpaths), .nPaths = numpaths }; WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); if (stringLens || numpaths) WriteToClient(client, stringLens + numpaths, bufferStart); return Success; }
0
linux
60085c3d009b0df252547adb336d1ccca5ce52ec
NOT_APPLICABLE
NOT_APPLICABLE
static int listen(struct socket *sock, int len) { struct sock *sk = sock->sk; int res; lock_sock(sk); if (sock->state != SS_UNCONNECTED) res = -EINVAL; else { sock->state = SS_LISTENING; res = 0; } release_sock(sk); return res; }
0
envoy
e9f936d85dc1edc34fabd0a1725ec180f2316353
NOT_APPLICABLE
NOT_APPLICABLE
bool expectNoCertChain() const { return expect_no_cert_chain_; }
0
libtiff
b18012dae552f85dcc5c57d3bf4e997a15b1cc1c
NOT_APPLICABLE
NOT_APPLICABLE
NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { static const char module[] = "NeXTDecode"; unsigned char *bp, *op; tmsize_t cc; uint8* row; tmsize_t scanline, n; (void) s; /* * Each scanline is assumed to start off as all * white (we assume a PhotometricInterpretation * of ``min-is-black''). */ for (op = (unsigned char*) buf, cc = occ; cc-- > 0;) *op++ = 0xff; bp = (unsigned char *)tif->tif_rawcp; cc = tif->tif_rawcc; scanline = tif->tif_scanlinesize; if (occ % scanline) { TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); return (0); } for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) { n = *bp++, cc--; switch (n) { case LITERALROW: /* * The entire scanline is given as literal values. */ if (cc < scanline) goto bad; _TIFFmemcpy(row, bp, scanline); bp += scanline; cc -= scanline; break; case LITERALSPAN: { tmsize_t off; /* * The scanline has a literal span that begins at some * offset. */ if( cc < 4 ) goto bad; off = (bp[0] * 256) + bp[1]; n = (bp[2] * 256) + bp[3]; if (cc < 4+n || off+n > scanline) goto bad; _TIFFmemcpy(row+off, bp+4, n); bp += 4+n; cc -= 4+n; break; } default: { uint32 npixels = 0, grey; uint32 imagewidth = tif->tif_dir.td_imagewidth; if( isTiled(tif) ) imagewidth = tif->tif_dir.td_tilewidth; tmsize_t op_offset = 0; /* * The scanline is composed of a sequence of constant * color ``runs''. We shift into ``run mode'' and * interpret bytes as codes of the form * <color><npixels> until we've filled the scanline. */ op = row; for (;;) { grey = (uint32)((n>>6) & 0x3); n &= 0x3f; /* * Ensure the run does not exceed the scanline * bounds, potentially resulting in a security * issue. */ while (n-- > 0 && npixels < imagewidth && op_offset < scanline) SETPIXEL(op, grey); if (npixels >= imagewidth) break; if (op_offset >= scanline ) { TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld", (long) tif->tif_row); return (0); } if (cc == 0) goto bad; n = *bp++, cc--; } break; } } } tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; return (1); bad: TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", (long) tif->tif_row); return (0); }
0
libvirt
15073504dbb624d3f6c911e85557019d3620fdb2
NOT_APPLICABLE
NOT_APPLICABLE
virSecuritySELinuxDomainSetPathLabel(virSecurityManager *mgr, virDomainDef *def, const char *path, bool allowSubtree G_GNUC_UNUSED) { virSecurityLabelDef *seclabel; seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); if (!seclabel || !seclabel->relabel) return 0; return virSecuritySELinuxSetFilecon(mgr, path, seclabel->imagelabel, true); }
0
ovs
0befd1f3745055c32940f5faf9559be6a14395e6
NOT_APPLICABLE
NOT_APPLICABLE
ofproto_port_get_stp_status(struct ofproto *ofproto, ofp_port_t ofp_port, struct ofproto_port_stp_status *s) { struct ofport *ofport = ofproto_get_port(ofproto, ofp_port); if (!ofport) { VLOG_WARN_RL(&rl, "%s: cannot get STP status on nonexistent " "port %"PRIu32, ofproto->name, ofp_port); return ENODEV; } return (ofproto->ofproto_class->get_stp_port_status ? ofproto->ofproto_class->get_stp_port_status(ofport, s) : EOPNOTSUPP); }
0
Chrome
f3030ed0e4a5832b62dc0d434c08be21203fd17b
NOT_APPLICABLE
NOT_APPLICABLE
AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch( const ScoredHistoryMatch& history_match, int score) { const history::URLRow& info = history_match.url_info; AutocompleteMatch match(this, score, !!info.visit_count(), history_match.url_matches.empty() ? AutocompleteMatch::HISTORY_TITLE : AutocompleteMatch::HISTORY_URL); match.destination_url = info.url(); DCHECK(match.destination_url.is_valid()); std::vector<size_t> offsets = OffsetsFromTermMatches(history_match.url_matches); const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & ~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP); match.fill_into_edit = AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), net::FormatUrlWithOffsets(info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, NULL, &offsets)); history::TermMatches new_matches = ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); match.contents = net::FormatUrl(info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, NULL, NULL); match.contents_class = SpansFromTermMatch(new_matches, match.contents.length(), true); if (!history_match.can_inline) { match.inline_autocomplete_offset = string16::npos; } else { DCHECK(!new_matches.empty()); match.inline_autocomplete_offset = new_matches[0].offset + new_matches[0].length; if (match.inline_autocomplete_offset > match.fill_into_edit.length()) match.inline_autocomplete_offset = match.fill_into_edit.length(); } match.description = info.title(); match.description_class = SpansFromTermMatch( history_match.title_matches, match.description.length(), false); return match; }
0
libxml2
6360a31a84efe69d155ed96306b9a931a40beab9
NOT_APPLICABLE
NOT_APPLICABLE
xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) { unsigned long key, okey, nbi = 0; xmlDictEntryPtr insert; unsigned int l; if ((dict == NULL) || (name == NULL)) return(NULL); if (len < 0) l = strlen((const char *) name); else l = len; if (((dict->limit > 0) && (l >= dict->limit)) || (l > INT_MAX / 2)) return(NULL); /* * Check for duplicate and insertion location. */ okey = xmlDictComputeKey(dict, name, l); key = okey % dict->size; if (dict->dict[key].valid == 0) { insert = NULL; } else { for (insert = &(dict->dict[key]); insert->next != NULL; insert = insert->next) { #ifdef __GNUC__ if ((insert->okey == okey) && (insert->len == l)) { if (!memcmp(insert->name, name, l)) return(insert->name); } #else if ((insert->okey == okey) && (insert->len == l) && (!xmlStrncmp(insert->name, name, l))) return(insert->name); #endif nbi++; } #ifdef __GNUC__ if ((insert->okey == okey) && (insert->len == l)) { if (!memcmp(insert->name, name, l)) return(insert->name); } #else if ((insert->okey == okey) && (insert->len == l) && (!xmlStrncmp(insert->name, name, l))) return(insert->name); #endif } if (dict->subdict) { unsigned long skey; /* we cannot always reuse the same okey for the subdict */ if (((dict->size == MIN_DICT_SIZE) && (dict->subdict->size != MIN_DICT_SIZE)) || ((dict->size != MIN_DICT_SIZE) && (dict->subdict->size == MIN_DICT_SIZE))) skey = xmlDictComputeKey(dict->subdict, name, l); else skey = okey; key = skey % dict->subdict->size; if (dict->subdict->dict[key].valid != 0) { xmlDictEntryPtr tmp; for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL; tmp = tmp->next) { #ifdef __GNUC__ if ((tmp->okey == skey) && (tmp->len == l)) { if (!memcmp(tmp->name, name, l)) return(tmp->name); } #else if ((tmp->okey == skey) && (tmp->len == l) && (!xmlStrncmp(tmp->name, name, l))) return(tmp->name); #endif nbi++; } #ifdef __GNUC__ if ((tmp->okey == skey) && (tmp->len == l)) { if (!memcmp(tmp->name, name, l)) return(tmp->name); } #else if ((tmp->okey == skey) && (tmp->len == l) && (!xmlStrncmp(tmp->name, name, l))) return(tmp->name); #endif } } /* not found */ return(NULL); }
0
tensorflow
69c68ecbb24dff3fa0e46da0d16c821a2dd22d7c
NOT_APPLICABLE
NOT_APPLICABLE
void Compute(OpKernelContext* context) override { SparseTensorsMap* map = nullptr; OP_REQUIRES_OK(context, GetMap(context, false /* is_writing */, &map)); const Tensor& sparse_handles = context->input(0); OP_REQUIRES(context, TensorShapeUtils::IsVector(sparse_handles.shape()), errors::InvalidArgument( "sparse_handles should be a vector but received shape ", sparse_handles.shape().DebugString())); int64 N = sparse_handles.shape().dim_size(0); OP_REQUIRES( context, N > 0, errors::InvalidArgument("Must have at least 1 serialized SparseTensor, " "but input matrix has 0 rows")); std::vector<Tensor> indices_to_concat; std::vector<Tensor> values_to_concat; std::vector<TensorShape> shapes_to_concat; const auto& sparse_handles_t = sparse_handles.vec<int64>(); std::vector<SparseTensor> sparse_tensors; OP_REQUIRES_OK(context, map->RetrieveAndClearSparseTensors( context, sparse_handles_t, &sparse_tensors)); for (int64 i = 0; i < N; ++i) { const SparseTensor& st = sparse_tensors[i]; const Tensor& output_indices = st.indices(); const Tensor& output_values = st.values(); const auto output_shape = st.shape(); OP_REQUIRES(context, TensorShapeUtils::IsMatrix(output_indices.shape()), errors::InvalidArgument( "Expected sparse_handles[", i, "] to represent an index matrix but received shape ", output_indices.shape().DebugString())); OP_REQUIRES(context, TensorShapeUtils::IsVector(output_values.shape()), errors::InvalidArgument( "Expected sparse_handles[", i, "] to represent a values vector but received shape ", output_values.shape().DebugString())); OP_REQUIRES( context, DataTypeToEnum<T>::value == output_values.dtype(), errors::InvalidArgument( "Requested SparseTensor of type ", DataTypeString(DataTypeToEnum<T>::value), " but SparseTensor[", i, "].values.dtype() == ", DataTypeString(output_values.dtype()))); int64 num_entries = output_indices.dim_size(0); OP_REQUIRES(context, num_entries == output_values.dim_size(0), errors::InvalidArgument( "Expected row counts of SparseTensor[", i, "].indices and SparseTensor[", i, "].values to match but they do not: ", num_entries, " vs. ", output_values.dim_size(0))); int rank = output_indices.dim_size(1); OP_REQUIRES( context, rank == output_shape.size(), errors::InvalidArgument("Expected column counts of SparseTensor[", i, "].indices to match size of SparseTensor[", i, "].shape " "but they do not: ", rank, " vs. ", output_shape.size())); // Now we expand each SparseTensors' indices and shape by // prefixing a dimension Tensor expanded_indices( DT_INT64, TensorShape({num_entries, 1 + output_indices.dim_size(1)})); Tensor expanded_shape(DT_INT64, TensorShape({1 + rank})); const auto& output_indices_t = output_indices.matrix<int64>(); auto expanded_indices_t = expanded_indices.matrix<int64>(); auto expanded_shape_t = expanded_shape.vec<int64>(); expanded_indices_t.chip<1>(0).setZero(); Eigen::DSizes<Eigen::DenseIndex, 2> indices_start(0, 1); Eigen::DSizes<Eigen::DenseIndex, 2> indices_sizes(num_entries, rank); expanded_indices_t.slice(indices_start, indices_sizes) = output_indices_t; expanded_shape_t(0) = 1; // TODO: copy shape from TensorShape to &expanded_shape_t(1) // std::copy_n(&output_shape_t(0), rank, &expanded_shape_t(1)); for (int i = 0; i < rank; ++i) { expanded_shape_t(i + 1) = output_shape[i]; } TensorShape expanded_tensor_shape(expanded_shape_t); indices_to_concat.push_back(std::move(expanded_indices)); values_to_concat.push_back(output_values); shapes_to_concat.push_back(std::move(expanded_tensor_shape)); } int rank = -1; for (int i = 0; i < N; ++i) { if (rank < 0) rank = shapes_to_concat[i].dims(); OP_REQUIRES(context, rank == shapes_to_concat[i].dims(), errors::InvalidArgument( "Inconsistent rank across SparseTensors: rank prior to " "SparseTensor[", i, "] was: ", rank, " but rank of SparseTensor[", i, "] is: ", shapes_to_concat[i].dims())); } // SparseTensor::Concat requires consistent shape for all but the // primary order dimension (dimension 0 in this case). So we get // the maximum value across all the input SparseTensors for each // dimension and use that. TensorShape preconcat_shape(shapes_to_concat[0]); for (int i = 0; i < N; ++i) { for (int d = 0; d < rank; ++d) { preconcat_shape.set_dim(d, std::max(preconcat_shape.dim_size(d), shapes_to_concat[i].dim_size(d))); } } // Dimension 0 is the primary dimension. gtl::InlinedVector<int64, 8> std_order(rank); std::iota(std_order.begin(), std_order.end(), 0); std::vector<SparseTensor> tensors_to_concat; tensors_to_concat.reserve(N); for (int i = 0; i < N; ++i) { SparseTensor tensor; OP_REQUIRES_OK(context, SparseTensor::Create(std::move(indices_to_concat[i]), std::move(values_to_concat[i]), preconcat_shape, std_order, &tensor)); tensors_to_concat.push_back(std::move(tensor)); } auto output = SparseTensor::Concat<T>(tensors_to_concat); Tensor final_output_shape(DT_INT64, TensorShape({output.dims()})); std::copy_n(output.shape().data(), output.dims(), final_output_shape.vec<int64>().data()); context->set_output(0, output.indices()); context->set_output(1, output.values()); context->set_output(2, final_output_shape); }
0
Chrome
4c8b008f055f79e622344627fed7f820375a4f01
NOT_APPLICABLE
NOT_APPLICABLE
Document& Document::axObjectCacheOwner() const { Document* top = const_cast<Document*>(this); LocalFrame* frame = this->frame(); if (!frame) return *top; while (frame && frame->owner() && frame->owner()->isLocal()) { HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(frame->owner()); top = &owner->document(); frame = top->frame(); } if (top->frame() && top->frame()->pagePopupOwner()) { ASSERT(!top->m_axObjectCache); return top->frame()->pagePopupOwner()->document().axObjectCacheOwner(); } ASSERT(top); return *top; }
0
gegl
c83b05d565a1e3392c9606a4ecaa560eb9a4ee29
NOT_APPLICABLE
NOT_APPLICABLE
ppm_load_read_image(FILE *fp, pnm_struct *img) { guint i; if (img->type == PIXMAP_RAW || img->type == PIXMAP_RAW_GRAY) { if (fread (img->data, img->bpc, img->numsamples, fp) == 0) return; /* Fix endianness if necessary */ if (img->bpc > 1) { gushort *ptr = (gushort *) img->data; for (i=0; i < img->numsamples; i++) { *ptr = GUINT16_FROM_BE (*ptr); ptr++; } } } else { /* Plain PPM or PGM format */ if (img->bpc == sizeof (guchar)) { guchar *ptr = img->data; for (i = 0; i < img->numsamples; i++) { guint sample; if (!fscanf (fp, " %u", &sample)) sample = 0; *ptr++ = sample; } } else if (img->bpc == sizeof (gushort)) { gushort *ptr = (gushort *) img->data; for (i = 0; i < img->numsamples; i++) { guint sample; if (!fscanf (fp, " %u", &sample)) sample = 0; *ptr++ = sample; } } else { g_warning ("%s: Programmer stupidity error", G_STRLOC); } } }
0
linux
d3bd7413e0ca40b60cf60d4003246d067cafdeda
NOT_APPLICABLE
NOT_APPLICABLE
static bool func_states_equal(struct bpf_func_state *old, struct bpf_func_state *cur) { struct idpair *idmap; bool ret = false; int i; idmap = kcalloc(ID_MAP_SIZE, sizeof(struct idpair), GFP_KERNEL); /* If we failed to allocate the idmap, just say it's not safe */ if (!idmap) return false; for (i = 0; i < MAX_BPF_REG; i++) { if (!regsafe(&old->regs[i], &cur->regs[i], idmap)) goto out_free; } if (!stacksafe(old, cur, idmap)) goto out_free; if (!refsafe(old, cur)) goto out_free; ret = true; out_free: kfree(idmap); return ret; }
0
radare2
ecc44b6a2f18ee70ac133365de0e509d26d5e168
NOT_APPLICABLE
NOT_APPLICABLE
R_API void r_bin_java_get_field_json_definition(RBinJavaObj *bin, RBinJavaField *fm_type, PJ *pj) { r_bin_java_get_fm_type_definition_json (bin, fm_type, pj, 0); }
0
libxslt
7ca19df892ca22d9314e95d59ce2abdeff46b617
NOT_APPLICABLE
NOT_APPLICABLE
xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) { #ifdef XSLT_REFACTORED xsltStyleItemAttributePtr comp; #else xsltStylePreCompPtr comp; #endif /* * <xsl:attribute * name = { qname } * namespace = { uri-reference }> * <!-- Content: template --> * </xsl:attribute> */ if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE)) return; #ifdef XSLT_REFACTORED comp = (xsltStyleItemAttributePtr) xsltNewStylePreComp(style, XSLT_FUNC_ATTRIBUTE); #else comp = xsltNewStylePreComp(style, XSLT_FUNC_ATTRIBUTE); #endif if (comp == NULL) return; inst->psvi = comp; comp->inst = inst; /* * Attribute "name". */ /* * TODO: Precompile the AVT. See bug #344894. */ comp->name = xsltEvalStaticAttrValueTemplate(style, inst, (const xmlChar *)"name", NULL, &comp->has_name); if (! comp->has_name) { xsltTransformError(NULL, style, inst, "XSLT-attribute: The attribute 'name' is missing.\n"); style->errors++; return; } /* * Attribute "namespace". */ /* * TODO: Precompile the AVT. See bug #344894. */ comp->ns = xsltEvalStaticAttrValueTemplate(style, inst, (const xmlChar *)"namespace", NULL, &comp->has_ns); if (comp->name != NULL) { if (xmlValidateQName(comp->name, 0)) { xsltTransformError(NULL, style, inst, "xsl:attribute: The value '%s' of the attribute 'name' is " "not a valid QName.\n", comp->name); style->errors++; } else if (xmlStrEqual(comp->name, BAD_CAST "xmlns")) { xsltTransformError(NULL, style, inst, "xsl:attribute: The attribute name 'xmlns' is not allowed.\n"); style->errors++; } else { const xmlChar *prefix = NULL, *name; name = xsltSplitQName(style->dict, comp->name, &prefix); if (prefix != NULL) { if (comp->has_ns == 0) { xmlNsPtr ns; /* * SPEC XSLT 1.0: * "If the namespace attribute is not present, then the * QName is expanded into an expanded-name using the * namespace declarations in effect for the xsl:element * element, including any default namespace declaration. */ ns = xmlSearchNs(inst->doc, inst, prefix); if (ns != NULL) { comp->ns = xmlDictLookup(style->dict, ns->href, -1); comp->has_ns = 1; #ifdef XSLT_REFACTORED comp->nsPrefix = prefix; comp->name = name; #else (void)name; /* Suppress unused variable warning. */ #endif } else { xsltTransformError(NULL, style, inst, "xsl:attribute: The prefixed QName '%s' " "has no namespace binding in scope in the " "stylesheet; this is an error, since the " "namespace was not specified by the instruction " "itself.\n", comp->name); style->errors++; } } } } } }
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
qemu
7f61f4690dd153be98900a2a508b88989e692753
CVE-2016-7155
CWE-125
pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri) { int i; uint32_t txr_len_log2, rxr_len_log2; uint32_t req_ring_size, cmp_ring_size; m->rs_pa = ri->ringsStatePPN << VMW_PAGE_SHIFT; if ((ri->reqRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES) || (ri->cmpRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)) { return -1; } req_ring_size = ri->reqRingNumPages * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; cmp_ring_size = ri->cmpRingNumPages * PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE; txr_len_log2 = pvscsi_log2(req_ring_size - 1); }
1
Chrome
d57ecffa058b2af3b0678c43dce75f731550bbce
NOT_APPLICABLE
NOT_APPLICABLE
ChangeListLoader::~ChangeListLoader() { STLDeleteElements(&fast_fetch_feed_fetcher_set_); }
0
linux
a8b0ca17b80e92faab46ee7179ba9e99ccb61233
NOT_APPLICABLE
NOT_APPLICABLE
fmov_idx_reg(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n) { if (FPSCR_SZ) { FMOV_EXT(n); READ(FRn, Rm + R0 + 4); n++; READ(FRn, Rm + R0); } else { READ(FRn, Rm + R0); } return 0; }
0
linux
e50293ef9775c5f1cf3fcc093037dd6a8c5684ea
NOT_APPLICABLE
NOT_APPLICABLE
static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) { int ret = 0; if (hub_is_superspeed(hub->hdev)) { if (portstatus & USB_SS_PORT_STAT_POWER) ret = 1; } else { if (portstatus & USB_PORT_STAT_POWER) ret = 1; } return ret; }
0
libheif
2710c930918609caaf0a664e9c7bc3dce05d5b58
NOT_APPLICABLE
NOT_APPLICABLE
bool Box_hvcC::get_headers(std::vector<uint8_t>* dest) const { for (const auto& array : m_nal_array) { for (const auto& unit : array.m_nal_units) { dest->push_back( (unit.size()>>24) & 0xFF ); dest->push_back( (unit.size()>>16) & 0xFF ); dest->push_back( (unit.size()>> 8) & 0xFF ); dest->push_back( (unit.size()>> 0) & 0xFF ); /* dest->push_back(0); dest->push_back(0); dest->push_back(1); */ dest->insert(dest->end(), unit.begin(), unit.end()); } } return true; }
0
httpd
29afdd2550b3d30a8defece2b95ae81edcf66ac9
NOT_APPLICABLE
NOT_APPLICABLE
AP_CORE_DECLARE(void) ap_random_parent_after_fork(void) { /* * To ensure that the RNG state in the parent changes after the fork, we * pull some data from the RNG and discard it. This ensures that the RNG * states in the children are different even after the pid wraps around. * As we only use apr_random for insecure random bytes, pulling 2 bytes * should be enough. * XXX: APR should probably have some dedicated API to do this, but it * XXX: currently doesn't. */ apr_uint16_t data; apr_random_insecure_bytes(rng, &data, sizeof(data)); }
0
u-boot
master
NOT_APPLICABLE
NOT_APPLICABLE
int qrio_get_gpio(u8 port_off, u8 gpio_nr) { u32 gprt; void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE; gprt = in_be32(qrio_base + port_off + GPRT_OFF); return (gprt >> gpio_nr) & 1U; }
0
mupdf
83d4dae44c71816c084a635550acc1a51529b881
NOT_APPLICABLE
NOT_APPLICABLE
icc_base_conv_color(fz_context *ctx, fz_color_converter *cc, float *dstv, const float *srcv) { const fz_colorspace *srcs = cc->ss; float local_src_map[FZ_MAX_COLORS]; float local_src_map2[FZ_MAX_COLORS]; float *src_map = local_src_map; do { srcs->to_ccs(ctx, srcs, srcv, src_map); srcs = srcs->get_base(srcs); srcs->clamp(srcs, src_map, src_map); srcv = src_map; src_map = (src_map == local_src_map ? local_src_map2 : local_src_map); } while (!fz_colorspace_is_icc(ctx, srcs) && !fz_colorspace_is_cal(ctx, srcs)); icc_conv_color(ctx, cc, dstv, srcv); }
0
libvirt
e4f7589a3ec285489618ca04c8c0230cc31f3d99
NOT_APPLICABLE
NOT_APPLICABLE
libxlDomainCleanup(libxlDriverPrivate *driver, virDomainObj *vm) { libxlDomainObjPrivate *priv = vm->privateData; g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver); int vnc_port; char *file; virHostdevManager *hostdev_mgr = driver->hostdevMgr; unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI; VIR_DEBUG("Cleaning up domain with id '%d' and name '%s'", vm->def->id, vm->def->name); hostdev_flags |= VIR_HOSTDEV_SP_USB; /* Call hook with stopped operation. Ignore error and continue with cleanup */ ignore_value(libxlDomainHookRun(driver, vm->def, 0, VIR_HOOK_LIBXL_OP_STOPPED, VIR_HOOK_SUBOP_END, NULL)); virHostdevReAttachDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME, vm->def, hostdev_flags); if (priv->lockProcessRunning) { VIR_FREE(priv->lockState); if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0) VIR_WARN("Unable to release lease on %s", vm->def->name); else priv->lockProcessRunning = false; VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); } libxlLoggerCloseFile(cfg->logger, vm->def->id); vm->def->id = -1; if (priv->deathW) { libxl_evdisable_domain_death(cfg->ctx, priv->deathW); priv->deathW = NULL; } if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback) driver->inhibitCallback(false, driver->inhibitOpaque); if ((vm->def->ngraphics == 1) && vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && vm->def->graphics[0]->data.vnc.autoport) { vnc_port = vm->def->graphics[0]->data.vnc.port; if (vnc_port >= LIBXL_VNC_PORT_MIN) { if (virPortAllocatorRelease(vnc_port) < 0) VIR_DEBUG("Could not mark port %d as unused", vnc_port); } } libxlNetworkUnwindDevices(vm->def); file = g_strdup_printf("%s/%s.xml", cfg->stateDir, vm->def->name); if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR) VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name); VIR_FREE(file); /* Call hook with release operation. Ignore error and continue with cleanup */ ignore_value(libxlDomainHookRun(driver, vm->def, 0, VIR_HOOK_LIBXL_OP_RELEASE, VIR_HOOK_SUBOP_END, NULL)); virDomainObjRemoveTransientDef(vm); }
0
Chrome
04aaacb936a08d70862d6d9d7e8354721ae46be8
NOT_APPLICABLE
NOT_APPLICABLE
void Verify_BasicFindMainResponse() { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); EXPECT_EQ(1, delegate()->found_cache_id_); EXPECT_EQ(2, delegate()->found_group_id_); EXPECT_EQ(1, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); TestFinished(); }
0
linux
43629f8f5ea32a998d06d1bb41eefa0e821ff573
NOT_APPLICABLE
NOT_APPLICABLE
static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, int kern) { struct sock *sk; BT_DBG("sock %p", sock); if (sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto); if (!sk) return -ENOMEM; sock_init_data(sock, sk); sock->ops = &bnep_sock_ops; sock->state = SS_UNCONNECTED; sock_reset_flag(sk, SOCK_ZAPPED); sk->sk_protocol = protocol; sk->sk_state = BT_OPEN; return 0; }
0
linux
5d26a105b5a73e5635eae0629b42fa0a90e07b7b
NOT_APPLICABLE
NOT_APPLICABLE
static int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { struct des_ctx *dctx = crypto_tfm_ctx(tfm); u32 *flags = &tfm->crt_flags; u32 tmp[DES_EXPKEY_WORDS]; int ret; /* Expand to tmp */ ret = des_ekey(tmp, key); if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) { *flags |= CRYPTO_TFM_RES_WEAK_KEY; return -EINVAL; } /* Copy to output */ memcpy(dctx->expkey, tmp, sizeof(dctx->expkey)); return 0; }
0
net-snmp
5f881d3bf24599b90d67a45cae7a3eb099cd71c9
NOT_APPLICABLE
NOT_APPLICABLE
snmpv3_privtype_conf(const char *word, char *cptr) { int priv_type = usm_lookup_priv_type(cptr); if (priv_type < 0) config_perror("Unknown privacy type"); defaultPrivType = sc_get_priv_oid(priv_type, &defaultPrivTypeLen); DEBUGMSGTL(("snmpv3", "set default privacy type: %s\n", cptr)); }
0
libtiff
ce6841d9e41d621ba23cf18b190ee6a23b2cc833
NOT_APPLICABLE
NOT_APPLICABLE
readextension(void) { int count; char buf[255]; (void) getc(infile); while ((count = getc(infile))) fread(buf, 1, count, infile); }
0
Android
01ca88bb6c5bdd44e071f8effebe12f1d7da9853
CVE-2017-0540
CWE-119
WORD32 ihevcd_parse_transform_tree(codec_t *ps_codec, WORD32 x0, WORD32 y0, WORD32 cu_x_base, WORD32 cu_y_base, WORD32 log2_trafo_size, WORD32 trafo_depth, WORD32 blk_idx, WORD32 intra_pred_mode) { IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; sps_t *ps_sps; pps_t *ps_pps; WORD32 value; WORD32 x1, y1; WORD32 max_trafo_depth; bitstrm_t *ps_bitstrm = &ps_codec->s_parse.s_bitstrm; WORD32 intra_split_flag; WORD32 split_transform_flag; WORD32 ctxt_idx; cab_ctxt_t *ps_cabac = &ps_codec->s_parse.s_cabac; max_trafo_depth = ps_codec->s_parse.s_cu.i4_max_trafo_depth; ps_sps = ps_codec->s_parse.ps_sps; ps_pps = ps_codec->s_parse.ps_pps; intra_split_flag = ps_codec->s_parse.s_cu.i4_intra_split_flag; { split_transform_flag = 0; if((log2_trafo_size <= ps_sps->i1_log2_max_transform_block_size) && (log2_trafo_size > ps_sps->i1_log2_min_transform_block_size) && (trafo_depth < max_trafo_depth) && !(intra_split_flag && (trafo_depth == 0))) { /* encode the split transform flag, context derived as per Table9-37 */ ctxt_idx = IHEVC_CAB_SPLIT_TFM + (5 - log2_trafo_size); TRACE_CABAC_CTXT("split_transform_flag", ps_cabac->u4_range, ctxt_idx); split_transform_flag = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, ctxt_idx); AEV_TRACE("split_transform_flag", split_transform_flag, ps_cabac->u4_range); } else { WORD32 inter_split_flag = 0; if((0 == ps_sps->i1_max_transform_hierarchy_depth_inter) && (PRED_MODE_INTER == ps_codec->s_parse.s_cu.i4_pred_mode) && (PART_2Nx2N != ps_codec->s_parse.s_cu.i4_part_mode) && (0 == trafo_depth)) { inter_split_flag = 1; } if((log2_trafo_size > ps_sps->i1_log2_max_transform_block_size) || ((1 == intra_split_flag) && (0 == trafo_depth)) || (1 == inter_split_flag)) { split_transform_flag = 1; } } if(0 == trafo_depth) { ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth] = 0; ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth] = 0; } else { ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth] = ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth - 1]; ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth] = ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth - 1]; } if(trafo_depth == 0 || log2_trafo_size > 2) { ctxt_idx = IHEVC_CAB_CBCR_IDX + trafo_depth; /* CBF for Cb/Cr is sent only if the parent CBF for Cb/Cr is non-zero */ if((trafo_depth == 0) || ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth - 1]) { TRACE_CABAC_CTXT("cbf_cb", ps_cabac->u4_range, ctxt_idx); value = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, ctxt_idx); AEV_TRACE("cbf_cb", value, ps_cabac->u4_range); ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth] = value; } if((trafo_depth == 0) || ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth - 1]) { TRACE_CABAC_CTXT("cbf_cr", ps_cabac->u4_range, ctxt_idx); value = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, ctxt_idx); AEV_TRACE("cbf_cr", value, ps_cabac->u4_range); ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth] = value; } } if(split_transform_flag) { WORD32 intra_pred_mode_tmp; x1 = x0 + ((1 << log2_trafo_size) >> 1); y1 = y0 + ((1 << log2_trafo_size) >> 1); /* For transform depth of zero, intra pred mode as decoded at CU */ /* level is sent to the transform tree nodes */ /* When depth is non-zero intra pred mode of parent node is sent */ /* This takes care of passing correct mode to all the child nodes */ intra_pred_mode_tmp = trafo_depth ? intra_pred_mode : ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]; ihevcd_parse_transform_tree(ps_codec, x0, y0, x0, y0, log2_trafo_size - 1, trafo_depth + 1, 0, intra_pred_mode_tmp); intra_pred_mode_tmp = trafo_depth ? intra_pred_mode : ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[1]; ihevcd_parse_transform_tree(ps_codec, x1, y0, x0, y0, log2_trafo_size - 1, trafo_depth + 1, 1, intra_pred_mode_tmp); intra_pred_mode_tmp = trafo_depth ? intra_pred_mode : ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[2]; ihevcd_parse_transform_tree(ps_codec, x0, y1, x0, y0, log2_trafo_size - 1, trafo_depth + 1, 2, intra_pred_mode_tmp); intra_pred_mode_tmp = trafo_depth ? intra_pred_mode : ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[3]; ihevcd_parse_transform_tree(ps_codec, x1, y1, x0, y0, log2_trafo_size - 1, trafo_depth + 1, 3, intra_pred_mode_tmp); } else { WORD32 ctb_x_base; WORD32 ctb_y_base; WORD32 cu_qp_delta_abs; tu_t *ps_tu = ps_codec->s_parse.ps_tu; cu_qp_delta_abs = 0; ctb_x_base = ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size; ctb_y_base = ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size; if((ps_codec->s_parse.s_cu.i4_pred_mode == PRED_MODE_INTRA) || (trafo_depth != 0) || (ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth]) || (ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth])) { ctxt_idx = IHEVC_CAB_CBF_LUMA_IDX; ctxt_idx += (trafo_depth == 0) ? 1 : 0; TRACE_CABAC_CTXT("cbf_luma", ps_cabac->u4_range, ctxt_idx); value = ihevcd_cabac_decode_bin(ps_cabac, ps_bitstrm, ctxt_idx); AEV_TRACE("cbf_luma", value, ps_cabac->u4_range); ps_codec->s_parse.s_cu.i1_cbf_luma = value; } else { ps_codec->s_parse.s_cu.i1_cbf_luma = 1; } /* Initialize ps_tu to default values */ /* If required change this to WORD32 packed write */ ps_tu->b1_cb_cbf = 0; ps_tu->b1_cr_cbf = 0; ps_tu->b1_y_cbf = 0; ps_tu->b4_pos_x = ((x0 - ctb_x_base) >> 2); ps_tu->b4_pos_y = ((y0 - ctb_y_base) >> 2); ps_tu->b1_transquant_bypass = ps_codec->s_parse.s_cu.i4_cu_transquant_bypass; ps_tu->b3_size = (log2_trafo_size - 2); ps_tu->b7_qp = ps_codec->s_parse.u4_qp; ps_tu->b6_luma_intra_mode = intra_pred_mode; ps_tu->b3_chroma_intra_mode_idx = ps_codec->s_parse.s_cu.i4_intra_chroma_pred_mode_idx; /* Section:7.3.12 Transform unit syntax inlined here */ if(ps_codec->s_parse.s_cu.i1_cbf_luma || ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth] || ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth]) { WORD32 intra_pred_mode_chroma; if(ps_pps->i1_cu_qp_delta_enabled_flag && !ps_codec->s_parse.i4_is_cu_qp_delta_coded) { WORD32 c_max = TU_MAX_QP_DELTA_ABS; WORD32 ctxt_inc = IHEVC_CAB_QP_DELTA_ABS; WORD32 ctxt_inc_max = CTXT_MAX_QP_DELTA_ABS; TRACE_CABAC_CTXT("cu_qp_delta_abs", ps_cabac->u4_range, ctxt_inc); /* qp_delta_abs is coded as combination of tunary and eg0 code */ /* See Table 9-32 and Table 9-37 for details on cu_qp_delta_abs */ cu_qp_delta_abs = ihevcd_cabac_decode_bins_tunary(ps_cabac, ps_bitstrm, c_max, ctxt_inc, 0, ctxt_inc_max); if(cu_qp_delta_abs >= c_max) { value = ihevcd_cabac_decode_bypass_bins_egk(ps_cabac, ps_bitstrm, 0); cu_qp_delta_abs += value; } AEV_TRACE("cu_qp_delta_abs", cu_qp_delta_abs, ps_cabac->u4_range); ps_codec->s_parse.i4_is_cu_qp_delta_coded = 1; if(cu_qp_delta_abs) { value = ihevcd_cabac_decode_bypass_bin(ps_cabac, ps_bitstrm); AEV_TRACE("cu_qp_delta_sign", value, ps_cabac->u4_range); if(value) cu_qp_delta_abs = -cu_qp_delta_abs; } ps_codec->s_parse.s_cu.i4_cu_qp_delta = cu_qp_delta_abs; } if(ps_codec->s_parse.s_cu.i1_cbf_luma) { ps_tu->b1_y_cbf = 1; ihevcd_parse_residual_coding(ps_codec, x0, y0, log2_trafo_size, 0, intra_pred_mode); } if(4 == ps_codec->s_parse.s_cu.i4_intra_chroma_pred_mode_idx) intra_pred_mode_chroma = ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]; else { intra_pred_mode_chroma = gau1_intra_pred_chroma_modes[ps_codec->s_parse.s_cu.i4_intra_chroma_pred_mode_idx]; if(intra_pred_mode_chroma == ps_codec->s_parse.s_cu.ai4_intra_luma_pred_mode[0]) { intra_pred_mode_chroma = INTRA_ANGULAR(34); } } if(log2_trafo_size > 2) { if(ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth]) { ps_tu->b1_cb_cbf = 1; ihevcd_parse_residual_coding(ps_codec, x0, y0, log2_trafo_size - 1, 1, intra_pred_mode_chroma); } if(ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth]) { ps_tu->b1_cr_cbf = 1; ihevcd_parse_residual_coding(ps_codec, x0, y0, log2_trafo_size - 1, 2, intra_pred_mode_chroma); } } else if(blk_idx == 3) { if(ps_codec->s_parse.s_cu.ai1_cbf_cb[trafo_depth]) { ps_tu->b1_cb_cbf = 1; ihevcd_parse_residual_coding(ps_codec, cu_x_base, cu_y_base, log2_trafo_size, 1, intra_pred_mode_chroma); } if(ps_codec->s_parse.s_cu.ai1_cbf_cr[trafo_depth]) { ps_tu->b1_cr_cbf = 1; ihevcd_parse_residual_coding(ps_codec, cu_x_base, cu_y_base, log2_trafo_size, 2, intra_pred_mode_chroma); } } else { ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; } } else { if((3 != blk_idx) && (2 == log2_trafo_size)) { ps_tu->b3_chroma_intra_mode_idx = INTRA_PRED_CHROMA_IDX_NONE; } } /* Set the first TU in CU flag */ { if((ps_codec->s_parse.s_cu.i4_pos_x << 3) == (ps_tu->b4_pos_x << 2) && (ps_codec->s_parse.s_cu.i4_pos_y << 3) == (ps_tu->b4_pos_y << 2)) { ps_tu->b1_first_tu_in_cu = 1; } else { ps_tu->b1_first_tu_in_cu = 0; } } ps_codec->s_parse.ps_tu++; ps_codec->s_parse.s_cu.i4_tu_cnt++; ps_codec->s_parse.i4_pic_tu_idx++; } } return ret; }
1
qemu
30663fd26c0307e414622c7a8607fbc04f92ec14
NOT_APPLICABLE
NOT_APPLICABLE
static void gen_shift(DisasContext *s1, int op, TCGMemOp ot, int d, int s) { if (s != OR_TMP1) gen_op_mov_v_reg(ot, cpu_T1, s); switch(op) { case OP_ROL: gen_rot_rm_T1(s1, ot, d, 0); break; case OP_ROR: gen_rot_rm_T1(s1, ot, d, 1); break; case OP_SHL: case OP_SHL1: gen_shift_rm_T1(s1, ot, d, 0, 0); break; case OP_SHR: gen_shift_rm_T1(s1, ot, d, 1, 0); break; case OP_SAR: gen_shift_rm_T1(s1, ot, d, 1, 1); break; case OP_RCL: gen_rotc_rm_T1(s1, ot, d, 0); break; case OP_RCR: gen_rotc_rm_T1(s1, ot, d, 1); break; } }
0
Little-CMS
5ca71a7bc18b6897ab21d815d15e218e204581e2
NOT_APPLICABLE
NOT_APPLICABLE
cmsStage* ReadSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset, cmsUInt32Number nCurves) { cmsToneCurve* Curves[cmsMAXCHANNELS]; cmsUInt32Number i; cmsStage* Lin = NULL; if (nCurves > cmsMAXCHANNELS) return FALSE; if (!io -> Seek(io, Offset)) return FALSE; for (i=0; i < nCurves; i++) Curves[i] = NULL; for (i=0; i < nCurves; i++) { Curves[i] = ReadEmbeddedCurve(self, io); if (Curves[i] == NULL) goto Error; if (!_cmsReadAlignment(io)) goto Error; } Lin = cmsStageAllocToneCurves(self ->ContextID, nCurves, Curves); Error: for (i=0; i < nCurves; i++) cmsFreeToneCurve(Curves[i]); return Lin; }
0
linux
c70422f760c120480fee4de6c38804c72aa26bc1
NOT_APPLICABLE
NOT_APPLICABLE
nfsd_inject_forget_clients(u64 max) { u64 count = 0; struct nfs4_client *clp, *next; struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, nfsd_net_id); LIST_HEAD(reaplist); if (!nfsd_netns_ready(nn)) return count; spin_lock(&nn->client_lock); list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) { if (mark_client_expired_locked(clp) == nfs_ok) { list_add(&clp->cl_lru, &reaplist); if (max != 0 && ++count >= max) break; } } spin_unlock(&nn->client_lock); list_for_each_entry_safe(clp, next, &reaplist, cl_lru) expire_client(clp); return count; }
0
upx
ef336dbcc6dc8344482f8cf6c909ae96c3286317
NOT_APPLICABLE
NOT_APPLICABLE
void PackLinuxElf64::unpack(OutputFile *fo) { if (e_phoff != sizeof(Elf64_Ehdr)) {// Phdrs not contiguous with Ehdr throwCantUnpack("bad e_phoff"); } unsigned const c_phnum = get_te16(&ehdri.e_phnum); upx_uint64_t old_data_off = 0; upx_uint64_t old_data_len = 0; upx_uint64_t old_dtinit = 0; unsigned szb_info = sizeof(b_info); { upx_uint64_t const e_entry = get_te64(&ehdri.e_entry); if (e_entry < 0x401180 && get_te16(&ehdri.e_machine)==Elf64_Ehdr::EM_386) { /* old style, 8-byte b_info */ szb_info = 2*sizeof(unsigned); } } fi->seek(overlay_offset - sizeof(l_info), SEEK_SET); fi->readx(&linfo, sizeof(linfo)); lsize = get_te16(&linfo.l_lsize); p_info hbuf; fi->readx(&hbuf, sizeof(hbuf)); unsigned orig_file_size = get_te32(&hbuf.p_filesize); blocksize = get_te32(&hbuf.p_blocksize); if (file_size > (off_t)orig_file_size || blocksize > orig_file_size || !mem_size_valid(1, blocksize, OVERHEAD)) throwCantUnpack("p_info corrupted"); #define MAX_ELF_HDR 1024 union { unsigned char buf[MAX_ELF_HDR]; //struct { Elf64_Ehdr ehdr; Elf64_Phdr phdr; } e; } u; Elf64_Ehdr *const ehdr = (Elf64_Ehdr *) u.buf; Elf64_Phdr const *phdr = 0; ibuf.alloc(blocksize + OVERHEAD); b_info bhdr; memset(&bhdr, 0, sizeof(bhdr)); fi->readx(&bhdr, szb_info); ph.u_len = get_te32(&bhdr.sz_unc); ph.c_len = get_te32(&bhdr.sz_cpr); if (ph.c_len > (unsigned)file_size || ph.c_len == 0 || ph.u_len == 0 || ph.u_len > sizeof(u)) throwCantUnpack("b_info corrupted"); ph.filter_cto = bhdr.b_cto8; // Uncompress Ehdr and Phdrs. if (ibuf.getSize() < ph.c_len || sizeof(u) < ph.u_len) throwCompressedDataViolation(); fi->readx(ibuf, ph.c_len); decompress(ibuf, (upx_byte *)ehdr, false); if (ehdr->e_type !=ehdri.e_type || ehdr->e_machine!=ehdri.e_machine || ehdr->e_version!=ehdri.e_version // less strict for EM_PPC64 to workaround earlier bug || !( ehdr->e_flags==ehdri.e_flags || Elf64_Ehdr::EM_PPC64 == get_te16(&ehdri.e_machine)) || ehdr->e_ehsize !=ehdri.e_ehsize // check EI_MAG[0-3], EI_CLASS, EI_DATA, EI_VERSION || memcmp(ehdr->e_ident, ehdri.e_ident, Elf64_Ehdr::EI_OSABI)) { throwCantUnpack("ElfXX_Ehdr corrupted"); } fi->seek(- (off_t) (szb_info + ph.c_len), SEEK_CUR); unsigned const u_phnum = get_te16(&ehdr->e_phnum); unsigned total_in = 0; unsigned total_out = 0; unsigned c_adler = upx_adler32(NULL, 0); unsigned u_adler = upx_adler32(NULL, 0); // Packed ET_EXE has no PT_DYNAMIC. // Packed ET_DYN has original PT_DYNAMIC for info needed by rtld. bool const is_shlib = !!elf_find_ptype(Elf64_Phdr::PT_DYNAMIC, phdri, c_phnum); if (is_shlib) { // Unpack and output the Ehdr and Phdrs for real. // This depends on position within input file fi. unpackExtent(ph.u_len, fo, total_in, total_out, c_adler, u_adler, false, szb_info); // The first PT_LOAD. Part is not compressed (for benefit of rtld.) // Read enough to position the input for next unpackExtent. fi->seek(0, SEEK_SET); fi->readx(ibuf, overlay_offset + sizeof(hbuf) + szb_info + ph.c_len); overlay_offset -= sizeof(linfo); if (fo) { fo->write(ibuf + ph.u_len, overlay_offset - ph.u_len); } // Search the Phdrs of compressed int n_ptload = 0; phdr = (Elf64_Phdr *) (void *) (1+ (Elf64_Ehdr *)(unsigned char *)ibuf); for (unsigned j=0; j < u_phnum; ++phdr, ++j) { if (PT_LOAD64==get_te32(&phdr->p_type) && 0!=n_ptload++) { old_data_off = get_te64(&phdr->p_offset); old_data_len = get_te64(&phdr->p_filesz); break; } } total_in = overlay_offset; total_out = overlay_offset; ph.u_len = 0; // Decompress and unfilter the tail of first PT_LOAD. phdr = (Elf64_Phdr *) (void *) (1+ ehdr); for (unsigned j=0; j < u_phnum; ++phdr, ++j) { if (PT_LOAD64==get_te32(&phdr->p_type)) { ph.u_len = get_te64(&phdr->p_filesz) - overlay_offset; break; } } unpackExtent(ph.u_len, fo, total_in, total_out, c_adler, u_adler, false, szb_info); } else { // main executable // Decompress each PT_LOAD. bool first_PF_X = true; phdr = (Elf64_Phdr *) (void *) (1+ ehdr); // uncompressed for (unsigned j=0; j < u_phnum; ++phdr, ++j) { if (PT_LOAD64==get_te32(&phdr->p_type)) { unsigned const filesz = get_te64(&phdr->p_filesz); unsigned const offset = get_te64(&phdr->p_offset); if (fo) fo->seek(offset, SEEK_SET); if (Elf64_Phdr::PF_X & get_te32(&phdr->p_flags)) { unpackExtent(filesz, fo, total_in, total_out, c_adler, u_adler, first_PF_X, szb_info); first_PF_X = false; } else { unpackExtent(filesz, fo, total_in, total_out, c_adler, u_adler, false, szb_info); } } } } phdr = phdri; load_va = 0; for (unsigned j=0; j < c_phnum; ++j) { if (PT_LOAD64==get_te32(&phdr->p_type)) { load_va = get_te64(&phdr->p_vaddr); break; } } if (is_shlib || ((unsigned)(get_te64(&ehdri.e_entry) - load_va) + up4(lsize) + ph.getPackHeaderSize() + sizeof(overlay_offset)) < up4(file_size)) { // Loader is not at end; skip past it. funpad4(fi); // MATCH01 unsigned d_info[6]; fi->readx(d_info, sizeof(d_info)); if (0==old_dtinit) { old_dtinit = d_info[2 + (0==d_info[0])]; } fi->seek(lsize - sizeof(d_info), SEEK_CUR); } // The gaps between PT_LOAD and after last PT_LOAD phdr = (Elf64_Phdr *) (u.buf + sizeof(*ehdr)); upx_uint64_t hi_offset(0); for (unsigned j = 0; j < u_phnum; ++j) { if (PT_LOAD64==phdr[j].p_type && hi_offset < phdr[j].p_offset) hi_offset = phdr[j].p_offset; } for (unsigned j = 0; j < u_phnum; ++j) { unsigned const size = find_LOAD_gap(phdr, j, u_phnum); if (size) { unsigned const where = get_te64(&phdr[j].p_offset) + get_te64(&phdr[j].p_filesz); if (fo) fo->seek(where, SEEK_SET); unpackExtent(size, fo, total_in, total_out, c_adler, u_adler, false, szb_info, (phdr[j].p_offset != hi_offset)); } } // check for end-of-file fi->readx(&bhdr, szb_info); unsigned const sz_unc = ph.u_len = get_te32(&bhdr.sz_unc); if (sz_unc == 0) { // uncompressed size 0 -> EOF // note: magic is always stored le32 unsigned const sz_cpr = get_le32(&bhdr.sz_cpr); if (sz_cpr != UPX_MAGIC_LE32) // sz_cpr must be h->magic throwCompressedDataViolation(); } else { // extra bytes after end? throwCompressedDataViolation(); } if (is_shlib) { // the non-first PT_LOAD int n_ptload = 0; unsigned load_off = 0; phdr = (Elf64_Phdr *) (u.buf + sizeof(*ehdr)); for (unsigned j= 0; j < u_phnum; ++j, ++phdr) { if (PT_LOAD64==get_te32(&phdr->p_type) && 0!=n_ptload++) { load_off = get_te64(&phdr->p_offset); fi->seek(old_data_off, SEEK_SET); fi->readx(ibuf, old_data_len); total_in += old_data_len; total_out += old_data_len; if (fo) { fo->seek(get_te64(&phdr->p_offset), SEEK_SET); fo->rewrite(ibuf, old_data_len); } } } // Restore DT_INIT.d_val phdr = (Elf64_Phdr *) (u.buf + sizeof(*ehdr)); for (unsigned j= 0; j < u_phnum; ++j, ++phdr) { if (phdr->PT_DYNAMIC==get_te32(&phdr->p_type)) { unsigned const dyn_off = get_te64(&phdr->p_offset); unsigned const dyn_len = get_te64(&phdr->p_filesz); Elf64_Dyn *dyn = (Elf64_Dyn *)((unsigned char *)ibuf + (dyn_off - load_off)); for (unsigned j2= 0; j2 < dyn_len; ++dyn, j2 += sizeof(*dyn)) { if (dyn->DT_INIT==get_te32(&dyn->d_tag)) { if (fo) { fo->seek(sizeof(upx_uint64_t) + j2 + dyn_off, SEEK_SET); fo->rewrite(&old_dtinit, sizeof(old_dtinit)); fo->seek(0, SEEK_END); } break; } } } } } // update header with totals ph.c_len = total_in; ph.u_len = total_out; // all bytes must be written if (total_out != orig_file_size) throwEOFException(); // finally test the checksums if (ph.c_adler != c_adler || ph.u_adler != u_adler) throwChecksumError(); #undef MAX_ELF_HDR }
0
OpenSC
360e95d45ac4123255a4c796db96337f332160ad
NOT_APPLICABLE
NOT_APPLICABLE
static int _listFile(mscfs_file_t *file, int reset, void *udata) { int next = reset ? 0x00 : 0x01; return msc_list_objects( (sc_card_t*)udata, next, file); }
0
typed_ast
156afcb26c198e162504a57caddfe0acd9ed7dce
NOT_APPLICABLE
NOT_APPLICABLE
ExtSlice(asdl_seq * dims, PyArena *arena) { slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) return NULL; p->kind = ExtSlice_kind; p->v.ExtSlice.dims = dims; return p; }
0
linux-2.6
16175a796d061833aacfbd9672235f2d2725df65
NOT_APPLICABLE
NOT_APPLICABLE
static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) { skip_emulated_instruction(vcpu); kvm_emulate_hypercall(vcpu); return 1; }
0
libvirt
15073504dbb624d3f6c911e85557019d3620fdb2
NOT_APPLICABLE
NOT_APPLICABLE
virSecuritySELinuxClearSocketLabel(virSecurityManager *mgr G_GNUC_UNUSED, virDomainDef *def) { /* TODO: verify DOI */ virSecurityLabelDef *secdef; secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); if (!secdef || !secdef->label) return 0; if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("security label driver mismatch: " "'%s' model configured for domain, but " "hypervisor driver is '%s'."), secdef->model, SECURITY_SELINUX_NAME); if (security_getenforce() == 1) return -1; } if (setsockcreatecon_raw(NULL) == -1) { virReportSystemError(errno, _("unable to clear socket security context '%s'"), secdef->label); if (security_getenforce() == 1) return -1; } return 0; }
0
linux
a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e
NOT_APPLICABLE
NOT_APPLICABLE
static ssize_t phys_port_id_show(struct device *dev, struct device_attribute *attr, char *buf) { struct net_device *netdev = to_net_dev(dev); ssize_t ret = -EINVAL; if (!rtnl_trylock()) return restart_syscall(); if (dev_isalive(netdev)) { struct netdev_phys_item_id ppid; ret = dev_get_phys_port_id(netdev, &ppid); if (!ret) ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id); } rtnl_unlock(); return ret;
0
linux
dee1f973ca341c266229faa5a1a5bb268bed3531
CVE-2012-4508
CWE-362
static int ext4_split_unwritten_extents(handle_t *handle, struct inode *inode, struct ext4_map_blocks *map, struct ext4_ext_path *path, int flags) { ext4_lblk_t eof_block; ext4_lblk_t ee_block; struct ext4_extent *ex; unsigned int ee_len; int split_flag = 0, depth; ext_debug("ext4_split_unwritten_extents: inode %lu, logical" "block %llu, max_blocks %u\n", inode->i_ino, (unsigned long long)map->m_lblk, map->m_len); eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; if (eof_block < map->m_lblk + map->m_len) eof_block = map->m_lblk + map->m_len; /* * It is safe to convert extent to initialized via explicit * zeroout only if extent is fully insde i_size or new_size. */ depth = ext_depth(inode); ex = path[depth].p_ext; ee_block = le32_to_cpu(ex->ee_block); ee_len = ext4_ext_get_actual_len(ex); split_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0; split_flag |= EXT4_EXT_MARK_UNINIT2; flags |= EXT4_GET_BLOCKS_PRE_IO; return ext4_split_extent(handle, inode, path, map, split_flag, flags); }
1
linux
34b88a68f26a75e4fded796f1a49c40f82234b7d
NOT_APPLICABLE
NOT_APPLICABLE
SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, int __user *, upeer_addrlen, int, flags) { struct socket *sock, *newsock; struct file *newfile; int err, len, newfd, fput_needed; struct sockaddr_storage address; if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) return -EINVAL; if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; sock = sockfd_lookup_light(fd, &err, &fput_needed); if (!sock) goto out; err = -ENFILE; newsock = sock_alloc(); if (!newsock) goto out_put; newsock->type = sock->type; newsock->ops = sock->ops; /* * We don't need try_module_get here, as the listening socket (sock) * has the protocol module (sock->ops->owner) held. */ __module_get(newsock->ops->owner); newfd = get_unused_fd_flags(flags); if (unlikely(newfd < 0)) { err = newfd; sock_release(newsock); goto out_put; } newfile = sock_alloc_file(newsock, flags, sock->sk->sk_prot_creator->name); if (IS_ERR(newfile)) { err = PTR_ERR(newfile); put_unused_fd(newfd); sock_release(newsock); goto out_put; } err = security_socket_accept(sock, newsock); if (err) goto out_fd; err = sock->ops->accept(sock, newsock, sock->file->f_flags); if (err < 0) goto out_fd; if (upeer_sockaddr) { if (newsock->ops->getname(newsock, (struct sockaddr *)&address, &len, 2) < 0) { err = -ECONNABORTED; goto out_fd; } err = move_addr_to_user(&address, len, upeer_sockaddr, upeer_addrlen); if (err < 0) goto out_fd; } /* File flags are not inherited via accept() unlike another OSes. */ fd_install(newfd, newfile); err = newfd; out_put: fput_light(sock->file, fput_needed); out: return err; out_fd: fput(newfile); put_unused_fd(newfd); goto out_put; }
0
exiv2
ae49250942f4395639961abeed3c15920fcd7241
NOT_APPLICABLE
NOT_APPLICABLE
int ImageFactory::getType(BasicIo& io) { if (io.open() != 0) return ImageType::none; IoCloser closer(io); for (unsigned int i = 0; registry[i].imageType_ != ImageType::none; ++i) { if (registry[i].isThisType_(io, false)) { return registry[i].imageType_; } } return ImageType::none; } // ImageFactory::getType
0
Android
7df7ec13b1d222ac3a66797fbe432605ea8f973f
NOT_APPLICABLE
NOT_APPLICABLE
static uint32_t out_get_latency(const struct audio_stream_out *stream) { struct stream_out *out = (struct stream_out *)stream; return (out->config.period_count * out->config.period_size * 1000) / (out->config.rate); }
0
OpenSC
f015746d22d249642c19674298a18ad824db0ed7
NOT_APPLICABLE
NOT_APPLICABLE
void idprime_free_private_data(idprime_private_data_t *priv) { free(priv->cache_buf); list_destroy(&priv->pki_list); free(priv); return; }
0
Chrome
c0569cc04741cccf6548c2169fcc1609d958523f
NOT_APPLICABLE
NOT_APPLICABLE
void Dispatcher::DidCreateDocumentElement(blink::WebLocalFrame* frame) { GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( frame, frame->document().url(), true /* match_about_blank */); const Extension* extension = RendererExtensionRegistry::Get()->GetExtensionOrAppByURL( effective_document_url); if (extension && (extension->is_extension() || extension->is_platform_app())) { int resource_id = extension->is_platform_app() ? IDR_PLATFORM_APP_CSS : IDR_EXTENSION_FONTS_CSS; std::string stylesheet = ResourceBundle::GetSharedInstance() .GetRawDataResource(resource_id) .as_string(); base::ReplaceFirstSubstringAfterOffset( &stylesheet, 0, "$FONTFAMILY", system_font_family_); base::ReplaceFirstSubstringAfterOffset( &stylesheet, 0, "$FONTSIZE", system_font_size_); frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet)); } if (extension && extension->is_extension() && OptionsPageInfo::ShouldUseChromeStyle(extension) && effective_document_url == OptionsPageInfo::GetOptionsPage(extension)) { frame->document().insertStyleSheet( WebString::fromUTF8(ResourceBundle::GetSharedInstance() .GetRawDataResource(IDR_EXTENSION_CSS) .as_string())); } if (content_watcher_) { content_watcher_->DidCreateDocumentElement(frame); } }
0
linux
b9e146d8eb3b9ecae5086d373b50fa0c1f3e7f0f
NOT_APPLICABLE
NOT_APPLICABLE
static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset) { if (signal_pending(tsk) && !thread_group_empty(tsk)) { sigset_t newblocked; /* A set of now blocked but previously unblocked signals. */ sigandnsets(&newblocked, newset, &current->blocked); retarget_shared_pending(tsk, &newblocked); } tsk->blocked = *newset; recalc_sigpending(); }
0
savannah
29c759284e305ec428703c9a5831d0b1fc3497ef
NOT_APPLICABLE
NOT_APPLICABLE
Ins_OR( FT_Long* args ) { args[0] = ( args[0] || args[1] ); }
0
linux
f8bd2258e2d520dff28c855658bd24bdafb5102d
NOT_APPLICABLE
NOT_APPLICABLE
static inline void *get_freepointer(struct kmem_cache *s, void *object) { return *(void **)(object + s->offset); }
0
linux
e2b3b35eb9896f26c98b9a2c047d9111638059a2
NOT_APPLICABLE
NOT_APPLICABLE
static inline unsigned long busy_clock(void) { return local_clock() >> 10; }
0