project
stringclasses 788
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 126
values | func
stringlengths 14
482k
| vul
int8 0
1
|
---|---|---|---|---|---|
chafa | e6ce3746cdcf0836b9dae659a5aed15d73a080d8 | NOT_APPLICABLE | NOT_APPLICABLE | static lzw_result lzw__block_advance(struct lzw_read_ctx *ctx)
{
uint64_t block_size;
uint64_t next_block_pos = ctx->data_sb_next;
const uint8_t *data_next = ctx->data + next_block_pos;
if (next_block_pos >= ctx->data_len) {
return LZW_NO_DATA;
}
block_size = *data_next;
if ((next_block_pos + block_size) >= ctx->data_len) {
return LZW_NO_DATA;
}
ctx->sb_bit = 0;
ctx->sb_bit_count = block_size * 8;
if (block_size == 0) {
ctx->data_sb_next += 1;
return LZW_OK_EOD;
}
ctx->sb_data = data_next + 1;
ctx->data_sb_next += block_size + 1;
return LZW_OK;
} | 0 |
Chrome | 784f56a9c97a838448dd23f9bdc7c05fe8e639b3 | NOT_APPLICABLE | NOT_APPLICABLE | void RenderFrameHostImpl::FilesSelectedInChooser(
const std::vector<content::FileChooserFileInfo>& files,
FileChooserParams::Mode permissions) {
storage::FileSystemContext* const file_system_context =
BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(),
GetSiteInstance())
->GetFileSystemContext();
for (const auto& file : files) {
if (permissions == FileChooserParams::Save) {
ChildProcessSecurityPolicyImpl::GetInstance()->GrantCreateReadWriteFile(
GetProcess()->GetID(), file.file_path);
} else {
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
GetProcess()->GetID(), file.file_path);
}
if (file.file_system_url.is_valid()) {
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem(
GetProcess()->GetID(),
file_system_context->CrackURL(file.file_system_url)
.mount_filesystem_id());
}
}
Send(new FrameMsg_RunFileChooserResponse(routing_id_, files));
}
| 0 |
Android | 224858e719d045c8554856b12c4ab73d2375cf33 | NOT_APPLICABLE | NOT_APPLICABLE | void NuPlayer::GenericSource::notifyBufferingUpdate(int percentage) {
sp<AMessage> msg = dupNotify();
msg->setInt32("what", kWhatBufferingUpdate);
msg->setInt32("percentage", percentage);
msg->post();
}
| 0 |
linux | b3b7c4795ccab5be71f080774c45bbbcc75c2aaf | NOT_APPLICABLE | NOT_APPLICABLE | static inline u32 misc_reg(int bank)
{
return MSR_IA32_MCx_MISC(bank);
} | 0 |
Chrome | 0c45ffd2a1b2b6b91aaaac989ad10a76765083c6 | NOT_APPLICABLE | NOT_APPLICABLE | CSSStyleSheet* CSSStyleSheet::Create(Document& document,
const String& text,
const CSSStyleSheetInit& options,
ExceptionState& exception_state) {
if (!RuntimeEnabledFeatures::ConstructableStylesheetsEnabled()) {
exception_state.ThrowTypeError("Illegal constructor");
return nullptr;
}
CSSParserContext* parser_context = CSSParserContext::Create(document);
StyleSheetContents* contents = StyleSheetContents::Create(parser_context);
CSSStyleSheet* sheet = new CSSStyleSheet(contents, nullptr);
sheet->SetTitle(options.title());
sheet->ClearOwnerNode();
sheet->ClearOwnerRule();
if (options.media().IsString()) {
MediaList* media_list = MediaList::Create(
MediaQuerySet::Create(), const_cast<CSSStyleSheet*>(sheet));
media_list->setMediaText(options.media().GetAsString());
sheet->SetMedia(media_list);
} else {
sheet->SetMedia(options.media().GetAsMediaList());
}
if (options.alternate())
sheet->SetAlternateFromConstructor(true);
if (options.disabled())
sheet->setDisabled(true);
sheet->SetText(text);
return sheet;
}
| 0 |
weechat | efb795c74fe954b9544074aafcebb1be4452b03a | NOT_APPLICABLE | NOT_APPLICABLE | string_toupper (char *string)
{
while (string && string[0])
{
if ((string[0] >= 'a') && (string[0] <= 'z'))
string[0] -= ('a' - 'A');
string = utf8_next_char (string);
}
} | 0 |
linux | 485e71e8fb6356c08c7fc6bcce4bf02c9a9a663f | NOT_APPLICABLE | NOT_APPLICABLE | static void posix_acl_fix_xattr_userns(
struct user_namespace *to, struct user_namespace *from,
void *value, size_t size)
{
posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
int count;
kuid_t uid;
kgid_t gid;
if (!value)
return;
if (size < sizeof(posix_acl_xattr_header))
return;
if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
return;
count = posix_acl_xattr_count(size);
if (count < 0)
return;
if (count == 0)
return;
for (end = entry + count; entry != end; entry++) {
switch(le16_to_cpu(entry->e_tag)) {
case ACL_USER:
uid = make_kuid(from, le32_to_cpu(entry->e_id));
entry->e_id = cpu_to_le32(from_kuid(to, uid));
break;
case ACL_GROUP:
gid = make_kgid(from, le32_to_cpu(entry->e_id));
entry->e_id = cpu_to_le32(from_kgid(to, gid));
break;
default:
break;
}
}
} | 0 |
zfs | 99aa4d2b4fd12c6bef62d02ffd1b375ddd42fcf4 | NOT_APPLICABLE | NOT_APPLICABLE | update_sharetab(sa_handle_impl_t impl_handle)
{
sa_share_impl_t impl_share;
int temp_fd;
FILE *temp_fp;
char tempfile[] = "/etc/dfs/sharetab.XXXXXX";
sa_fstype_t *fstype;
const char *resource;
if (mkdir("/etc/dfs", 0755) < 0 && errno != EEXIST) {
return;
}
temp_fd = mkstemp(tempfile);
if (temp_fd < 0)
return;
temp_fp = fdopen(temp_fd, "w");
if (temp_fp == NULL)
return;
impl_share = impl_handle->shares;
while (impl_share != NULL) {
fstype = fstypes;
while (fstype != NULL) {
if (FSINFO(impl_share, fstype)->active &&
FSINFO(impl_share, fstype)->shareopts != NULL) {
resource = FSINFO(impl_share, fstype)->resource;
if (resource == NULL)
resource = "-";
fprintf(temp_fp, "%s\t%s\t%s\t%s\n",
impl_share->sharepath, resource,
fstype->name,
FSINFO(impl_share, fstype)->shareopts);
}
fstype = fstype->next;
}
impl_share = impl_share->next;
}
fflush(temp_fp);
fsync(temp_fd);
fclose(temp_fp);
rename(tempfile, "/etc/dfs/sharetab");
}
| 0 |
ImageMagick6 | 025e77fcb2f45b21689931ba3bf74eac153afa48 | NOT_APPLICABLE | NOT_APPLICABLE | static inline void GetStandardDeviationPixelList(PixelList *pixel_list,
Quantum *pixel)
{
double
sum,
sum_squared;
register SkipList
*p;
size_t
color;
ssize_t
count;
/*
Find the standard-deviation value for each of the color.
*/
p=(&pixel_list->skip_list);
color=65536L;
count=0;
sum=0.0;
sum_squared=0.0;
do
{
register ssize_t
i;
color=p->nodes[color].next[0];
sum+=(double) p->nodes[color].count*color;
for (i=0; i < (ssize_t) p->nodes[color].count; i++)
sum_squared+=((double) color)*((double) color);
count+=p->nodes[color].count;
} while (count < (ssize_t) pixel_list->length);
sum/=pixel_list->length;
sum_squared/=pixel_list->length;
*pixel=ScaleShortToQuantum((unsigned short) sqrt(sum_squared-(sum*sum)));
}
| 0 |
Chrome | d926098e2e2be270c80a5ba25ab8a611b80b8556 | NOT_APPLICABLE | NOT_APPLICABLE | void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame,
const blink::WebString& title,
blink::WebTextDirection direction) {
DCHECK(!frame_ || frame_ == frame);
if (!frame->parent()) {
base::string16 title16 = title;
base::trace_event::TraceLog::GetInstance()->UpdateProcessLabel(
routing_id_, base::UTF16ToUTF8(title16));
base::string16 shortened_title = title16.substr(0, kMaxTitleChars);
Send(new FrameHostMsg_UpdateTitle(routing_id_,
shortened_title, direction));
}
UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
}
| 0 |
linux | f2fcfcd670257236ebf2088bbdf26f6a8ef459fe | NOT_APPLICABLE | NOT_APPLICABLE | static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
{
struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data;
u16 dcid, scid;
struct sock *sk;
scid = __le16_to_cpu(rsp->scid);
dcid = __le16_to_cpu(rsp->dcid);
BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid);
sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
if (!sk)
return 0;
l2cap_chan_del(sk, 0);
bh_unlock_sock(sk);
l2cap_sock_kill(sk);
return 0;
}
| 0 |
linux | e4d4d456436bfb2fe412ee2cd489f7658449b098 | NOT_APPLICABLE | NOT_APPLICABLE | int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,
void *old_addr, void *new_addr)
{
if (!is_kernel_text((long)ip) &&
!is_bpf_text_address((long)ip))
/* BPF poking in modules is not supported */
return -EINVAL;
return __bpf_arch_text_poke(ip, t, old_addr, new_addr, true);
} | 0 |
Chrome | b44e68087804e6543a99c87076ab7648d11d9b07 | NOT_APPLICABLE | NOT_APPLICABLE | void ProfilingService::MaybeRequestQuit() {
DCHECK(ref_factory_);
if (ref_factory_->HasNoRefs())
context()->RequestQuit();
}
| 0 |
openssl | d8541d7e9e63bf5f343af24644046c8d96498c17 | NOT_APPLICABLE | NOT_APPLICABLE | static int rsa_sig_print(BIO *bp, const X509_ALGOR *sigalg,
const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx)
{
if (OBJ_obj2nid(sigalg->algorithm) == NID_rsassaPss) {
int rv;
RSA_PSS_PARAMS *pss;
X509_ALGOR *maskHash;
pss = rsa_pss_decode(sigalg, &maskHash);
rv = rsa_pss_param_print(bp, pss, maskHash, indent);
if (pss)
RSA_PSS_PARAMS_free(pss);
if (maskHash)
X509_ALGOR_free(maskHash);
if (!rv)
return 0;
} else if (!sig && BIO_puts(bp, "\n") <= 0)
return 0;
if (sig)
return X509_signature_dump(bp, sig, indent);
return 1;
}
| 0 |
libmicrohttpd | a110ae6276660bee3caab30e9ff3f12f85cf3241 | NOT_APPLICABLE | NOT_APPLICABLE | test_urlencoding (void)
{
unsigned int errorCount = 0;
errorCount += test_urlencoding_case (URL_START,
URL_END,
URL_DATA);
errorCount += test_urlencoding_case (URL_NOVALUE1_START,
URL_NOVALUE1_END,
URL_NOVALUE1_DATA);
errorCount += test_urlencoding_case (URL_NOVALUE2_START,
URL_NOVALUE2_END,
URL_NOVALUE2_DATA);
if (0 != errorCount)
fprintf (stderr,
"Test failed in line %u with %u errors\n",
(unsigned int) __LINE__,
errorCount);
return errorCount;
} | 0 |
hhvm | 8e7266fef1f329b805b37f32c9ad0090215ab269 | NOT_APPLICABLE | NOT_APPLICABLE | static void HHVM_METHOD(SimpleXMLElement, addAttribute,
const String& qname,
const String& value /* = null_string */,
const String& ns /* = null_string */) {
if (qname.size() == 0) {
raise_warning("Attribute name is required");
return;
}
auto data = Native::data<SimpleXMLElement>(this_);
xmlNodePtr node = data->nodep();
node = php_sxe_get_first_node(data, node);
if (node && node->type != XML_ELEMENT_NODE) {
node = node->parent;
}
if (node == nullptr) {
raise_warning("Unable to locate parent Element");
return;
}
xmlChar* prefix = nullptr;
xmlChar* localname = xmlSplitQName2((xmlChar*)qname.data(), &prefix);
if (localname == nullptr) {
if (ns.size() > 0) {
if (prefix != nullptr) {
xmlFree(prefix);
}
raise_warning("Attribute requires prefix for namespace");
return;
}
localname = xmlStrdup((xmlChar*)qname.data());
}
xmlAttrPtr attrp = xmlHasNsProp(node, localname, (xmlChar*)ns.data());
if (attrp != nullptr && attrp->type != XML_ATTRIBUTE_DECL) {
xmlFree(localname);
if (prefix != nullptr) {
xmlFree(prefix);
}
raise_warning("Attribute already exists");
return;
}
xmlNsPtr nsptr = nullptr;
if (ns.size()) {
nsptr = xmlSearchNsByHref(node->doc, node, (xmlChar*)ns.data());
if (nsptr == nullptr) {
nsptr = xmlNewNs(node, (xmlChar*)ns.data(), prefix);
}
}
attrp = xmlNewNsProp(node, nsptr, localname, (xmlChar*)value.data());
xmlFree(localname);
if (prefix != nullptr) {
xmlFree(prefix);
}
} | 0 |
Chrome | fbeba958bb83c05ec8cc54e285a4a9ca10d1b311 | NOT_APPLICABLE | NOT_APPLICABLE | int GlobalConfirmInfoBar::DelegateProxy::GetButtons() const {
return global_info_bar_ ? global_info_bar_->delegate_->GetButtons()
: 0;
}
| 0 |
veyon | f231ec511b9a09f43f49b2c7bb7c60b8046276b1 | NOT_APPLICABLE | NOT_APPLICABLE | WindowsServiceControl::~WindowsServiceControl()
{
CloseServiceHandle( m_serviceHandle );
CloseServiceHandle( m_serviceManager );
} | 0 |
linux | d846f71195d57b0bbb143382647c2c6638b04c5a | NOT_APPLICABLE | NOT_APPLICABLE | static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack *cl_s,
unsigned int udc_cnt, unsigned int hooknr, char *base)
{
int i, chain_nr = -1, pos = 0, nentries = chain->nentries, verdict;
const struct ebt_entry *e = (struct ebt_entry *)chain->data;
const struct ebt_entry_target *t;
while (pos < nentries || chain_nr != -1) {
/* end of udc, go back one 'recursion' step */
if (pos == nentries) {
/* put back values of the time when this chain was called */
e = cl_s[chain_nr].cs.e;
if (cl_s[chain_nr].from != -1)
nentries =
cl_s[cl_s[chain_nr].from].cs.chaininfo->nentries;
else
nentries = chain->nentries;
pos = cl_s[chain_nr].cs.n;
/* make sure we won't see a loop that isn't one */
cl_s[chain_nr].cs.n = 0;
chain_nr = cl_s[chain_nr].from;
if (pos == nentries)
continue;
}
t = (struct ebt_entry_target *)
(((char *)e) + e->target_offset);
if (strcmp(t->u.name, EBT_STANDARD_TARGET))
goto letscontinue;
if (e->target_offset + sizeof(struct ebt_standard_target) >
e->next_offset) {
BUGPRINT("Standard target size too big\n");
return -1;
}
verdict = ((struct ebt_standard_target *)t)->verdict;
if (verdict >= 0) { /* jump to another chain */
struct ebt_entries *hlp2 =
(struct ebt_entries *)(base + verdict);
for (i = 0; i < udc_cnt; i++)
if (hlp2 == cl_s[i].cs.chaininfo)
break;
/* bad destination or loop */
if (i == udc_cnt) {
BUGPRINT("bad destination\n");
return -1;
}
if (cl_s[i].cs.n) {
BUGPRINT("loop\n");
return -1;
}
if (cl_s[i].hookmask & (1 << hooknr))
goto letscontinue;
/* this can't be 0, so the loop test is correct */
cl_s[i].cs.n = pos + 1;
pos = 0;
cl_s[i].cs.e = ebt_next_entry(e);
e = (struct ebt_entry *)(hlp2->data);
nentries = hlp2->nentries;
cl_s[i].from = chain_nr;
chain_nr = i;
/* this udc is accessible from the base chain for hooknr */
cl_s[i].hookmask |= (1 << hooknr);
continue;
}
letscontinue:
e = ebt_next_entry(e);
pos++;
}
return 0;
}
| 0 |
spice-vd_agent | 91caa9223857708475d29df1768208fed1675340 | NOT_APPLICABLE | NOT_APPLICABLE | void udscs_destroy_server(struct udscs_server *server)
{
if (!server)
return;
g_list_free_full(server->connections, vdagent_connection_destroy);
g_object_unref(server->service);
g_free(server);
} | 0 |
Android | b04aee833c5cfb6b31b8558350feb14bb1a0f353 | NOT_APPLICABLE | NOT_APPLICABLE | status_t Camera3Device::RequestThread::flush() {
ATRACE_CALL();
Mutex::Autolock l(mFlushLock);
if (mHal3Device->common.version >= CAMERA_DEVICE_API_VERSION_3_1) {
return mHal3Device->ops->flush(mHal3Device);
}
return -ENOTSUP;
}
| 0 |
libsndfile | 85c877d5072866aadbe8ed0c3e0590fbb5e16788 | NOT_APPLICABLE | NOT_APPLICABLE | bd2d_write (double *buffer, int count)
{ while (--count >= 0)
{ DOUBLE64_WRITE (buffer [count], (unsigned char*) (buffer + count)) ;
} ;
} /* bd2d_write */ | 0 |
linux | 12176503366885edd542389eed3aaf94be163fdb | NOT_APPLICABLE | NOT_APPLICABLE | static int compat_ioctl_check_table(unsigned int xcmd)
{
int i;
const int max = ARRAY_SIZE(ioctl_pointer) - 1;
BUILD_BUG_ON(max >= (1 << 16));
/* guess initial offset into table, assuming a
normalized distribution */
i = ((xcmd >> 16) * max) >> 16;
/* do linear search up first, until greater or equal */
while (ioctl_pointer[i] < xcmd && i < max)
i++;
/* then do linear search down */
while (ioctl_pointer[i] > xcmd && i > 0)
i--;
return ioctl_pointer[i] == xcmd;
}
| 0 |
mongo | 07b8851825836911265e909d6842d4586832f9bb | NOT_APPLICABLE | NOT_APPLICABLE | DocumentSource::GetModPathsReturn GroupFromFirstDocumentTransformation::getModifiedPaths() const {
// Replaces the entire root, so all paths are modified.
return {DocumentSource::GetModPathsReturn::Type::kAllPaths, std::set<std::string>{}, {}};
} | 0 |
linux | 78c9c4dfbf8c04883941445a195276bb4bb92c76 | NOT_APPLICABLE | NOT_APPLICABLE | static void release_posix_timer(struct k_itimer *tmr, int it_id_set)
{
if (it_id_set) {
unsigned long flags;
spin_lock_irqsave(&hash_lock, flags);
hlist_del_rcu(&tmr->t_hash);
spin_unlock_irqrestore(&hash_lock, flags);
}
put_pid(tmr->it_pid);
sigqueue_free(tmr->sigq);
call_rcu(&tmr->it.rcu, k_itimer_rcu_free);
}
| 0 |
linux | 124d3b7041f9a0ca7c43a6293e1cae4576c32fd5 | NOT_APPLICABLE | NOT_APPLICABLE | int remove_suid(struct dentry *dentry)
{
int killsuid = should_remove_suid(dentry);
int killpriv = security_inode_need_killpriv(dentry);
int error = 0;
if (killpriv < 0)
return killpriv;
if (killpriv)
error = security_inode_killpriv(dentry);
if (!error && killsuid)
error = __remove_suid(dentry, killsuid);
return error;
}
| 0 |
gnupg | 2cbd76f7911fc215845e89b50d6af5ff4a83dd77 | NOT_APPLICABLE | NOT_APPLICABLE | gpgsm_cancel (void *engine)
{
engine_gpgsm_t gpgsm = engine;
if (!gpgsm)
return gpg_error (GPG_ERR_INV_VALUE);
if (gpgsm->status_cb.fd != -1)
_gpgme_io_close (gpgsm->status_cb.fd);
if (gpgsm->input_cb.fd != -1)
_gpgme_io_close (gpgsm->input_cb.fd);
if (gpgsm->output_cb.fd != -1)
_gpgme_io_close (gpgsm->output_cb.fd);
if (gpgsm->message_cb.fd != -1)
_gpgme_io_close (gpgsm->message_cb.fd);
if (gpgsm->assuan_ctx)
{
assuan_release (gpgsm->assuan_ctx);
gpgsm->assuan_ctx = NULL;
}
return 0;
}
| 0 |
linux | 9a5729f68d3a82786aea110b1bfe610be318f80a | NOT_APPLICABLE | NOT_APPLICABLE | static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
void *kernbuffer, char __user *userbuffer, ssize_t *bytes_read,
unsigned int tflags)
{
int result = 0, retry, count = len;
int bufsize, thispass, transferred_len;
unsigned int pipe;
char *buffer;
(*bytes_read) = 0;
/* Sanity check */
if (!sisusb || !sisusb->present || !sisusb->sisusb_dev)
return -ENODEV;
pipe = usb_rcvbulkpipe(sisusb->sisusb_dev, ep);
buffer = sisusb->ibuf;
bufsize = sisusb->ibufsize;
retry = 5;
#ifdef SISUSB_DONTSYNC
if (!(sisusb_wait_all_out_complete(sisusb)))
return -EIO;
#endif
while (count > 0) {
if (!sisusb->sisusb_dev)
return -ENODEV;
thispass = (bufsize < count) ? bufsize : count;
result = sisusb_bulkin_msg(sisusb, pipe, buffer, thispass,
&transferred_len, 5 * HZ, tflags);
if (transferred_len)
thispass = transferred_len;
else if (result == -ETIMEDOUT) {
if (!retry--)
return -ETIME;
continue;
} else
return -EIO;
if (thispass) {
(*bytes_read) += thispass;
count -= thispass;
if (userbuffer) {
if (copy_to_user(userbuffer, buffer, thispass))
return -EFAULT;
userbuffer += thispass;
} else {
memcpy(kernbuffer, buffer, thispass);
kernbuffer += thispass;
}
}
}
return ((*bytes_read) == len) ? 0 : -EIO;
} | 0 |
qemu | 6d4b9e55fc625514a38d27cff4b9933f617fa7dc | NOT_APPLICABLE | NOT_APPLICABLE | static void curl_multi_timeout_do(void *arg)
{
#ifdef NEED_CURL_TIMER_CALLBACK
BDRVCURLState *s = (BDRVCURLState *)arg;
int running;
if (!s->multi) {
return;
}
curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
curl_multi_read(s);
#else
abort();
#endif
} | 0 |
linux | f3747379accba8e95d70cec0eae0582c8c182050 | NOT_APPLICABLE | NOT_APPLICABLE | static inline int assign_eip(struct x86_emulate_ctxt *ctxt, ulong dst,
enum x86emul_mode mode)
{
ulong linear;
int rc;
unsigned max_size;
struct segmented_address addr = { .seg = VCPU_SREG_CS,
.ea = dst };
if (ctxt->op_bytes != sizeof(unsigned long))
addr.ea = dst & ((1UL << (ctxt->op_bytes << 3)) - 1);
rc = __linearize(ctxt, addr, &max_size, 1, false, true, mode, &linear);
if (rc == X86EMUL_CONTINUE)
ctxt->_eip = addr.ea;
return rc;
}
| 0 |
linux | 4291086b1f081b869c6d79e5b7441633dc3ace00 | NOT_APPLICABLE | NOT_APPLICABLE | static void echo_char(unsigned char c, struct tty_struct *tty)
{
struct n_tty_data *ldata = tty->disc_data;
if (c == ECHO_OP_START) {
add_echo_byte(ECHO_OP_START, ldata);
add_echo_byte(ECHO_OP_START, ldata);
} else {
if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')
add_echo_byte(ECHO_OP_START, ldata);
add_echo_byte(c, ldata);
}
}
| 0 |
linux | 1f461dcdd296eecedaffffc6bae2bfa90bd7eb89 | NOT_APPLICABLE | NOT_APPLICABLE | ppp_receive_error(struct ppp *ppp)
{
++ppp->dev->stats.rx_errors;
if (ppp->vj)
slhc_toss(ppp->vj);
}
| 0 |
varnish-cache | c5fd097e5cce8b461c6443af02b3448baef2491d | NOT_APPLICABLE | NOT_APPLICABLE | http_Teardown(struct http *hp)
{
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
AN(hp->shd);
memset(&hp->nhd, 0, sizeof *hp - offsetof(struct http, nhd));
memset(hp->hd, 0, sizeof *hp->hd * hp->shd);
memset(hp->hdf, 0, sizeof *hp->hdf * hp->shd);
} | 0 |
linux | f227e3ec3b5cad859ad15666874405e8c1bbc1d4 | NOT_APPLICABLE | NOT_APPLICABLE | static void enqueue_timer(struct timer_base *base, struct timer_list *timer,
unsigned int idx)
{
hlist_add_head(&timer->entry, base->vectors + idx);
__set_bit(idx, base->pending_map);
timer_set_idx(timer, idx);
trace_timer_start(timer, timer->expires, timer->flags);
} | 0 |
varnish-cache | bd7b3d6d47ccbb5e1747126f8e2a297f38e56b8c | CVE-2019-20637 | CWE-212 | cnt_recv_prep(struct req *req, const char *ci)
{
const char *xff;
if (req->restarts == 0) {
/*
* This really should be done earlier, but we want to capture
* it in the VSL log.
*/
http_CollectHdr(req->http, H_X_Forwarded_For);
if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) {
http_Unset(req->http, H_X_Forwarded_For);
http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s",
xff, ci);
} else {
http_PrintfHeader(req->http, "X-Forwarded-For: %s", ci);
}
http_CollectHdr(req->http, H_Cache_Control);
/* By default we use the first backend */
req->director_hint = VCL_DefaultDirector(req->vcl);
req->d_ttl = -1;
req->d_grace = -1;
req->disable_esi = 0;
req->hash_always_miss = 0;
req->hash_ignore_busy = 0;
req->client_identity = NULL;
req->storage = NULL;
}
req->vdc->retval = 0;
req->is_hit = 0;
req->is_hitmiss = 0;
req->is_hitpass = 0;
} | 1 |
collectd | f6be4f9b49b949b379326c3d7002476e6ce4f211 | NOT_APPLICABLE | NOT_APPLICABLE | static int parse_packet(sockent_t *se, /* {{{ */
void *buffer, size_t buffer_size, int flags,
const char *username) {
int status;
value_list_t vl = VALUE_LIST_INIT;
notification_t n = {0};
#if HAVE_LIBGCRYPT
int packet_was_signed = (flags & PP_SIGNED);
int packet_was_encrypted = (flags & PP_ENCRYPTED);
int printed_ignore_warning = 0;
#endif /* HAVE_LIBGCRYPT */
memset(&vl, '\0', sizeof(vl));
status = 0;
while ((status == 0) && (0 < buffer_size) &&
((unsigned int)buffer_size > sizeof(part_header_t))) {
uint16_t pkg_length;
uint16_t pkg_type;
memcpy((void *)&pkg_type, (void *)buffer, sizeof(pkg_type));
memcpy((void *)&pkg_length, (void *)(((char *)buffer) + sizeof(pkg_type)),
sizeof(pkg_length));
pkg_length = ntohs(pkg_length);
pkg_type = ntohs(pkg_type);
if (pkg_length > buffer_size)
break;
/* Ensure that this loop terminates eventually */
if (pkg_length < (2 * sizeof(uint16_t)))
break;
if (pkg_type == TYPE_ENCR_AES256) {
status = parse_part_encr_aes256(se, &buffer, &buffer_size, flags);
if (status != 0) {
ERROR("network plugin: Decrypting AES256 "
"part failed "
"with status %i.",
status);
break;
}
}
#if HAVE_LIBGCRYPT
else if ((se->data.server.security_level == SECURITY_LEVEL_ENCRYPT) &&
(packet_was_encrypted == 0)) {
if (printed_ignore_warning == 0) {
INFO("network plugin: Unencrypted packet or "
"part has been ignored.");
printed_ignore_warning = 1;
}
buffer = ((char *)buffer) + pkg_length;
buffer_size -= (size_t)pkg_length;
continue;
}
#endif /* HAVE_LIBGCRYPT */
else if (pkg_type == TYPE_SIGN_SHA256) {
status = parse_part_sign_sha256(se, &buffer, &buffer_size, flags);
if (status != 0) {
ERROR("network plugin: Verifying HMAC-SHA-256 "
"signature failed "
"with status %i.",
status);
break;
}
}
#if HAVE_LIBGCRYPT
else if ((se->data.server.security_level == SECURITY_LEVEL_SIGN) &&
(packet_was_encrypted == 0) && (packet_was_signed == 0)) {
if (printed_ignore_warning == 0) {
INFO("network plugin: Unsigned packet or "
"part has been ignored.");
printed_ignore_warning = 1;
}
buffer = ((char *)buffer) + pkg_length;
buffer_size -= (size_t)pkg_length;
continue;
}
#endif /* HAVE_LIBGCRYPT */
else if (pkg_type == TYPE_VALUES) {
status =
parse_part_values(&buffer, &buffer_size, &vl.values, &vl.values_len);
if (status != 0)
break;
network_dispatch_values(&vl, username);
sfree(vl.values);
} else if (pkg_type == TYPE_TIME) {
uint64_t tmp = 0;
status = parse_part_number(&buffer, &buffer_size, &tmp);
if (status == 0) {
vl.time = TIME_T_TO_CDTIME_T(tmp);
n.time = TIME_T_TO_CDTIME_T(tmp);
}
} else if (pkg_type == TYPE_TIME_HR) {
uint64_t tmp = 0;
status = parse_part_number(&buffer, &buffer_size, &tmp);
if (status == 0) {
vl.time = (cdtime_t)tmp;
n.time = (cdtime_t)tmp;
}
} else if (pkg_type == TYPE_INTERVAL) {
uint64_t tmp = 0;
status = parse_part_number(&buffer, &buffer_size, &tmp);
if (status == 0)
vl.interval = TIME_T_TO_CDTIME_T(tmp);
} else if (pkg_type == TYPE_INTERVAL_HR) {
uint64_t tmp = 0;
status = parse_part_number(&buffer, &buffer_size, &tmp);
if (status == 0)
vl.interval = (cdtime_t)tmp;
} else if (pkg_type == TYPE_HOST) {
status =
parse_part_string(&buffer, &buffer_size, vl.host, sizeof(vl.host));
if (status == 0)
sstrncpy(n.host, vl.host, sizeof(n.host));
} else if (pkg_type == TYPE_PLUGIN) {
status = parse_part_string(&buffer, &buffer_size, vl.plugin,
sizeof(vl.plugin));
if (status == 0)
sstrncpy(n.plugin, vl.plugin, sizeof(n.plugin));
} else if (pkg_type == TYPE_PLUGIN_INSTANCE) {
status = parse_part_string(&buffer, &buffer_size, vl.plugin_instance,
sizeof(vl.plugin_instance));
if (status == 0)
sstrncpy(n.plugin_instance, vl.plugin_instance,
sizeof(n.plugin_instance));
} else if (pkg_type == TYPE_TYPE) {
status =
parse_part_string(&buffer, &buffer_size, vl.type, sizeof(vl.type));
if (status == 0)
sstrncpy(n.type, vl.type, sizeof(n.type));
} else if (pkg_type == TYPE_TYPE_INSTANCE) {
status = parse_part_string(&buffer, &buffer_size, vl.type_instance,
sizeof(vl.type_instance));
if (status == 0)
sstrncpy(n.type_instance, vl.type_instance, sizeof(n.type_instance));
} else if (pkg_type == TYPE_MESSAGE) {
status = parse_part_string(&buffer, &buffer_size, n.message,
sizeof(n.message));
if (status != 0) {
/* do nothing */
} else if ((n.severity != NOTIF_FAILURE) &&
(n.severity != NOTIF_WARNING) && (n.severity != NOTIF_OKAY)) {
INFO("network plugin: "
"Ignoring notification with "
"unknown severity %i.",
n.severity);
} else if (n.time == 0) {
INFO("network plugin: "
"Ignoring notification with "
"time == 0.");
} else if (strlen(n.message) == 0) {
INFO("network plugin: "
"Ignoring notification with "
"an empty message.");
} else {
network_dispatch_notification(&n);
}
} else if (pkg_type == TYPE_SEVERITY) {
uint64_t tmp = 0;
status = parse_part_number(&buffer, &buffer_size, &tmp);
if (status == 0)
n.severity = (int)tmp;
} else {
DEBUG("network plugin: parse_packet: Unknown part"
" type: 0x%04hx",
pkg_type);
buffer = ((char *)buffer) + pkg_length;
buffer_size -= (size_t)pkg_length;
}
} /* while (buffer_size > sizeof (part_header_t)) */
if (status == 0 && buffer_size > 0)
WARNING("network plugin: parse_packet: Received truncated "
"packet, try increasing `MaxPacketSize'");
return (status);
} /* }}} int parse_packet */ | 0 |
optee_os | d5c5b0b77b2b589666024d219a8007b3f5b6faeb | NOT_APPLICABLE | NOT_APPLICABLE | TEE_Result syscall_open_ta_session(const TEE_UUID *dest,
unsigned long cancel_req_to,
struct utee_params *usr_param, uint32_t *ta_sess,
uint32_t *ret_orig)
{
TEE_Result res;
uint32_t ret_o = TEE_ORIGIN_TEE;
struct tee_ta_session *s = NULL;
struct tee_ta_session *sess;
struct mobj *mobj_param = NULL;
TEE_UUID *uuid = malloc(sizeof(TEE_UUID));
struct tee_ta_param *param = malloc(sizeof(struct tee_ta_param));
TEE_Identity *clnt_id = malloc(sizeof(TEE_Identity));
void *tmp_buf_va[TEE_NUM_PARAMS] = { NULL };
struct user_ta_ctx *utc;
if (uuid == NULL || param == NULL || clnt_id == NULL) {
res = TEE_ERROR_OUT_OF_MEMORY;
goto out_free_only;
}
memset(param, 0, sizeof(struct tee_ta_param));
res = tee_ta_get_current_session(&sess);
if (res != TEE_SUCCESS)
goto out_free_only;
utc = to_user_ta_ctx(sess->ctx);
res = tee_svc_copy_from_user(uuid, dest, sizeof(TEE_UUID));
if (res != TEE_SUCCESS)
goto function_exit;
clnt_id->login = TEE_LOGIN_TRUSTED_APP;
memcpy(&clnt_id->uuid, &sess->ctx->uuid, sizeof(TEE_UUID));
res = tee_svc_copy_param(sess, NULL, usr_param, param, tmp_buf_va,
&mobj_param);
if (res != TEE_SUCCESS)
goto function_exit;
res = tee_ta_open_session(&ret_o, &s, &utc->open_sessions, uuid,
clnt_id, cancel_req_to, param);
tee_mmu_set_ctx(&utc->ctx);
if (res != TEE_SUCCESS)
goto function_exit;
res = tee_svc_update_out_param(param, tmp_buf_va, usr_param);
function_exit:
mobj_free(mobj_param);
if (res == TEE_SUCCESS)
tee_svc_copy_kaddr_to_uref(ta_sess, s);
tee_svc_copy_to_user(ret_orig, &ret_o, sizeof(ret_o));
out_free_only:
free(param);
free(uuid);
free(clnt_id);
return res;
}
| 0 |
linux-2.6 | 8a47077a0b5aa2649751c46e7a27884e6686ccbf | NOT_APPLICABLE | NOT_APPLICABLE | cbq_under_limit(struct cbq_class *cl)
{
struct cbq_sched_data *q = qdisc_priv(cl->qdisc);
struct cbq_class *this_cl = cl;
if (cl->tparent == NULL)
return cl;
if (PSCHED_IS_PASTPERFECT(cl->undertime) ||
!PSCHED_TLESS(q->now, cl->undertime)) {
cl->delayed = 0;
return cl;
}
do {
/* It is very suspicious place. Now overlimit
action is generated for not bounded classes
only if link is completely congested.
Though it is in agree with ancestor-only paradigm,
it looks very stupid. Particularly,
it means that this chunk of code will either
never be called or result in strong amplification
of burstiness. Dangerous, silly, and, however,
no another solution exists.
*/
if ((cl = cl->borrow) == NULL) {
this_cl->qstats.overlimits++;
this_cl->overlimit(this_cl);
return NULL;
}
if (cl->level > q->toplevel)
return NULL;
} while (!PSCHED_IS_PASTPERFECT(cl->undertime) &&
PSCHED_TLESS(q->now, cl->undertime));
cl->delayed = 0;
return cl;
} | 0 |
tensorflow | 1361fb7e29449629e1df94d44e0427ebec8c83c7 | NOT_APPLICABLE | NOT_APPLICABLE | InferenceContext::ShapeManager::ShapeManager() {} | 0 |
krb5 | a7886f0ed1277c69142b14a2c6629175a6331edc | NOT_APPLICABLE | NOT_APPLICABLE | make_spnego_token(const char *name)
{
return (spnego_token_t)strdup(name);
}
| 0 |
gpac | ad18ece95fa064efc0995c4ab2c985f77fb166ec | NOT_APPLICABLE | NOT_APPLICABLE | GF_Err gf_isom_rtp_set_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeScale)
{
GF_TrackBox *trak;
GF_HintSampleEntryBox *hdesc;
u32 i, count;
GF_TSHintEntryBox *ent;
trak = gf_isom_get_track_from_file(the_file, trackNumber);
if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM;
//OK, create a new HintSampleDesc
hdesc = (GF_HintSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, HintDescriptionIndex - 1);
if (!hdesc) return GF_BAD_PARAM;
count = gf_list_count(hdesc->child_boxes);
for (i=0; i< count; i++) {
ent = (GF_TSHintEntryBox *)gf_list_get(hdesc->child_boxes, i);
if (ent->type == GF_ISOM_BOX_TYPE_TIMS) {
ent->timeScale = TimeScale;
return GF_OK;
}
}
//we have to create a new entry...
ent = (GF_TSHintEntryBox *) gf_isom_box_new_parent(&hdesc->child_boxes, GF_ISOM_BOX_TYPE_TIMS);
if (!ent) return GF_OUT_OF_MEM;
ent->timeScale = TimeScale;
return GF_OK;
} | 0 |
libming | a009a38dce1d9316cad1ab522b813b1d5ba4c62a | NOT_APPLICABLE | NOT_APPLICABLE | destroySWFInput(SWFInput input)
{
input->destroy(input);
} | 0 |
Android | cc274e2abe8b2a6698a5c47d8aa4bb45f1f9538d | CVE-2016-2464 | CWE-20 | long AudioTrack::Parse(Segment* pSegment, const Info& info,
long long element_start, long long element_size,
AudioTrack*& pResult) {
if (pResult)
return -1;
if (info.type != Track::kAudio)
return -1;
IMkvReader* const pReader = pSegment->m_pReader;
const Settings& s = info.settings;
assert(s.start >= 0);
assert(s.size >= 0);
long long pos = s.start;
assert(pos >= 0);
const long long stop = pos + s.size;
double rate = 8000.0; // MKV default
long long channels = 1;
long long bit_depth = 0;
while (pos < stop) {
long long id, size;
long status = ParseElementHeader(pReader, pos, stop, id, size);
if (status < 0) // error
return status;
if (id == 0x35) { // Sample Rate
status = UnserializeFloat(pReader, pos, size, rate);
if (status < 0)
return status;
if (rate <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x1F) { // Channel Count
channels = UnserializeUInt(pReader, pos, size);
if (channels <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x2264) { // Bit Depth
bit_depth = UnserializeUInt(pReader, pos, size);
if (bit_depth <= 0)
return E_FILE_FORMAT_INVALID;
}
pos += size; // consume payload
assert(pos <= stop);
}
assert(pos == stop);
AudioTrack* const pTrack =
new (std::nothrow) AudioTrack(pSegment, element_start, element_size);
if (pTrack == NULL)
return -1; // generic error
const int status = info.Copy(pTrack->m_info);
if (status) {
delete pTrack;
return status;
}
pTrack->m_rate = rate;
pTrack->m_channels = channels;
pTrack->m_bitDepth = bit_depth;
pResult = pTrack;
return 0; // success
}
| 1 |
rpm | bd36c5dc9fb6d90c46fbfed8c2d67516fc571ec8 | NOT_APPLICABLE | NOT_APPLICABLE | static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen,
pgpDigParams _digp)
{
uint8_t version = 0;
const uint8_t * p = NULL;
int rc = 1;
if (pgpVersion(h, hlen, &version))
return rc;
/* We only permit V4 keys, V3 keys are long long since deprecated */
switch (version) {
case 4:
{ pgpPktKeyV4 v = (pgpPktKeyV4)h;
if (hlen > sizeof(*v)) {
pgpPrtVal("V4 ", pgpTagTbl, tag);
pgpPrtVal(" ", pgpPubkeyTbl, v->pubkey_algo);
pgpPrtTime(" ", v->time, sizeof(v->time));
pgpPrtNL();
/* If _digp->hash is not NULL then signature is already loaded */
if (_digp->hash == NULL) {
_digp->version = v->version;
_digp->time = pgpGrab(v->time, sizeof(v->time));
_digp->pubkey_algo = v->pubkey_algo;
}
p = ((uint8_t *)v) + sizeof(*v);
rc = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen, _digp);
}
} break;
default:
rpmlog(RPMLOG_WARNING, _("Unsupported version of key: V%d\n"), h[0]);
}
return rc;
} | 0 |
qemu | 1d7678dec4761acdc43439da6ceda41a703ba1a6 | CVE-2014-0148 | CWE-835 | static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s)
{
int ret = 0;
uint8_t *buffer;
int offset = 0;
uint32_t i = 0;
VHDXMetadataTableEntry md_entry;
buffer = qemu_blockalign(bs, VHDX_METADATA_TABLE_MAX_SIZE);
ret = bdrv_pread(bs->file, s->metadata_rt.file_offset, buffer,
VHDX_METADATA_TABLE_MAX_SIZE);
if (ret < 0) {
goto exit;
}
memcpy(&s->metadata_hdr, buffer, sizeof(s->metadata_hdr));
offset += sizeof(s->metadata_hdr);
vhdx_metadata_header_le_import(&s->metadata_hdr);
if (memcmp(&s->metadata_hdr.signature, "metadata", 8)) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.present = 0;
if ((s->metadata_hdr.entry_count * sizeof(md_entry)) >
(VHDX_METADATA_TABLE_MAX_SIZE - offset)) {
ret = -EINVAL;
goto exit;
}
for (i = 0; i < s->metadata_hdr.entry_count; i++) {
memcpy(&md_entry, buffer + offset, sizeof(md_entry));
offset += sizeof(md_entry);
vhdx_metadata_entry_le_import(&md_entry);
if (guid_eq(md_entry.item_id, file_param_guid)) {
if (s->metadata_entries.present & META_FILE_PARAMETER_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.file_parameters_entry = md_entry;
s->metadata_entries.present |= META_FILE_PARAMETER_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, virtual_size_guid)) {
if (s->metadata_entries.present & META_VIRTUAL_DISK_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.virtual_disk_size_entry = md_entry;
s->metadata_entries.present |= META_VIRTUAL_DISK_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, page83_guid)) {
if (s->metadata_entries.present & META_PAGE_83_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.page83_data_entry = md_entry;
s->metadata_entries.present |= META_PAGE_83_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, logical_sector_guid)) {
if (s->metadata_entries.present &
META_LOGICAL_SECTOR_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.logical_sector_size_entry = md_entry;
s->metadata_entries.present |= META_LOGICAL_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, phys_sector_guid)) {
if (s->metadata_entries.present & META_PHYS_SECTOR_SIZE_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.phys_sector_size_entry = md_entry;
s->metadata_entries.present |= META_PHYS_SECTOR_SIZE_PRESENT;
continue;
}
if (guid_eq(md_entry.item_id, parent_locator_guid)) {
if (s->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
ret = -EINVAL;
goto exit;
}
s->metadata_entries.parent_locator_entry = md_entry;
s->metadata_entries.present |= META_PARENT_LOCATOR_PRESENT;
continue;
}
if (md_entry.data_bits & VHDX_META_FLAGS_IS_REQUIRED) {
/* cannot read vhdx file - required region table entry that
* we do not understand. per spec, we must fail to open */
ret = -ENOTSUP;
goto exit;
}
}
if (s->metadata_entries.present != META_ALL_PRESENT) {
ret = -ENOTSUP;
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.file_parameters_entry.offset
+ s->metadata_rt.file_offset,
&s->params,
sizeof(s->params));
if (ret < 0) {
goto exit;
}
le32_to_cpus(&s->params.block_size);
le32_to_cpus(&s->params.data_bits);
/* We now have the file parameters, so we can tell if this is a
* differencing file (i.e.. has_parent), is dynamic or fixed
* sized (leave_blocks_allocated), and the block size */
/* The parent locator required iff the file parameters has_parent set */
if (s->params.data_bits & VHDX_PARAMS_HAS_PARENT) {
if (s->metadata_entries.present & META_PARENT_LOCATOR_PRESENT) {
/* TODO: parse parent locator fields */
ret = -ENOTSUP; /* temp, until differencing files are supported */
goto exit;
} else {
/* if has_parent is set, but there is not parent locator present,
* then that is an invalid combination */
ret = -EINVAL;
goto exit;
}
}
/* determine virtual disk size, logical sector size,
* and phys sector size */
ret = bdrv_pread(bs->file,
s->metadata_entries.virtual_disk_size_entry.offset
+ s->metadata_rt.file_offset,
&s->virtual_disk_size,
sizeof(uint64_t));
if (ret < 0) {
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.logical_sector_size_entry.offset
+ s->metadata_rt.file_offset,
&s->logical_sector_size,
sizeof(uint32_t));
if (ret < 0) {
goto exit;
}
ret = bdrv_pread(bs->file,
s->metadata_entries.phys_sector_size_entry.offset
+ s->metadata_rt.file_offset,
&s->physical_sector_size,
sizeof(uint32_t));
if (ret < 0) {
goto exit;
}
le64_to_cpus(&s->virtual_disk_size);
le32_to_cpus(&s->logical_sector_size);
le32_to_cpus(&s->physical_sector_size);
if (s->logical_sector_size == 0 || s->params.block_size == 0) {
ret = -EINVAL;
goto exit;
}
/* both block_size and sector_size are guaranteed powers of 2 */
s->sectors_per_block = s->params.block_size / s->logical_sector_size;
s->chunk_ratio = (VHDX_MAX_SECTORS_PER_BLOCK) *
(uint64_t)s->logical_sector_size /
(uint64_t)s->params.block_size;
/* These values are ones we will want to use for division / multiplication
* later on, and they are all guaranteed (per the spec) to be powers of 2,
* so we can take advantage of that for shift operations during
* reads/writes */
if (s->logical_sector_size & (s->logical_sector_size - 1)) {
ret = -EINVAL;
goto exit;
}
if (s->sectors_per_block & (s->sectors_per_block - 1)) {
ret = -EINVAL;
goto exit;
}
if (s->chunk_ratio & (s->chunk_ratio - 1)) {
ret = -EINVAL;
goto exit;
}
s->block_size = s->params.block_size;
if (s->block_size & (s->block_size - 1)) {
ret = -EINVAL;
goto exit;
}
vhdx_set_shift_bits(s);
ret = 0;
exit:
qemu_vfree(buffer);
return ret;
} | 1 |
clamav-devel | 3d664817f6ef833a17414a4ecea42004c35cc42f | NOT_APPLICABLE | NOT_APPLICABLE | static int add_selfcheck(struct cli_all_bc *bcs)
{
struct cli_bc_func *func;
struct cli_bc_inst *inst;
struct cli_bc *bc;
bcs->all_bcs = cli_realloc2(bcs->all_bcs, sizeof(*bcs->all_bcs)*(bcs->count+1));
if (!bcs->all_bcs) {
cli_errmsg("cli_loadcbc: Can't allocate memory for bytecode entry\n");
return CL_EMEM;
}
bc = &bcs->all_bcs[bcs->count++];
memset(bc, 0, sizeof(*bc));
bc->trusted = 1;
bc->num_globals = 1;
bc->globals = cli_calloc(1, sizeof(*bc->globals));
if (!bc->globals) {
cli_errmsg("Failed to allocate memory for globals\n");
return CL_EMEM;
}
bc->globals[0] = cli_calloc(1, sizeof(*bc->globals[0]));
if (!bc->globals[0]) {
cli_errmsg("Failed to allocate memory for globals\n");
return CL_EMEM;
}
bc->globaltys = cli_calloc(1, sizeof(*bc->globaltys));
if (!bc->globaltys) {
cli_errmsg("Failed to allocate memory for globaltypes\n");
return CL_EMEM;
}
bc->globaltys[0] = 32;
*bc->globals[0] = 0;
bc->id = ~0;
bc->kind = 0;
bc->num_types = 5;
bc->num_func = 1;
bc->funcs = cli_calloc(1, sizeof(*bc->funcs));
if (!bc->funcs) {
cli_errmsg("Failed to allocate memory for func\n");
return CL_EMEM;
}
func = bc->funcs;
func->numInsts = 2;
func->numLocals = 1;
func->numValues = 1;
func->numConstants = 1;
func->numBB = 1;
func->returnType = 32;
func->types = cli_calloc(1, sizeof(*func->types));
if (!func->types) {
cli_errmsg("Failed to allocate memory for types\n");
return CL_EMEM;
}
func->types[0] = 32;
func->BB = cli_calloc(1, sizeof(*func->BB));
if (!func->BB) {
cli_errmsg("Failed to allocate memory for BB\n");
return CL_EMEM;
}
func->allinsts = cli_calloc(2, sizeof(*func->allinsts));
if (!func->allinsts) {
cli_errmsg("Failed to allocate memory for insts\n");
return CL_EMEM;
}
func->BB->numInsts = 2;
func->BB->insts = func->allinsts;
func->constants = cli_calloc(1, sizeof(*func->constants));
if (!func->constants) {
cli_errmsg("Failed to allocate memory for constants\n");
return CL_EMEM;
}
func->constants[0] = 0xf00d;
inst = func->allinsts;
inst->opcode = OP_BC_CALL_API;
inst->u.ops.numOps = 1;
inst->u.ops.opsizes = NULL;
inst->u.ops.ops = cli_calloc(1, sizeof(*inst->u.ops.ops));
if (!inst->u.ops.ops) {
cli_errmsg("Failed to allocate memory for instructions\n");
return CL_EMEM;
}
inst->u.ops.ops[0] = 1;
inst->u.ops.funcid = 18; /* test2 */
inst->dest = 0;
inst->type = 32;
inst->interp_op = inst->opcode* 5 + 3;
inst = &func->allinsts[1];
inst->opcode = OP_BC_RET;
inst->type = 32;
inst->u.unaryop = 0;
inst->interp_op = inst->opcode* 5;
bc->state = bc_loaded;
return 0;
} | 0 |
libdwarf-code | faf99408e3f9f706fc3809dd400e831f989778d3 | NOT_APPLICABLE | NOT_APPLICABLE | _dwarf_print_lines(Dwarf_Die die, Dwarf_Error * error)
{
int only_line_header = 0;
int err_count = 0;
int res = _dwarf_internal_printlines(die,
&err_count,
only_line_header,error);
/* No way to get error count back in this interface */
return res;
} | 0 |
ImageMagick | b5ed738f8060266bf4ae521f7e3ed145aa4498a3 | NOT_APPLICABLE | NOT_APPLICABLE | MagickExport MagickBooleanType SetQuantumFormat(const Image *image,
QuantumInfo *quantum_info,const QuantumFormatType format)
{
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(quantum_info != (QuantumInfo *) NULL);
assert(quantum_info->signature == MagickSignature);
quantum_info->format=format;
return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
}
| 0 |
mujs | 5008105780c0b0182ea6eda83ad5598f225be3ee | NOT_APPLICABLE | NOT_APPLICABLE | static void ceval(JF, js_Ast *fun, js_Ast *args)
{
int n = cargs(J, F, args);
if (n == 0)
emit(J, F, OP_UNDEF);
else while (n-- > 1)
emit(J, F, OP_POP);
emit(J, F, OP_EVAL);
} | 0 |
git | a124133e1e6ab5c7a9fef6d0e6bcb084e3455b46 | NOT_APPLICABLE | NOT_APPLICABLE | int fsck_object(struct object *obj, void *data, unsigned long size,
struct fsck_options *options)
{
if (!obj)
return report(options, obj, FSCK_MSG_BAD_OBJECT_SHA1, "no valid object to fsck");
if (obj->type == OBJ_BLOB)
return fsck_blob((struct blob *)obj, data, size, options);
if (obj->type == OBJ_TREE)
return fsck_tree((struct tree *) obj, options);
if (obj->type == OBJ_COMMIT)
return fsck_commit((struct commit *) obj, (const char *) data,
size, options);
if (obj->type == OBJ_TAG)
return fsck_tag((struct tag *) obj, (const char *) data,
size, options);
return report(options, obj, FSCK_MSG_UNKNOWN_TYPE, "unknown type '%d' (internal fsck error)",
obj->type);
}
| 0 |
Chrome | dd3b6fe574edad231c01c78e4647a74c38dc4178 | NOT_APPLICABLE | NOT_APPLICABLE | void GDataFileSystem::OnUpdatedFileUploaded(
const FileOperationCallback& callback,
GDataFileError error,
scoped_ptr<UploadFileInfo> upload_file_info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(upload_file_info.get());
if (error != GDATA_FILE_OK) {
if (!callback.is_null())
callback.Run(error);
return;
}
AddUploadedFile(UPLOAD_EXISTING_FILE,
upload_file_info->gdata_path.DirName(),
upload_file_info->entry.Pass(),
upload_file_info->file_path,
GDataCache::FILE_OPERATION_MOVE,
base::Bind(&OnAddUploadFileCompleted, callback, error));
}
| 0 |
ImageMagick | 9fd10cf630832b36a588c1545d8736539b2f1fb5 | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t ReadBlobBlock(Image *image,unsigned char *data)
{
ssize_t
count;
unsigned char
block_count;
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
assert(data != (unsigned char *) NULL);
count=ReadBlob(image,1,&block_count);
if (count != 1)
return(0);
count=ReadBlob(image,(size_t) block_count,data);
if (count != (ssize_t) block_count)
return(0);
return(count);
}
| 0 |
pngquant | b7c217680cda02dddced245d237ebe8c383be285 | NOT_APPLICABLE | NOT_APPLICABLE | static void user_flush_data(png_structp png_ptr)
{
}
| 0 |
sqlite | 5f69512404cd2e5153ddf90ea277fbba6dd58ab7 | NOT_APPLICABLE | NOT_APPLICABLE | static void codeOffset(
Vdbe *v, /* Generate code into this VM */
int iOffset, /* Register holding the offset counter */
int iContinue /* Jump here to skip the current record */
){
if( iOffset>0 ){
sqlite3VdbeAddOp3(v, OP_IfPos, iOffset, iContinue, 1); VdbeCoverage(v);
VdbeComment((v, "OFFSET"));
}
} | 0 |
libde265 | 697aa4f7c774abd6374596e6707a6f4f54265355 | NOT_APPLICABLE | NOT_APPLICABLE | void generate_inter_prediction_samples(base_context* ctx,
const slice_segment_header* shdr,
de265_image* img,
int xC,int yC,
int xB,int yB,
int nCS, int nPbW,int nPbH,
const PBMotion* vi)
{
int xP = xC+xB;
int yP = yC+yB;
void* pixels[3];
int stride[3];
const pic_parameter_set* pps = shdr->pps.get();
const seq_parameter_set* sps = pps->sps.get();
const int SubWidthC = sps->SubWidthC;
const int SubHeightC = sps->SubHeightC;
pixels[0] = img->get_image_plane_at_pos_any_depth(0,xP,yP);
stride[0] = img->get_image_stride(0);
pixels[1] = img->get_image_plane_at_pos_any_depth(1,xP/SubWidthC,yP/SubHeightC);
stride[1] = img->get_image_stride(1);
pixels[2] = img->get_image_plane_at_pos_any_depth(2,xP/SubWidthC,yP/SubHeightC);
stride[2] = img->get_image_stride(2);
ALIGNED_16(int16_t) predSamplesL [2 /* LX */][MAX_CU_SIZE* MAX_CU_SIZE];
ALIGNED_16(int16_t) predSamplesC[2 /* chroma */ ][2 /* LX */][MAX_CU_SIZE* MAX_CU_SIZE];
//int xP = xC+xB;
//int yP = yC+yB;
int predFlag[2];
predFlag[0] = vi->predFlag[0];
predFlag[1] = vi->predFlag[1];
const int bit_depth_L = sps->BitDepth_Y;
const int bit_depth_C = sps->BitDepth_C;
// Some encoders use bi-prediction with two similar MVs.
// Identify this case and use only one MV.
// do this only without weighted prediction, because the weights/offsets may be different
if (pps->weighted_pred_flag==0) {
if (predFlag[0] && predFlag[1]) {
if (vi->mv[0].x == vi->mv[1].x &&
vi->mv[0].y == vi->mv[1].y &&
shdr->RefPicList[0][vi->refIdx[0]] ==
shdr->RefPicList[1][vi->refIdx[1]]) {
predFlag[1] = 0;
}
}
}
for (int l=0;l<2;l++) {
if (predFlag[l]) {
// 8.5.3.2.1
if (vi->refIdx[l] >= MAX_NUM_REF_PICS) {
img->integrity = INTEGRITY_DECODING_ERRORS;
ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);
return;
}
const de265_image* refPic = ctx->get_image(shdr->RefPicList[l][vi->refIdx[l]]);
logtrace(LogMotion, "refIdx: %d -> dpb[%d]\n", vi->refIdx[l], shdr->RefPicList[l][vi->refIdx[l]]);
if (!refPic || refPic->PicState == UnusedForReference) {
img->integrity = INTEGRITY_DECODING_ERRORS;
ctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED, false);
// TODO: fill predSamplesC with black or grey
}
else {
// 8.5.3.2.2
logtrace(LogMotion,"do MC: L%d,MV=%d;%d RefPOC=%d\n",
l,vi->mv[l].x,vi->mv[l].y,refPic->PicOrderCntVal);
// TODO: must predSamples stride really be nCS or can it be somthing smaller like nPbW?
if (img->high_bit_depth(0)) {
mc_luma(ctx, sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
predSamplesL[l],nCS,
(const uint16_t*)refPic->get_image_plane(0),
refPic->get_luma_stride(), nPbW,nPbH, bit_depth_L);
}
else {
mc_luma(ctx, sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
predSamplesL[l],nCS,
(const uint8_t*)refPic->get_image_plane(0),
refPic->get_luma_stride(), nPbW,nPbH, bit_depth_L);
}
if (img->high_bit_depth(1)) {
mc_chroma(ctx, sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
predSamplesC[0][l],nCS, (const uint16_t*)refPic->get_image_plane(1),
refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
mc_chroma(ctx, sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
predSamplesC[1][l],nCS, (const uint16_t*)refPic->get_image_plane(2),
refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
}
else {
mc_chroma(ctx, sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
predSamplesC[0][l],nCS, (const uint8_t*)refPic->get_image_plane(1),
refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
mc_chroma(ctx, sps, vi->mv[l].x, vi->mv[l].y, xP,yP,
predSamplesC[1][l],nCS, (const uint8_t*)refPic->get_image_plane(2),
refPic->get_chroma_stride(), nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
}
}
}
}
// weighted sample prediction (8.5.3.2.3)
const int shift1_L = libde265_max(2,14-sps->BitDepth_Y);
const int offset_shift1_L = img->get_sps().WpOffsetBdShiftY;
const int shift1_C = libde265_max(2,14-sps->BitDepth_C);
const int offset_shift1_C = img->get_sps().WpOffsetBdShiftC;
/*
const int shift1_L = 14-img->sps.BitDepth_Y;
const int offset_shift1_L = img->sps.BitDepth_Y-8;
const int shift1_C = 14-img->sps.BitDepth_C;
const int offset_shift1_C = img->sps.BitDepth_C-8;
*/
/*
if (0)
printf("%d/%d %d/%d %d/%d %d/%d\n",
shift1_L,
Nshift1_L,
offset_shift1_L,
Noffset_shift1_L,
shift1_C,
Nshift1_C,
offset_shift1_C,
Noffset_shift1_C);
assert(shift1_L==
Nshift1_L);
assert(offset_shift1_L==
Noffset_shift1_L);
assert(shift1_C==
Nshift1_C);
assert(offset_shift1_C==
Noffset_shift1_C);
*/
logtrace(LogMotion,"predFlags (modified): %d %d\n", predFlag[0], predFlag[1]);
if (shdr->slice_type == SLICE_TYPE_P) {
if (pps->weighted_pred_flag==0) {
if (predFlag[0]==1 && predFlag[1]==0) {
ctx->acceleration.put_unweighted_pred(pixels[0], stride[0],
predSamplesL[0],nCS, nPbW,nPbH, bit_depth_L);
ctx->acceleration.put_unweighted_pred(pixels[1], stride[1],
predSamplesC[0][0],nCS,
nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
ctx->acceleration.put_unweighted_pred(pixels[2], stride[2],
predSamplesC[1][0],nCS,
nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
}
else {
ctx->add_warning(DE265_WARNING_BOTH_PREDFLAGS_ZERO, false);
img->integrity = INTEGRITY_DECODING_ERRORS;
}
}
else {
// weighted prediction
if (predFlag[0]==1 && predFlag[1]==0) {
int refIdx0 = vi->refIdx[0];
int luma_log2WD = shdr->luma_log2_weight_denom + shift1_L;
int chroma_log2WD = shdr->ChromaLog2WeightDenom + shift1_C;
int luma_w0 = shdr->LumaWeight[0][refIdx0];
int luma_o0 = shdr->luma_offset[0][refIdx0] * (1<<(offset_shift1_L));
int chroma0_w0 = shdr->ChromaWeight[0][refIdx0][0];
int chroma0_o0 = shdr->ChromaOffset[0][refIdx0][0] * (1<<(offset_shift1_C));
int chroma1_w0 = shdr->ChromaWeight[0][refIdx0][1];
int chroma1_o0 = shdr->ChromaOffset[0][refIdx0][1] * (1<<(offset_shift1_C));
logtrace(LogMotion,"weighted-0 [%d] %d %d %d %dx%d\n", refIdx0, luma_log2WD-6,luma_w0,luma_o0,nPbW,nPbH);
ctx->acceleration.put_weighted_pred(pixels[0], stride[0],
predSamplesL[0],nCS, nPbW,nPbH,
luma_w0, luma_o0, luma_log2WD, bit_depth_L);
ctx->acceleration.put_weighted_pred(pixels[1], stride[1],
predSamplesC[0][0],nCS, nPbW/SubWidthC,nPbH/SubHeightC,
chroma0_w0, chroma0_o0, chroma_log2WD, bit_depth_C);
ctx->acceleration.put_weighted_pred(pixels[2], stride[2],
predSamplesC[1][0],nCS, nPbW/SubWidthC,nPbH/SubHeightC,
chroma1_w0, chroma1_o0, chroma_log2WD, bit_depth_C);
}
else {
ctx->add_warning(DE265_WARNING_BOTH_PREDFLAGS_ZERO, false);
img->integrity = INTEGRITY_DECODING_ERRORS;
}
}
}
else {
assert(shdr->slice_type == SLICE_TYPE_B);
if (predFlag[0]==1 && predFlag[1]==1) {
if (pps->weighted_bipred_flag==0) {
//const int shift2 = 15-8; // TODO: real bit depth
//const int offset2 = 1<<(shift2-1);
int16_t* in0 = predSamplesL[0];
int16_t* in1 = predSamplesL[1];
ctx->acceleration.put_weighted_pred_avg(pixels[0], stride[0],
in0,in1, nCS, nPbW, nPbH, bit_depth_L);
int16_t* in00 = predSamplesC[0][0];
int16_t* in01 = predSamplesC[0][1];
int16_t* in10 = predSamplesC[1][0];
int16_t* in11 = predSamplesC[1][1];
ctx->acceleration.put_weighted_pred_avg(pixels[1], stride[1],
in00,in01, nCS,
nPbW/SubWidthC, nPbH/SubHeightC, bit_depth_C);
ctx->acceleration.put_weighted_pred_avg(pixels[2], stride[2],
in10,in11, nCS,
nPbW/SubWidthC, nPbH/SubHeightC, bit_depth_C);
}
else {
// weighted prediction
int refIdx0 = vi->refIdx[0];
int refIdx1 = vi->refIdx[1];
int luma_log2WD = shdr->luma_log2_weight_denom + shift1_L;
int chroma_log2WD = shdr->ChromaLog2WeightDenom + shift1_C;
int luma_w0 = shdr->LumaWeight[0][refIdx0];
int luma_o0 = shdr->luma_offset[0][refIdx0] * (1<<(offset_shift1_L));
int luma_w1 = shdr->LumaWeight[1][refIdx1];
int luma_o1 = shdr->luma_offset[1][refIdx1] * (1<<(offset_shift1_L));
int chroma0_w0 = shdr->ChromaWeight[0][refIdx0][0];
int chroma0_o0 = shdr->ChromaOffset[0][refIdx0][0] * (1<<(offset_shift1_C));
int chroma1_w0 = shdr->ChromaWeight[0][refIdx0][1];
int chroma1_o0 = shdr->ChromaOffset[0][refIdx0][1] * (1<<(offset_shift1_C));
int chroma0_w1 = shdr->ChromaWeight[1][refIdx1][0];
int chroma0_o1 = shdr->ChromaOffset[1][refIdx1][0] * (1<<(offset_shift1_C));
int chroma1_w1 = shdr->ChromaWeight[1][refIdx1][1];
int chroma1_o1 = shdr->ChromaOffset[1][refIdx1][1] * (1<<(offset_shift1_C));
logtrace(LogMotion,"weighted-BI-0 [%d] %d %d %d %dx%d\n", refIdx0, luma_log2WD-6,luma_w0,luma_o0,nPbW,nPbH);
logtrace(LogMotion,"weighted-BI-1 [%d] %d %d %d %dx%d\n", refIdx1, luma_log2WD-6,luma_w1,luma_o1,nPbW,nPbH);
int16_t* in0 = predSamplesL[0];
int16_t* in1 = predSamplesL[1];
ctx->acceleration.put_weighted_bipred(pixels[0], stride[0],
in0,in1, nCS, nPbW, nPbH,
luma_w0,luma_o0,
luma_w1,luma_o1,
luma_log2WD, bit_depth_L);
int16_t* in00 = predSamplesC[0][0];
int16_t* in01 = predSamplesC[0][1];
int16_t* in10 = predSamplesC[1][0];
int16_t* in11 = predSamplesC[1][1];
ctx->acceleration.put_weighted_bipred(pixels[1], stride[1],
in00,in01, nCS, nPbW/SubWidthC, nPbH/SubHeightC,
chroma0_w0,chroma0_o0,
chroma0_w1,chroma0_o1,
chroma_log2WD, bit_depth_C);
ctx->acceleration.put_weighted_bipred(pixels[2], stride[2],
in10,in11, nCS, nPbW/SubWidthC, nPbH/SubHeightC,
chroma1_w0,chroma1_o0,
chroma1_w1,chroma1_o1,
chroma_log2WD, bit_depth_C);
}
}
else if (predFlag[0]==1 || predFlag[1]==1) {
int l = predFlag[0] ? 0 : 1;
if (pps->weighted_bipred_flag==0) {
ctx->acceleration.put_unweighted_pred(pixels[0], stride[0],
predSamplesL[l],nCS, nPbW,nPbH, bit_depth_L);
ctx->acceleration.put_unweighted_pred(pixels[1], stride[1],
predSamplesC[0][l],nCS,
nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
ctx->acceleration.put_unweighted_pred(pixels[2], stride[2],
predSamplesC[1][l],nCS,
nPbW/SubWidthC,nPbH/SubHeightC, bit_depth_C);
}
else {
int refIdx = vi->refIdx[l];
int luma_log2WD = shdr->luma_log2_weight_denom + shift1_L;
int chroma_log2WD = shdr->ChromaLog2WeightDenom + shift1_C;
int luma_w = shdr->LumaWeight[l][refIdx];
int luma_o = shdr->luma_offset[l][refIdx] * (1<<(offset_shift1_L));
int chroma0_w = shdr->ChromaWeight[l][refIdx][0];
int chroma0_o = shdr->ChromaOffset[l][refIdx][0] * (1<<(offset_shift1_C));
int chroma1_w = shdr->ChromaWeight[l][refIdx][1];
int chroma1_o = shdr->ChromaOffset[l][refIdx][1] * (1<<(offset_shift1_C));
logtrace(LogMotion,"weighted-B-L%d [%d] %d %d %d %dx%d\n", l, refIdx, luma_log2WD-6,luma_w,luma_o,nPbW,nPbH);
ctx->acceleration.put_weighted_pred(pixels[0], stride[0],
predSamplesL[l],nCS, nPbW,nPbH,
luma_w, luma_o, luma_log2WD, bit_depth_L);
ctx->acceleration.put_weighted_pred(pixels[1], stride[1],
predSamplesC[0][l],nCS,
nPbW/SubWidthC,nPbH/SubHeightC,
chroma0_w, chroma0_o, chroma_log2WD, bit_depth_C);
ctx->acceleration.put_weighted_pred(pixels[2], stride[2],
predSamplesC[1][l],nCS,
nPbW/SubWidthC,nPbH/SubHeightC,
chroma1_w, chroma1_o, chroma_log2WD, bit_depth_C);
}
}
else {
// TODO: check why it can actually happen that both predFlags[] are false.
// For now, we ignore this and continue decoding.
ctx->add_warning(DE265_WARNING_BOTH_PREDFLAGS_ZERO, false);
img->integrity = INTEGRITY_DECODING_ERRORS;
}
}
#if defined(DE265_LOG_TRACE) && 0
logtrace(LogTransform,"MC pixels (luma), position %d %d:\n", xP,yP);
for (int y=0;y<nPbH;y++) {
logtrace(LogTransform,"MC-y-%d-%d ",xP,yP+y);
for (int x=0;x<nPbW;x++) {
logtrace(LogTransform,"*%02x ", pixels[0][x+y*stride[0]]);
}
logtrace(LogTransform,"*\n");
}
logtrace(LogTransform,"MC pixels (chroma cb), position %d %d:\n", xP/2,yP/2);
for (int y=0;y<nPbH/2;y++) {
logtrace(LogTransform,"MC-cb-%d-%d ",xP/2,yP/2+y);
for (int x=0;x<nPbW/2;x++) {
logtrace(LogTransform,"*%02x ", pixels[1][x+y*stride[1]]);
}
logtrace(LogTransform,"*\n");
}
logtrace(LogTransform,"MC pixels (chroma cr), position %d %d:\n", xP/2,yP/2);
for (int y=0;y<nPbH/2;y++) {
logtrace(LogTransform,"MC-cr-%d-%d ",xP/2,yP/2+y);
for (int x=0;x<nPbW/2;x++) {
logtrace(LogTransform,"*%02x ", pixels[2][x+y*stride[2]]);
}
logtrace(LogTransform,"*\n");
}
#endif
} | 0 |
rawstudio | 983bda1f0fa5fa86884381208274198a620f006e | NOT_APPLICABLE | NOT_APPLICABLE | void CLASS phase_one_correct()
{
unsigned entries, tag, data, save, col, row, type;
int len, i, j, k, cip, val[4], dev[4], sum, max;
int head[9], diff, mindiff=INT_MAX, off_412=0;
static const signed char dir[12][2] =
{ {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0},
{-2,-2}, {-2,2}, {2,-2}, {2,2} };
float poly[8], num, cfrac, frac, mult[2], *yval[2];
ushort *xval[2];
if (half_size || !meta_length) return;
dcraw_message (DCRAW_VERBOSE,_("Phase One correction...\n"));
fseek (ifp, meta_offset, SEEK_SET);
order = get2();
fseek (ifp, 6, SEEK_CUR);
fseek (ifp, meta_offset+get4(), SEEK_SET);
entries = get4(); get4();
while (entries--) {
tag = get4();
len = get4();
data = get4();
save = ftell(ifp);
fseek (ifp, meta_offset+data, SEEK_SET);
if (tag == 0x419) { /* Polynomial curve */
for (get4(), i=0; i < 8; i++)
poly[i] = getreal(11);
poly[3] += (ph1.tag_210 - poly[7]) * poly[6] + 1;
for (i=0; i < 0x10000; i++) {
num = (poly[5]*i + poly[3])*i + poly[1];
curve[i] = LIM(num,0,65535);
} goto apply; /* apply to right half */
} else if (tag == 0x41a) { /* Polynomial curve */
for (i=0; i < 4; i++)
poly[i] = getreal(11);
for (i=0; i < 0x10000; i++) {
for (num=0, j=4; j--; )
num = num * i + poly[j];
curve[i] = LIM(num+i,0,65535);
} apply: /* apply to whole image */
for (row=0; row < height; row++)
for (col = (tag & 1)*ph1.split_col; col < width; col++)
BAYER(row,col) = curve[BAYER(row,col)];
} else if (tag == 0x400) { /* Sensor defects */
while ((len -= 8) >= 0) {
col = get2() - left_margin;
row = get2() - top_margin;
type = get2(); get2();
if (col >= width) continue;
if (type == 131) /* Bad column */
for (row=0; row < height; row++)
if (FC(row,col) == 1) {
for (sum=i=0; i < 4; i++)
sum += val[i] = bayer (row+dir[i][0], col+dir[i][1]);
for (max=i=0; i < 4; i++) {
dev[i] = abs((val[i] << 2) - sum);
if (dev[max] < dev[i]) max = i;
}
BAYER(row,col) = (sum - val[max])/3.0 + 0.5;
} else {
for (sum=0, i=8; i < 12; i++)
sum += bayer (row+dir[i][0], col+dir[i][1]);
BAYER(row,col) = 0.5 + sum * 0.0732233 +
(bayer(row,col-2) + bayer(row,col+2)) * 0.3535534;
}
else if (type == 129) { /* Bad pixel */
if (row >= height) continue;
j = (FC(row,col) != 1) * 4;
for (sum=0, i=j; i < j+8; i++)
sum += bayer (row+dir[i][0], col+dir[i][1]);
BAYER(row,col) = (sum + 4) >> 3;
}
}
} else if (tag == 0x401) { /* All-color flat fields */
phase_one_flat_field (1, 2);
} else if (tag == 0x416 || tag == 0x410) {
phase_one_flat_field (0, 2);
} else if (tag == 0x40b) { /* Red+blue flat field */
phase_one_flat_field (0, 4);
} else if (tag == 0x412) {
fseek (ifp, 36, SEEK_CUR);
diff = abs (get2() - ph1.tag_21a);
if (mindiff > diff) {
mindiff = diff;
off_412 = ftell(ifp) - 38;
}
}
fseek (ifp, save, SEEK_SET);
}
if (off_412) {
fseek (ifp, off_412, SEEK_SET);
for (i=0; i < 9; i++) head[i] = get4() & 0x7fff;
yval[0] = (float *) calloc (head[1]*head[3] + head[2]*head[4], 6);
merror (yval[0], "phase_one_correct()");
yval[1] = (float *) (yval[0] + head[1]*head[3]);
xval[0] = (ushort *) (yval[1] + head[2]*head[4]);
xval[1] = (ushort *) (xval[0] + head[1]*head[3]);
get2();
for (i=0; i < 2; i++)
for (j=0; j < head[i+1]*head[i+3]; j++)
yval[i][j] = getreal(11);
for (i=0; i < 2; i++)
for (j=0; j < head[i+1]*head[i+3]; j++)
xval[i][j] = get2();
for (row=0; row < height; row++)
for (col=0; col < width; col++) {
cfrac = (float) col * head[3] / raw_width;
cfrac -= cip = cfrac;
num = BAYER(row,col) * 0.5;
for (i=cip; i < cip+2; i++) {
for (k=j=0; j < head[1]; j++)
if (num < xval[0][k = head[1]*i+j]) break;
frac = (j == 0 || j == head[1]) ? 0 :
(xval[0][k] - num) / (xval[0][k] - xval[0][k-1]);
mult[i-cip] = yval[0][k-1] * frac + yval[0][k] * (1-frac);
}
i = ((mult[0] * (1-cfrac) + mult[1] * cfrac)
* (row + top_margin) + num) * 2;
BAYER(row,col) = LIM(i,0,65535);
}
free (yval[0]);
}
}
| 0 |
savannah | e3058617f384cb6709f3878f753fa17aca9e3a30 | CVE-2015-9290 | CWE-125 | T1_Get_Private_Dict( T1_Parser parser,
PSAux_Service psaux )
{
FT_Stream stream = parser->stream;
FT_Memory memory = parser->root.memory;
FT_Error error = FT_Err_Ok;
FT_ULong size;
if ( parser->in_pfb )
{
/* in the case of the PFB format, the private dictionary can be */
/* made of several segments. We thus first read the number of */
/* segments to compute the total size of the private dictionary */
/* then re-read them into memory. */
FT_ULong start_pos = FT_STREAM_POS();
FT_UShort tag;
parser->private_len = 0;
for (;;)
{
error = read_pfb_tag( stream, &tag, &size );
if ( error )
goto Fail;
if ( tag != 0x8002U )
break;
parser->private_len += size;
if ( FT_STREAM_SKIP( size ) )
goto Fail;
}
/* Check that we have a private dictionary there */
/* and allocate private dictionary buffer */
if ( parser->private_len == 0 )
{
FT_ERROR(( "T1_Get_Private_Dict:"
" invalid private dictionary section\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
if ( FT_STREAM_SEEK( start_pos ) ||
FT_ALLOC( parser->private_dict, parser->private_len ) )
goto Fail;
parser->private_len = 0;
for (;;)
{
error = read_pfb_tag( stream, &tag, &size );
if ( error || tag != 0x8002U )
{
error = FT_Err_Ok;
break;
}
if ( FT_STREAM_READ( parser->private_dict + parser->private_len,
size ) )
goto Fail;
parser->private_len += size;
}
}
else
{
/* We have already `loaded' the whole PFA font file into memory; */
/* if this is a memory resource, allocate a new block to hold */
/* the private dict. Otherwise, simply overwrite into the base */
/* dictionary block in the heap. */
/* first of all, look at the `eexec' keyword */
FT_Byte* cur = parser->base_dict;
FT_Byte* limit = cur + parser->base_len;
FT_Byte c;
FT_Pointer pos_lf;
FT_Bool test_cr;
Again:
for (;;)
{
c = cur[0];
if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */
/* whitespace + 4 chars */
{
if ( cur[1] == 'e' &&
cur[2] == 'x' &&
cur[3] == 'e' &&
cur[4] == 'c' )
break;
}
cur++;
if ( cur >= limit )
{
FT_ERROR(( "T1_Get_Private_Dict:"
" could not find `eexec' keyword\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
}
/* check whether `eexec' was real -- it could be in a comment */
/* or string (as e.g. in u003043t.gsf from ghostscript) */
parser->root.cursor = parser->base_dict;
/* set limit to `eexec' + whitespace + 4 characters */
parser->root.limit = cur + 10;
cur = parser->root.cursor;
limit = parser->root.limit;
while ( cur < limit )
{
if ( *cur == 'e' && ft_strncmp( (char*)cur, "eexec", 5 ) == 0 )
goto Found;
T1_Skip_PS_Token( parser );
if ( parser->root.error )
break;
T1_Skip_Spaces ( parser );
cur = parser->root.cursor;
}
/* we haven't found the correct `eexec'; go back and continue */
/* searching */
cur = limit;
limit = parser->base_dict + parser->base_len;
goto Again;
/* now determine where to write the _encrypted_ binary private */
/* According to the Type 1 spec, the first cipher byte must not be */
/* an ASCII whitespace character code (blank, tab, carriage return */
/* or line feed). We have seen Type 1 fonts with two line feed */
/* characters... So skip now all whitespace character codes. */
/* */
/* On the other hand, Adobe's Type 1 parser handles fonts just */
/* fine that are violating this limitation, so we add a heuristic */
/* test to stop at \r only if it is not used for EOL. */
pos_lf = ft_memchr( cur, '\n', (size_t)( limit - cur ) );
test_cr = FT_BOOL( !pos_lf ||
pos_lf > ft_memchr( cur,
'\r',
(size_t)( limit - cur ) ) );
while ( cur < limit &&
( *cur == ' ' ||
*cur == '\t' ||
(test_cr && *cur == '\r' ) ||
*cur == '\n' ) )
++cur;
if ( cur >= limit )
{
FT_ERROR(( "T1_Get_Private_Dict:"
" `eexec' not properly terminated\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
size = parser->base_len - (FT_ULong)( cur - parser->base_dict );
if ( parser->in_memory )
{
/* note that we allocate one more byte to put a terminating `0' */
if ( FT_ALLOC( parser->private_dict, size + 1 ) )
goto Fail;
parser->private_len = size;
}
else
{
parser->single_block = 1;
parser->private_dict = parser->base_dict;
parser->private_len = size;
parser->base_dict = NULL;
parser->base_len = 0;
}
/* now determine whether the private dictionary is encoded in binary */
/* or hexadecimal ASCII format -- decode it accordingly */
/* we need to access the next 4 bytes (after the final whitespace */
/* following the `eexec' keyword); if they all are hexadecimal */
/* digits, then we have a case of ASCII storage */
if ( cur + 3 < limit &&
ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) )
{
/* ASCII hexadecimal encoding */
FT_ULong len;
parser->root.cursor = cur;
(void)psaux->ps_parser_funcs->to_bytes( &parser->root,
parser->private_dict,
parser->private_len,
&len,
0 );
parser->private_len = len;
/* put a safeguard */
parser->private_dict[len] = '\0';
}
else
/* binary encoding -- copy the private dict */
FT_MEM_MOVE( parser->private_dict, cur, size );
}
/* we now decrypt the encoded binary private dictionary */
psaux->t1_decrypt( parser->private_dict, parser->private_len, 55665U );
if ( parser->private_len < 4 )
{
FT_ERROR(( "T1_Get_Private_Dict:"
" invalid private dictionary section\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* replace the four random bytes at the beginning with whitespace */
parser->private_dict[0] = ' ';
parser->private_dict[1] = ' ';
parser->private_dict[2] = ' ';
parser->private_dict[3] = ' ';
parser->root.base = parser->private_dict;
parser->root.cursor = parser->private_dict;
parser->root.limit = parser->root.cursor + parser->private_len;
Fail:
Exit:
return error;
}
| 1 |
asylo | a37fb6a0e7daf30134dbbf357c9a518a1026aa02 | CVE-2020-8937 | CWE-787 | int32_t *enc_untrusted_create_wait_queue() {
MessageWriter input;
MessageReader output;
input.Push<uint64_t>(sizeof(int32_t));
const auto status = NonSystemCallDispatcher(
::asylo::host_call::kLocalLifetimeAllocHandler, &input, &output);
CheckStatusAndParamCount(status, output, "enc_untrusted_create_wait_queue",
2);
int32_t *queue = reinterpret_cast<int32_t *>(output.next<uintptr_t>());
int klinux_errno = output.next<int>();
if (queue == nullptr) {
errno = FromkLinuxErrorNumber(klinux_errno);
}
enc_untrusted_disable_waiting(queue);
return queue;
} | 1 |
Chrome | e89cfcb9090e8c98129ae9160c513f504db74599 | NOT_APPLICABLE | NOT_APPLICABLE | BrowserViewLayout* BrowserView::GetBrowserViewLayout() const {
return static_cast<BrowserViewLayout*>(GetLayoutManager());
}
| 0 |
Android | 65c49d5b382de4085ee5668732bcb0f6ecaf7148 | NOT_APPLICABLE | NOT_APPLICABLE | BlockEntry::Kind BlockGroup::GetKind() const { return kBlockGroup; }
| 0 |
Chrome | 11a4cc4a6d6e665d9a118fada4b7c658d6f70d95 | NOT_APPLICABLE | NOT_APPLICABLE | bool RenderLayerScrollableArea::hitTestOverflowControls(HitTestResult& result, const IntPoint& localPoint)
{
if (!hasScrollbar() && !box().canResize())
return false;
IntRect resizeControlRect;
if (box().style()->resize() != RESIZE_NONE) {
resizeControlRect = resizerCornerRect(box().pixelSnappedBorderBoxRect(), ResizerForPointer);
if (resizeControlRect.contains(localPoint))
return true;
}
int resizeControlSize = max(resizeControlRect.height(), 0);
if (m_vBar && m_vBar->shouldParticipateInHitTesting()) {
LayoutRect vBarRect(verticalScrollbarStart(0, box().width()),
box().borderTop(),
m_vBar->width(),
box().height() - (box().borderTop() + box().borderBottom()) - (m_hBar ? m_hBar->height() : resizeControlSize));
if (vBarRect.contains(localPoint)) {
result.setScrollbar(m_vBar.get());
return true;
}
}
resizeControlSize = max(resizeControlRect.width(), 0);
if (m_hBar && m_hBar->shouldParticipateInHitTesting()) {
LayoutRect hBarRect(horizontalScrollbarStart(0),
box().height() - box().borderBottom() - m_hBar->height(),
box().width() - (box().borderLeft() + box().borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize),
m_hBar->height());
if (hBarRect.contains(localPoint)) {
result.setScrollbar(m_hBar.get());
return true;
}
}
return false;
}
| 0 |
redcarpet | e5a10516d07114d582d13b9125b733008c61c242 | NOT_APPLICABLE | NOT_APPLICABLE | add_footnote_ref(struct footnote_list *list, struct footnote_ref *ref)
{
struct footnote_item *item = calloc(1, sizeof(struct footnote_item));
if (!item)
return 0;
item->ref = ref;
if (list->head == NULL) {
list->head = list->tail = item;
} else {
list->tail->next = item;
list->tail = item;
}
list->count++;
return 1;
} | 0 |
guile | 245608911698adb3472803856019bdd5670b6614 | NOT_APPLICABLE | NOT_APPLICABLE | scm_i_relativize_path (SCM path, SCM in_path)
{
char *str, *canon;
SCM scanon;
str = scm_to_locale_string (path);
canon = canonicalize_file_name (str);
free (str);
if (!canon)
return SCM_BOOL_F;
scanon = scm_take_locale_string (canon);
for (; scm_is_pair (in_path); in_path = scm_cdr (in_path))
{
SCM dir = scm_car (in_path);
size_t len = scm_c_string_length (dir);
/* When DIR is empty, it means "current working directory". We
could set DIR to (getcwd) in that case, but then the
canonicalization would depend on the current directory, which
is not what we want in the context of `compile-file', for
instance. */
if (len > 0
&& scm_is_true (scm_string_prefix_p (dir, scanon,
SCM_UNDEFINED, SCM_UNDEFINED,
SCM_UNDEFINED, SCM_UNDEFINED)))
{
/* DIR either has a trailing delimiter or doesn't. SCANON
will be delimited by single delimiters. When DIR does not
have a trailing delimiter, add one to the length to strip
off the delimiter within SCANON. */
if (!is_file_name_separator (scm_c_string_ref (dir, len - 1)))
len++;
if (scm_c_string_length (scanon) > len)
return scm_substring (scanon, scm_from_size_t (len), SCM_UNDEFINED);
else
return SCM_BOOL_F;
}
}
return SCM_BOOL_F;
} | 0 |
linux | 854e8bb1aa06c578c2c9145fa6bfe3680ef63b23 | NOT_APPLICABLE | NOT_APPLICABLE | static void svm_set_dr6(struct kvm_vcpu *vcpu, unsigned long value)
{
struct vcpu_svm *svm = to_svm(vcpu);
svm->vmcb->save.dr6 = value;
mark_dirty(svm->vmcb, VMCB_DR);
}
| 0 |
tcpdump | e6511cc1a950fe1566b2236329d6b4bd0826cc7a | CVE-2017-13054 | CWE-125 | lldp_private_8023_print(netdissect_options *ndo,
const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_8023_subtype_values, "unknown", subtype),
subtype));
switch (subtype) {
case LLDP_PRIVATE_8023_SUBTYPE_MACPHY:
if (tlv_len < 9) {
return hexdump;
}
ND_PRINT((ndo, "\n\t autonegotiation [%s] (0x%02x)",
bittok2str(lldp_8023_autonegotiation_values, "none", *(tptr+4)),
*(tptr + 4)));
ND_PRINT((ndo, "\n\t PMD autoneg capability [%s] (0x%04x)",
bittok2str(lldp_pmd_capability_values,"unknown", EXTRACT_16BITS(tptr+5)),
EXTRACT_16BITS(tptr + 5)));
ND_PRINT((ndo, "\n\t MAU type %s (0x%04x)",
tok2str(lldp_mau_types_values, "unknown", EXTRACT_16BITS(tptr+7)),
EXTRACT_16BITS(tptr + 7)));
break;
case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER:
if (tlv_len < 7) {
return hexdump;
}
ND_PRINT((ndo, "\n\t MDI power support [%s], power pair %s, power class %s",
bittok2str(lldp_mdi_values, "none", *(tptr+4)),
tok2str(lldp_mdi_power_pairs_values, "unknown", *(tptr+5)),
tok2str(lldp_mdi_power_class_values, "unknown", *(tptr + 6))));
break;
case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR:
if (tlv_len < 9) {
return hexdump;
}
ND_PRINT((ndo, "\n\t aggregation status [%s], aggregation port ID %u",
bittok2str(lldp_aggregation_values, "none", *(tptr+4)),
EXTRACT_32BITS(tptr + 5)));
break;
case LLDP_PRIVATE_8023_SUBTYPE_MTU:
ND_PRINT((ndo, "\n\t MTU size %u", EXTRACT_16BITS(tptr + 4)));
break;
default:
hexdump = TRUE;
break;
}
return hexdump;
}
| 1 |
mruby | 55edae0226409de25e59922807cb09acb45731a2 | NOT_APPLICABLE | NOT_APPLICABLE | mrb_obj_hash(mrb_state *mrb, mrb_value self)
{
return mrb_fixnum_value(mrb_obj_id(self));
}
| 0 |
savannah | af8346172a7b573715134f7a51e6c5c60fa7f2ab | NOT_APPLICABLE | NOT_APPLICABLE | _bdf_add_property( bdf_font_t* font,
char* name,
char* value,
unsigned long lineno )
{
size_t propid;
hashnode hn;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
FT_Error error = FT_Err_Ok;
FT_UNUSED( lineno ); /* only used in debug mode */
/* First, check whether the property already exists in the font. */
if ( ( hn = hash_lookup( name, (hashtable *)font->internal ) ) != 0 )
{
/* The property already exists in the font, so simply replace */
/* the value of the property with the current value. */
fp = font->props + hn->data;
switch ( fp->format )
{
case BDF_ATOM:
/* Delete the current atom if it exists. */
FT_FREE( fp->value.atom );
if ( value && value[0] != 0 )
{
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
}
break;
case BDF_INTEGER:
fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
default:
;
}
goto Exit;
}
/* See whether this property type exists yet or not. */
/* If not, create it. */
hn = hash_lookup( name, &(font->proptbl) );
if ( hn == 0 )
{
error = bdf_create_property( name, BDF_ATOM, font );
if ( error )
goto Exit;
hn = hash_lookup( name, &(font->proptbl) );
}
/* Allocate another property if this is overflow. */
if ( font->props_used == font->props_size )
{
if ( font->props_size == 0 )
{
if ( FT_NEW_ARRAY( font->props, 1 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->props,
font->props_size,
font->props_size + 1 ) )
goto Exit;
}
fp = font->props + font->props_size;
FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) );
font->props_size++;
}
propid = hn->data;
if ( propid >= _num_bdf_properties )
prop = font->user_props + ( propid - _num_bdf_properties );
else
prop = (bdf_property_t*)_bdf_properties + propid;
fp = font->props + font->props_used;
fp->name = prop->name;
fp->format = prop->format;
fp->builtin = prop->builtin;
switch ( prop->format )
{
case BDF_ATOM:
fp->value.atom = 0;
if ( value != 0 && value[0] )
{
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
}
break;
case BDF_INTEGER:
fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
}
/* If the property happens to be a comment, then it doesn't need */
/* to be added to the internal hash table. */
if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
{
/* Add the property to the font property table. */
error = hash_insert( fp->name,
font->props_used,
(hashtable *)font->internal,
memory );
if ( error )
goto Exit;
}
font->props_used++;
/* Some special cases need to be handled here. The DEFAULT_CHAR */
/* property needs to be located if it exists in the property list, the */
/* FONT_ASCENT and FONT_DESCENT need to be assigned if they are */
/* present, and the SPACING property should override the default */
/* spacing. */
if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_char = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
font->font_descent = fp->value.l;
else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
{
if ( !fp->value.atom )
{
FT_ERROR(( "_bdf_add_property: " ERRMSG8, lineno, "SPACING" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( fp->value.atom[0] == 'p' || fp->value.atom[0] == 'P' )
font->spacing = BDF_PROPORTIONAL;
else if ( fp->value.atom[0] == 'm' || fp->value.atom[0] == 'M' )
font->spacing = BDF_MONOWIDTH;
else if ( fp->value.atom[0] == 'c' || fp->value.atom[0] == 'C' )
font->spacing = BDF_CHARCELL;
}
Exit:
return error;
}
| 0 |
linux | b5b515445f4f5a905c5dd27e6e682868ccd6c09d | NOT_APPLICABLE | NOT_APPLICABLE | static irqreturn_t pmcraid_isr_msix(int irq, void *dev_id)
{
struct pmcraid_isr_param *hrrq_vector;
struct pmcraid_instance *pinstance;
unsigned long lock_flags;
u32 intrs_val;
int hrrq_id;
hrrq_vector = (struct pmcraid_isr_param *)dev_id;
hrrq_id = hrrq_vector->hrrq_id;
pinstance = hrrq_vector->drv_inst;
if (!hrrq_id) {
/* Read the interrupt */
intrs_val = pmcraid_read_interrupts(pinstance);
if (intrs_val &&
((ioread32(pinstance->int_regs.host_ioa_interrupt_reg)
& DOORBELL_INTR_MSIX_CLR) == 0)) {
/* Any error interrupts including unit_check,
* initiate IOA reset.In case of unit check indicate
* to reset_sequence that IOA unit checked and prepare
* for a dump during reset sequence
*/
if (intrs_val & PMCRAID_ERROR_INTERRUPTS) {
if (intrs_val & INTRS_IOA_UNIT_CHECK)
pinstance->ioa_unit_check = 1;
pmcraid_err("ISR: error interrupts: %x \
initiating reset\n", intrs_val);
spin_lock_irqsave(pinstance->host->host_lock,
lock_flags);
pmcraid_initiate_reset(pinstance);
spin_unlock_irqrestore(
pinstance->host->host_lock,
lock_flags);
}
/* If interrupt was as part of the ioa initialization,
* clear it. Delete the timer and wakeup the
* reset engine to proceed with reset sequence
*/
if (intrs_val & INTRS_TRANSITION_TO_OPERATIONAL)
pmcraid_clr_trans_op(pinstance);
/* Clear the interrupt register by writing
* to host to ioa doorbell. Once done
* FW will clear the interrupt.
*/
iowrite32(DOORBELL_INTR_MSIX_CLR,
pinstance->int_regs.host_ioa_interrupt_reg);
ioread32(pinstance->int_regs.host_ioa_interrupt_reg);
}
}
tasklet_schedule(&(pinstance->isr_tasklet[hrrq_id]));
return IRQ_HANDLED;
}
| 0 |
w3m | d43527cfa0dbb3ccefec4a6f7b32c1434739aa29 | NOT_APPLICABLE | NOT_APPLICABLE | Strcat_charp_n(Str x, const char *y, int n)
{
int newlen;
STR_LENGTH_CHECK(x);
if (y == NULL)
return;
newlen = x->length + n + 1;
if (x->area_size < newlen) {
char *old = x->ptr;
newlen = newlen * 3 / 2;
x->ptr = GC_MALLOC_ATOMIC(newlen);
x->area_size = newlen;
bcopy((void *)old, (void *)x->ptr, x->length);
GC_free(old);
}
bcopy((void *)y, (void *)&x->ptr[x->length], n);
x->length += n;
x->ptr[x->length] = '\0';
}
| 0 |
rpm | 8e847d52c811e9a57239e18672d40f781e0ec48e | NOT_APPLICABLE | NOT_APPLICABLE | static rpmRC headerSigVerify(rpmKeyring keyring, rpmVSFlags vsflags,
int il, int dl, int ril, int rdl,
entryInfo pe, unsigned char * dataStart,
char **buf)
{
size_t siglen = 0;
rpmRC rc = RPMRC_FAIL;
pgpDigParams sig = NULL;
struct rpmtd_s sigtd;
struct entryInfo_s info, einfo;
struct sigtInfo_s sinfo;
rpmtdReset(&sigtd);
memset(&info, 0, sizeof(info));
memset(&einfo, 0, sizeof(einfo));
/* Find a header-only digest/signature tag. */
for (int i = ril; i < il; i++) {
if (headerVerifyInfo(1, dl, pe+i, &einfo, 0) != -1) {
rasprintf(buf,
_("tag[%d]: BAD, tag %d type %d offset %d count %d"),
i, einfo.tag, einfo.type,
einfo.offset, einfo.count);
goto exit;
}
switch (einfo.tag) {
case RPMTAG_SHA1HEADER: {
size_t blen = 0;
unsigned const char * b;
if (vsflags & RPMVSF_NOSHA1HEADER)
break;
for (b = dataStart + einfo.offset; *b != '\0'; b++) {
if (strchr("0123456789abcdefABCDEF", *b) == NULL)
break;
blen++;
}
if (einfo.type != RPM_STRING_TYPE || *b != '\0' || blen != 40)
{
rasprintf(buf, _("hdr SHA1: BAD, not hex"));
goto exit;
}
if (info.tag == 0) {
info = einfo; /* structure assignment */
siglen = blen + 1;
}
} break;
case RPMTAG_RSAHEADER:
if (vsflags & RPMVSF_NORSAHEADER)
break;
if (einfo.type != RPM_BIN_TYPE) {
rasprintf(buf, _("hdr RSA: BAD, not binary"));
goto exit;
}
info = einfo; /* structure assignment */
siglen = info.count;
break;
case RPMTAG_DSAHEADER:
if (vsflags & RPMVSF_NODSAHEADER)
break;
if (einfo.type != RPM_BIN_TYPE) {
rasprintf(buf, _("hdr DSA: BAD, not binary"));
goto exit;
}
info = einfo; /* structure assignment */
siglen = info.count;
break;
default:
break;
}
}
/* No header-only digest/signature found, get outta here */
if (info.tag == 0) {
rc = RPMRC_NOTFOUND;
goto exit;
}
sigtd.tag = info.tag;
sigtd.type = info.type;
sigtd.count = info.count;
sigtd.data = memcpy(xmalloc(siglen), dataStart + info.offset, siglen);
sigtd.flags = RPMTD_ALLOCED;
if (rpmSigInfoParse(&sigtd, "header", &sinfo, &sig, buf))
goto exit;
if (sinfo.hashalgo) {
DIGEST_CTX ctx = rpmDigestInit(sinfo.hashalgo, RPMDIGEST_NONE);
int32_t ildl[2] = { htonl(ril), htonl(rdl) };
rpmDigestUpdate(ctx, rpm_header_magic, sizeof(rpm_header_magic));
rpmDigestUpdate(ctx, ildl, sizeof(ildl));
rpmDigestUpdate(ctx, pe, (ril * sizeof(*pe)));
rpmDigestUpdate(ctx, dataStart, rdl);
rc = rpmVerifySignature(keyring, &sigtd, sig, ctx, buf);
rpmDigestFinal(ctx, NULL, NULL, 0);
}
exit:
rpmtdFreeData(&sigtd);
pgpDigParamsFree(sig);
return rc;
} | 0 |
tensorflow | f57315566d7094f322b784947093406c2aea0d7d | NOT_APPLICABLE | NOT_APPLICABLE | explicit MapPeekOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} | 0 |
linux | 9590232bb4f4cc824f3425a6e1349afbe6d6d2b7 | NOT_APPLICABLE | NOT_APPLICABLE | void ion_pages_sync_for_device(struct device *dev, struct page *page,
size_t size, enum dma_data_direction dir)
{
struct scatterlist sg;
sg_init_table(&sg, 1);
sg_set_page(&sg, page, size, 0);
/*
* This is not correct - sg_dma_address needs a dma_addr_t that is valid
* for the targeted device, but this works on the currently targeted
* hardware.
*/
sg_dma_address(&sg) = page_to_phys(page);
dma_sync_sg_for_device(dev, &sg, 1, dir);
}
| 0 |
xserver | 446ff2d3177087b8173fa779fa5b77a2a128988b | NOT_APPLICABLE | NOT_APPLICABLE | _CheckSetSections(XkbGeometryPtr geom,
xkbSetGeometryReq * req, char **wire_inout, ClientPtr client)
{
Status status;
register int s;
char *wire;
xkbSectionWireDesc *sWire;
XkbSectionPtr section;
wire = *wire_inout;
if (req->nSections < 1)
return Success;
sWire = (xkbSectionWireDesc *) wire;
for (s = 0; s < req->nSections; s++) {
register int r;
xkbRowWireDesc *rWire;
if (client->swapped) {
swapl(&sWire->name);
swaps(&sWire->top);
swaps(&sWire->left);
swaps(&sWire->width);
swaps(&sWire->height);
swaps(&sWire->angle);
}
CHK_ATOM_ONLY(sWire->name);
section = XkbAddGeomSection(geom, sWire->name, sWire->nRows,
sWire->nDoodads, sWire->nOverlays);
if (!section)
return BadAlloc;
section->priority = sWire->priority;
section->top = sWire->top;
section->left = sWire->left;
section->width = sWire->width;
section->height = sWire->height;
section->angle = sWire->angle;
rWire = (xkbRowWireDesc *) &sWire[1];
for (r = 0; r < sWire->nRows; r++) {
register int k;
XkbRowPtr row;
xkbKeyWireDesc *kWire;
if (client->swapped) {
swaps(&rWire->top);
swaps(&rWire->left);
}
row = XkbAddGeomRow(section, rWire->nKeys);
if (!row)
return BadAlloc;
row->top = rWire->top;
row->left = rWire->left;
row->vertical = rWire->vertical;
kWire = (xkbKeyWireDesc *) &rWire[1];
for (k = 0; k < rWire->nKeys; k++) {
XkbKeyPtr key;
key = XkbAddGeomKey(row);
if (!key)
return BadAlloc;
memcpy(key->name.name, kWire[k].name, XkbKeyNameLength);
key->gap = kWire[k].gap;
key->shape_ndx = kWire[k].shapeNdx;
key->color_ndx = kWire[k].colorNdx;
if (key->shape_ndx >= geom->num_shapes) {
client->errorValue = _XkbErrCode3(0x10, key->shape_ndx,
geom->num_shapes);
return BadMatch;
}
if (key->color_ndx >= geom->num_colors) {
client->errorValue = _XkbErrCode3(0x11, key->color_ndx,
geom->num_colors);
return BadMatch;
}
}
rWire = (xkbRowWireDesc *) &kWire[rWire->nKeys];
}
wire = (char *) rWire;
if (sWire->nDoodads > 0) {
register int d;
for (d = 0; d < sWire->nDoodads; d++) {
status = _CheckSetDoodad(&wire, geom, section, client);
if (status != Success)
return status;
}
}
if (sWire->nOverlays > 0) {
register int o;
for (o = 0; o < sWire->nOverlays; o++) {
status = _CheckSetOverlay(&wire, geom, section, client);
if (status != Success)
return status;
}
}
sWire = (xkbSectionWireDesc *) wire;
}
wire = (char *) sWire;
*wire_inout = wire;
return Success;
} | 0 |
cpython | c3c9db89273fabc62ea1b48389d9a3000c1c03ae | NOT_APPLICABLE | NOT_APPLICABLE | string_rfind(PyStringObject *self, PyObject *args)
{
Py_ssize_t result = string_find_internal(self, args, -1);
if (result == -2)
return NULL;
return PyInt_FromSsize_t(result);
} | 0 |
httpd | 29afdd2550b3d30a8defece2b95ae81edcf66ac9 | CVE-2017-9798 | CWE-416 | AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd,
void *dummy,
const char *arg)
{
const char *endp = ap_strrchr_c(arg, '>');
const char *limited_methods;
void *tog = cmd->cmd->cmd_data;
apr_int64_t limited = 0;
apr_int64_t old_limited = cmd->limited;
const char *errmsg;
if (endp == NULL) {
return unclosed_directive(cmd);
}
limited_methods = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg);
if (!limited_methods[0]) {
return missing_container_arg(cmd);
}
while (limited_methods[0]) {
char *method = ap_getword_conf(cmd->temp_pool, &limited_methods);
int methnum;
/* check for builtin or module registered method number */
methnum = ap_method_number_of(method);
if (methnum == M_TRACE && !tog) {
return "TRACE cannot be controlled by <Limit>, see TraceEnable";
}
else if (methnum == M_INVALID) {
/* method has not been registered yet, but resource restriction
* is always checked before method handling, so register it.
*/
methnum = ap_method_register(cmd->pool,
apr_pstrdup(cmd->pool, method));
}
limited |= (AP_METHOD_BIT << methnum);
}
/* Killing two features with one function,
* if (tog == NULL) <Limit>, else <LimitExcept>
*/
limited = tog ? ~limited : limited;
if (!(old_limited & limited)) {
return apr_pstrcat(cmd->pool, cmd->cmd->name,
"> directive excludes all methods", NULL);
}
else if ((old_limited & limited) == old_limited) {
return apr_pstrcat(cmd->pool, cmd->cmd->name,
"> directive specifies methods already excluded",
NULL);
}
cmd->limited &= limited;
errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
cmd->limited = old_limited;
return errmsg;
}
| 1 |
media_tree | eca2d34b9d2ce70165a50510659838e28ca22742 | NOT_APPLICABLE | NOT_APPLICABLE | static int mb86a20s_i2c_writeregdata(struct mb86a20s_state *state,
u8 i2c_addr, struct regdata *rd, int size)
{
int i, rc;
for (i = 0; i < size; i++) {
rc = mb86a20s_i2c_writereg(state, i2c_addr, rd[i].reg,
rd[i].data);
if (rc < 0)
return rc;
}
return 0;
} | 0 |
linux | 42933c8aa14be1caa9eda41f65cde8a3a95d3e39 | NOT_APPLICABLE | NOT_APPLICABLE | static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
{
struct memstick_host *msh;
struct rtsx_usb_ms *host;
struct rtsx_ucr *ucr;
int err;
ucr = usb_get_intfdata(to_usb_interface(pdev->dev.parent));
if (!ucr)
return -ENXIO;
dev_dbg(&(pdev->dev),
"Realtek USB Memstick controller found\n");
msh = memstick_alloc_host(sizeof(*host), &pdev->dev);
if (!msh)
return -ENOMEM;
host = memstick_priv(msh);
host->ucr = ucr;
host->msh = msh;
host->pdev = pdev;
host->power_mode = MEMSTICK_POWER_OFF;
platform_set_drvdata(pdev, host);
mutex_init(&host->host_mutex);
INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req);
INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card);
msh->request = rtsx_usb_ms_request;
msh->set_param = rtsx_usb_ms_set_param;
msh->caps = MEMSTICK_CAP_PAR4;
pm_runtime_get_noresume(ms_dev(host));
pm_runtime_set_active(ms_dev(host));
pm_runtime_enable(ms_dev(host));
err = memstick_add_host(msh);
if (err)
goto err_out;
pm_runtime_put(ms_dev(host));
return 0;
err_out:
pm_runtime_disable(ms_dev(host));
pm_runtime_put_noidle(ms_dev(host));
memstick_free_host(msh);
return err;
} | 0 |
ImageMagick | 1bc1fd0ff8c555841c78829217ac81fa0598255d | CVE-2016-10071 | CWE-125 | static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image *image, *image2=NULL,
*rotated_image;
register Quantum *q;
unsigned int status;
MATHeader MATLAB_HDR;
size_t size;
size_t CellType;
QuantumInfo *quantum_info;
ImageInfo *clone_info;
int i;
ssize_t ldblk;
unsigned char *BImgBuff = NULL;
double MinVal, MaxVal;
unsigned z, z2;
unsigned Frames;
int logging;
int sample_size;
MagickOffsetType filepos=0x80;
BlobInfo *blob;
size_t one;
unsigned int (*ReadBlobXXXLong)(Image *image);
unsigned short (*ReadBlobXXXShort)(Image *image);
void (*ReadBlobDoublesXXX)(Image * image, size_t len, double *data);
void (*ReadBlobFloatsXXX)(Image * image, size_t len, float *data);
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
/*
Open image file.
*/
image = AcquireImage(image_info,exception);
status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read MATLAB image.
*/
clone_info=CloneImageInfo(image_info);
if(ReadBlob(image,124,(unsigned char *) &MATLAB_HDR.identific) != 124)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
MATLAB_HDR.Version = ReadBlobLSBShort(image);
if(ReadBlob(image,2,(unsigned char *) &MATLAB_HDR.EndianIndicator) != 2)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule()," Endian %c%c",
MATLAB_HDR.EndianIndicator[0],MATLAB_HDR.EndianIndicator[1]);
if (!strncmp(MATLAB_HDR.EndianIndicator, "IM", 2))
{
ReadBlobXXXLong = ReadBlobLSBLong;
ReadBlobXXXShort = ReadBlobLSBShort;
ReadBlobDoublesXXX = ReadBlobDoublesLSB;
ReadBlobFloatsXXX = ReadBlobFloatsLSB;
image->endian = LSBEndian;
}
else if (!strncmp(MATLAB_HDR.EndianIndicator, "MI", 2))
{
ReadBlobXXXLong = ReadBlobMSBLong;
ReadBlobXXXShort = ReadBlobMSBShort;
ReadBlobDoublesXXX = ReadBlobDoublesMSB;
ReadBlobFloatsXXX = ReadBlobFloatsMSB;
image->endian = MSBEndian;
}
else
goto MATLAB_KO; /* unsupported endian */
if (strncmp(MATLAB_HDR.identific, "MATLAB", 6))
MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader");
filepos = TellBlob(image);
while(!EOFBlob(image)) /* object parser loop */
{
Frames = 1;
(void) SeekBlob(image,filepos,SEEK_SET);
/* printf("pos=%X\n",TellBlob(image)); */
MATLAB_HDR.DataType = ReadBlobXXXLong(image);
if(EOFBlob(image)) break;
MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image);
if(EOFBlob(image)) break;
filepos += MATLAB_HDR.ObjectSize + 4 + 4;
image2 = image;
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if(MATLAB_HDR.DataType == miCOMPRESSED)
{
image2 = DecompressBlock(image,MATLAB_HDR.ObjectSize,clone_info,exception);
if(image2==NULL) continue;
MATLAB_HDR.DataType = ReadBlobXXXLong(image2); /* replace compressed object type. */
}
#endif
if(MATLAB_HDR.DataType!=miMATRIX) continue; /* skip another objects. */
MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2);
MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2);
MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2);
MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF;
MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF;
MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2);
if(image!=image2)
MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); /* ??? don't understand why ?? */
MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);
MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2);
MATLAB_HDR.SizeX = ReadBlobXXXLong(image2);
MATLAB_HDR.SizeY = ReadBlobXXXLong(image2);
switch(MATLAB_HDR.DimFlag)
{
case 8: z2=z=1; break; /* 2D matrix*/
case 12: z2=z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/
(void) ReadBlobXXXLong(image2);
if(z!=3) ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported");
break;
case 16: z2=z = ReadBlobXXXLong(image2); /* 4D matrix animation */
if(z!=3 && z!=1)
ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported");
Frames = ReadBlobXXXLong(image2);
break;
default: ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported");
}
MATLAB_HDR.Flag1 = ReadBlobXXXShort(image2);
MATLAB_HDR.NameFlag = ReadBlobXXXShort(image2);
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
"MATLAB_HDR.StructureClass %d",MATLAB_HDR.StructureClass);
if (MATLAB_HDR.StructureClass != mxCHAR_CLASS &&
MATLAB_HDR.StructureClass != mxSINGLE_CLASS && /* float + complex float */
MATLAB_HDR.StructureClass != mxDOUBLE_CLASS && /* double + complex double */
MATLAB_HDR.StructureClass != mxINT8_CLASS &&
MATLAB_HDR.StructureClass != mxUINT8_CLASS && /* uint8 + uint8 3D */
MATLAB_HDR.StructureClass != mxINT16_CLASS &&
MATLAB_HDR.StructureClass != mxUINT16_CLASS && /* uint16 + uint16 3D */
MATLAB_HDR.StructureClass != mxINT32_CLASS &&
MATLAB_HDR.StructureClass != mxUINT32_CLASS && /* uint32 + uint32 3D */
MATLAB_HDR.StructureClass != mxINT64_CLASS &&
MATLAB_HDR.StructureClass != mxUINT64_CLASS) /* uint64 + uint64 3D */
ThrowReaderException(CoderError,"UnsupportedCellTypeInTheMatrix");
switch (MATLAB_HDR.NameFlag)
{
case 0:
size = ReadBlobXXXLong(image2); /* Object name string size */
size = 4 * (ssize_t) ((size + 3 + 1) / 4);
(void) SeekBlob(image2, size, SEEK_CUR);
break;
case 1:
case 2:
case 3:
case 4:
(void) ReadBlob(image2, 4, (unsigned char *) &size); /* Object name string */
break;
default:
goto MATLAB_KO;
}
CellType = ReadBlobXXXLong(image2); /* Additional object type */
if (logging)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"MATLAB_HDR.CellType: %.20g",(double) CellType);
(void) ReadBlob(image2, 4, (unsigned char *) &size); /* data size */
NEXT_FRAME:
switch (CellType)
{
case miINT8:
case miUINT8:
sample_size = 8;
if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL)
image->depth = 1;
else
image->depth = 8; /* Byte type cell */
ldblk = (ssize_t) MATLAB_HDR.SizeX;
break;
case miINT16:
case miUINT16:
sample_size = 16;
image->depth = 16; /* Word type cell */
ldblk = (ssize_t) (2 * MATLAB_HDR.SizeX);
break;
case miINT32:
case miUINT32:
sample_size = 32;
image->depth = 32; /* Dword type cell */
ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);
break;
case miINT64:
case miUINT64:
sample_size = 64;
image->depth = 64; /* Qword type cell */
ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);
break;
case miSINGLE:
sample_size = 32;
image->depth = 32; /* double type cell */
(void) SetImageOption(clone_info,"quantum:format","floating-point");
if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
{ /* complex float type cell */
}
ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);
break;
case miDOUBLE:
sample_size = 64;
image->depth = 64; /* double type cell */
(void) SetImageOption(clone_info,"quantum:format","floating-point");
DisableMSCWarning(4127)
if (sizeof(double) != 8)
RestoreMSCWarning
ThrowReaderException(CoderError, "IncompatibleSizeOfDouble");
if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
{ /* complex double type cell */
}
ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);
break;
default:
ThrowReaderException(CoderError, "UnsupportedCellTypeInTheMatrix");
}
(void) sample_size;
image->columns = MATLAB_HDR.SizeX;
image->rows = MATLAB_HDR.SizeY;
quantum_info=AcquireQuantumInfo(clone_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
one=1;
image->colors = one << image->depth;
if (image->columns == 0 || image->rows == 0)
goto MATLAB_KO;
/* Image is gray when no complex flag is set and 2D Matrix */
if ((MATLAB_HDR.DimFlag == 8) &&
((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))
{
image->type=GrayscaleType;
SetImageColorspace(image,GRAYColorspace,exception);
}
/*
If ping is true, then only set image size and colors without
reading any image data.
*/
if (image_info->ping)
{
size_t temp = image->columns;
image->columns = image->rows;
image->rows = temp;
goto done_reading; /* !!!!!! BAD !!!! */
}
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
/* ----- Load raster data ----- */
BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(unsigned char)); /* Ldblk was set in the check phase */
if (BImgBuff == NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
MinVal = 0;
MaxVal = 0;
if (CellType==miDOUBLE || CellType==miSINGLE) /* Find Min and Max Values for floats */
{
CalcMinMax(image2, image_info->endian, MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &quantum_info->minimum, &quantum_info->maximum);
}
/* Main loop for reading all scanlines */
if(z==1) z=0; /* read grey scanlines */
/* else read color scanlines */
do
{
for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)
{
q=GetAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception);
if (q == (Quantum *) NULL)
{
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
" MAT set image pixels returns unexpected NULL on a row %u.", (unsigned)(MATLAB_HDR.SizeY-i-1));
goto done_reading; /* Skip image rotation, when cannot set image pixels */
}
if(ReadBlob(image2,ldblk,(unsigned char *)BImgBuff) != (ssize_t) ldblk)
{
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
" MAT cannot read scanrow %u from a file.", (unsigned)(MATLAB_HDR.SizeY-i-1));
goto ExitLoop;
}
if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL))
{
FixLogical((unsigned char *)BImgBuff,ldblk);
if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0)
{
ImportQuantumPixelsFailed:
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
" MAT failed to ImportQuantumPixels for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1));
break;
}
}
else
{
if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0)
goto ImportQuantumPixelsFailed;
if (z<=1 && /* fix only during a last pass z==0 || z==1 */
(CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64))
FixSignedValues(image,q,MATLAB_HDR.SizeX);
}
if (!SyncAuthenticPixels(image,exception))
{
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
" MAT failed to sync image pixels for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1));
goto ExitLoop;
}
}
} while(z-- >= 2);
ExitLoop:
/* Read complex part of numbers here */
if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
{ /* Find Min and Max Values for complex parts of floats */
CellType = ReadBlobXXXLong(image2); /* Additional object type */
i = ReadBlobXXXLong(image2); /* size of a complex part - toss away*/
if (CellType==miDOUBLE || CellType==miSINGLE)
{
CalcMinMax(image2, image_info->endian, MATLAB_HDR.SizeX, MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &MinVal, &MaxVal);
}
if (CellType==miDOUBLE)
for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)
{
ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff);
InsertComplexDoubleRow(image, (double *)BImgBuff, i, MinVal, MaxVal,
exception);
}
if (CellType==miSINGLE)
for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)
{
ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff);
InsertComplexFloatRow(image,(float *)BImgBuff,i,MinVal,MaxVal,
exception);
}
}
/* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! */
if ((MATLAB_HDR.DimFlag == 8) &&
((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0))
image->type=GrayscaleType;
if (image->depth == 1)
image->type=BilevelType;
if(image2==image)
image2 = NULL; /* Remove shadow copy to an image before rotation. */
/* Rotate image. */
rotated_image = RotateImage(image, 90.0, exception);
if (rotated_image != (Image *) NULL)
{
/* Remove page offsets added by RotateImage */
rotated_image->page.x=0;
rotated_image->page.y=0;
blob = rotated_image->blob;
rotated_image->blob = image->blob;
rotated_image->colors = image->colors;
image->blob = blob;
AppendImageToList(&image,rotated_image);
DeleteImageFromList(&image);
}
done_reading:
if(image2!=NULL)
if(image2!=image)
{
DeleteImageFromList(&image2);
if(clone_info)
{
if(clone_info->file)
{
fclose(clone_info->file);
clone_info->file = NULL;
(void) remove_utf8(clone_info->filename);
}
}
}
/* Allocate next image structure. */
AcquireNextImage(image_info,image,exception);
if (image->next == (Image *) NULL) break;
image=SyncNextImageInList(image);
image->columns=image->rows=0;
image->colors=0;
/* row scan buffer is no longer needed */
RelinquishMagickMemory(BImgBuff);
BImgBuff = NULL;
if(--Frames>0)
{
z = z2;
if(image2==NULL) image2 = image;
goto NEXT_FRAME;
}
if ((image2!=NULL) && (image2!=image)) /* Does shadow temporary decompressed image exist? */
{
/* CloseBlob(image2); */
DeleteImageFromList(&image2);
if(clone_info)
{
if(clone_info->file)
{
fclose(clone_info->file);
clone_info->file = NULL;
(void) remove_utf8(clone_info->filename);
}
}
}
}
clone_info=DestroyImageInfo(clone_info);
RelinquishMagickMemory(BImgBuff);
CloseBlob(image);
{
Image *p;
ssize_t scene=0;
/*
Rewind list, removing any empty images while rewinding.
*/
p=image;
image=NULL;
while (p != (Image *) NULL)
{
Image *tmp=p;
if ((p->rows == 0) || (p->columns == 0)) {
p=p->previous;
DeleteImageFromList(&tmp);
} else {
image=p;
p=p->previous;
}
}
/*
Fix scene numbers
*/
for (p=image; p != (Image *) NULL; p=p->next)
p->scene=scene++;
}
if(clone_info != NULL) /* cleanup garbage file from compression */
{
if(clone_info->file)
{
fclose(clone_info->file);
clone_info->file = NULL;
(void) remove_utf8(clone_info->filename);
}
DestroyImageInfo(clone_info);
clone_info = NULL;
}
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");
if(image==NULL)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
return (image);
} | 1 |
envoy | 2c60632d41555ec8b3d9ef5246242be637a2db0f | NOT_APPLICABLE | NOT_APPLICABLE | static inline MessageType anyConvert(const ProtobufWkt::Any& message) {
return MessageUtil::anyConvert<MessageType>(message);
} | 0 |
linux | 09ccfd238e5a0e670d8178cf50180ea81ae09ae1 | NOT_APPLICABLE | NOT_APPLICABLE | static void __exit pptp_exit_module(void)
{
unregister_pppox_proto(PX_PROTO_PPTP);
proto_unregister(&pptp_sk_proto);
gre_del_protocol(&gre_pptp_protocol, GREPROTO_PPTP);
vfree(callid_sock);
}
| 0 |
xbmc | 80c8138c09598e88b4ddb6dbb279fa193bbb3237 | NOT_APPLICABLE | NOT_APPLICABLE | bool CPlayListPLS::Load(const std::string &strFile)
{
//read it from the file
std::string strFileName(strFile);
m_strPlayListName = URIUtils::GetFileName(strFileName);
Clear();
bool bShoutCast = false;
if( StringUtils::StartsWithNoCase(strFileName, "shout://") )
{
strFileName.replace(0, 8, "http://");
m_strBasePath = "";
bShoutCast = true;
}
else
URIUtils::GetParentPath(strFileName, m_strBasePath);
CFile file;
if (!file.Open(strFileName) )
{
file.Close();
return false;
}
if (file.GetLength() > 1024*1024)
{
CLog::Log(LOGWARNING, "{} - File is larger than 1 MB, most likely not a playlist",
__FUNCTION__);
return false;
}
char szLine[4096];
std::string strLine;
// run through looking for the [playlist] marker.
// if we find another http stream, then load it.
while (true)
{
if ( !file.ReadString(szLine, sizeof(szLine) ) )
{
file.Close();
return size() > 0;
}
strLine = szLine;
StringUtils::Trim(strLine);
if(StringUtils::EqualsNoCase(strLine, START_PLAYLIST_MARKER))
break;
// if there is something else before playlist marker, this isn't a pls file
if(!strLine.empty())
return false;
}
bool bFailed = false;
while (file.ReadString(szLine, sizeof(szLine) ) )
{
strLine = szLine;
StringUtils::RemoveCRLF(strLine);
size_t iPosEqual = strLine.find('=');
if (iPosEqual != std::string::npos)
{
std::string strLeft = strLine.substr(0, iPosEqual);
iPosEqual++;
std::string strValue = strLine.substr(iPosEqual);
StringUtils::ToLower(strLeft);
StringUtils::TrimLeft(strLeft);
if (strLeft == "numberofentries")
{
m_vecItems.reserve(atoi(strValue.c_str()));
}
else if (StringUtils::StartsWith(strLeft, "file"))
{
std::vector <int>::size_type idx = atoi(strLeft.c_str() + 4);
if (!Resize(idx))
{
bFailed = true;
break;
}
// Skip self - do not load playlist recursively
if (StringUtils::EqualsNoCase(URIUtils::GetFileName(strValue),
URIUtils::GetFileName(strFileName)))
continue;
if (m_vecItems[idx - 1]->GetLabel().empty())
m_vecItems[idx - 1]->SetLabel(URIUtils::GetFileName(strValue));
CFileItem item(strValue, false);
if (bShoutCast && !item.IsAudio())
strValue.replace(0, 7, "shout://");
strValue = URIUtils::SubstitutePath(strValue);
CUtil::GetQualifiedFilename(m_strBasePath, strValue);
g_charsetConverter.unknownToUTF8(strValue);
m_vecItems[idx - 1]->SetPath(strValue);
}
else if (StringUtils::StartsWith(strLeft, "title"))
{
std::vector <int>::size_type idx = atoi(strLeft.c_str() + 5);
if (!Resize(idx))
{
bFailed = true;
break;
}
g_charsetConverter.unknownToUTF8(strValue);
m_vecItems[idx - 1]->SetLabel(strValue);
}
else if (StringUtils::StartsWith(strLeft, "length"))
{
std::vector <int>::size_type idx = atoi(strLeft.c_str() + 6);
if (!Resize(idx))
{
bFailed = true;
break;
}
m_vecItems[idx - 1]->GetMusicInfoTag()->SetDuration(atol(strValue.c_str()));
}
else if (strLeft == "playlistname")
{
m_strPlayListName = strValue;
g_charsetConverter.unknownToUTF8(m_strPlayListName);
}
}
}
file.Close();
if (bFailed)
{
CLog::Log(LOGERROR,
"File {} is not a valid PLS playlist. Location of first file,title or length is not "
"permitted (eg. File0 should be File1)",
URIUtils::GetFileName(strFileName));
return false;
}
// check for missing entries
ivecItems p = m_vecItems.begin();
while ( p != m_vecItems.end())
{
if ((*p)->GetPath().empty())
{
p = m_vecItems.erase(p);
}
else
{
++p;
}
}
return true;
} | 0 |
Chrome | e9841fbdaf41b4a2baaa413f94d5c0197f9261f4 | NOT_APPLICABLE | NOT_APPLICABLE | bool RenderViewHostManager::ShouldTransitionCrossSite() {
return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab);
}
| 0 |
vlc | 2e7c7091a61aa5d07e7997b393d821e91f593c39 | NOT_APPLICABLE | NOT_APPLICABLE | static int MP4_ReadBox_rmvc( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_rmvc_t );
MP4_GETVERSIONFLAGS( p_box->data.p_rmvc );
MP4_GETFOURCC( p_box->data.p_rmvc->i_gestaltType );
MP4_GET4BYTES( p_box->data.p_rmvc->i_val1 );
MP4_GET4BYTES( p_box->data.p_rmvc->i_val2 );
MP4_GET2BYTES( p_box->data.p_rmvc->i_checkType );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream,
"read box: \"rmvc\" gestaltType:%4.4s val1:0x%x val2:0x%x checkType:0x%x",
(char*)&p_box->data.p_rmvc->i_gestaltType,
p_box->data.p_rmvc->i_val1,p_box->data.p_rmvc->i_val2,
p_box->data.p_rmvc->i_checkType );
#endif
MP4_READBOX_EXIT( 1 );
} | 0 |
ImageMagick | 504ada82b6fa38a30c846c1c29116af7290decb2 | CVE-2014-9907 | CWE-20 | static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image
*image;
MagickBooleanType
status,
cubemap = MagickFalse,
volume = MagickFalse,
matte;
CompressionType
compression;
DDSInfo
dds_info;
DDSDecoder
*decoder;
size_t
n,
num_images;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Initialize image structure.
*/
if (ReadDDSInfo(image, &dds_info) != MagickTrue) {
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP)
cubemap = MagickTrue;
if (dds_info.ddscaps2 & DDSCAPS2_VOLUME && dds_info.depth > 0)
volume = MagickTrue;
(void) SeekBlob(image, 128, SEEK_SET);
/*
Determine pixel format
*/
if (dds_info.pixelformat.flags & DDPF_RGB)
{
compression = NoCompression;
if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS)
{
matte = MagickTrue;
decoder = ReadUncompressedRGBA;
}
else
{
matte = MagickTrue;
decoder = ReadUncompressedRGB;
}
}
else if (dds_info.pixelformat.flags & DDPF_LUMINANCE)
{
compression = NoCompression;
if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS)
{
/* Not sure how to handle this */
ThrowReaderException(CorruptImageError, "ImageTypeNotSupported");
}
else
{
matte = MagickFalse;
decoder = ReadUncompressedRGB;
}
}
else if (dds_info.pixelformat.flags & DDPF_FOURCC)
{
switch (dds_info.pixelformat.fourcc)
{
case FOURCC_DXT1:
{
matte = MagickFalse;
compression = DXT1Compression;
decoder = ReadDXT1;
break;
}
case FOURCC_DXT3:
{
matte = MagickTrue;
compression = DXT3Compression;
decoder = ReadDXT3;
break;
}
case FOURCC_DXT5:
{
matte = MagickTrue;
compression = DXT5Compression;
decoder = ReadDXT5;
break;
}
default:
{
/* Unknown FOURCC */
ThrowReaderException(CorruptImageError, "ImageTypeNotSupported");
}
}
}
else
{
/* Neither compressed nor uncompressed... thus unsupported */
ThrowReaderException(CorruptImageError, "ImageTypeNotSupported");
}
num_images = 1;
if (cubemap)
{
/*
Determine number of faces defined in the cubemap
*/
num_images = 0;
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX) num_images++;
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) num_images++;
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY) num_images++;
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) num_images++;
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) num_images++;
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) num_images++;
}
if (volume)
num_images = dds_info.depth;
for (n = 0; n < num_images; n++)
{
if (n != 0)
{
/* Start a new image */
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
return(DestroyImageList(image));
image=SyncNextImageInList(image);
}
image->matte = matte;
image->compression = compression;
image->columns = dds_info.width;
image->rows = dds_info.height;
image->storage_class = DirectClass;
image->endian = LSBEndian;
image->depth = 8;
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
if ((decoder)(image, &dds_info, exception) != MagickTrue)
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
}
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
| 1 |
Chrome | 673ce95d481ea9368c4d4d43ac756ba1d6d9e608 | CVE-2018-6063 | CWE-787 | void MojoAudioOutputIPC::StreamCreated(
mojo::ScopedSharedBufferHandle shared_memory,
mojo::ScopedHandle socket) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(delegate_);
DCHECK(socket.is_valid());
DCHECK(shared_memory.is_valid());
base::PlatformFile socket_handle;
auto result = mojo::UnwrapPlatformFile(std::move(socket), &socket_handle);
DCHECK_EQ(result, MOJO_RESULT_OK);
base::SharedMemoryHandle memory_handle;
bool read_only = false;
size_t memory_length = 0;
result = mojo::UnwrapSharedMemoryHandle(
std::move(shared_memory), &memory_handle, &memory_length, &read_only);
DCHECK_EQ(result, MOJO_RESULT_OK);
DCHECK(!read_only);
delegate_->OnStreamCreated(memory_handle, socket_handle);
}
| 1 |
qemu | 6d4b9e55fc625514a38d27cff4b9933f617fa7dc | NOT_APPLICABLE | NOT_APPLICABLE | static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
CURLAIOCB *acb)
{
int i;
size_t end = start + len;
for (i=0; i<CURL_NUM_STATES; i++) {
CURLState *state = &s->states[i];
size_t buf_end = (state->buf_start + state->buf_off);
size_t buf_fend = (state->buf_start + state->buf_len);
if (!state->orig_buf)
continue;
if (!state->buf_off)
continue;
// Does the existing buffer cover our section?
if ((start >= state->buf_start) &&
(start <= buf_end) &&
(end >= state->buf_start) &&
(end <= buf_end))
{
char *buf = state->orig_buf + (start - state->buf_start);
qemu_iovec_from_buf(acb->qiov, 0, buf, len);
acb->common.cb(acb->common.opaque, 0);
return FIND_RET_OK;
}
// Wait for unfinished chunks
if ((start >= state->buf_start) &&
(start <= buf_fend) &&
(end >= state->buf_start) &&
(end <= buf_fend))
{
int j;
acb->start = start - state->buf_start;
acb->end = acb->start + len;
for (j=0; j<CURL_NUM_ACB; j++) {
if (!state->acb[j]) {
state->acb[j] = acb;
return FIND_RET_WAIT;
}
}
}
}
return FIND_RET_NONE;
} | 0 |
xserver | 5725849a1b427cd4a72b84e57f211edb35838718 | NOT_APPLICABLE | NOT_APPLICABLE | SProcRenderCreateCursor (ClientPtr client)
{
register int n;
REQUEST(xRenderCreateCursorReq);
REQUEST_SIZE_MATCH (xRenderCreateCursorReq);
swaps(&stuff->length, n);
swapl(&stuff->cid, n);
swapl(&stuff->src, n);
swaps(&stuff->x, n);
swaps(&stuff->y, n);
return (*ProcRenderVector[stuff->renderReqType]) (client);
}
| 0 |
Chrome | 3c8e4852477d5b1e2da877808c998dc57db9460f | NOT_APPLICABLE | NOT_APPLICABLE | void InputHandler::Wire(UberDispatcher* dispatcher) {
Input::Dispatcher::wire(dispatcher, this);
}
| 0 |
liblouis | dc97ef791a4fae9da11592c79f9f79e010596e0c | NOT_APPLICABLE | NOT_APPLICABLE | addCharOrDots (FileInfo * nested, widechar c, int m)
{
/*See if a character or dot pattern is in the appropriate table. If not,
* insert it. In either
* case, return a pointer to it. */
TranslationTableOffset bucket;
TranslationTableCharacter *character;
TranslationTableCharacter *oldchar;
TranslationTableOffset offset;
unsigned long int makeHash;
if ((character = compile_findCharOrDots (c, m)))
return character;
if (!allocateSpaceInTable (nested, &offset, sizeof (*character)))
return NULL;
character = (TranslationTableCharacter *) & table->ruleArea[offset];
memset (character, 0, sizeof (*character));
character->realchar = c;
makeHash = (unsigned long int) c % HASHNUM;
if (m == 0)
bucket = table->characters[makeHash];
else
bucket = table->dots[makeHash];
if (!bucket)
{
if (m == 0)
table->characters[makeHash] = offset;
else
table->dots[makeHash] = offset;
}
else
{
oldchar = (TranslationTableCharacter *) & table->ruleArea[bucket];
while (oldchar->next)
oldchar =
(TranslationTableCharacter *) & table->ruleArea[oldchar->next];
oldchar->next = offset;
}
return character;
} | 0 |
linux | 55f0fc7a02de8f12757f4937143d8d5091b2e40b | NOT_APPLICABLE | NOT_APPLICABLE | static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
struct dst_entry *dst,
const struct flowi6 *fl6)
{
struct ipv6_pinfo *np = inet6_sk(sk);
struct rt6_info *rt;
if (!dst)
goto out;
if (dst->ops->family != AF_INET6) {
dst_release(dst);
return NULL;
}
rt = (struct rt6_info *)dst;
/* Yes, checking route validity in not connected
* case is not very simple. Take into account,
* that we do not support routing by source, TOS,
* and MSG_DONTROUTE --ANK (980726)
*
* 1. ip6_rt_check(): If route was host route,
* check that cached destination is current.
* If it is network route, we still may
* check its validity using saved pointer
* to the last used address: daddr_cache.
* We do not want to save whole address now,
* (because main consumer of this service
* is tcp, which has not this problem),
* so that the last trick works only on connected
* sockets.
* 2. oif also should be the same.
*/
if (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) ||
#ifdef CONFIG_IPV6_SUBTREES
ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) ||
#endif
(fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) {
dst_release(dst);
dst = NULL;
}
out:
return dst;
}
| 0 |
linux | 189b0ddc245139af81198d1a3637cac74f96e13a | NOT_APPLICABLE | NOT_APPLICABLE | int create_pipe_files(struct file **res, int flags)
{
struct inode *inode = get_pipe_inode();
struct file *f;
int error;
if (!inode)
return -ENFILE;
if (flags & O_NOTIFICATION_PIPE) {
error = watch_queue_init(inode->i_pipe);
if (error) {
free_pipe_info(inode->i_pipe);
iput(inode);
return error;
}
}
f = alloc_file_pseudo(inode, pipe_mnt, "",
O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)),
&pipefifo_fops);
if (IS_ERR(f)) {
free_pipe_info(inode->i_pipe);
iput(inode);
return PTR_ERR(f);
}
f->private_data = inode->i_pipe;
res[0] = alloc_file_clone(f, O_RDONLY | (flags & O_NONBLOCK),
&pipefifo_fops);
if (IS_ERR(res[0])) {
put_pipe_info(inode, inode->i_pipe);
fput(f);
return PTR_ERR(res[0]);
}
res[0]->private_data = inode->i_pipe;
res[1] = f;
stream_open(inode, res[0]);
stream_open(inode, res[1]);
return 0;
} | 0 |
w3m | 8354763b90490d4105695df52674d0fcef823e92 | NOT_APPLICABLE | NOT_APPLICABLE | dv2sv(double *dv, short *iv, int size)
{
int i, k, iw;
short *indexarray;
double *edv;
double w = 0., x;
indexarray = NewAtom_N(short, size);
edv = NewAtom_N(double, size);
for (i = 0; i < size; i++) {
iv[i] = (short) ceil(dv[i]);
edv[i] = (double)iv[i] - dv[i];
}
w = 0.;
for (k = 0; k < size; k++) {
x = edv[k];
w += x;
i = bsearch_double(x, edv, indexarray, k);
if (k > i) {
int ii;
for (ii = k; ii > i; ii--)
indexarray[ii] = indexarray[ii - 1];
}
indexarray[i] = k;
}
iw = min((int)(w + 0.5), size);
if (iw <= 1)
return;
x = edv[(int)indexarray[iw - 1]];
for (i = 0; i < size; i++) {
k = indexarray[i];
if (i >= iw && abs(edv[k] - x) > 1e-6)
break;
iv[k]--;
}
}
| 0 |
neomutt | 6296f7153f0c9d5e5cd3aaf08f9731e56621bdd3 | NOT_APPLICABLE | NOT_APPLICABLE | static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)
{
return snprintf(dest, destlen, "%s.hcache", path);
}
| 0 |
mongo | 6518b22420c5bbd92c42caf907671c3a2b140bb6 | NOT_APPLICABLE | NOT_APPLICABLE | Pipeline::SourceContainer::iterator DocumentSourceUnionWith::doOptimizeAt(
Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) {
auto duplicateAcrossUnion = [&](auto&& nextStage) {
_pipeline->addFinalSource(nextStage->clone());
auto newStageItr = container->insert(itr, std::move(nextStage));
container->erase(std::next(itr));
return newStageItr == container->begin() ? newStageItr : std::prev(newStageItr);
};
if (std::next(itr) != container->end()) {
if (auto nextMatch = dynamic_cast<DocumentSourceMatch*>((*std::next(itr)).get()))
return duplicateAcrossUnion(nextMatch);
else if (auto nextProject = dynamic_cast<DocumentSourceSingleDocumentTransformation*>(
(*std::next(itr)).get()))
return duplicateAcrossUnion(nextProject);
}
return std::next(itr);
}; | 0 |
Chrome | 9d81094d7b0bfc8be6bba2f5084e790677e527c8 | NOT_APPLICABLE | NOT_APPLICABLE | bool ProfilingProcessHost::ShouldProfileProcessType(int process_type) {
switch (mode()) {
case Mode::kAll:
return true;
case Mode::kMinimal:
return (process_type == content::ProcessType::PROCESS_TYPE_GPU ||
process_type == content::ProcessType::PROCESS_TYPE_BROWSER);
case Mode::kGpu:
return process_type == content::ProcessType::PROCESS_TYPE_GPU;
case Mode::kBrowser:
return process_type == content::ProcessType::PROCESS_TYPE_BROWSER;
case Mode::kRendererSampling:
return false;
case Mode::kNone:
return false;
case Mode::kCount:
{}
}
NOTREACHED();
return false;
}
| 0 |
w3m | 807e8b7fbffca6dcaf5db40e35f05d05c5cf02d3 | CVE-2016-9432 | CWE-119 | formUpdateBuffer(Anchor *a, Buffer *buf, FormItemList *form)
{
Buffer save;
char *p;
int spos, epos, rows, c_rows, pos, col = 0;
Line *l;
copyBuffer(&save, buf);
gotoLine(buf, a->start.line);
switch (form->type) {
case FORM_TEXTAREA:
case FORM_INPUT_TEXT:
case FORM_INPUT_FILE:
case FORM_INPUT_PASSWORD:
case FORM_INPUT_CHECKBOX:
case FORM_INPUT_RADIO:
#ifdef MENU_SELECT
case FORM_SELECT:
#endif /* MENU_SELECT */
spos = a->start.pos;
epos = a->end.pos;
break;
default:
spos = a->start.pos + 1;
epos = a->end.pos - 1;
}
switch (form->type) {
case FORM_INPUT_CHECKBOX:
case FORM_INPUT_RADIO:
if (form->checked)
buf->currentLine->lineBuf[spos] = '*';
else
buf->currentLine->lineBuf[spos] = ' ';
break;
case FORM_INPUT_TEXT:
case FORM_INPUT_FILE:
case FORM_INPUT_PASSWORD:
case FORM_TEXTAREA:
#ifdef MENU_SELECT
case FORM_SELECT:
if (form->type == FORM_SELECT) {
p = form->label->ptr;
updateSelectOption(form, form->select_option);
}
else
#endif /* MENU_SELECT */
p = form->value->ptr;
l = buf->currentLine;
if (form->type == FORM_TEXTAREA) {
int n = a->y - buf->currentLine->linenumber;
if (n > 0)
for (; l && n; l = l->prev, n--) ;
else if (n < 0)
for (; l && n; l = l->prev, n++) ;
if (!l)
break;
}
rows = form->rows ? form->rows : 1;
col = COLPOS(l, a->start.pos);
for (c_rows = 0; c_rows < rows; c_rows++, l = l->next) {
if (rows > 1) {
pos = columnPos(l, col);
a = retrieveAnchor(buf->formitem, l->linenumber, pos);
if (a == NULL)
break;
spos = a->start.pos;
epos = a->end.pos;
}
if (a->start.line != a->end.line || spos > epos)
epos = spos;
pos = form_update_line(l, &p, spos, epos, COLPOS(l, epos) - col,
rows > 1,
form->type == FORM_INPUT_PASSWORD);
if (pos != epos) {
shiftAnchorPosition(buf->href, buf->hmarklist,
a->start.line, spos, pos - epos);
shiftAnchorPosition(buf->name, buf->hmarklist,
a->start.line, spos, pos - epos);
shiftAnchorPosition(buf->img, buf->hmarklist,
a->start.line, spos, pos - epos);
shiftAnchorPosition(buf->formitem, buf->hmarklist,
a->start.line, spos, pos - epos);
}
}
break;
}
copyBuffer(buf, &save);
arrangeLine(buf);
} | 1 |
Espruino | bf4416ab9129ee3afd56739ea4e3cd0da5484b6b | CVE-2018-11598 | CWE-125 | NO_INLINE JsVar *jspeArrowFunction(JsVar *funcVar, JsVar *a) {
assert(!a || jsvIsName(a));
JSP_ASSERT_MATCH(LEX_ARROW_FUNCTION);
funcVar = jspeAddNamedFunctionParameter(funcVar, a);
bool expressionOnly = lex->tk!='{';
jspeFunctionDefinitionInternal(funcVar, expressionOnly);
if (execInfo.thisVar) {
jsvObjectSetChild(funcVar, JSPARSE_FUNCTION_THIS_NAME, execInfo.thisVar);
}
return funcVar;
}
NO_INLINE JsVar *jspeExpressionOrArrowFunction() {
JsVar *a = 0;
JsVar *funcVar = 0;
bool allNames = true;
while (lex->tk!=')' && !JSP_SHOULDNT_PARSE) {
if (allNames && a) {
funcVar = jspeAddNamedFunctionParameter(funcVar, a);
}
jsvUnLock(a);
a = jspeAssignmentExpression();
if (!(jsvIsName(a) && jsvIsString(a))) allNames = false;
if (lex->tk!=')') JSP_MATCH_WITH_CLEANUP_AND_RETURN(',', jsvUnLock2(a,funcVar), 0);
}
JSP_MATCH_WITH_CLEANUP_AND_RETURN(')', jsvUnLock2(a,funcVar), 0);
if (allNames && lex->tk==LEX_ARROW_FUNCTION) {
funcVar = jspeArrowFunction(funcVar, a);
jsvUnLock(a);
return funcVar;
} else {
jsvUnLock(funcVar);
return a;
}
}
NO_INLINE JsVar *jspeClassDefinition(bool parseNamedClass) {
JsVar *classFunction = 0;
JsVar *classPrototype = 0;
JsVar *classInternalName = 0;
bool actuallyCreateClass = JSP_SHOULD_EXECUTE;
if (actuallyCreateClass)
classFunction = jsvNewWithFlags(JSV_FUNCTION);
if (parseNamedClass && lex->tk==LEX_ID) {
if (classFunction)
classInternalName = jslGetTokenValueAsVar(lex);
JSP_ASSERT_MATCH(LEX_ID);
}
if (classFunction) {
JsVar *prototypeName = jsvFindChildFromString(classFunction, JSPARSE_PROTOTYPE_VAR, true);
jspEnsureIsPrototype(classFunction, prototypeName); // make sure it's an object
classPrototype = jsvSkipName(prototypeName);
jsvUnLock(prototypeName);
}
if (lex->tk==LEX_R_EXTENDS) {
JSP_ASSERT_MATCH(LEX_R_EXTENDS);
JsVar *extendsFrom = actuallyCreateClass ? jsvSkipNameAndUnLock(jspGetNamedVariable(jslGetTokenValueAsString(lex))) : 0;
JSP_MATCH_WITH_CLEANUP_AND_RETURN(LEX_ID,jsvUnLock4(extendsFrom,classFunction,classInternalName,classPrototype),0);
if (classPrototype) {
if (jsvIsFunction(extendsFrom)) {
jsvObjectSetChild(classPrototype, JSPARSE_INHERITS_VAR, extendsFrom);
jsvObjectSetChildAndUnLock(classFunction, JSPARSE_FUNCTION_CODE_NAME, jsvNewFromString("if(this.__proto__.__proto__)this.__proto__.__proto__.apply(this,arguments)"));
} else
jsExceptionHere(JSET_SYNTAXERROR, "'extends' argument should be a function, got %t", extendsFrom);
}
jsvUnLock(extendsFrom);
}
JSP_MATCH_WITH_CLEANUP_AND_RETURN('{',jsvUnLock3(classFunction,classInternalName,classPrototype),0);
while ((lex->tk==LEX_ID || lex->tk==LEX_R_STATIC) && !jspIsInterrupted()) {
bool isStatic = lex->tk==LEX_R_STATIC;
if (isStatic) JSP_ASSERT_MATCH(LEX_R_STATIC);
JsVar *funcName = jslGetTokenValueAsVar(lex);
JSP_MATCH_WITH_CLEANUP_AND_RETURN(LEX_ID,jsvUnLock3(classFunction,classInternalName,classPrototype),0);
JsVar *method = jspeFunctionDefinition(false);
if (classFunction && classPrototype) {
if (jsvIsStringEqual(funcName, "get") || jsvIsStringEqual(funcName, "set")) {
jsExceptionHere(JSET_SYNTAXERROR, "'get' and 'set' and not supported in Espruino");
} else if (jsvIsStringEqual(funcName, "constructor")) {
jswrap_function_replaceWith(classFunction, method);
} else {
funcName = jsvMakeIntoVariableName(funcName, 0);
jsvSetValueOfName(funcName, method);
jsvAddName(isStatic ? classFunction : classPrototype, funcName);
}
}
jsvUnLock2(method,funcName);
}
jsvUnLock(classPrototype);
if (classInternalName)
jsvObjectSetChildAndUnLock(classFunction, JSPARSE_FUNCTION_NAME_NAME, classInternalName);
JSP_MATCH_WITH_CLEANUP_AND_RETURN('}',jsvUnLock(classFunction),0);
return classFunction;
}
#endif
NO_INLINE JsVar *jspeFactor() {
if (lex->tk==LEX_ID) {
JsVar *a = jspGetNamedVariable(jslGetTokenValueAsString(lex));
JSP_ASSERT_MATCH(LEX_ID);
#ifndef SAVE_ON_FLASH
if (lex->tk==LEX_TEMPLATE_LITERAL)
jsExceptionHere(JSET_SYNTAXERROR, "Tagged template literals not supported");
else if (lex->tk==LEX_ARROW_FUNCTION && jsvIsName(a)) {
JsVar *funcVar = jspeArrowFunction(0,a);
jsvUnLock(a);
a=funcVar;
}
#endif
return a;
} else if (lex->tk==LEX_INT) {
JsVar *v = 0;
if (JSP_SHOULD_EXECUTE) {
v = jsvNewFromLongInteger(stringToInt(jslGetTokenValueAsString(lex)));
}
JSP_ASSERT_MATCH(LEX_INT);
return v;
} else if (lex->tk==LEX_FLOAT) {
JsVar *v = 0;
if (JSP_SHOULD_EXECUTE) {
v = jsvNewFromFloat(stringToFloat(jslGetTokenValueAsString(lex)));
}
JSP_ASSERT_MATCH(LEX_FLOAT);
return v;
} else if (lex->tk=='(') {
JSP_ASSERT_MATCH('(');
if (!jspCheckStackPosition()) return 0;
#ifdef SAVE_ON_FLASH
JsVar *a = jspeExpression();
if (!JSP_SHOULDNT_PARSE) JSP_MATCH_WITH_RETURN(')',a);
return a;
#else
return jspeExpressionOrArrowFunction();
#endif
} else if (lex->tk==LEX_R_TRUE) {
JSP_ASSERT_MATCH(LEX_R_TRUE);
return JSP_SHOULD_EXECUTE ? jsvNewFromBool(true) : 0;
} else if (lex->tk==LEX_R_FALSE) {
JSP_ASSERT_MATCH(LEX_R_FALSE);
return JSP_SHOULD_EXECUTE ? jsvNewFromBool(false) : 0;
} else if (lex->tk==LEX_R_NULL) {
JSP_ASSERT_MATCH(LEX_R_NULL);
return JSP_SHOULD_EXECUTE ? jsvNewWithFlags(JSV_NULL) : 0;
} else if (lex->tk==LEX_R_UNDEFINED) {
JSP_ASSERT_MATCH(LEX_R_UNDEFINED);
return 0;
} else if (lex->tk==LEX_STR) {
JsVar *a = 0;
if (JSP_SHOULD_EXECUTE)
a = jslGetTokenValueAsVar(lex);
JSP_ASSERT_MATCH(LEX_STR);
return a;
#ifndef SAVE_ON_FLASH
} else if (lex->tk==LEX_TEMPLATE_LITERAL) {
return jspeTemplateLiteral();
#endif
} else if (lex->tk==LEX_REGEX) {
JsVar *a = 0;
#ifdef SAVE_ON_FLASH
jsExceptionHere(JSET_SYNTAXERROR, "RegEx are not supported in this version of Espruino\n");
#else
JsVar *regex = jslGetTokenValueAsVar(lex);
size_t regexEnd = 0, regexLen = 0;
JsvStringIterator it;
jsvStringIteratorNew(&it, regex, 0);
while (jsvStringIteratorHasChar(&it)) {
regexLen++;
if (jsvStringIteratorGetChar(&it)=='/')
regexEnd = regexLen;
jsvStringIteratorNext(&it);
}
jsvStringIteratorFree(&it);
JsVar *flags = 0;
if (regexEnd < regexLen)
flags = jsvNewFromStringVar(regex, regexEnd, JSVAPPENDSTRINGVAR_MAXLENGTH);
JsVar *regexSource = jsvNewFromStringVar(regex, 1, regexEnd-2);
a = jswrap_regexp_constructor(regexSource, flags);
jsvUnLock3(regex, flags, regexSource);
#endif
JSP_ASSERT_MATCH(LEX_REGEX);
return a;
} else if (lex->tk=='{') {
if (!jspCheckStackPosition()) return 0;
return jspeFactorObject();
} else if (lex->tk=='[') {
if (!jspCheckStackPosition()) return 0;
return jspeFactorArray();
} else if (lex->tk==LEX_R_FUNCTION) {
if (!jspCheckStackPosition()) return 0;
JSP_ASSERT_MATCH(LEX_R_FUNCTION);
return jspeFunctionDefinition(true);
#ifndef SAVE_ON_FLASH
} else if (lex->tk==LEX_R_CLASS) {
if (!jspCheckStackPosition()) return 0;
JSP_ASSERT_MATCH(LEX_R_CLASS);
return jspeClassDefinition(true);
} else if (lex->tk==LEX_R_SUPER) {
JSP_ASSERT_MATCH(LEX_R_SUPER);
/* This is kind of nasty, since super appears to do
three different things.
* In the constructor it references the extended class's constructor
* in a method it references the constructor's prototype.
* in a static method it references the extended class's constructor (but this is different)
*/
if (jsvIsObject(execInfo.thisVar)) {
JsVar *proto1 = jsvObjectGetChild(execInfo.thisVar, JSPARSE_INHERITS_VAR, 0); // if we're in a method, get __proto__ first
JsVar *proto2 = jsvIsObject(proto1) ? jsvObjectGetChild(proto1, JSPARSE_INHERITS_VAR, 0) : 0; // still in method, get __proto__.__proto__
jsvUnLock(proto1);
if (!proto2) {
jsExceptionHere(JSET_SYNTAXERROR, "Calling 'super' outside of class");
return 0;
}
if (lex->tk=='(') return proto2; // eg. used in a constructor
JsVar *proto3 = jsvIsFunction(proto2) ? jsvObjectGetChild(proto2, JSPARSE_PROTOTYPE_VAR, 0) : 0;
jsvUnLock(proto2);
return proto3;
} else if (jsvIsFunction(execInfo.thisVar)) {
JsVar *proto1 = jsvObjectGetChild(execInfo.thisVar, JSPARSE_PROTOTYPE_VAR, 0);
JsVar *proto2 = jsvIsObject(proto1) ? jsvObjectGetChild(proto1, JSPARSE_INHERITS_VAR, 0) : 0;
jsvUnLock(proto1);
if (!proto2) {
jsExceptionHere(JSET_SYNTAXERROR, "Calling 'super' outside of class");
return 0;
}
return proto2;
}
jsExceptionHere(JSET_SYNTAXERROR, "Calling 'super' outside of class");
return 0;
#endif
} else if (lex->tk==LEX_R_THIS) {
JSP_ASSERT_MATCH(LEX_R_THIS);
return jsvLockAgain( execInfo.thisVar ? execInfo.thisVar : execInfo.root );
} else if (lex->tk==LEX_R_DELETE) {
if (!jspCheckStackPosition()) return 0;
return jspeFactorDelete();
} else if (lex->tk==LEX_R_TYPEOF) {
if (!jspCheckStackPosition()) return 0;
return jspeFactorTypeOf();
} else if (lex->tk==LEX_R_VOID) {
if (!jspCheckStackPosition()) return 0;
JSP_ASSERT_MATCH(LEX_R_VOID);
jsvUnLock(jspeUnaryExpression());
return 0;
}
JSP_MATCH(LEX_EOF);
jsExceptionHere(JSET_SYNTAXERROR, "Unexpected end of Input\n");
return 0;
}
NO_INLINE JsVar *__jspePostfixExpression(JsVar *a) {
while (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) {
int op = lex->tk;
JSP_ASSERT_MATCH(op);
if (JSP_SHOULD_EXECUTE) {
JsVar *one = jsvNewFromInteger(1);
JsVar *oldValue = jsvAsNumberAndUnLock(jsvSkipName(a)); // keep the old value (but convert to number)
JsVar *res = jsvMathsOpSkipNames(oldValue, one, op==LEX_PLUSPLUS ? '+' : '-');
jsvUnLock(one);
jspReplaceWith(a, res);
jsvUnLock(res);
jsvUnLock(a);
a = oldValue;
}
}
return a;
}
NO_INLINE JsVar *jspePostfixExpression() {
JsVar *a;
if (lex->tk==LEX_PLUSPLUS || lex->tk==LEX_MINUSMINUS) {
int op = lex->tk;
JSP_ASSERT_MATCH(op);
a = jspePostfixExpression();
if (JSP_SHOULD_EXECUTE) {
JsVar *one = jsvNewFromInteger(1);
JsVar *res = jsvMathsOpSkipNames(a, one, op==LEX_PLUSPLUS ? '+' : '-');
jsvUnLock(one);
jspReplaceWith(a, res);
jsvUnLock(res);
}
} else
a = jspeFactorFunctionCall();
return __jspePostfixExpression(a);
}
NO_INLINE JsVar *jspeUnaryExpression() {
if (lex->tk=='!' || lex->tk=='~' || lex->tk=='-' || lex->tk=='+') {
short tk = lex->tk;
JSP_ASSERT_MATCH(tk);
if (!JSP_SHOULD_EXECUTE) {
return jspeUnaryExpression();
}
if (tk=='!') { // logical not
return jsvNewFromBool(!jsvGetBoolAndUnLock(jsvSkipNameAndUnLock(jspeUnaryExpression())));
} else if (tk=='~') { // bitwise not
return jsvNewFromInteger(~jsvGetIntegerAndUnLock(jsvSkipNameAndUnLock(jspeUnaryExpression())));
} else if (tk=='-') { // unary minus
return jsvNegateAndUnLock(jspeUnaryExpression()); // names already skipped
} else if (tk=='+') { // unary plus (convert to number)
JsVar *v = jsvSkipNameAndUnLock(jspeUnaryExpression());
JsVar *r = jsvAsNumber(v); // names already skipped
jsvUnLock(v);
return r;
}
assert(0);
return 0;
} else
return jspePostfixExpression();
}
unsigned int jspeGetBinaryExpressionPrecedence(int op) {
switch (op) {
case LEX_OROR: return 1; break;
case LEX_ANDAND: return 2; break;
case '|' : return 3; break;
case '^' : return 4; break;
case '&' : return 5; break;
case LEX_EQUAL:
case LEX_NEQUAL:
case LEX_TYPEEQUAL:
case LEX_NTYPEEQUAL: return 6;
case LEX_LEQUAL:
case LEX_GEQUAL:
case '<':
case '>':
case LEX_R_INSTANCEOF: return 7;
case LEX_R_IN: return (execInfo.execute&EXEC_FOR_INIT)?0:7;
case LEX_LSHIFT:
case LEX_RSHIFT:
case LEX_RSHIFTUNSIGNED: return 8;
case '+':
case '-': return 9;
case '*':
case '/':
case '%': return 10;
default: return 0;
}
}
NO_INLINE JsVar *__jspeBinaryExpression(JsVar *a, unsigned int lastPrecedence) {
/* This one's a bit strange. Basically all the ops have their own precedence, it's not
* like & and | share the same precedence. We don't want to recurse for each one,
* so instead we do this.
*
* We deal with an expression in recursion ONLY if it's of higher precedence
* than the current one, otherwise we stick in the while loop.
*/
unsigned int precedence = jspeGetBinaryExpressionPrecedence(lex->tk);
while (precedence && precedence>lastPrecedence) {
int op = lex->tk;
JSP_ASSERT_MATCH(op);
if (op==LEX_ANDAND || op==LEX_OROR) {
bool aValue = jsvGetBoolAndUnLock(jsvSkipName(a));
if ((!aValue && op==LEX_ANDAND) ||
(aValue && op==LEX_OROR)) {
JSP_SAVE_EXECUTE();
jspSetNoExecute();
jsvUnLock(__jspeBinaryExpression(jspeUnaryExpression(),precedence));
JSP_RESTORE_EXECUTE();
} else {
jsvUnLock(a);
a = __jspeBinaryExpression(jspeUnaryExpression(),precedence);
}
} else { // else it's a more 'normal' logical expression - just use Maths
JsVar *b = __jspeBinaryExpression(jspeUnaryExpression(),precedence);
if (JSP_SHOULD_EXECUTE) {
if (op==LEX_R_IN) {
JsVar *av = jsvSkipName(a); // needle
JsVar *bv = jsvSkipName(b); // haystack
if (jsvIsArray(bv) || jsvIsObject(bv)) { // search keys, NOT values
av = jsvAsArrayIndexAndUnLock(av);
JsVar *varFound = jspGetVarNamedField( bv, av, true);
jsvUnLock(a);
a = jsvNewFromBool(varFound!=0);
jsvUnLock(varFound);
} else {// else it will be undefined
jsExceptionHere(JSET_ERROR, "Cannot use 'in' operator to search a %t", bv);
jsvUnLock(a);
a = 0;
}
jsvUnLock2(av, bv);
} else if (op==LEX_R_INSTANCEOF) {
bool inst = false;
JsVar *av = jsvSkipName(a);
JsVar *bv = jsvSkipName(b);
if (!jsvIsFunction(bv)) {
jsExceptionHere(JSET_ERROR, "Expecting a function on RHS in instanceof check, got %t", bv);
} else {
if (jsvIsObject(av) || jsvIsFunction(av)) {
JsVar *bproto = jspGetNamedField(bv, JSPARSE_PROTOTYPE_VAR, false);
JsVar *proto = jsvObjectGetChild(av, JSPARSE_INHERITS_VAR, 0);
while (proto) {
if (proto == bproto) inst=true;
JsVar *childProto = jsvObjectGetChild(proto, JSPARSE_INHERITS_VAR, 0);
jsvUnLock(proto);
proto = childProto;
}
if (jspIsConstructor(bv, "Object")) inst = true;
jsvUnLock(bproto);
}
if (!inst) {
const char *name = jswGetBasicObjectName(av);
if (name) {
inst = jspIsConstructor(bv, name);
}
if (!inst && (jsvIsArray(av) || jsvIsArrayBuffer(av)) &&
jspIsConstructor(bv, "Object"))
inst = true;
}
}
jsvUnLock3(av, bv, a);
a = jsvNewFromBool(inst);
} else { // --------------------------------------------- NORMAL
JsVar *res = jsvMathsOpSkipNames(a, b, op);
jsvUnLock(a); a = res;
}
}
jsvUnLock(b);
}
precedence = jspeGetBinaryExpressionPrecedence(lex->tk);
}
return a;
}
JsVar *jspeBinaryExpression() {
return __jspeBinaryExpression(jspeUnaryExpression(),0);
}
NO_INLINE JsVar *__jspeConditionalExpression(JsVar *lhs) {
if (lex->tk=='?') {
JSP_ASSERT_MATCH('?');
if (!JSP_SHOULD_EXECUTE) {
jsvUnLock(jspeAssignmentExpression());
JSP_MATCH(':');
jsvUnLock(jspeAssignmentExpression());
} else {
bool first = jsvGetBoolAndUnLock(jsvSkipName(lhs));
jsvUnLock(lhs);
if (first) {
lhs = jspeAssignmentExpression();
JSP_MATCH(':');
JSP_SAVE_EXECUTE();
jspSetNoExecute();
jsvUnLock(jspeAssignmentExpression());
JSP_RESTORE_EXECUTE();
} else {
JSP_SAVE_EXECUTE();
jspSetNoExecute();
jsvUnLock(jspeAssignmentExpression());
JSP_RESTORE_EXECUTE();
JSP_MATCH(':');
lhs = jspeAssignmentExpression();
}
}
}
return lhs;
}
JsVar *jspeConditionalExpression() {
return __jspeConditionalExpression(jspeBinaryExpression());
}
NO_INLINE JsVar *__jspeAssignmentExpression(JsVar *lhs) {
if (lex->tk=='=' || lex->tk==LEX_PLUSEQUAL || lex->tk==LEX_MINUSEQUAL ||
lex->tk==LEX_MULEQUAL || lex->tk==LEX_DIVEQUAL || lex->tk==LEX_MODEQUAL ||
lex->tk==LEX_ANDEQUAL || lex->tk==LEX_OREQUAL ||
lex->tk==LEX_XOREQUAL || lex->tk==LEX_RSHIFTEQUAL ||
lex->tk==LEX_LSHIFTEQUAL || lex->tk==LEX_RSHIFTUNSIGNEDEQUAL) {
JsVar *rhs;
int op = lex->tk;
JSP_ASSERT_MATCH(op);
rhs = jspeAssignmentExpression();
rhs = jsvSkipNameAndUnLock(rhs); // ensure we get rid of any references on the RHS
if (JSP_SHOULD_EXECUTE && lhs) {
if (op=='=') {
/* If we're assigning to this and we don't have a parent,
* add it to the symbol table root */
if (!jsvGetRefs(lhs) && jsvIsName(lhs)) {
if (!jsvIsArrayBufferName(lhs) && !jsvIsNewChild(lhs))
jsvAddName(execInfo.root, lhs);
}
jspReplaceWith(lhs, rhs);
} else {
if (op==LEX_PLUSEQUAL) op='+';
else if (op==LEX_MINUSEQUAL) op='-';
else if (op==LEX_MULEQUAL) op='*';
else if (op==LEX_DIVEQUAL) op='/';
else if (op==LEX_MODEQUAL) op='%';
else if (op==LEX_ANDEQUAL) op='&';
else if (op==LEX_OREQUAL) op='|';
else if (op==LEX_XOREQUAL) op='^';
else if (op==LEX_RSHIFTEQUAL) op=LEX_RSHIFT;
else if (op==LEX_LSHIFTEQUAL) op=LEX_LSHIFT;
else if (op==LEX_RSHIFTUNSIGNEDEQUAL) op=LEX_RSHIFTUNSIGNED;
if (op=='+' && jsvIsName(lhs)) {
JsVar *currentValue = jsvSkipName(lhs);
if (jsvIsString(currentValue) && !jsvIsFlatString(currentValue) && jsvGetRefs(currentValue)==1 && rhs!=currentValue) {
/* A special case for string += where this is the only use of the string
* and we're not appending to ourselves. In this case we can do a
* simple append (rather than clone + append)*/
JsVar *str = jsvAsString(rhs, false);
jsvAppendStringVarComplete(currentValue, str);
jsvUnLock(str);
op = 0;
}
jsvUnLock(currentValue);
}
if (op) {
/* Fallback which does a proper add */
JsVar *res = jsvMathsOpSkipNames(lhs,rhs,op);
jspReplaceWith(lhs, res);
jsvUnLock(res);
}
}
}
jsvUnLock(rhs);
}
return lhs;
}
JsVar *jspeAssignmentExpression() {
return __jspeAssignmentExpression(jspeConditionalExpression());
}
NO_INLINE JsVar *jspeExpression() {
while (!JSP_SHOULDNT_PARSE) {
JsVar *a = jspeAssignmentExpression();
if (lex->tk!=',') return a;
jsvCheckReferenceError(a);
jsvUnLock(a);
JSP_ASSERT_MATCH(',');
}
return 0;
}
/** Parse a block `{ ... }` but assume brackets are already parsed */
NO_INLINE void jspeBlockNoBrackets() {
if (JSP_SHOULD_EXECUTE) {
while (lex->tk && lex->tk!='}') {
JsVar *a = jspeStatement();
jsvCheckReferenceError(a);
jsvUnLock(a);
if (JSP_HAS_ERROR) {
if (lex && !(execInfo.execute&EXEC_ERROR_LINE_REPORTED)) {
execInfo.execute = (JsExecFlags)(execInfo.execute | EXEC_ERROR_LINE_REPORTED);
JsVar *stackTrace = jsvObjectGetChild(execInfo.hiddenRoot, JSPARSE_STACKTRACE_VAR, JSV_STRING_0);
if (stackTrace) {
jsvAppendPrintf(stackTrace, "at ");
jspAppendStackTrace(stackTrace);
jsvUnLock(stackTrace);
}
}
}
if (JSP_SHOULDNT_PARSE)
return;
}
} else {
int brackets = 0;
while (lex->tk && (brackets || lex->tk != '}')) {
if (lex->tk == '{') brackets++;
if (lex->tk == '}') brackets--;
JSP_ASSERT_MATCH(lex->tk);
}
}
return;
}
| 1 |
Chrome | 5576cbc1d3e214dfbb5d3ffcdbe82aa8ba0088fc | NOT_APPLICABLE | NOT_APPLICABLE | ~Logger() {}
| 0 |
libtiff | 681748ec2f5ce88da5f9fa6831e1653e46af8a66 | NOT_APPLICABLE | NOT_APPLICABLE | static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16* pplane)
{
static const char module[] = "TIFFReadEncodedStrip";
TIFFDirectory *td = &tif->tif_dir;
uint32 rowsperstrip;
uint32 stripsperplane;
uint32 stripinplane;
uint32 rows;
tmsize_t stripsize;
if (!TIFFCheckRead(tif,0))
return((tmsize_t)(-1));
if (strip>=td->td_nstrips)
{
TIFFErrorExt(tif->tif_clientdata,module,
"%lu: Strip out of range, max %lu",(unsigned long)strip,
(unsigned long)td->td_nstrips);
return((tmsize_t)(-1));
}
rowsperstrip=td->td_rowsperstrip;
if (rowsperstrip>td->td_imagelength)
rowsperstrip=td->td_imagelength;
stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
stripinplane=(strip%stripsperplane);
if( pplane ) *pplane=(uint16)(strip/stripsperplane);
rows=td->td_imagelength-stripinplane*rowsperstrip;
if (rows>rowsperstrip)
rows=rowsperstrip;
stripsize=TIFFVStripSize(tif,rows);
if (stripsize==0)
return((tmsize_t)(-1));
return stripsize;
} | 0 |
Pillow | 5f4504bb03f4edeeef8c2633dc5ba03a4c2a8a97 | NOT_APPLICABLE | NOT_APPLICABLE | rgb2rgba(UINT8 *out, const UINT8 *in, int xsize) {
int x;
for (x = 0; x < xsize; x++) {
*out++ = *in++;
*out++ = *in++;
*out++ = *in++;
*out++ = 255;
in++;
}
} | 0 |
Subsets and Splits