project
stringclasses 791
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 127
values | func
stringlengths 5
484k
| vul
int8 0
1
|
---|---|---|---|---|---|
qemu | 8b98a2f07175d46c3f7217639bd5e03f2ec56343 | CVE-2015-7512 | CWE-119 | ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
{
PCNetState *s = qemu_get_nic_opaque(nc);
int is_padr = 0, is_bcast = 0, is_ladr = 0;
uint8_t buf1[60];
int remaining;
int crc_err = 0;
int size = size_;
if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size ||
(CSR_LOOP(s) && !s->looptest)) {
return -1;
}
#ifdef PCNET_DEBUG
printf("pcnet_receive size=%d\n", size);
#endif
/* if too small buffer, then expand it */
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
if (CSR_PROM(s)
|| (is_padr=padr_match(s, buf, size))
|| (is_bcast=padr_bcast(s, buf, size))
|| (is_ladr=ladr_match(s, buf, size))) {
pcnet_rdte_poll(s);
if (!(CSR_CRST(s) & 0x8000) && s->rdra) {
struct pcnet_RMD rmd;
int rcvrc = CSR_RCVRC(s)-1,i;
hwaddr nrda;
for (i = CSR_RCVRL(s)-1; i > 0; i--, rcvrc--) {
if (rcvrc <= 1)
rcvrc = CSR_RCVRL(s);
nrda = s->rdra +
(CSR_RCVRL(s) - rcvrc) *
(BCR_SWSTYLE(s) ? 16 : 8 );
RMDLOAD(&rmd, nrda);
if (GET_FIELD(rmd.status, RMDS, OWN)) {
#ifdef PCNET_DEBUG_RMD
printf("pcnet - scan buffer: RCVRC=%d PREV_RCVRC=%d\n",
rcvrc, CSR_RCVRC(s));
#endif
CSR_RCVRC(s) = rcvrc;
pcnet_rdte_poll(s);
break;
}
}
}
if (!(CSR_CRST(s) & 0x8000)) {
#ifdef PCNET_DEBUG_RMD
printf("pcnet - no buffer: RCVRC=%d\n", CSR_RCVRC(s));
#endif
s->csr[0] |= 0x1000; /* Set MISS flag */
CSR_MISSC(s)++;
} else {
uint8_t *src = s->buffer;
hwaddr crda = CSR_CRDA(s);
struct pcnet_RMD rmd;
int pktcount = 0;
if (!s->looptest) {
memcpy(src, buf, size);
/* no need to compute the CRC */
src[size] = 0;
uint32_t fcs = ~0;
uint8_t *p = src;
while (p != &src[size])
CRC(fcs, *p++);
*(uint32_t *)p = htonl(fcs);
size += 4;
} else {
uint32_t fcs = ~0;
uint8_t *p = src;
while (p != &src[size])
CRC(fcs, *p++);
crc_err = (*(uint32_t *)p != htonl(fcs));
}
#ifdef PCNET_DEBUG_MATCH
PRINT_PKTHDR(buf);
#endif
RMDLOAD(&rmd, PHYSADDR(s,crda));
/*if (!CSR_LAPPEN(s))*/
SET_FIELD(&rmd.status, RMDS, STP, 1);
#define PCNET_RECV_STORE() do { \
int count = MIN(4096 - GET_FIELD(rmd.buf_length, RMDL, BCNT),remaining); \
hwaddr rbadr = PHYSADDR(s, rmd.rbadr); \
s->phys_mem_write(s->dma_opaque, rbadr, src, count, CSR_BSWP(s)); \
src += count; remaining -= count; \
SET_FIELD(&rmd.status, RMDS, OWN, 0); \
RMDSTORE(&rmd, PHYSADDR(s,crda)); \
pktcount++; \
} while (0)
remaining = size;
PCNET_RECV_STORE();
if ((remaining > 0) && CSR_NRDA(s)) {
hwaddr nrda = CSR_NRDA(s);
#ifdef PCNET_DEBUG_RMD
PRINT_RMD(&rmd);
#endif
RMDLOAD(&rmd, PHYSADDR(s,nrda));
if (GET_FIELD(rmd.status, RMDS, OWN)) {
crda = nrda;
PCNET_RECV_STORE();
#ifdef PCNET_DEBUG_RMD
PRINT_RMD(&rmd);
#endif
if ((remaining > 0) && (nrda=CSR_NNRD(s))) {
RMDLOAD(&rmd, PHYSADDR(s,nrda));
if (GET_FIELD(rmd.status, RMDS, OWN)) {
crda = nrda;
PCNET_RECV_STORE();
}
}
}
}
#undef PCNET_RECV_STORE
RMDLOAD(&rmd, PHYSADDR(s,crda));
if (remaining == 0) {
SET_FIELD(&rmd.msg_length, RMDM, MCNT, size);
SET_FIELD(&rmd.status, RMDS, ENP, 1);
SET_FIELD(&rmd.status, RMDS, PAM, !CSR_PROM(s) && is_padr);
SET_FIELD(&rmd.status, RMDS, LFAM, !CSR_PROM(s) && is_ladr);
SET_FIELD(&rmd.status, RMDS, BAM, !CSR_PROM(s) && is_bcast);
if (crc_err) {
SET_FIELD(&rmd.status, RMDS, CRC, 1);
SET_FIELD(&rmd.status, RMDS, ERR, 1);
}
} else {
SET_FIELD(&rmd.status, RMDS, OFLO, 1);
SET_FIELD(&rmd.status, RMDS, BUFF, 1);
SET_FIELD(&rmd.status, RMDS, ERR, 1);
}
RMDSTORE(&rmd, PHYSADDR(s,crda));
s->csr[0] |= 0x0400;
#ifdef PCNET_DEBUG
printf("RCVRC=%d CRDA=0x%08x BLKS=%d\n",
CSR_RCVRC(s), PHYSADDR(s,CSR_CRDA(s)), pktcount);
#endif
#ifdef PCNET_DEBUG_RMD
PRINT_RMD(&rmd);
#endif
while (pktcount--) {
if (CSR_RCVRC(s) <= 1)
CSR_RCVRC(s) = CSR_RCVRL(s);
else
CSR_RCVRC(s)--;
}
pcnet_rdte_poll(s);
}
}
pcnet_poll(s);
pcnet_update_irq(s);
return size_;
}
| 1 |
ghostscript | b326a71659b7837d3acde954b18bda1a6f5e9498 | NOT_APPLICABLE | NOT_APPLICABLE | static int graybasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth)
{
os_ptr op = osp;
float Gray, RGB[3];
*cont = 0;
*stage = 0;
check_op(1);
if (!r_has_type(op, t_integer)) {
if (r_has_type(op, t_real)) {
Gray = op->value.realval;
} else
return_error(gs_error_typecheck);
} else
Gray = (float)op->value.intval;
if (Gray < 0 || Gray > 1)
return_error(gs_error_rangecheck);
switch (base) {
case 0:
/* Requested space is DeviceGray, just use the value */
make_real(op, Gray);
break;
case 1:
/* Requested space is HSB */
case 2:
/* Requested space is RGB, set all the components
* to the gray value
*/
push(2);
RGB[0] = RGB[1] = RGB[2] = Gray;
if (base == 1)
/* If the requested space is HSB, convert the RGB to HSB */
rgb2hsb((float *)&RGB);
make_real(&op[-2], RGB[0]);
make_real(&op[-1], RGB[1]);
make_real(op, RGB[2]);
break;
case 3:
/* Requested space is CMYK, use the gray value to set the
* black channel.
*/
push(3);
make_real(&op[-3], (float)0);
make_real(&op[-2], (float)0);
make_real(&op[-1], (float)0);
make_real(op, (float)1.0 - Gray);
break;
default:
return_error(gs_error_undefined);
}
return 0;
}
| 0 |
openssl | 4ad93618d26a3ea23d36ad5498ff4f59eff3a4d2 | NOT_APPLICABLE | NOT_APPLICABLE | static int ssl_check_ca_name(STACK_OF(X509_NAME) *names, X509 *x)
{
X509_NAME *nm;
int i;
nm = X509_get_issuer_name(x);
for (i = 0; i < sk_X509_NAME_num(names); i++) {
if (!X509_NAME_cmp(nm, sk_X509_NAME_value(names, i)))
return 1;
}
return 0;
}
| 0 |
linux | 451a2886b6bf90e2fb378f7c46c655450fb96e81 | NOT_APPLICABLE | NOT_APPLICABLE | sg_proc_write_adio(struct file *filp, const char __user *buffer,
size_t count, loff_t *off)
{
int err;
unsigned long num;
if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
return -EACCES;
err = kstrtoul_from_user(buffer, count, 0, &num);
if (err)
return err;
sg_allow_dio = num ? 1 : 0;
return count;
}
| 0 |
Chrome | c552cd7b8a0862f6b3c8c6a07f98bda3721101eb | NOT_APPLICABLE | NOT_APPLICABLE | ui::WindowShowState BrowserView::GetRestoredState() const {
gfx::Rect bounds;
ui::WindowShowState state;
frame_->GetWindowPlacement(&bounds, &state);
return state;
}
| 0 |
Chrome | 3aad1a37affb1ab70d1897f2b03eb8c077264984 | NOT_APPLICABLE | NOT_APPLICABLE | void GLES2DecoderImpl::DoAttachShader(
GLuint program_client_id, GLint shader_client_id) {
ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader(
program_client_id, "glAttachShader");
if (!program_info) {
return;
}
ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram(
shader_client_id, "glAttachShader");
if (!shader_info) {
return;
}
if (!program_info->AttachShader(shader_manager(), shader_info)) {
SetGLError(GL_INVALID_OPERATION,
"glAttachShader", "can not attach more than"
" one shader of the same type.");
return;
}
glAttachShader(program_info->service_id(), shader_info->service_id());
}
| 0 |
linux | 4442dc8a92b8f9ad8ee9e7f8438f4c04c03a22dc | CVE-2014-4027 | CWE-264 | static int rd_build_device_space(struct rd_dev *rd_dev)
{
u32 i = 0, j, page_offset = 0, sg_per_table, sg_tables, total_sg_needed;
u32 max_sg_per_table = (RD_MAX_ALLOCATION_SIZE /
sizeof(struct scatterlist));
struct rd_dev_sg_table *sg_table;
struct page *pg;
struct scatterlist *sg;
if (rd_dev->rd_page_count <= 0) {
pr_err("Illegal page count: %u for Ramdisk device\n",
rd_dev->rd_page_count);
return -EINVAL;
}
/* Don't need backing pages for NULLIO */
if (rd_dev->rd_flags & RDF_NULLIO)
return 0;
total_sg_needed = rd_dev->rd_page_count;
sg_tables = (total_sg_needed / max_sg_per_table) + 1;
sg_table = kzalloc(sg_tables * sizeof(struct rd_dev_sg_table), GFP_KERNEL);
if (!sg_table) {
pr_err("Unable to allocate memory for Ramdisk"
" scatterlist tables\n");
return -ENOMEM;
}
rd_dev->sg_table_array = sg_table;
rd_dev->sg_table_count = sg_tables;
while (total_sg_needed) {
sg_per_table = (total_sg_needed > max_sg_per_table) ?
max_sg_per_table : total_sg_needed;
sg = kzalloc(sg_per_table * sizeof(struct scatterlist),
GFP_KERNEL);
if (!sg) {
pr_err("Unable to allocate scatterlist array"
" for struct rd_dev\n");
return -ENOMEM;
}
sg_init_table(sg, sg_per_table);
sg_table[i].sg_table = sg;
sg_table[i].rd_sg_count = sg_per_table;
sg_table[i].page_start_offset = page_offset;
sg_table[i++].page_end_offset = (page_offset + sg_per_table)
- 1;
for (j = 0; j < sg_per_table; j++) {
pg = alloc_pages(GFP_KERNEL, 0);
if (!pg) {
pr_err("Unable to allocate scatterlist"
" pages for struct rd_dev_sg_table\n");
return -ENOMEM;
}
sg_assign_page(&sg[j], pg);
sg[j].length = PAGE_SIZE;
}
page_offset += sg_per_table;
total_sg_needed -= sg_per_table;
}
pr_debug("CORE_RD[%u] - Built Ramdisk Device ID: %u space of"
" %u pages in %u tables\n", rd_dev->rd_host->rd_host_id,
rd_dev->rd_dev_id, rd_dev->rd_page_count,
rd_dev->sg_table_count);
return 0;
}
| 1 |
php-src | 0bfb970f43acd1e81d11be1154805f86655f15d5 | NOT_APPLICABLE | NOT_APPLICABLE | int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int defaultstub, char **error) /* {{{ */
{
char *pos;
smart_str main_metadata_str = {0};
static const char newstub[] = "<?php // zip-based phar archive stub file\n__HALT_COMPILER();";
char halt_stub[] = "__HALT_COMPILER();";
char *tmp;
php_stream *stubfile, *oldfile;
php_serialize_data_t metadata_hash;
int free_user_stub, closeoldfile = 0;
phar_entry_info entry = {0};
char *temperr = NULL;
struct _phar_zip_pass pass;
phar_zip_dir_end eocd;
php_uint32 cdir_size, cdir_offset;
pass.error = &temperr;
entry.flags = PHAR_ENT_PERM_DEF_FILE;
entry.timestamp = time(NULL);
entry.is_modified = 1;
entry.is_zip = 1;
entry.phar = phar;
entry.fp_type = PHAR_MOD;
if (phar->is_persistent) {
if (error) {
spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
if (phar->is_data) {
goto nostub;
}
/* set alias */
if (!phar->is_temporary_alias && phar->alias_len) {
entry.fp = php_stream_fopen_tmpfile();
if (entry.fp == NULL) {
spprintf(error, 0, "phar error: unable to create temporary file");
return EOF;
}
if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) {
if (error) {
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
entry.uncompressed_filesize = entry.compressed_filesize = phar->alias_len;
entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1);
entry.filename_len = sizeof(".phar/alias.txt")-1;
if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
if (error) {
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
} else {
zend_hash_str_del(&phar->manifest, ".phar/alias.txt", sizeof(".phar/alias.txt")-1);
}
/* register alias */
if (phar->alias_len) {
if (FAILURE == phar_get_archive(&phar, phar->fname, phar->fname_len, phar->alias, phar->alias_len, error)) {
return EOF;
}
}
/* set stub */
if (user_stub && !defaultstub) {
if (len < 0) {
/* resource passed in */
if (!(php_stream_from_zval_no_verify(stubfile, (zval *)user_stub))) {
if (error) {
spprintf(error, 0, "unable to access resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
if (len == -1) {
len = PHP_STREAM_COPY_ALL;
} else {
len = -len;
}
user_stub = 0;
// TODO: refactor to avoid reallocation ???
//??? len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)
{
zend_string *str = php_stream_copy_to_mem(stubfile, len, 0);
if (str) {
len = ZSTR_LEN(str);
user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
zend_string_release(str);
} else {
user_stub = NULL;
len = 0;
}
}
if (!len || !user_stub) {
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
free_user_stub = 1;
} else {
free_user_stub = 0;
}
tmp = estrndup(user_stub, len);
if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
efree(tmp);
if (error) {
spprintf(error, 0, "illegal stub for zip-based phar \"%s\"", phar->fname);
}
if (free_user_stub) {
efree(user_stub);
}
return EOF;
}
pos = user_stub + (pos - tmp);
efree(tmp);
len = pos - user_stub + 18;
entry.fp = php_stream_fopen_tmpfile();
if (entry.fp == NULL) {
spprintf(error, 0, "phar error: unable to create temporary file");
return EOF;
}
entry.uncompressed_filesize = len + 5;
if ((size_t)len != php_stream_write(entry.fp, user_stub, len)
|| 5 != php_stream_write(entry.fp, " ?>\r\n", 5)) {
if (error) {
spprintf(error, 0, "unable to create stub from string in new zip-based phar \"%s\"", phar->fname);
}
if (free_user_stub) {
efree(user_stub);
}
php_stream_close(entry.fp);
return EOF;
}
entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
entry.filename_len = sizeof(".phar/stub.php")-1;
if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
if (free_user_stub) {
efree(user_stub);
}
if (error) {
spprintf(error, 0, "unable to set stub in zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
if (free_user_stub) {
efree(user_stub);
}
} else {
/* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */
entry.fp = php_stream_fopen_tmpfile();
if (entry.fp == NULL) {
spprintf(error, 0, "phar error: unable to create temporary file");
return EOF;
}
if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) {
php_stream_close(entry.fp);
if (error) {
spprintf(error, 0, "unable to %s stub in%szip-based phar \"%s\", failed", user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname);
}
return EOF;
}
entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1;
entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1);
entry.filename_len = sizeof(".phar/stub.php")-1;
if (!defaultstub) {
if (!zend_hash_str_exists(&phar->manifest, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
if (NULL == zend_hash_str_add_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
php_stream_close(entry.fp);
efree(entry.filename);
if (error) {
spprintf(error, 0, "unable to create stub in zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
} else {
php_stream_close(entry.fp);
efree(entry.filename);
}
} else {
if (NULL == zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info))) {
php_stream_close(entry.fp);
efree(entry.filename);
if (error) {
spprintf(error, 0, "unable to overwrite stub in zip-based phar \"%s\"", phar->fname);
}
return EOF;
}
}
}
nostub:
if (phar->fp && !phar->is_brandnew) {
oldfile = phar->fp;
closeoldfile = 0;
php_stream_rewind(oldfile);
} else {
oldfile = php_stream_open_wrapper(phar->fname, "rb", 0, NULL);
closeoldfile = oldfile != NULL;
}
/* save modified files to the zip */
pass.old = oldfile;
pass.filefp = php_stream_fopen_tmpfile();
if (!pass.filefp) {
fperror:
if (closeoldfile) {
php_stream_close(oldfile);
}
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to open temporary file", phar->fname);
}
return EOF;
}
pass.centralfp = php_stream_fopen_tmpfile();
if (!pass.centralfp) {
goto fperror;
}
pass.free_fp = pass.free_ufp = 1;
memset(&eocd, 0, sizeof(eocd));
strncpy(eocd.signature, "PK\5\6", 4);
if (!phar->is_data && !phar->sig_flags) {
phar->sig_flags = PHAR_SIG_SHA1;
}
if (phar->sig_flags) {
PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest) + 1);
PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest) + 1);
} else {
PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest));
PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest));
}
zend_hash_apply_with_argument(&phar->manifest, phar_zip_changed_apply, (void *) &pass);
if (Z_TYPE(phar->metadata) != IS_UNDEF) {
/* set phar metadata */
PHP_VAR_SERIALIZE_INIT(metadata_hash);
php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
}
if (temperr) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr);
}
efree(temperr);
temperror:
php_stream_close(pass.centralfp);
nocentralerror:
if (Z_TYPE(phar->metadata) != IS_UNDEF) {
smart_str_free(&main_metadata_str);
}
php_stream_close(pass.filefp);
if (closeoldfile) {
php_stream_close(oldfile);
}
return EOF;
}
if (FAILURE == phar_zip_applysignature(phar, &pass, &main_metadata_str)) {
goto temperror;
}
/* save zip */
cdir_size = php_stream_tell(pass.centralfp);
cdir_offset = php_stream_tell(pass.filefp);
PHAR_SET_32(eocd.cdir_size, cdir_size);
PHAR_SET_32(eocd.cdir_offset, cdir_offset);
php_stream_seek(pass.centralfp, 0, SEEK_SET);
{
size_t clen;
int ret = php_stream_copy_to_stream_ex(pass.centralfp, pass.filefp, PHP_STREAM_COPY_ALL, &clen);
if (SUCCESS != ret || clen != cdir_size) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname);
}
goto temperror;
}
}
php_stream_close(pass.centralfp);
if (Z_TYPE(phar->metadata) != IS_UNDEF) {
/* set phar metadata */
PHAR_SET_16(eocd.comment_len, ZSTR_LEN(main_metadata_str.s));
if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname);
}
goto nocentralerror;
}
if (ZSTR_LEN(main_metadata_str.s) != php_stream_write(pass.filefp, ZSTR_VAL(main_metadata_str.s), ZSTR_LEN(main_metadata_str.s))) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname);
}
goto nocentralerror;
}
smart_str_free(&main_metadata_str);
} else {
if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname);
}
goto nocentralerror;
}
}
if (phar->fp && pass.free_fp) {
php_stream_close(phar->fp);
}
if (phar->ufp) {
if (pass.free_ufp) {
php_stream_close(phar->ufp);
}
phar->ufp = NULL;
}
/* re-open */
phar->is_brandnew = 0;
if (phar->donotflush) {
/* deferred flush */
phar->fp = pass.filefp;
} else {
phar->fp = php_stream_open_wrapper(phar->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
if (!phar->fp) {
if (closeoldfile) {
php_stream_close(oldfile);
}
phar->fp = pass.filefp;
if (error) {
spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname);
}
return EOF;
}
php_stream_rewind(pass.filefp);
php_stream_copy_to_stream_ex(pass.filefp, phar->fp, PHP_STREAM_COPY_ALL, NULL);
/* we could also reopen the file in "rb" mode but there is no need for that */
php_stream_close(pass.filefp);
}
if (closeoldfile) {
php_stream_close(oldfile);
}
return EOF;
} | 0 |
linux | fa40d9734a57bcbfa79a280189799f76c88f7bb0 | NOT_APPLICABLE | NOT_APPLICABLE | static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead,
u8 tx_key, struct sk_buff *skb,
struct tipc_crypto *__rx)
{
struct tipc_msg *hdr = buf_msg(skb);
struct tipc_ehdr *ehdr;
u32 user = msg_user(hdr);
u64 seqno;
int ehsz;
/* Make room for encryption header */
ehsz = (user != LINK_CONFIG) ? EHDR_SIZE : EHDR_CFG_SIZE;
WARN_ON(skb_headroom(skb) < ehsz);
ehdr = (struct tipc_ehdr *)skb_push(skb, ehsz);
/* Obtain a seqno first:
* Use the key seqno (= cluster wise) if dest is unknown or we're in
* cluster key mode, otherwise it's better for a per-peer seqno!
*/
if (!__rx || aead->mode == CLUSTER_KEY)
seqno = atomic64_inc_return(&aead->seqno);
else
seqno = atomic64_inc_return(&__rx->sndnxt);
/* Revoke the key if seqno is wrapped around */
if (unlikely(!seqno))
return tipc_crypto_key_revoke(net, tx_key);
/* Word 1-2 */
ehdr->seqno = cpu_to_be64(seqno);
/* Words 0, 3- */
ehdr->version = TIPC_EVERSION;
ehdr->user = 0;
ehdr->keepalive = 0;
ehdr->tx_key = tx_key;
ehdr->destined = (__rx) ? 1 : 0;
ehdr->rx_key_active = (__rx) ? __rx->key.active : 0;
ehdr->rx_nokey = (__rx) ? __rx->nokey : 0;
ehdr->master_key = aead->crypto->key_master;
ehdr->reserved_1 = 0;
ehdr->reserved_2 = 0;
switch (user) {
case LINK_CONFIG:
ehdr->user = LINK_CONFIG;
memcpy(ehdr->id, tipc_own_id(net), NODE_ID_LEN);
break;
default:
if (user == LINK_PROTOCOL && msg_type(hdr) == STATE_MSG) {
ehdr->user = LINK_PROTOCOL;
ehdr->keepalive = msg_is_keepalive(hdr);
}
ehdr->addr = hdr->hdr[3];
break;
}
return ehsz;
} | 0 |
CImg | 10af1e8c1ad2a58a0a3342a856bae63e8f257abb | NOT_APPLICABLE | NOT_APPLICABLE |
static double mp_list_jxyzc(_cimg_math_parser& mp) {
const unsigned int
ind = (unsigned int)cimg::mod((int)_mp_arg(2),mp.listin.width()),
interpolation = (unsigned int)_mp_arg(7),
boundary_conditions = (unsigned int)_mp_arg(8);
const CImg<T> &img = mp.listin[ind];
const double
ox = mp.mem[_cimg_mp_slot_x], oy = mp.mem[_cimg_mp_slot_y],
oz = mp.mem[_cimg_mp_slot_z], oc = mp.mem[_cimg_mp_slot_c],
x = ox + _mp_arg(3), y = oy + _mp_arg(4),
z = oz + _mp_arg(5), c = oc + _mp_arg(6);
if (interpolation==0) switch (boundary_conditions) { // Nearest neighbor interpolation
case 3 : { // Mirror
const int
w2 = 2*img.width(), h2 = 2*img.height(), d2 = 2*img.depth(), s2 = 2*img.spectrum(),
mx = cimg::mod((int)x,w2), my = cimg::mod((int)y,h2),
mz = cimg::mod((int)z,d2), mc = cimg::mod((int)c,s2);
return (double)img(mx<img.width()?mx:w2 - mx - 1,
my<img.height()?my:h2 - my - 1,
mz<img.depth()?mz:d2 - mz - 1,
mc<img.spectrum()?mc:s2 - mc - 1);
}
case 2 : // Periodic
return (double)img(cimg::mod((int)x,img.width()),
cimg::mod((int)y,img.height()),
cimg::mod((int)z,img.depth()),
cimg::mod((int)c,img.spectrum()));
case 1 : // Neumann
return (double)img._atXYZC((int)x,(int)y,(int)z,(int)c);
default : // Dirichlet
return (double)img.atXYZC((int)x,(int)y,(int)z,(int)c,(T)0);
} else switch (boundary_conditions) { // Linear interpolation
case 3 : { // Mirror
const float
w2 = 2.0f*img.width(), h2 = 2.0f*img.height(), d2 = 2.0f*img.depth(), s2 = 2.0f*img.spectrum(),
mx = cimg::mod((float)x,w2), my = cimg::mod((float)y,h2),
mz = cimg::mod((float)z,d2), mc = cimg::mod((float)c,s2);
return (double)img._linear_atXYZC(mx<img.width()?mx:w2 - mx - 1,
my<img.height()?my:h2 - my - 1,
mz<img.depth()?mz:d2 - mz - 1,
mc<img.spectrum()?mc:s2 - mc - 1);
}
case 2 : // Periodic
return (double)img._linear_atXYZC(cimg::mod((float)x,(float)img.width()),
cimg::mod((float)y,(float)img.height()),
cimg::mod((float)z,(float)img.depth()),
cimg::mod((float)c,(float)img.spectrum()));
case 1 : // Neumann
return (double)img._linear_atXYZC((float)x,(float)y,(float)z,(float)c);
default : // Dirichlet
return (double)img.linear_atXYZC((float)x,(float)y,(float)z,(float)c,(T)0);
} | 0 |
net | e40607cbe270a9e8360907cb1e62ddf0736e4864 | NOT_APPLICABLE | NOT_APPLICABLE | static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
const struct sctp_association *asoc,
const struct sctp_chunk *init_chunk,
int *cookie_len,
const __u8 *raw_addrs, int addrs_len)
{
sctp_cookie_param_t *retval;
struct sctp_signed_cookie *cookie;
struct scatterlist sg;
int headersize, bodysize;
/* Header size is static data prior to the actual cookie, including
* any padding.
*/
headersize = sizeof(sctp_paramhdr_t) +
(sizeof(struct sctp_signed_cookie) -
sizeof(struct sctp_cookie));
bodysize = sizeof(struct sctp_cookie)
+ ntohs(init_chunk->chunk_hdr->length) + addrs_len;
/* Pad out the cookie to a multiple to make the signature
* functions simpler to write.
*/
if (bodysize % SCTP_COOKIE_MULTIPLE)
bodysize += SCTP_COOKIE_MULTIPLE
- (bodysize % SCTP_COOKIE_MULTIPLE);
*cookie_len = headersize + bodysize;
/* Clear this memory since we are sending this data structure
* out on the network.
*/
retval = kzalloc(*cookie_len, GFP_ATOMIC);
if (!retval)
goto nodata;
cookie = (struct sctp_signed_cookie *) retval->body;
/* Set up the parameter header. */
retval->p.type = SCTP_PARAM_STATE_COOKIE;
retval->p.length = htons(*cookie_len);
/* Copy the cookie part of the association itself. */
cookie->c = asoc->c;
/* Save the raw address list length in the cookie. */
cookie->c.raw_addr_list_len = addrs_len;
/* Remember PR-SCTP capability. */
cookie->c.prsctp_capable = asoc->peer.prsctp_capable;
/* Save adaptation indication in the cookie. */
cookie->c.adaptation_ind = asoc->peer.adaptation_ind;
/* Set an expiration time for the cookie. */
cookie->c.expiration = ktime_add(asoc->cookie_life,
ktime_get());
/* Copy the peer's init packet. */
memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr,
ntohs(init_chunk->chunk_hdr->length));
/* Copy the raw local address list of the association. */
memcpy((__u8 *)&cookie->c.peer_init[0] +
ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len);
if (sctp_sk(ep->base.sk)->hmac) {
struct hash_desc desc;
/* Sign the message. */
sg_init_one(&sg, &cookie->c, bodysize);
desc.tfm = sctp_sk(ep->base.sk)->hmac;
desc.flags = 0;
if (crypto_hash_setkey(desc.tfm, ep->secret_key,
sizeof(ep->secret_key)) ||
crypto_hash_digest(&desc, &sg, bodysize, cookie->signature))
goto free_cookie;
}
return retval;
free_cookie:
kfree(retval);
nodata:
*cookie_len = 0;
return NULL;
} | 0 |
linux | 15753588bcd4bbffae1cca33c8ced5722477fe1f | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t interf_grp_compatible_id_show(struct config_item *item,
char *page)
{
memcpy(page, to_usb_os_desc(item)->ext_compat_id, 8);
return 8;
} | 0 |
linux | ded89912156b1a47d940a0c954c43afbabd0c42c | NOT_APPLICABLE | NOT_APPLICABLE | brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable)
{
s32 err;
u32 mode;
if (enable)
mode = BRCMF_ARP_OL_AGENT | BRCMF_ARP_OL_PEER_AUTO_REPLY;
else
mode = 0;
/* Try to set and enable ARP offload feature, this may fail, then it */
/* is simply not supported and err 0 will be returned */
err = brcmf_fil_iovar_int_set(ifp, "arp_ol", mode);
if (err) {
brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, err = %d\n",
mode, err);
err = 0;
} else {
err = brcmf_fil_iovar_int_set(ifp, "arpoe", enable);
if (err) {
brcmf_dbg(TRACE, "failed to configure (%d) ARP offload err = %d\n",
enable, err);
err = 0;
} else
brcmf_dbg(TRACE, "successfully configured (%d) ARP offload to 0x%x\n",
enable, mode);
}
err = brcmf_fil_iovar_int_set(ifp, "ndoe", enable);
if (err) {
brcmf_dbg(TRACE, "failed to configure (%d) ND offload err = %d\n",
enable, err);
err = 0;
} else
brcmf_dbg(TRACE, "successfully configured (%d) ND offload to 0x%x\n",
enable, mode);
return err;
}
| 0 |
openldap | 8c1d96ee36ed98b32cd0e28b7069c7b8ea09d793 | NOT_APPLICABLE | NOT_APPLICABLE | ldap_pvt_tls_accept( Sockbuf *sb, void *ctx_arg )
{
int err;
tls_session *ssl = NULL;
if ( HAS_TLS( sb )) {
ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_SSL, (void *)&ssl );
} else {
ssl = alloc_handle( ctx_arg, 1 );
if ( ssl == NULL ) return -1;
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( sb, &ber_sockbuf_io_debug,
LBER_SBIOD_LEVEL_TRANSPORT, (void *)"tls_" );
#endif
ber_sockbuf_add_io( sb, tls_imp->ti_sbio,
LBER_SBIOD_LEVEL_TRANSPORT, (void *)ssl );
}
err = tls_imp->ti_session_accept( ssl );
#ifdef HAVE_WINSOCK
errno = WSAGetLastError();
#endif
if ( err < 0 )
{
if ( update_flags( sb, ssl, err )) return 1;
if ( DebugTest( LDAP_DEBUG_ANY ) ) {
char buf[256], *msg;
msg = tls_imp->ti_session_errmsg( ssl, err, buf, sizeof(buf) );
Debug( LDAP_DEBUG_ANY,"TLS: can't accept: %s.\n",
msg ? msg : "(unknown)", 0, 0 );
}
ber_sockbuf_remove_io( sb, tls_imp->ti_sbio,
LBER_SBIOD_LEVEL_TRANSPORT );
#ifdef LDAP_DEBUG
ber_sockbuf_remove_io( sb, &ber_sockbuf_io_debug,
LBER_SBIOD_LEVEL_TRANSPORT );
#endif
return -1;
}
return 0;
} | 0 |
exiv2 | ae49250942f4395639961abeed3c15920fcd7241 | NOT_APPLICABLE | NOT_APPLICABLE | void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,uint32_t start,bool bSwap,char c,int depth)
{
depth++;
bool bFirst = true ;
// buffer
const size_t dirSize = 32;
DataBuf dir(dirSize);
bool bPrint = option == kpsBasic || option == kpsRecursive;
do {
// Read top of directory
const int seekSuccess = !io.seek(start,BasicIo::beg);
const long bytesRead = io.read(dir.pData_, 2);
if (!seekSuccess || bytesRead == 0) {
throw Error(kerCorruptedMetadata);
}
uint16_t dirLength = byteSwap2(dir,0,bSwap);
bool tooBig = dirLength > 500;
if ( tooBig ) throw Error(kerTiffDirectoryTooLarge);
if ( bFirst && bPrint ) {
out << Internal::indent(depth) << Internal::stringFormat("STRUCTURE OF TIFF FILE (%c%c): ",c,c) << io.path() << std::endl;
if ( tooBig ) out << Internal::indent(depth) << "dirLength = " << dirLength << std::endl;
}
// Read the dictionary
for ( int i = 0 ; i < dirLength ; i ++ ) {
if ( bFirst && bPrint ) {
out << Internal::indent(depth)
<< " address | tag | "
<< " type | count | offset | value\n";
}
bFirst = false;
io.read(dir.pData_, 12);
uint16_t tag = byteSwap2(dir,0,bSwap);
uint16_t type = byteSwap2(dir,2,bSwap);
uint32_t count = byteSwap4(dir,4,bSwap);
uint32_t offset = byteSwap4(dir,8,bSwap);
// Break for unknown tag types else we may segfault.
if ( !typeValid(type) ) {
std::cerr << "invalid type value detected in Image::printIFDStructure: " << type << std::endl;
start = 0; // break from do loop
throw Error(kerInvalidTypeValue);
}
std::string sp = "" ; // output spacer
//prepare to print the value
uint32_t kount = isPrintXMP(tag,option) ? count // haul in all the data
: isPrintICC(tag,option) ? count // ditto
: isStringType(type) ? (count > 32 ? 32 : count) // restrict long arrays
: count > 5 ? 5
: count
;
uint32_t pad = isStringType(type) ? 1 : 0;
uint32_t size = isStringType(type) ? 1
: is2ByteType(type) ? 2
: is4ByteType(type) ? 4
: is8ByteType(type) ? 8
: 1
;
// if ( offset > io.size() ) offset = 0; // Denial of service?
// #55 and #56 memory allocation crash test/data/POC8
long long allocate = (long long) size*count + pad+20;
if ( allocate > (long long) io.size() ) {
throw Error(kerInvalidMalloc);
}
DataBuf buf((long)allocate); // allocate a buffer
std::memset(buf.pData_, 0, buf.size_);
std::memcpy(buf.pData_,dir.pData_+8,4); // copy dir[8:11] into buffer (short strings)
const bool bOffsetIsPointer = count*size > 4;
if ( bOffsetIsPointer ) { // read into buffer
size_t restore = io.tell(); // save
io.seek(offset,BasicIo::beg); // position
io.read(buf.pData_,count*size);// read
io.seek(restore,BasicIo::beg); // restore
}
if ( bPrint ) {
const uint32_t address = start + 2 + i*12 ;
const std::string offsetString = bOffsetIsPointer?
Internal::stringFormat("%10u", offset):
"";
out << Internal::indent(depth)
<< Internal::stringFormat("%8u | %#06x %-28s |%10s |%9u |%10s | "
,address,tag,tagName(tag).c_str(),typeName(type),count,offsetString.c_str());
if ( isShortType(type) ){
for ( size_t k = 0 ; k < kount ; k++ ) {
out << sp << byteSwap2(buf,k*size,bSwap);
sp = " ";
}
} else if ( isLongType(type) ){
for ( size_t k = 0 ; k < kount ; k++ ) {
out << sp << byteSwap4(buf,k*size,bSwap);
sp = " ";
}
} else if ( isRationalType(type) ){
for ( size_t k = 0 ; k < kount ; k++ ) {
uint32_t a = byteSwap4(buf,k*size+0,bSwap);
uint32_t b = byteSwap4(buf,k*size+4,bSwap);
out << sp << a << "/" << b;
sp = " ";
}
} else if ( isStringType(type) ) {
out << sp << Internal::binaryToString(makeSlice(buf, 0, kount));
}
sp = kount == count ? "" : " ...";
out << sp << std::endl;
if ( option == kpsRecursive && (tag == 0x8769 /* ExifTag */ || tag == 0x014a/*SubIFDs*/ || type == tiffIfd) ) {
for ( size_t k = 0 ; k < count ; k++ ) {
size_t restore = io.tell();
uint32_t offset = byteSwap4(buf,k*size,bSwap);
printIFDStructure(io,out,option,offset,bSwap,c,depth);
io.seek(restore,BasicIo::beg);
}
} else if ( option == kpsRecursive && tag == 0x83bb /* IPTCNAA */ ) {
if (static_cast<size_t>(Safe::add(count, offset)) > io.size()) {
throw Error(kerCorruptedMetadata);
}
const size_t restore = io.tell();
io.seek(offset, BasicIo::beg); // position
std::vector<byte> bytes(count) ; // allocate memory
// TODO: once we have C++11 use bytes.data()
const long read_bytes = io.read(&bytes[0], count);
io.seek(restore, BasicIo::beg);
// TODO: once we have C++11 use bytes.data()
IptcData::printStructure(out, makeSliceUntil(&bytes[0], read_bytes), depth);
} else if ( option == kpsRecursive && tag == 0x927c /* MakerNote */ && count > 10) {
size_t restore = io.tell(); // save
uint32_t jump= 10 ;
byte bytes[20] ;
const char* chars = (const char*) &bytes[0] ;
io.seek(offset,BasicIo::beg); // position
io.read(bytes,jump ) ; // read
bytes[jump]=0 ;
if ( ::strcmp("Nikon",chars) == 0 ) {
// tag is an embedded tiff
byte* bytes=new byte[count-jump] ; // allocate memory
io.read(bytes,count-jump) ; // read
MemIo memIo(bytes,count-jump) ; // create a file
printTiffStructure(memIo,out,option,depth);
delete[] bytes ; // free
} else {
// tag is an IFD
io.seek(0,BasicIo::beg); // position
printIFDStructure(io,out,option,offset,bSwap,c,depth);
}
io.seek(restore,BasicIo::beg); // restore
}
}
if ( isPrintXMP(tag,option) ) {
buf.pData_[count]=0;
out << (char*) buf.pData_;
}
if ( isPrintICC(tag,option) ) {
out.write((const char*)buf.pData_,count);
}
}
if ( start ) {
io.read(dir.pData_, 4);
start = tooBig ? 0 : byteSwap4(dir,0,bSwap);
}
} while (start) ;
if ( bPrint ) {
out << Internal::indent(depth) << "END " << io.path() << std::endl;
}
out.flush();
depth--;
} | 0 |
ovs | 65c61b0c23a0d474696d7b1cea522a5016a8aeb3 | NOT_APPLICABLE | NOT_APPLICABLE | format_WRITE_METADATA(const struct ofpact_metadata *a,
const struct ofpact_format_params *fp)
{
ds_put_format(fp->s, "%swrite_metadata:%s%#"PRIx64,
colors.param, colors.end, ntohll(a->metadata));
if (a->mask != OVS_BE64_MAX) {
ds_put_format(fp->s, "/%#"PRIx64, ntohll(a->mask));
}
} | 0 |
spnego-http-auth-nginx-module | a06f9efca373e25328b1c53639a48decd0854570 | NOT_APPLICABLE | NOT_APPLICABLE | ngx_http_auth_spnego_token(
ngx_http_request_t *r,
ngx_http_auth_spnego_ctx_t *ctx)
{
ngx_str_t token;
ngx_str_t decoded;
size_t nego_sz = sizeof("Negotiate");
if (NULL == r->headers_in.authorization) {
return NGX_DECLINED;
}
/* but don't decode second time? */
if (ctx->token.len)
return NGX_OK;
token = r->headers_in.authorization->value;
if (token.len < nego_sz ||
ngx_strncasecmp(token.data, (u_char *) "Negotiate ", nego_sz) != 0) {
if (ngx_strncasecmp(
token.data, (u_char *) "NTLM", sizeof("NTLM")) == 0) {
spnego_log_error("Detected unsupported mechanism: NTLM");
}
return NGX_DECLINED;
}
token.len -= nego_sz;
token.data += nego_sz;
while (token.len && token.data[0] == ' ') {
token.len--;
token.data++;
}
if (token.len == 0) {
return NGX_DECLINED;
}
decoded.len = ngx_base64_decoded_length(token.len);
decoded.data = ngx_pnalloc(r->pool, decoded.len);
if (NULL == decoded.data) {
return NGX_ERROR;
}
if (ngx_decode_base64(&decoded, &token) != NGX_OK) {
return NGX_DECLINED;
}
ctx->token.len = decoded.len;
ctx->token.data = decoded.data;
spnego_debug2("Token decoded: %*s", token.len, token.data);
return NGX_OK;
} | 0 |
Android | 8b4ed5a23175b7ffa56eea4678db7287f825e985 | NOT_APPLICABLE | NOT_APPLICABLE | WORD16 impeg2d_dec_vld_symbol(stream_t *ps_stream,const WORD16 ai2_code_table[][2], UWORD16 u2_max_len)
{
UWORD16 u2_data;
WORD16 u2_end = 0;
UWORD16 u2_org_max_len = u2_max_len;
UWORD16 u2_i_bit;
/* Get the maximum number of bits needed to decode a symbol */
u2_data = impeg2d_bit_stream_nxt(ps_stream,u2_max_len);
do
{
u2_max_len--;
/* Read one bit at a time from the variable to decode the huffman code */
u2_i_bit = (UWORD8)((u2_data >> u2_max_len) & 0x1);
/* Get the next node pointer or the symbol from the tree */
u2_end = ai2_code_table[u2_end][u2_i_bit];
}while(u2_end > 0);
/* Flush the appropriate number of bits from the ps_stream */
impeg2d_bit_stream_flush(ps_stream,(UWORD8)(u2_org_max_len - u2_max_len));
return(u2_end);
}
| 0 |
exiv2 | c72d16f4c402a8acc2dfe06fe3d58bf6cf99069e | NOT_APPLICABLE | NOT_APPLICABLE | PentaxDngMnHeader::~PentaxDngMnHeader()
{
} | 0 |
Chrome | 5385c44d9634d00b1cec2abf0fe7290d4205c7b0 | NOT_APPLICABLE | NOT_APPLICABLE | void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) {
scoped_refptr<SSLRequestInfo> info(new SSLRequestInfo(
details->url(),
ResourceType::SUB_RESOURCE,
details->pid(),
details->ssl_cert_id(),
details->ssl_cert_status()));
policy()->OnRequestStarted(info.get());
}
| 0 |
Chrome | 5cfe3023574666663d970ce48cdbc8ed15ce61d9 | NOT_APPLICABLE | NOT_APPLICABLE | gfx::Size AutofillDialogViews::GetMinimumSize() const {
return CalculatePreferredSize(true);
}
| 0 |
openssl | 1fb9fdc3027b27d8eb6a1e6a846435b070980770 | NOT_APPLICABLE | NOT_APPLICABLE | void ssl3_cbc_copy_mac(unsigned char *out,
const SSL3_RECORD *rec, unsigned md_size)
{
#if defined(CBC_MAC_ROTATE_IN_PLACE)
unsigned char rotated_mac_buf[64 + EVP_MAX_MD_SIZE];
unsigned char *rotated_mac;
#else
unsigned char rotated_mac[EVP_MAX_MD_SIZE];
#endif
/*
* mac_end is the index of |rec->data| just after the end of the MAC.
*/
unsigned mac_end = rec->length;
unsigned mac_start = mac_end - md_size;
/*
* scan_start contains the number of bytes that we can ignore because the
* MAC's position can only vary by 255 bytes.
*/
unsigned scan_start = 0;
unsigned i, j;
unsigned div_spoiler;
unsigned rotate_offset;
OPENSSL_assert(rec->orig_len >= md_size);
OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE);
#if defined(CBC_MAC_ROTATE_IN_PLACE)
rotated_mac = rotated_mac_buf + ((0 - (size_t)rotated_mac_buf) & 63);
#endif
/* This information is public so it's safe to branch based on it. */
if (rec->orig_len > md_size + 255 + 1)
scan_start = rec->orig_len - (md_size + 255 + 1);
/*
* div_spoiler contains a multiple of md_size that is used to cause the
* modulo operation to be constant time. Without this, the time varies
* based on the amount of padding when running on Intel chips at least.
* The aim of right-shifting md_size is so that the compiler doesn't
* figure out that it can remove div_spoiler as that would require it to
* prove that md_size is always even, which I hope is beyond it.
*/
div_spoiler = md_size >> 1;
div_spoiler <<= (sizeof(div_spoiler) - 1) * 8;
rotate_offset = (div_spoiler + mac_start - scan_start) % md_size;
memset(rotated_mac, 0, md_size);
for (i = scan_start, j = 0; i < rec->orig_len; i++) {
unsigned char mac_started = constant_time_ge_8(i, mac_start);
unsigned char mac_ended = constant_time_ge_8(i, mac_end);
unsigned char b = rec->data[i];
rotated_mac[j++] |= b & mac_started & ~mac_ended;
j &= constant_time_lt(j, md_size);
}
/* Now rotate the MAC */
#if defined(CBC_MAC_ROTATE_IN_PLACE)
j = 0;
for (i = 0; i < md_size; i++) {
/* in case cache-line is 32 bytes, touch second line */
((volatile unsigned char *)rotated_mac)[rotate_offset ^ 32];
out[j++] = rotated_mac[rotate_offset++];
rotate_offset &= constant_time_lt(rotate_offset, md_size);
}
#else
memset(out, 0, md_size);
rotate_offset = md_size - rotate_offset;
rotate_offset &= constant_time_lt(rotate_offset, md_size);
for (i = 0; i < md_size; i++) {
for (j = 0; j < md_size; j++)
out[j] |= rotated_mac[i] & constant_time_eq_8(j, rotate_offset);
rotate_offset++;
rotate_offset &= constant_time_lt(rotate_offset, md_size);
}
#endif
}
| 0 |
wesnoth | f8914468182e8d0a1551b430c0879ba236fe4d6d | NOT_APPLICABLE | NOT_APPLICABLE | std::codecvt_base::result unshift( std::mbstate_t& /*state*/,
char* /*to*/,
char* /*to_end*/,
char*& /*to_next*/) const
{
//Not used by boost filesystem
throw "Not supported";
} | 0 |
qemu | 4154c7e03fa55b4cf52509a83d50d6c09d743b77 | NOT_APPLICABLE | NOT_APPLICABLE | e1000e_autoneg_timer(void *opaque)
{
E1000ECore *core = opaque;
if (!qemu_get_queue(core->owner_nic)->link_down) {
e1000x_update_regs_on_autoneg_done(core->mac, core->phy[0]);
e1000e_start_recv(core);
e1000e_update_flowctl_status(core);
/* signal link status change to the guest */
e1000e_set_interrupt_cause(core, E1000_ICR_LSC);
}
}
| 0 |
sqlite | 8654186b0236d556aa85528c2573ee0b6ab71be3 | NOT_APPLICABLE | NOT_APPLICABLE | void sqlite3VdbeCountChanges(Vdbe *v){
v->changeCntOn = 1;
} | 0 |
Chrome | 6bdf46c517fd12674ffc61d827dc8987e67f0334 | NOT_APPLICABLE | NOT_APPLICABLE | void ReverbConvolverStage::process(const float* source, size_t framesToProcess)
{
ASSERT(source);
if (!source)
return;
const float* preDelayedSource;
float* preDelayedDestination;
float* temporaryBuffer;
bool isTemporaryBufferSafe = false;
if (m_preDelayLength > 0) {
bool isPreDelaySafe = m_preReadWriteIndex + framesToProcess <= m_preDelayBuffer.size();
ASSERT(isPreDelaySafe);
if (!isPreDelaySafe)
return;
isTemporaryBufferSafe = framesToProcess <= m_temporaryBuffer.size();
preDelayedDestination = m_preDelayBuffer.data() + m_preReadWriteIndex;
preDelayedSource = preDelayedDestination;
temporaryBuffer = m_temporaryBuffer.data();
} else {
preDelayedDestination = 0;
preDelayedSource = source;
temporaryBuffer = m_preDelayBuffer.data();
isTemporaryBufferSafe = framesToProcess <= m_preDelayBuffer.size();
}
ASSERT(isTemporaryBufferSafe);
if (!isTemporaryBufferSafe)
return;
if (m_framesProcessed < m_preDelayLength) {
m_accumulationBuffer->updateReadIndex(&m_accumulationReadIndex, framesToProcess);
} else {
if (!m_directMode)
m_fftConvolver->process(m_fftKernel.get(), preDelayedSource, temporaryBuffer, framesToProcess);
else
m_directConvolver->process(m_directKernel.get(), preDelayedSource, temporaryBuffer, framesToProcess);
m_accumulationBuffer->accumulate(temporaryBuffer, framesToProcess, &m_accumulationReadIndex, m_postDelayLength);
}
if (m_preDelayLength > 0) {
memcpy(preDelayedDestination, source, sizeof(float) * framesToProcess);
m_preReadWriteIndex += framesToProcess;
ASSERT(m_preReadWriteIndex <= m_preDelayLength);
if (m_preReadWriteIndex >= m_preDelayLength)
m_preReadWriteIndex = 0;
}
m_framesProcessed += framesToProcess;
}
| 0 |
raptor | a676f235309a59d4aa78eeffd2574ae5d341fcb0 | NOT_APPLICABLE | NOT_APPLICABLE | raptor_rss_emit_item(raptor_parser* rdf_parser, raptor_rss_item *item)
{
raptor_rss_parser* rss_parser = (raptor_rss_parser*)rdf_parser->context;
int f;
raptor_rss_block *block;
raptor_uri *type_uri;
if(!item->fields_count)
return 0;
/* HACK - FIXME - set correct atom output class type */
if(item->node_typei == RAPTOR_ATOM_AUTHOR)
type_uri = rdf_parser->world->rss_fields_info_uris[RAPTOR_RSS_RDF_ATOM_AUTHOR_CLASS];
else
type_uri = rdf_parser->world->rss_types_info_uris[item->node_typei];
if(raptor_rss_emit_type_triple(rdf_parser, item->term, type_uri))
return 1;
for(f = 0; f< RAPTOR_RSS_FIELDS_SIZE; f++) {
raptor_rss_field* field;
raptor_uri* predicate_uri = NULL;
raptor_term* predicate_term = NULL;
/* This is only made by a connection */
if(f == RAPTOR_RSS_FIELD_ITEMS)
continue;
/* skip predicates with no URI (no namespace e.g. RSS 2) */
predicate_uri = rdf_parser->world->rss_fields_info_uris[f];
if(!predicate_uri)
continue;
predicate_term = raptor_new_term_from_uri(rdf_parser->world,
predicate_uri);
if(!predicate_term)
continue;
rss_parser->statement.predicate = predicate_term;
for(field = item->fields[f]; field; field = field->next) {
raptor_term* object_term;
if(field->value) {
/* FIXME - should store and emit languages */
object_term = raptor_new_term_from_literal(rdf_parser->world,
field->value,
NULL, NULL);
} else {
object_term = raptor_new_term_from_uri(rdf_parser->world,
field->uri);
}
rss_parser->statement.object = object_term;
/* Generate the statement */
(*rdf_parser->statement_handler)(rdf_parser->user_data,
&rss_parser->statement);
raptor_free_term(object_term);
}
raptor_free_term(predicate_term);
}
for(block = item->blocks; block; block = block->next) {
raptor_rss_emit_block(rdf_parser, item->term, block);
}
return 0;
}
| 0 |
Chrome | f85a87ec670ad0fce9d98d90c9a705b72a288154 | NOT_APPLICABLE | NOT_APPLICABLE | static void classAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
imp->setAttribute(HTMLNames::classAttr, cppValue);
}
| 0 |
Android | a24543157ae2cdd25da43e20f4e48a07481e6ceb | NOT_APPLICABLE | NOT_APPLICABLE | static uint32_t GetEntryForIndexImpl(Isolate* isolate, JSObject* holder,
FixedArrayBase* backing_store,
uint32_t index, PropertyFilter filter) {
uint32_t length = Subclass::GetMaxIndex(holder, backing_store);
if (IsHoleyElementsKind(kind())) {
return index < length &&
!BackingStore::cast(backing_store)
->is_the_hole(isolate, index)
? index
: kMaxUInt32;
} else {
return index < length ? index : kMaxUInt32;
}
}
| 0 |
sqlite | 5f69512404cd2e5153ddf90ea277fbba6dd58ab7 | NOT_APPLICABLE | NOT_APPLICABLE | static int tableAndColumnIndex(
SrcList *pSrc, /* Array of tables to search */
int N, /* Number of tables in pSrc->a[] to search */
const char *zCol, /* Name of the column we are looking for */
int *piTab, /* Write index of pSrc->a[] here */
int *piCol, /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
int bIgnoreHidden /* True to ignore hidden columns */
){
int i; /* For looping over tables in pSrc */
int iCol; /* Index of column matching zCol */
assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */
for(i=0; i<N; i++){
iCol = columnIndex(pSrc->a[i].pTab, zCol);
if( iCol>=0
&& (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pTab->aCol[iCol])==0)
){
if( piTab ){
*piTab = i;
*piCol = iCol;
}
return 1;
}
}
return 0;
} | 0 |
linux | f3d3342602f8bcbf37d7c46641cb9bca7618eb1c | NOT_APPLICABLE | NOT_APPLICABLE | static int netlink_connect(struct socket *sock, struct sockaddr *addr,
int alen, int flags)
{
int err = 0;
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
if (alen < sizeof(addr->sa_family))
return -EINVAL;
if (addr->sa_family == AF_UNSPEC) {
sk->sk_state = NETLINK_UNCONNECTED;
nlk->dst_portid = 0;
nlk->dst_group = 0;
return 0;
}
if (addr->sa_family != AF_NETLINK)
return -EINVAL;
/* Only superuser is allowed to send multicasts */
if (nladdr->nl_groups && !netlink_capable(sock, NL_CFG_F_NONROOT_SEND))
return -EPERM;
if (!nlk->portid)
err = netlink_autobind(sock);
if (err == 0) {
sk->sk_state = NETLINK_CONNECTED;
nlk->dst_portid = nladdr->nl_pid;
nlk->dst_group = ffs(nladdr->nl_groups);
}
return err;
}
| 0 |
Chrome | 784f56a9c97a838448dd23f9bdc7c05fe8e639b3 | NOT_APPLICABLE | NOT_APPLICABLE | void TestRenderWidgetHostView::SubmitCompositorFrame(
const cc::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) {
did_swap_compositor_frame_ = true;
}
| 0 |
evolution-data-server | f26a6f672096790d0bbd76903db4c9a2e44f116b | NOT_APPLICABLE | NOT_APPLICABLE | imapx_untagged (CamelIMAPXServer *is,
GInputStream *input_stream,
GCancellable *cancellable,
GError **error)
{
CamelIMAPXSettings *settings;
CamelSortType fetch_order;
guchar *p = NULL, c;
const gchar *token = NULL;
gboolean success = FALSE;
/* If is->priv->context is not NULL here, it basically means
* that imapx_untagged() got called concurrently for the same
* CamelIMAPXServer instance. Should this ever happen, then
* we will need to protect this data structure with locks
*/
g_return_val_if_fail (is->priv->context == NULL, FALSE);
is->priv->context = g_new0 (CamelIMAPXServerUntaggedContext, 1);
settings = camel_imapx_server_ref_settings (is);
fetch_order = camel_imapx_settings_get_fetch_order (settings);
g_object_unref (settings);
is->priv->context->lsub = FALSE;
is->priv->context->fetch_order = fetch_order;
e (is->priv->tagprefix, "got untagged response\n");
is->priv->context->id = 0;
is->priv->context->tok = camel_imapx_input_stream_token (
CAMEL_IMAPX_INPUT_STREAM (input_stream),
&(is->priv->context->token),
&(is->priv->context->len),
cancellable, error);
if (is->priv->context->tok < 0)
goto exit;
if (is->priv->context->tok == IMAPX_TOK_INT) {
is->priv->context->id = strtoul (
(gchar *) is->priv->context->token, NULL, 10);
is->priv->context->tok = camel_imapx_input_stream_token (
CAMEL_IMAPX_INPUT_STREAM (input_stream),
&(is->priv->context->token),
&(is->priv->context->len),
cancellable, error);
if (is->priv->context->tok < 0)
goto exit;
}
if (is->priv->context->tok == '\n') {
g_set_error (
error, CAMEL_IMAPX_ERROR, CAMEL_IMAPX_ERROR_SERVER_RESPONSE_MALFORMED,
"truncated server response");
goto exit;
}
e (is->priv->tagprefix, "Have token '%s' id %lu\n", is->priv->context->token, is->priv->context->id);
p = is->priv->context->token;
while ((c = *p))
*p++ = g_ascii_toupper ((gchar) c);
token = (const gchar *) is->priv->context->token; /* FIXME need 'guchar *token' here */
while (token != NULL) {
CamelIMAPXUntaggedRespHandlerDesc *desc = NULL;
desc = g_hash_table_lookup (is->priv->untagged_handlers, token);
if (desc == NULL) {
/* unknown response, just ignore it */
c (is->priv->tagprefix, "unknown token: %s\n", is->priv->context->token);
break;
}
if (desc->handler == NULL) {
/* no handler function, ignore token */
c (is->priv->tagprefix, "no handler for token: %s\n", is->priv->context->token);
break;
}
/* call the handler function */
success = desc->handler (is, input_stream, cancellable, error);
if (!success)
goto exit;
/* is there another handler next-in-line? */
token = desc->next_response;
if (token != NULL) {
/* TODO do we need to update 'priv->context->token'
* to the value of 'token' here, before
* calling the handler next-in-line for this
* specific run of imapx_untagged()?
* It has not been done in the original code
* in the "fall through" situation in the
* token switch statement, which is what
* we're mimicking here
*/
continue;
}
if (!desc->skip_stream_when_done)
goto exit;
}
success = camel_imapx_input_stream_skip (
CAMEL_IMAPX_INPUT_STREAM (input_stream), cancellable, error);
exit:
g_free (is->priv->context);
is->priv->context = NULL;
return success;
} | 0 |
src | a6981567e8e215acc1ef690c8dbb30f2d9b00a19 | NOT_APPLICABLE | NOT_APPLICABLE | process_extended_hardlink(u_int32_t id)
{
char *oldpath, *newpath;
int r, status;
if ((r = sshbuf_get_cstring(iqueue, &oldpath, NULL)) != 0 ||
(r = sshbuf_get_cstring(iqueue, &newpath, NULL)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
debug3("request %u: hardlink", id);
logit("hardlink old \"%s\" new \"%s\"", oldpath, newpath);
r = link(oldpath, newpath);
status = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
send_status(id, status);
free(oldpath);
free(newpath);
}
| 0 |
linux | 9590232bb4f4cc824f3425a6e1349afbe6d6d2b7 | NOT_APPLICABLE | NOT_APPLICABLE | static void ion_vm_open(struct vm_area_struct *vma)
{
struct ion_buffer *buffer = vma->vm_private_data;
struct ion_vma_list *vma_list;
vma_list = kmalloc(sizeof(struct ion_vma_list), GFP_KERNEL);
if (!vma_list)
return;
vma_list->vma = vma;
mutex_lock(&buffer->lock);
list_add(&vma_list->list, &buffer->vmas);
mutex_unlock(&buffer->lock);
pr_debug("%s: adding %p\n", __func__, vma);
}
| 0 |
linux | bf118a342f10dafe44b14451a1392c3254629a1f | NOT_APPLICABLE | NOT_APPLICABLE | static int decode_verifier(struct xdr_stream *xdr, void *verifier)
{
return decode_opaque_fixed(xdr, verifier, 8);
}
| 0 |
exiv2 | c72d16f4c402a8acc2dfe06fe3d58bf6cf99069e | NOT_APPLICABLE | NOT_APPLICABLE | int dataSize() const
{
assert(isValid());
return data_size_;
} | 0 |
kde | 82fdfd24d46966a117fa625b68784735a40f9065 | NOT_APPLICABLE | NOT_APPLICABLE | Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args)
: KParts::ReadWritePart(parent),
m_splitter(Q_NULLPTR),
m_busy(false),
m_jobTracker(Q_NULLPTR)
{
Q_UNUSED(args)
KAboutData aboutData(QStringLiteral("ark"),
i18n("ArkPart"),
QStringLiteral("3.0"));
setComponentData(aboutData, false);
new DndExtractAdaptor(this);
const QString pathName = QStringLiteral("/DndExtract/%1").arg(s_instanceCounter++);
if (!QDBusConnection::sessionBus().registerObject(pathName, this)) {
qCCritical(ARK) << "Could not register a D-Bus object for drag'n'drop";
}
QWidget *mainWidget = new QWidget;
m_vlayout = new QVBoxLayout;
m_model = new ArchiveModel(pathName, this);
m_splitter = new QSplitter(Qt::Horizontal, parentWidget);
m_view = new ArchiveView;
m_infoPanel = new InfoPanel(m_model);
m_commentView = new QPlainTextEdit();
m_commentView->setReadOnly(true);
m_commentView->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
m_commentBox = new QGroupBox(i18n("Comment"));
m_commentBox->hide();
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(m_commentView);
m_commentBox->setLayout(vbox);
m_messageWidget = new KMessageWidget(parentWidget);
m_messageWidget->setWordWrap(true);
m_messageWidget->hide();
m_commentMsgWidget = new KMessageWidget();
m_commentMsgWidget->setText(i18n("Comment has been modified."));
m_commentMsgWidget->setMessageType(KMessageWidget::Information);
m_commentMsgWidget->setCloseButtonVisible(false);
m_commentMsgWidget->hide();
QAction *saveAction = new QAction(i18n("Save"), m_commentMsgWidget);
m_commentMsgWidget->addAction(saveAction);
connect(saveAction, &QAction::triggered, this, &Part::slotAddComment);
m_commentBox->layout()->addWidget(m_commentMsgWidget);
connect(m_commentView, &QPlainTextEdit::textChanged, this, &Part::slotCommentChanged);
setWidget(mainWidget);
mainWidget->setLayout(m_vlayout);
m_vlayout->setContentsMargins(0,0,0,0);
m_vlayout->addWidget(m_messageWidget);
m_vlayout->addWidget(m_splitter);
m_commentSplitter = new QSplitter(Qt::Vertical, parentWidget);
m_commentSplitter->setOpaqueResize(false);
m_commentSplitter->addWidget(m_view);
m_commentSplitter->addWidget(m_commentBox);
m_commentSplitter->setCollapsible(0, false);
m_splitter->addWidget(m_commentSplitter);
m_splitter->addWidget(m_infoPanel);
if (!ArkSettings::showInfoPanel()) {
m_infoPanel->hide();
} else {
m_splitter->setSizes(ArkSettings::splitterSizes());
}
setupView();
setupActions();
connect(m_view, &ArchiveView::entryChanged,
this, &Part::slotRenameFile);
connect(m_model, &ArchiveModel::loadingStarted,
this, &Part::slotLoadingStarted);
connect(m_model, &ArchiveModel::loadingFinished,
this, &Part::slotLoadingFinished);
connect(m_model, &ArchiveModel::droppedFiles,
this, static_cast<void (Part::*)(const QStringList&, const Archive::Entry*, const QString&)>(&Part::slotAddFiles));
connect(m_model, &ArchiveModel::error,
this, &Part::slotError);
connect(m_model, &ArchiveModel::messageWidget,
this, &Part::displayMsgWidget);
connect(this, &Part::busy,
this, &Part::setBusyGui);
connect(this, &Part::ready,
this, &Part::setReadyGui);
connect(this, static_cast<void (KParts::ReadOnlyPart::*)()>(&KParts::ReadOnlyPart::completed),
this, &Part::setFileNameFromArchive);
m_statusBarExtension = new KParts::StatusBarExtension(this);
setXMLFile(QStringLiteral("ark_part.rc"));
}
| 0 |
dpdk | 549de54c4f9fd36b2b11f3df7e81bf2567a2d526 | NOT_APPLICABLE | NOT_APPLICABLE | translate_ring_addresses(struct virtio_net *dev, int vq_index)
{
struct vhost_virtqueue *vq = dev->virtqueue[vq_index];
struct vhost_vring_addr *addr = &vq->ring_addrs;
uint64_t len, expected_len;
if (addr->flags & (1 << VHOST_VRING_F_LOG)) {
vq->log_guest_addr =
log_addr_to_gpa(dev, vq);
if (vq->log_guest_addr == 0) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map log_guest_addr.\n",
dev->vid);
return dev;
}
}
if (vq_is_packed(dev)) {
len = sizeof(struct vring_packed_desc) * vq->size;
vq->desc_packed = (struct vring_packed_desc *)(uintptr_t)
ring_addr_to_vva(dev, vq, addr->desc_user_addr, &len);
if (vq->desc_packed == NULL ||
len != sizeof(struct vring_packed_desc) *
vq->size) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map desc_packed ring.\n",
dev->vid);
return dev;
}
dev = numa_realloc(dev, vq_index);
vq = dev->virtqueue[vq_index];
addr = &vq->ring_addrs;
len = sizeof(struct vring_packed_desc_event);
vq->driver_event = (struct vring_packed_desc_event *)
(uintptr_t)ring_addr_to_vva(dev,
vq, addr->avail_user_addr, &len);
if (vq->driver_event == NULL ||
len != sizeof(struct vring_packed_desc_event)) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to find driver area address.\n",
dev->vid);
return dev;
}
len = sizeof(struct vring_packed_desc_event);
vq->device_event = (struct vring_packed_desc_event *)
(uintptr_t)ring_addr_to_vva(dev,
vq, addr->used_user_addr, &len);
if (vq->device_event == NULL ||
len != sizeof(struct vring_packed_desc_event)) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to find device area address.\n",
dev->vid);
return dev;
}
vq->access_ok = 1;
return dev;
}
/* The addresses are converted from QEMU virtual to Vhost virtual. */
if (vq->desc && vq->avail && vq->used)
return dev;
len = sizeof(struct vring_desc) * vq->size;
vq->desc = (struct vring_desc *)(uintptr_t)ring_addr_to_vva(dev,
vq, addr->desc_user_addr, &len);
if (vq->desc == 0 || len != sizeof(struct vring_desc) * vq->size) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map desc ring.\n",
dev->vid);
return dev;
}
dev = numa_realloc(dev, vq_index);
vq = dev->virtqueue[vq_index];
addr = &vq->ring_addrs;
len = sizeof(struct vring_avail) + sizeof(uint16_t) * vq->size;
if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))
len += sizeof(uint16_t);
expected_len = len;
vq->avail = (struct vring_avail *)(uintptr_t)ring_addr_to_vva(dev,
vq, addr->avail_user_addr, &len);
if (vq->avail == 0 || len != expected_len) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map avail ring.\n",
dev->vid);
return dev;
}
len = sizeof(struct vring_used) +
sizeof(struct vring_used_elem) * vq->size;
if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))
len += sizeof(uint16_t);
expected_len = len;
vq->used = (struct vring_used *)(uintptr_t)ring_addr_to_vva(dev,
vq, addr->used_user_addr, &len);
if (vq->used == 0 || len != expected_len) {
VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map used ring.\n",
dev->vid);
return dev;
}
if (vq->last_used_idx != vq->used->idx) {
VHOST_LOG_CONFIG(WARNING,
"last_used_idx (%u) and vq->used->idx (%u) mismatches; "
"some packets maybe resent for Tx and dropped for Rx\n",
vq->last_used_idx, vq->used->idx);
vq->last_used_idx = vq->used->idx;
vq->last_avail_idx = vq->used->idx;
}
vq->access_ok = 1;
VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address desc: %p\n",
dev->vid, vq->desc);
VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address avail: %p\n",
dev->vid, vq->avail);
VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address used: %p\n",
dev->vid, vq->used);
VHOST_LOG_CONFIG(DEBUG, "(%d) log_guest_addr: %" PRIx64 "\n",
dev->vid, vq->log_guest_addr);
return dev;
} | 0 |
postgres | 31400a673325147e1205326008e32135a78b4d8a | NOT_APPLICABLE | NOT_APPLICABLE | inter_sb(PG_FUNCTION_ARGS)
{
LSEG *lseg = PG_GETARG_LSEG_P(0);
BOX *box = PG_GETARG_BOX_P(1);
BOX lbox;
LSEG bseg;
Point point;
lbox.low.x = Min(lseg->p[0].x, lseg->p[1].x);
lbox.low.y = Min(lseg->p[0].y, lseg->p[1].y);
lbox.high.x = Max(lseg->p[0].x, lseg->p[1].x);
lbox.high.y = Max(lseg->p[0].y, lseg->p[1].y);
/* nothing close to overlap? then not going to intersect */
if (!box_ov(&lbox, box))
PG_RETURN_BOOL(false);
/* an endpoint of segment is inside box? then clearly intersects */
if (DatumGetBool(DirectFunctionCall2(on_pb,
PointPGetDatum(&lseg->p[0]),
BoxPGetDatum(box))) ||
DatumGetBool(DirectFunctionCall2(on_pb,
PointPGetDatum(&lseg->p[1]),
BoxPGetDatum(box))))
PG_RETURN_BOOL(true);
/* pairwise check lseg intersections */
point.x = box->low.x;
point.y = box->high.y;
statlseg_construct(&bseg, &box->low, &point);
if (lseg_intersect_internal(&bseg, lseg))
PG_RETURN_BOOL(true);
statlseg_construct(&bseg, &box->high, &point);
if (lseg_intersect_internal(&bseg, lseg))
PG_RETURN_BOOL(true);
point.x = box->high.x;
point.y = box->low.y;
statlseg_construct(&bseg, &box->low, &point);
if (lseg_intersect_internal(&bseg, lseg))
PG_RETURN_BOOL(true);
statlseg_construct(&bseg, &box->high, &point);
if (lseg_intersect_internal(&bseg, lseg))
PG_RETURN_BOOL(true);
/* if we dropped through, no two segs intersected */
PG_RETURN_BOOL(false);
}
| 0 |
linux | a9cf73ea7ff78f52662c8658d93c226effbbedde | NOT_APPLICABLE | NOT_APPLICABLE | void udp6_proc_exit(struct net *net) {
udp_proc_unregister(net, &udp6_seq_afinfo);
}
| 0 |
samba | 6093b2d815a00a577036fa001b47d7fc5514ad2c | NOT_APPLICABLE | NOT_APPLICABLE | static bool torture_winbind_struct_domain_name(struct torture_context *torture)
{
const char *expected;
char *domain;
torture_comment(torture, "Running WINBINDD_DOMAIN_NAME (struct based)\n");
expected = torture_setting_string(torture,
"winbindd_netbios_domain",
lpcfg_workgroup(torture->lp_ctx));
get_winbind_domain(torture, &domain);
torture_assert_str_equal(torture, domain, expected,
"winbindd's netbios domain doesn't match");
return true;
} | 0 |
linux-2.6 | 8faece5f906725c10e7a1f6caf84452abadbdc7b | NOT_APPLICABLE | NOT_APPLICABLE | static int ecryptfs_read_headers_virt(char *page_virt,
struct ecryptfs_crypt_stat *crypt_stat,
struct dentry *ecryptfs_dentry,
int validate_header_size)
{
int rc = 0;
int offset;
int bytes_read;
ecryptfs_set_default_sizes(crypt_stat);
crypt_stat->mount_crypt_stat = &ecryptfs_superblock_to_private(
ecryptfs_dentry->d_sb)->mount_crypt_stat;
offset = ECRYPTFS_FILE_SIZE_BYTES;
rc = contains_ecryptfs_marker(page_virt + offset);
if (rc == 0) {
rc = -EINVAL;
goto out;
}
offset += MAGIC_ECRYPTFS_MARKER_SIZE_BYTES;
rc = ecryptfs_process_flags(crypt_stat, (page_virt + offset),
&bytes_read);
if (rc) {
ecryptfs_printk(KERN_WARNING, "Error processing flags\n");
goto out;
}
if (crypt_stat->file_version > ECRYPTFS_SUPPORTED_FILE_VERSION) {
ecryptfs_printk(KERN_WARNING, "File version is [%d]; only "
"file version [%d] is supported by this "
"version of eCryptfs\n",
crypt_stat->file_version,
ECRYPTFS_SUPPORTED_FILE_VERSION);
rc = -EINVAL;
goto out;
}
offset += bytes_read;
if (crypt_stat->file_version >= 1) {
rc = parse_header_metadata(crypt_stat, (page_virt + offset),
&bytes_read, validate_header_size);
if (rc) {
ecryptfs_printk(KERN_WARNING, "Error reading header "
"metadata; rc = [%d]\n", rc);
}
offset += bytes_read;
} else
set_default_header_data(crypt_stat);
rc = ecryptfs_parse_packet_set(crypt_stat, (page_virt + offset),
ecryptfs_dentry);
out:
return rc;
} | 0 |
lua | 42d40581dd919fb134c07027ca1ce0844c670daf | NOT_APPLICABLE | NOT_APPLICABLE | void luaV_finishOp (lua_State *L) {
CallInfo *ci = L->ci;
StkId base = ci->func + 1;
Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
OpCode op = GET_OPCODE(inst);
switch (op) { /* finish its execution */
case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: {
setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top);
break;
}
case OP_UNM: case OP_BNOT: case OP_LEN:
case OP_GETTABUP: case OP_GETTABLE: case OP_GETI:
case OP_GETFIELD: case OP_SELF: {
setobjs2s(L, base + GETARG_A(inst), --L->top);
break;
}
case OP_LT: case OP_LE:
case OP_LTI: case OP_LEI:
case OP_GTI: case OP_GEI:
case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */
int res = !l_isfalse(s2v(L->top - 1));
L->top--;
#if defined(LUA_COMPAT_LT_LE)
if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */
ci->callstatus ^= CIST_LEQ; /* clear mark */
res = !res; /* negate result */
}
#endif
lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
if (res != GETARG_k(inst)) /* condition failed? */
ci->u.l.savedpc++; /* skip jump instruction */
break;
}
case OP_CONCAT: {
StkId top = L->top - 1; /* top when 'luaT_tryconcatTM' was called */
int a = GETARG_A(inst); /* first element to concatenate */
int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */
setobjs2s(L, top - 2, top); /* put TM result in proper position */
L->top = top - 1; /* top is one after last element (at top-2) */
luaV_concat(L, total); /* concat them (may yield again) */
break;
}
case OP_CLOSE: { /* yielded closing variables */
ci->u.l.savedpc--; /* repeat instruction to close other vars. */
break;
}
case OP_RETURN: { /* yielded closing variables */
StkId ra = base + GETARG_A(inst);
/* adjust top to signal correct number of returns, in case the
return is "up to top" ('isIT') */
L->top = ra + ci->u2.nres;
/* repeat instruction to close other vars. and complete the return */
ci->u.l.savedpc--;
break;
}
default: {
/* only these other opcodes can yield */
lua_assert(op == OP_TFORCALL || op == OP_CALL ||
op == OP_TAILCALL || op == OP_SETTABUP || op == OP_SETTABLE ||
op == OP_SETI || op == OP_SETFIELD);
break;
}
}
} | 0 |
linux | 30a46a4647fd1df9cf52e43bf467f0d9265096ca | NOT_APPLICABLE | NOT_APPLICABLE | static int apparmor_getprocattr(struct task_struct *task, char *name,
char **value)
{
int error = -ENOENT;
/* released below */
const struct cred *cred = get_task_cred(task);
struct aa_task_cxt *cxt = cred_cxt(cred);
struct aa_profile *profile = NULL;
if (strcmp(name, "current") == 0)
profile = aa_get_newest_profile(cxt->profile);
else if (strcmp(name, "prev") == 0 && cxt->previous)
profile = aa_get_newest_profile(cxt->previous);
else if (strcmp(name, "exec") == 0 && cxt->onexec)
profile = aa_get_newest_profile(cxt->onexec);
else
error = -EINVAL;
if (profile)
error = aa_getprocattr(profile, value);
aa_put_profile(profile);
put_cred(cred);
return error;
}
| 0 |
openssl | 00d965474b22b54e4275232bc71ee0c699c5cd21 | NOT_APPLICABLE | NOT_APPLICABLE | static int aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx);
if (!iv && !key)
return 1;
if (key)
do {
#ifdef HWAES_CAPABLE
if (HWAES_CAPABLE) {
HWAES_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,
&cctx->ks.ks);
CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
&cctx->ks, (block128_f) HWAES_encrypt);
cctx->str = NULL;
cctx->key_set = 1;
break;
} else
#endif
#ifdef VPAES_CAPABLE
if (VPAES_CAPABLE) {
vpaes_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,
&cctx->ks.ks);
CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
&cctx->ks, (block128_f) vpaes_encrypt);
cctx->str = NULL;
cctx->key_set = 1;
break;
}
#endif
AES_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,
&cctx->ks.ks);
CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
&cctx->ks, (block128_f) AES_encrypt);
cctx->str = NULL;
cctx->key_set = 1;
} while (0);
if (iv) {
memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), iv, 15 - cctx->L);
cctx->iv_set = 1;
}
return 1;
}
| 0 |
linux | 04f5866e41fb70690e28397487d8bd8eea7d712a | NOT_APPLICABLE | NOT_APPLICABLE | struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file,
struct ib_device *ib_dev)
{
struct ib_uverbs_async_event_file *ev_file;
struct file *filp;
ev_file = kzalloc(sizeof(*ev_file), GFP_KERNEL);
if (!ev_file)
return ERR_PTR(-ENOMEM);
ib_uverbs_init_event_queue(&ev_file->ev_queue);
ev_file->uverbs_file = uverbs_file;
kref_get(&ev_file->uverbs_file->ref);
kref_init(&ev_file->ref);
filp = anon_inode_getfile("[infinibandevent]", &uverbs_async_event_fops,
ev_file, O_RDONLY);
if (IS_ERR(filp))
goto err_put_refs;
mutex_lock(&uverbs_file->device->lists_mutex);
list_add_tail(&ev_file->list,
&uverbs_file->device->uverbs_events_file_list);
mutex_unlock(&uverbs_file->device->lists_mutex);
WARN_ON(uverbs_file->async_file);
uverbs_file->async_file = ev_file;
kref_get(&uverbs_file->async_file->ref);
INIT_IB_EVENT_HANDLER(&uverbs_file->event_handler,
ib_dev,
ib_uverbs_event_handler);
ib_register_event_handler(&uverbs_file->event_handler);
/* At that point async file stuff was fully set */
return filp;
err_put_refs:
kref_put(&ev_file->uverbs_file->ref, ib_uverbs_release_file);
kref_put(&ev_file->ref, ib_uverbs_release_async_event_file);
return filp;
}
| 0 |
qemu | 7b103b36d6ef3b11827c203d3a793bf7da50ecd6 | NOT_APPLICABLE | NOT_APPLICABLE | static void cloop_close(BlockDriverState *bs)
{
BDRVCloopState *s = bs->opaque;
if (s->n_blocks > 0) {
g_free(s->offsets);
}
g_free(s->compressed_block);
g_free(s->uncompressed_block);
inflateEnd(&s->zstream);
} | 0 |
neomutt | e52393740334443ae0206cab2d7caef381646725 | CVE-2018-14357 | CWE-77 | static int compile_search(struct Context *ctx, const struct Pattern *pat, struct Buffer *buf)
{
if (do_search(pat, 0) == 0)
return 0;
if (pat->not)
mutt_buffer_addstr(buf, "NOT ");
if (pat->child)
{
int clauses;
clauses = do_search(pat->child, 1);
if (clauses > 0)
{
const struct Pattern *clause = pat->child;
mutt_buffer_addch(buf, '(');
while (clauses)
{
if (do_search(clause, 0))
{
if (pat->op == MUTT_OR && clauses > 1)
mutt_buffer_addstr(buf, "OR ");
clauses--;
if (compile_search(ctx, clause, buf) < 0)
return -1;
if (clauses)
mutt_buffer_addch(buf, ' ');
}
clause = clause->next;
}
mutt_buffer_addch(buf, ')');
}
}
else
{
char term[STRING];
char *delim = NULL;
switch (pat->op)
{
case MUTT_HEADER:
mutt_buffer_addstr(buf, "HEADER ");
/* extract header name */
delim = strchr(pat->p.str, ':');
if (!delim)
{
mutt_error(_("Header search without header name: %s"), pat->p.str);
return -1;
}
*delim = '\0';
imap_quote_string(term, sizeof(term), pat->p.str);
mutt_buffer_addstr(buf, term);
mutt_buffer_addch(buf, ' ');
/* and field */
*delim = ':';
delim++;
SKIPWS(delim);
imap_quote_string(term, sizeof(term), delim);
mutt_buffer_addstr(buf, term);
break;
case MUTT_BODY:
mutt_buffer_addstr(buf, "BODY ");
imap_quote_string(term, sizeof(term), pat->p.str);
mutt_buffer_addstr(buf, term);
break;
case MUTT_WHOLE_MSG:
mutt_buffer_addstr(buf, "TEXT ");
imap_quote_string(term, sizeof(term), pat->p.str);
mutt_buffer_addstr(buf, term);
break;
case MUTT_SERVERSEARCH:
{
struct ImapData *idata = ctx->data;
if (!mutt_bit_isset(idata->capabilities, X_GM_EXT1))
{
mutt_error(_("Server-side custom search not supported: %s"), pat->p.str);
return -1;
}
}
mutt_buffer_addstr(buf, "X-GM-RAW ");
imap_quote_string(term, sizeof(term), pat->p.str);
mutt_buffer_addstr(buf, term);
break;
}
}
return 0;
}
| 1 |
radare2 | cb8b683758edddae2d2f62e8e63a738c39f92683 | NOT_APPLICABLE | NOT_APPLICABLE | static void autocomplete_flags(RCore *core, RLineCompletion *completion, const char* str) {
r_return_if_fail (str);
int n = strlen (str);
r_flag_foreach_prefix (core->flags, str, n, add_argv, completion);
} | 0 |
libtpms | ea62fd9679f8c6fc5e79471b33cfbd8227bfed72 | NOT_APPLICABLE | NOT_APPLICABLE | ObjectGetNameAlg(
OBJECT *object // IN: handle of the object
)
{
return object->publicArea.nameAlg;
} | 0 |
FreeRDP | 9fee4ae076b1ec97b97efb79ece08d1dab4df29a | NOT_APPLICABLE | NOT_APPLICABLE | static unsigned rgba8ToPixel(unsigned char* out, size_t i,
const LodePNGColorMode* mode, ColorTree* tree /*for palette*/,
unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
if(mode->colortype == LCT_GREY)
{
unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
if(mode->bitdepth == 8) out[i] = grey;
else if(mode->bitdepth == 16) out[i * 2 + 0] = out[i * 2 + 1] = grey;
else
{
/*take the most significant bits of grey*/
grey = (grey >> (8 - mode->bitdepth)) & ((1 << mode->bitdepth) - 1);
addColorBits(out, i, mode->bitdepth, grey);
}
}
else if(mode->colortype == LCT_RGB)
{
if(mode->bitdepth == 8)
{
out[i * 3 + 0] = r;
out[i * 3 + 1] = g;
out[i * 3 + 2] = b;
}
else
{
out[i * 6 + 0] = out[i * 6 + 1] = r;
out[i * 6 + 2] = out[i * 6 + 3] = g;
out[i * 6 + 4] = out[i * 6 + 5] = b;
}
}
else if(mode->colortype == LCT_PALETTE)
{
int index = color_tree_get(tree, r, g, b, a);
if(index < 0) return 82; /*color not in palette*/
if(mode->bitdepth == 8) out[i] = index;
else addColorBits(out, i, mode->bitdepth, (unsigned)index);
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
if(mode->bitdepth == 8)
{
out[i * 2 + 0] = grey;
out[i * 2 + 1] = a;
}
else if(mode->bitdepth == 16)
{
out[i * 4 + 0] = out[i * 4 + 1] = grey;
out[i * 4 + 2] = out[i * 4 + 3] = a;
}
}
else if(mode->colortype == LCT_RGBA)
{
if(mode->bitdepth == 8)
{
out[i * 4 + 0] = r;
out[i * 4 + 1] = g;
out[i * 4 + 2] = b;
out[i * 4 + 3] = a;
}
else
{
out[i * 8 + 0] = out[i * 8 + 1] = r;
out[i * 8 + 2] = out[i * 8 + 3] = g;
out[i * 8 + 4] = out[i * 8 + 5] = b;
out[i * 8 + 6] = out[i * 8 + 7] = a;
}
}
return 0; /*no error*/
} | 0 |
exiv2 | 9a38066b8eddf3948696a3362aac29e012ebe690 | NOT_APPLICABLE | NOT_APPLICABLE | std::string upper(const std::string& str)
{
std::string result;
transform(str.begin(), str.end(), std::back_inserter(result), toupper);
return result;
} | 0 |
FFmpeg | bab0716c7f4793ec42e05a5aa7e80d82a0dd4e75 | NOT_APPLICABLE | NOT_APPLICABLE | static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, AVRational edit_rate, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag)
{
int i;
int64_t offset_temp = 0;
edit_unit = av_rescale_q(edit_unit, index_table->segments[0]->index_edit_rate, edit_rate);
for (i = 0; i < index_table->nb_segments; i++) {
MXFIndexTableSegment *s = index_table->segments[i];
edit_unit = FFMAX(edit_unit, s->index_start_position); /* clamp if trying to seek before start */
if (edit_unit < s->index_start_position + s->index_duration) {
int64_t index = edit_unit - s->index_start_position;
if (s->edit_unit_byte_count)
offset_temp += s->edit_unit_byte_count * index;
else if (s->nb_index_entries) {
if (s->nb_index_entries == 2 * s->index_duration + 1)
index *= 2; /* Avid index */
if (index < 0 || index >= s->nb_index_entries) {
av_log(mxf->fc, AV_LOG_ERROR, "IndexSID %i segment at %"PRId64" IndexEntryArray too small\n",
index_table->index_sid, s->index_start_position);
return AVERROR_INVALIDDATA;
}
offset_temp = s->stream_offset_entries[index];
} else {
av_log(mxf->fc, AV_LOG_ERROR, "IndexSID %i segment at %"PRId64" missing EditUnitByteCount and IndexEntryArray\n",
index_table->index_sid, s->index_start_position);
return AVERROR_INVALIDDATA;
}
if (edit_unit_out)
*edit_unit_out = av_rescale_q(edit_unit, edit_rate, s->index_edit_rate);
return mxf_absolute_bodysid_offset(mxf, index_table->body_sid, offset_temp, offset_out, partition_out);
} else {
/* EditUnitByteCount == 0 for VBR indexes, which is fine since they use explicit StreamOffsets */
offset_temp += s->edit_unit_byte_count * s->index_duration;
}
}
if (nag)
av_log(mxf->fc, AV_LOG_ERROR, "failed to map EditUnit %"PRId64" in IndexSID %i to an offset\n", edit_unit, index_table->index_sid);
return AVERROR_INVALIDDATA;
}
| 0 |
linux | 574823bfab82d9d8fa47f422778043fbb4b4f50e | CVE-2019-5489 | CWE-200 | static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
struct mm_walk *walk)
{
spinlock_t *ptl;
struct vm_area_struct *vma = walk->vma;
pte_t *ptep;
unsigned char *vec = walk->private;
int nr = (end - addr) >> PAGE_SHIFT;
ptl = pmd_trans_huge_lock(pmd, vma);
if (ptl) {
memset(vec, 1, nr);
spin_unlock(ptl);
goto out;
}
if (pmd_trans_unstable(pmd)) {
__mincore_unmapped_range(addr, end, vma, vec);
goto out;
}
ptep = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
for (; addr != end; ptep++, addr += PAGE_SIZE) {
pte_t pte = *ptep;
if (pte_none(pte))
__mincore_unmapped_range(addr, addr + PAGE_SIZE,
vma, vec);
else if (pte_present(pte))
*vec = 1;
else { /* pte is a swap entry */
swp_entry_t entry = pte_to_swp_entry(pte);
if (non_swap_entry(entry)) {
/*
* migration or hwpoison entries are always
* uptodate
*/
*vec = 1;
} else {
#ifdef CONFIG_SWAP
*vec = mincore_page(swap_address_space(entry),
swp_offset(entry));
#else
WARN_ON(1);
*vec = 1;
#endif
}
}
vec++;
}
pte_unmap_unlock(ptep - 1, ptl);
out:
walk->private += nr;
cond_resched();
return 0;
}
| 1 |
openexr | 6bb36714528a9563dd3b92720c5063a1284b86f8 | NOT_APPLICABLE | NOT_APPLICABLE | TileBufferTask::TileBufferTask
(TaskGroup *group,
TiledInputFile::Data *ifd,
TileBuffer *tileBuffer)
:
Task (group),
_ifd (ifd),
_tileBuffer (tileBuffer)
{
// empty
} | 0 |
linux | 20e0fa98b751facf9a1101edaefbc19c82616a68 | NOT_APPLICABLE | NOT_APPLICABLE | static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmode, struct nfs4_state **res)
{
struct nfs4_state *newstate;
int ret;
opendata->o_arg.open_flags = 0;
opendata->o_arg.fmode = fmode;
memset(&opendata->o_res, 0, sizeof(opendata->o_res));
memset(&opendata->c_res, 0, sizeof(opendata->c_res));
nfs4_init_opendata_res(opendata);
ret = _nfs4_recover_proc_open(opendata);
if (ret != 0)
return ret;
newstate = nfs4_opendata_to_nfs4_state(opendata);
if (IS_ERR(newstate))
return PTR_ERR(newstate);
nfs4_close_state(newstate, fmode);
*res = newstate;
return 0;
}
| 0 |
httpd | 4cc27823899e070268b906ca677ee838d07cf67a | NOT_APPLICABLE | NOT_APPLICABLE | static char *unclosed_directive(cmd_parms *cmd)
{
return apr_pstrcat(cmd->pool, cmd->cmd->name,
"> directive missing closing '>'", NULL);
} | 0 |
curl | 31be461c6b659312100c47be6ddd5f0f569290f6 | NOT_APPLICABLE | NOT_APPLICABLE | CURLcode Curl_init_userdefined(struct UserDefined *set)
{
CURLcode result = CURLE_OK;
set->out = stdout; /* default output to stdout */
set->in = stdin; /* default input from stdin */
set->err = stderr; /* default stderr to stderr */
/* use fwrite as default function to store output */
set->fwrite_func = (curl_write_callback)fwrite;
/* use fread as default function to read input */
set->fread_func = (curl_read_callback)fread;
set->is_fread_set = 0;
set->is_fwrite_set = 0;
set->seek_func = ZERO_NULL;
set->seek_client = ZERO_NULL;
/* conversion callbacks for non-ASCII hosts */
set->convfromnetwork = ZERO_NULL;
set->convtonetwork = ZERO_NULL;
set->convfromutf8 = ZERO_NULL;
set->filesize = -1; /* we don't know the size */
set->postfieldsize = -1; /* unknown size */
set->maxredirs = -1; /* allow any amount by default */
set->httpreq = HTTPREQ_GET; /* Default HTTP request */
set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */
set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */
set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */
set->ftp_use_pret = FALSE; /* mainly useful for drftpd servers */
set->ftp_filemethod = FTPFILE_MULTICWD;
set->dns_cache_timeout = 60; /* Timeout every 60 seconds by default */
/* Set the default size of the SSL session ID cache */
set->ssl.max_ssl_sessions = 5;
set->proxyport = CURL_DEFAULT_PROXY_PORT; /* from url.h */
set->proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */
set->httpauth = CURLAUTH_BASIC; /* defaults to basic */
set->proxyauth = CURLAUTH_BASIC; /* defaults to basic */
/* make libcurl quiet by default: */
set->hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */
/*
* libcurl 7.10 introduced SSL verification *by default*! This needs to be
* switched off unless wanted.
*/
set->ssl.verifypeer = TRUE;
set->ssl.verifyhost = TRUE;
#ifdef USE_TLS_SRP
set->ssl.authtype = CURL_TLSAUTH_NONE;
#endif
set->ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth
type */
set->ssl.sessionid = TRUE; /* session ID caching enabled by default */
set->new_file_perms = 0644; /* Default permissions */
set->new_directory_perms = 0755; /* Default permissions */
/* for the *protocols fields we don't use the CURLPROTO_ALL convenience
define since we internally only use the lower 16 bits for the passed
in bitmask to not conflict with the private bits */
set->allowed_protocols = CURLPROTO_ALL;
set->redir_protocols = CURLPROTO_ALL & /* All except FILE, SCP and SMB */
~(CURLPROTO_FILE | CURLPROTO_SCP | CURLPROTO_SMB |
CURLPROTO_SMBS);
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
/*
* disallow unprotected protection negotiation NEC reference implementation
* seem not to follow rfc1961 section 4.3/4.4
*/
set->socks5_gssapi_nec = FALSE;
/* set default GSS-API service name */
result = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE],
(char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE);
if(result)
return result;
#endif
/* This is our preferred CA cert bundle/path since install time */
#if defined(CURL_CA_BUNDLE)
result = setstropt(&set->str[STRING_SSL_CAFILE], (char *) CURL_CA_BUNDLE);
if(result)
return result;
#endif
#if defined(CURL_CA_PATH)
result = setstropt(&set->str[STRING_SSL_CAPATH], (char *) CURL_CA_PATH);
if(result)
return result;
#endif
set->wildcardmatch = FALSE;
set->chunk_bgn = ZERO_NULL;
set->chunk_end = ZERO_NULL;
/* tcp keepalives are disabled by default, but provide reasonable values for
* the interval and idle times.
*/
set->tcp_keepalive = FALSE;
set->tcp_keepintvl = 60;
set->tcp_keepidle = 60;
set->ssl_enable_npn = TRUE;
set->ssl_enable_alpn = TRUE;
set->expect_100_timeout = 1000L; /* Wait for a second by default. */
return result;
} | 0 |
ImageMagick | 8c35502217c1879cb8257c617007282eee3fe1cc | NOT_APPLICABLE | NOT_APPLICABLE | void Magick::Image::segment(const double clusterThreshold_,
const double smoothingThreshold_)
{
modifyImage();
GetPPException;
SegmentImage(image(),options()->quantizeColorSpace(),
(MagickBooleanType) options()->verbose(),clusterThreshold_,
smoothingThreshold_,exceptionInfo);
SyncImage(image(),exceptionInfo);
ThrowImageException;
} | 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | static char min() { return ~max(); } | 0 |
openssl | 336923c0c8d705cb8af5216b29a205662db0d590 | NOT_APPLICABLE | NOT_APPLICABLE | static int file_rshift(STANZA *s)
{
BIGNUM *a = NULL, *rshift = NULL, *ret = NULL;
int n = 0, st = 0;
if (!TEST_ptr(a = getBN(s, "A"))
|| !TEST_ptr(rshift = getBN(s, "RShift"))
|| !TEST_ptr(ret = BN_new())
|| !getint(s, &n, "N"))
goto err;
if (!TEST_true(BN_rshift(ret, a, n))
|| !equalBN("A >> N", rshift, ret))
goto err;
/* If N == 1, try with rshift1 as well */
if (n == 1) {
if (!TEST_true(BN_rshift1(ret, a))
|| !equalBN("A >> 1 (rshift1)", rshift, ret))
goto err;
}
st = 1;
err:
BN_free(a);
BN_free(rshift);
BN_free(ret);
return st;
} | 0 |
linux | 27d461333459d282ffa4a2bdb6b215a59d493a8f | NOT_APPLICABLE | NOT_APPLICABLE | static void i40e_determine_queue_usage(struct i40e_pf *pf)
{
int queues_left;
int q_max;
pf->num_lan_qps = 0;
/* Find the max queues to be put into basic use. We'll always be
* using TC0, whether or not DCB is running, and TC0 will get the
* big RSS set.
*/
queues_left = pf->hw.func_caps.num_tx_qp;
if ((queues_left == 1) ||
!(pf->flags & I40E_FLAG_MSIX_ENABLED)) {
/* one qp for PF, no queues for anything else */
queues_left = 0;
pf->alloc_rss_size = pf->num_lan_qps = 1;
/* make sure all the fancies are disabled */
pf->flags &= ~(I40E_FLAG_RSS_ENABLED |
I40E_FLAG_IWARP_ENABLED |
I40E_FLAG_FD_SB_ENABLED |
I40E_FLAG_FD_ATR_ENABLED |
I40E_FLAG_DCB_CAPABLE |
I40E_FLAG_DCB_ENABLED |
I40E_FLAG_SRIOV_ENABLED |
I40E_FLAG_VMDQ_ENABLED);
pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
} else if (!(pf->flags & (I40E_FLAG_RSS_ENABLED |
I40E_FLAG_FD_SB_ENABLED |
I40E_FLAG_FD_ATR_ENABLED |
I40E_FLAG_DCB_CAPABLE))) {
/* one qp for PF */
pf->alloc_rss_size = pf->num_lan_qps = 1;
queues_left -= pf->num_lan_qps;
pf->flags &= ~(I40E_FLAG_RSS_ENABLED |
I40E_FLAG_IWARP_ENABLED |
I40E_FLAG_FD_SB_ENABLED |
I40E_FLAG_FD_ATR_ENABLED |
I40E_FLAG_DCB_ENABLED |
I40E_FLAG_VMDQ_ENABLED);
pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
} else {
/* Not enough queues for all TCs */
if ((pf->flags & I40E_FLAG_DCB_CAPABLE) &&
(queues_left < I40E_MAX_TRAFFIC_CLASS)) {
pf->flags &= ~(I40E_FLAG_DCB_CAPABLE |
I40E_FLAG_DCB_ENABLED);
dev_info(&pf->pdev->dev, "not enough queues for DCB. DCB is disabled.\n");
}
/* limit lan qps to the smaller of qps, cpus or msix */
q_max = max_t(int, pf->rss_size_max, num_online_cpus());
q_max = min_t(int, q_max, pf->hw.func_caps.num_tx_qp);
q_max = min_t(int, q_max, pf->hw.func_caps.num_msix_vectors);
pf->num_lan_qps = q_max;
queues_left -= pf->num_lan_qps;
}
if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
if (queues_left > 1) {
queues_left -= 1; /* save 1 queue for FD */
} else {
pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
dev_info(&pf->pdev->dev, "not enough queues for Flow Director. Flow Director feature is disabled\n");
}
}
if ((pf->flags & I40E_FLAG_SRIOV_ENABLED) &&
pf->num_vf_qps && pf->num_req_vfs && queues_left) {
pf->num_req_vfs = min_t(int, pf->num_req_vfs,
(queues_left / pf->num_vf_qps));
queues_left -= (pf->num_req_vfs * pf->num_vf_qps);
}
if ((pf->flags & I40E_FLAG_VMDQ_ENABLED) &&
pf->num_vmdq_vsis && pf->num_vmdq_qps && queues_left) {
pf->num_vmdq_vsis = min_t(int, pf->num_vmdq_vsis,
(queues_left / pf->num_vmdq_qps));
queues_left -= (pf->num_vmdq_vsis * pf->num_vmdq_qps);
}
pf->queues_left = queues_left;
dev_dbg(&pf->pdev->dev,
"qs_avail=%d FD SB=%d lan_qs=%d lan_tc0=%d vf=%d*%d vmdq=%d*%d, remaining=%d\n",
pf->hw.func_caps.num_tx_qp,
!!(pf->flags & I40E_FLAG_FD_SB_ENABLED),
pf->num_lan_qps, pf->alloc_rss_size, pf->num_req_vfs,
pf->num_vf_qps, pf->num_vmdq_vsis, pf->num_vmdq_qps,
queues_left);
} | 0 |
linux | f8bd2258e2d520dff28c855658bd24bdafb5102d | NOT_APPLICABLE | NOT_APPLICABLE | static __always_inline int slab_trylock(struct page *page)
{
int rc = 1;
rc = bit_spin_trylock(PG_locked, &page->flags);
return rc;
}
| 0 |
linux | ea3d7209ca01da209cda6f0dea8be9cc4b7a933b | NOT_APPLICABLE | NOT_APPLICABLE | static void print_daily_error_info(unsigned long arg)
{
struct super_block *sb = (struct super_block *) arg;
struct ext4_sb_info *sbi;
struct ext4_super_block *es;
sbi = EXT4_SB(sb);
es = sbi->s_es;
if (es->s_error_count)
/* fsck newer than v1.41.13 is needed to clean this condition. */
ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u",
le32_to_cpu(es->s_error_count));
if (es->s_first_error_time) {
printk(KERN_NOTICE "EXT4-fs (%s): initial error at time %u: %.*s:%d",
sb->s_id, le32_to_cpu(es->s_first_error_time),
(int) sizeof(es->s_first_error_func),
es->s_first_error_func,
le32_to_cpu(es->s_first_error_line));
if (es->s_first_error_ino)
printk(": inode %u",
le32_to_cpu(es->s_first_error_ino));
if (es->s_first_error_block)
printk(": block %llu", (unsigned long long)
le64_to_cpu(es->s_first_error_block));
printk("\n");
}
if (es->s_last_error_time) {
printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d",
sb->s_id, le32_to_cpu(es->s_last_error_time),
(int) sizeof(es->s_last_error_func),
es->s_last_error_func,
le32_to_cpu(es->s_last_error_line));
if (es->s_last_error_ino)
printk(": inode %u",
le32_to_cpu(es->s_last_error_ino));
if (es->s_last_error_block)
printk(": block %llu", (unsigned long long)
le64_to_cpu(es->s_last_error_block));
printk("\n");
}
mod_timer(&sbi->s_err_report, jiffies + 24*60*60*HZ); /* Once a day */
}
| 0 |
tensorflow | 97282c6d0d34476b6ba033f961590b783fa184cd | NOT_APPLICABLE | NOT_APPLICABLE | Status GraphProperties::InferDynamically(Cluster* cluster) {
TF_RETURN_IF_ERROR(cluster->Initialize(item_));
// Runs the model once to collect the shapes in the cost model.
RunMetadata metadata;
TF_RETURN_IF_ERROR(
cluster->Run(item_.graph, item_.feed, item_.fetch, &metadata));
return InferFromCostGraph(metadata.cost_graph());
} | 0 |
mono | 65292a69c837b8a5f7a392d34db63de592153358 | NOT_APPLICABLE | NOT_APPLICABLE | mono_class_repect_method_constraints (VerifyContext *ctx, MonoClass *klass)
{
MonoGenericClass *gklass = klass->generic_class;
MonoGenericInst *ginst = gklass->context.class_inst;
MonoGenericContainer *gc = gklass->container_class->generic_container;
return !gc || generic_arguments_respect_constraints (ctx, gc, &gklass->context, ginst);
} | 0 |
linux | 5d26a105b5a73e5635eae0629b42fa0a90e07b7b | NOT_APPLICABLE | NOT_APPLICABLE | static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
bool enc)
{
bool fpu_enabled = false;
struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
const unsigned int bsize = CAST5_BLOCK_SIZE;
unsigned int nbytes;
void (*fn)(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
int err;
fn = (enc) ? cast5_ecb_enc_16way : cast5_ecb_dec_16way;
err = blkcipher_walk_virt(desc, walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
while ((nbytes = walk->nbytes)) {
u8 *wsrc = walk->src.virt.addr;
u8 *wdst = walk->dst.virt.addr;
fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes);
/* Process multi-block batch */
if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) {
do {
fn(ctx, wdst, wsrc);
wsrc += bsize * CAST5_PARALLEL_BLOCKS;
wdst += bsize * CAST5_PARALLEL_BLOCKS;
nbytes -= bsize * CAST5_PARALLEL_BLOCKS;
} while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS);
if (nbytes < bsize)
goto done;
}
fn = (enc) ? __cast5_encrypt : __cast5_decrypt;
/* Handle leftovers */
do {
fn(ctx, wdst, wsrc);
wsrc += bsize;
wdst += bsize;
nbytes -= bsize;
} while (nbytes >= bsize);
done:
err = blkcipher_walk_done(desc, walk, nbytes);
}
cast5_fpu_end(fpu_enabled);
return err;
}
| 0 |
ghostscript | 6d444c273da5499a4cd72f21cb6d4c9a5256807d | NOT_APPLICABLE | NOT_APPLICABLE | void errflush(const gs_memory_t *mem)
{
if (!mem->gs_lib_ctx->stderr_fn)
fflush(mem->gs_lib_ctx->fstderr);
/* else nothing to flush */
}
| 0 |
linux | 01ea173e103edd5ec41acec65b9261b87e123fc2 | NOT_APPLICABLE | NOT_APPLICABLE | xfs_rename(
struct xfs_inode *src_dp,
struct xfs_name *src_name,
struct xfs_inode *src_ip,
struct xfs_inode *target_dp,
struct xfs_name *target_name,
struct xfs_inode *target_ip,
unsigned int flags)
{
struct xfs_mount *mp = src_dp->i_mount;
struct xfs_trans *tp;
struct xfs_inode *wip = NULL; /* whiteout inode */
struct xfs_inode *inodes[__XFS_SORT_INODES];
int i;
int num_inodes = __XFS_SORT_INODES;
bool new_parent = (src_dp != target_dp);
bool src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode);
int spaceres;
int error;
trace_xfs_rename(src_dp, target_dp, src_name, target_name);
if ((flags & RENAME_EXCHANGE) && !target_ip)
return -EINVAL;
/*
* If we are doing a whiteout operation, allocate the whiteout inode
* we will be placing at the target and ensure the type is set
* appropriately.
*/
if (flags & RENAME_WHITEOUT) {
ASSERT(!(flags & (RENAME_NOREPLACE | RENAME_EXCHANGE)));
error = xfs_rename_alloc_whiteout(target_dp, &wip);
if (error)
return error;
/* setup target dirent info as whiteout */
src_name->type = XFS_DIR3_FT_CHRDEV;
}
xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, wip,
inodes, &num_inodes);
spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, spaceres, 0, 0, &tp);
if (error == -ENOSPC) {
spaceres = 0;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, 0, 0, 0,
&tp);
}
if (error)
goto out_release_wip;
/*
* Attach the dquots to the inodes
*/
error = xfs_qm_vop_rename_dqattach(inodes);
if (error)
goto out_trans_cancel;
/*
* Lock all the participating inodes. Depending upon whether
* the target_name exists in the target directory, and
* whether the target directory is the same as the source
* directory, we can lock from 2 to 4 inodes.
*/
xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL);
/*
* Join all the inodes to the transaction. From this point on,
* we can rely on either trans_commit or trans_cancel to unlock
* them.
*/
xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL);
if (new_parent)
xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL);
if (target_ip)
xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL);
if (wip)
xfs_trans_ijoin(tp, wip, XFS_ILOCK_EXCL);
/*
* If we are using project inheritance, we only allow renames
* into our tree when the project IDs are the same; else the
* tree quota mechanism would be circumvented.
*/
if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
target_dp->i_d.di_projid != src_ip->i_d.di_projid)) {
error = -EXDEV;
goto out_trans_cancel;
}
/* RENAME_EXCHANGE is unique from here on. */
if (flags & RENAME_EXCHANGE)
return xfs_cross_rename(tp, src_dp, src_name, src_ip,
target_dp, target_name, target_ip,
spaceres);
/*
* Check for expected errors before we dirty the transaction
* so we can return an error without a transaction abort.
*
* Extent count overflow check:
*
* From the perspective of src_dp, a rename operation is essentially a
* directory entry remove operation. Hence the only place where we check
* for extent count overflow for src_dp is in
* xfs_bmap_del_extent_real(). xfs_bmap_del_extent_real() returns
* -ENOSPC when it detects a possible extent count overflow and in
* response, the higher layers of directory handling code do the
* following:
* 1. Data/Free blocks: XFS lets these blocks linger until a
* future remove operation removes them.
* 2. Dabtree blocks: XFS swaps the blocks with the last block in the
* Leaf space and unmaps the last block.
*
* For target_dp, there are two cases depending on whether the
* destination directory entry exists or not.
*
* When destination directory entry does not exist (i.e. target_ip ==
* NULL), extent count overflow check is performed only when transaction
* has a non-zero sized space reservation associated with it. With a
* zero-sized space reservation, XFS allows a rename operation to
* continue only when the directory has sufficient free space in its
* data/leaf/free space blocks to hold the new entry.
*
* When destination directory entry exists (i.e. target_ip != NULL), all
* we need to do is change the inode number associated with the already
* existing entry. Hence there is no need to perform an extent count
* overflow check.
*/
if (target_ip == NULL) {
/*
* If there's no space reservation, check the entry will
* fit before actually inserting it.
*/
if (!spaceres) {
error = xfs_dir_canenter(tp, target_dp, target_name);
if (error)
goto out_trans_cancel;
} else {
error = xfs_iext_count_may_overflow(target_dp,
XFS_DATA_FORK,
XFS_IEXT_DIR_MANIP_CNT(mp));
if (error)
goto out_trans_cancel;
}
} else {
/*
* If target exists and it's a directory, check that whether
* it can be destroyed.
*/
if (S_ISDIR(VFS_I(target_ip)->i_mode) &&
(!xfs_dir_isempty(target_ip) ||
(VFS_I(target_ip)->i_nlink > 2))) {
error = -EEXIST;
goto out_trans_cancel;
}
}
/*
* Lock the AGI buffers we need to handle bumping the nlink of the
* whiteout inode off the unlinked list and to handle dropping the
* nlink of the target inode. Per locking order rules, do this in
* increasing AG order and before directory block allocation tries to
* grab AGFs because we grab AGIs before AGFs.
*
* The (vfs) caller must ensure that if src is a directory then
* target_ip is either null or an empty directory.
*/
for (i = 0; i < num_inodes && inodes[i] != NULL; i++) {
if (inodes[i] == wip ||
(inodes[i] == target_ip &&
(VFS_I(target_ip)->i_nlink == 1 || src_is_directory))) {
struct xfs_buf *bp;
xfs_agnumber_t agno;
agno = XFS_INO_TO_AGNO(mp, inodes[i]->i_ino);
error = xfs_read_agi(mp, tp, agno, &bp);
if (error)
goto out_trans_cancel;
}
}
/*
* Directory entry creation below may acquire the AGF. Remove
* the whiteout from the unlinked list first to preserve correct
* AGI/AGF locking order. This dirties the transaction so failures
* after this point will abort and log recovery will clean up the
* mess.
*
* For whiteouts, we need to bump the link count on the whiteout
* inode. After this point, we have a real link, clear the tmpfile
* state flag from the inode so it doesn't accidentally get misused
* in future.
*/
if (wip) {
ASSERT(VFS_I(wip)->i_nlink == 0);
error = xfs_iunlink_remove(tp, wip);
if (error)
goto out_trans_cancel;
xfs_bumplink(tp, wip);
VFS_I(wip)->i_state &= ~I_LINKABLE;
}
/*
* Set up the target.
*/
if (target_ip == NULL) {
/*
* If target does not exist and the rename crosses
* directories, adjust the target directory link count
* to account for the ".." reference from the new entry.
*/
error = xfs_dir_createname(tp, target_dp, target_name,
src_ip->i_ino, spaceres);
if (error)
goto out_trans_cancel;
xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
if (new_parent && src_is_directory) {
xfs_bumplink(tp, target_dp);
}
} else { /* target_ip != NULL */
/*
* Link the source inode under the target name.
* If the source inode is a directory and we are moving
* it across directories, its ".." entry will be
* inconsistent until we replace that down below.
*
* In case there is already an entry with the same
* name at the destination directory, remove it first.
*/
error = xfs_dir_replace(tp, target_dp, target_name,
src_ip->i_ino, spaceres);
if (error)
goto out_trans_cancel;
xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
/*
* Decrement the link count on the target since the target
* dir no longer points to it.
*/
error = xfs_droplink(tp, target_ip);
if (error)
goto out_trans_cancel;
if (src_is_directory) {
/*
* Drop the link from the old "." entry.
*/
error = xfs_droplink(tp, target_ip);
if (error)
goto out_trans_cancel;
}
} /* target_ip != NULL */
/*
* Remove the source.
*/
if (new_parent && src_is_directory) {
/*
* Rewrite the ".." entry to point to the new
* directory.
*/
error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
target_dp->i_ino, spaceres);
ASSERT(error != -EEXIST);
if (error)
goto out_trans_cancel;
}
/*
* We always want to hit the ctime on the source inode.
*
* This isn't strictly required by the standards since the source
* inode isn't really being changed, but old unix file systems did
* it and some incremental backup programs won't work without it.
*/
xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG);
xfs_trans_log_inode(tp, src_ip, XFS_ILOG_CORE);
/*
* Adjust the link count on src_dp. This is necessary when
* renaming a directory, either within one parent when
* the target existed, or across two parent directories.
*/
if (src_is_directory && (new_parent || target_ip != NULL)) {
/*
* Decrement link count on src_directory since the
* entry that's moved no longer points to it.
*/
error = xfs_droplink(tp, src_dp);
if (error)
goto out_trans_cancel;
}
/*
* For whiteouts, we only need to update the source dirent with the
* inode number of the whiteout inode rather than removing it
* altogether.
*/
if (wip) {
error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
spaceres);
} else {
/*
* NOTE: We don't need to check for extent count overflow here
* because the dir remove name code will leave the dir block in
* place if the extent count would overflow.
*/
error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
spaceres);
}
if (error)
goto out_trans_cancel;
xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE);
if (new_parent)
xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE);
error = xfs_finish_rename(tp);
if (wip)
xfs_irele(wip);
return error;
out_trans_cancel:
xfs_trans_cancel(tp);
out_release_wip:
if (wip)
xfs_irele(wip);
return error;
} | 0 |
server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | NOT_APPLICABLE | NOT_APPLICABLE | const Type_handler *type_handler_for_comparison() const
{
return type_handler()->type_handler_for_comparison();
} | 0 |
Chrome | 0720b02e4f303ea6b114d4ae9453e3a7ff55f8dc | NOT_APPLICABLE | NOT_APPLICABLE | RenderFrameHostImpl* WebContentsImpl::FindFrameByFrameTreeNodeId(
int frame_tree_node_id,
int process_id) {
FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id);
if (!frame ||
frame->current_frame_host()->GetProcess()->GetID() != process_id)
return nullptr;
return frame->current_frame_host();
}
| 0 |
git | fd55a19eb1d49ae54008d932a65f79cd6fda45c9 | NOT_APPLICABLE | NOT_APPLICABLE | static void run_diffstat(struct diff_filepair *p, struct diff_options *o,
struct diffstat_t *diffstat)
{
const char *name;
const char *other;
int complete_rewrite = 0;
if (DIFF_PAIR_UNMERGED(p)) {
/* unmerged */
builtin_diffstat(p->one->path, NULL, NULL, NULL, diffstat, o, 0);
return;
}
name = p->one->path;
other = (strcmp(name, p->two->path) ? p->two->path : NULL);
if (o->prefix_length)
strip_prefix(o->prefix_length, &name, &other);
diff_fill_sha1_info(p->one);
diff_fill_sha1_info(p->two);
if (p->status == DIFF_STATUS_MODIFIED && p->score)
complete_rewrite = 1;
builtin_diffstat(name, other, p->one, p->two, diffstat, o, complete_rewrite);
} | 0 |
linux | 0b79459b482e85cb7426aa7da683a9f2c97aeae1 | NOT_APPLICABLE | NOT_APPLICABLE | static int complete_emulated_mmio(struct kvm_vcpu *vcpu)
{
struct kvm_run *run = vcpu->run;
struct kvm_mmio_fragment *frag;
unsigned len;
BUG_ON(!vcpu->mmio_needed);
/* Complete previous fragment */
frag = &vcpu->mmio_fragments[vcpu->mmio_cur_fragment];
len = min(8u, frag->len);
if (!vcpu->mmio_is_write)
memcpy(frag->data, run->mmio.data, len);
if (frag->len <= 8) {
/* Switch to the next fragment. */
frag++;
vcpu->mmio_cur_fragment++;
} else {
/* Go forward to the next mmio piece. */
frag->data += len;
frag->gpa += len;
frag->len -= len;
}
if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) {
vcpu->mmio_needed = 0;
if (vcpu->mmio_is_write)
return 1;
vcpu->mmio_read_completed = 1;
return complete_emulated_io(vcpu);
}
run->exit_reason = KVM_EXIT_MMIO;
run->mmio.phys_addr = frag->gpa;
if (vcpu->mmio_is_write)
memcpy(run->mmio.data, frag->data, min(8u, frag->len));
run->mmio.len = min(8u, frag->len);
run->mmio.is_write = vcpu->mmio_is_write;
vcpu->arch.complete_userspace_io = complete_emulated_mmio;
return 0;
}
| 0 |
gst-plugins-good | 87a2c140ca54c5128093377e9b25a5c24b346727 | NOT_APPLICABLE | NOT_APPLICABLE | gst_aac_parse_start (GstBaseParse * parse)
{
GstAacParse *aacparse;
aacparse = GST_AAC_PARSE (parse);
GST_DEBUG ("start");
aacparse->frame_samples = 1024;
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse), ADTS_MAX_SIZE);
aacparse->sent_codec_tag = FALSE;
aacparse->last_parsed_channels = 0;
aacparse->last_parsed_sample_rate = 0;
return TRUE;
} | 0 |
linux | 550fd08c2cebad61c548def135f67aba284c6162 | NOT_APPLICABLE | NOT_APPLICABLE | static int mpi_send_packet (struct net_device *dev)
{
struct sk_buff *skb;
unsigned char *buffer;
s16 len;
__le16 *payloadLen;
struct airo_info *ai = dev->ml_priv;
u8 *sendbuf;
/* get a packet to send */
if ((skb = skb_dequeue(&ai->txq)) == NULL) {
airo_print_err(dev->name,
"%s: Dequeue'd zero in send_packet()",
__func__);
return 0;
}
/* check min length*/
len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
buffer = skb->data;
ai->txfids[0].tx_desc.offset = 0;
ai->txfids[0].tx_desc.valid = 1;
ai->txfids[0].tx_desc.eoc = 1;
ai->txfids[0].tx_desc.len =len+sizeof(WifiHdr);
/*
* Magic, the cards firmware needs a length count (2 bytes) in the host buffer
* right after TXFID_HDR.The TXFID_HDR contains the status short so payloadlen
* is immediately after it. ------------------------------------------------
* |TXFIDHDR+STATUS|PAYLOADLEN|802.3HDR|PACKETDATA|
* ------------------------------------------------
*/
memcpy((char *)ai->txfids[0].virtual_host_addr,
(char *)&wifictlhdr8023, sizeof(wifictlhdr8023));
payloadLen = (__le16 *)(ai->txfids[0].virtual_host_addr +
sizeof(wifictlhdr8023));
sendbuf = ai->txfids[0].virtual_host_addr +
sizeof(wifictlhdr8023) + 2 ;
/*
* Firmware automatically puts 802 header on so
* we don't need to account for it in the length
*/
if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled &&
(ntohs(((__be16 *)buffer)[6]) != 0x888E)) {
MICBuffer pMic;
if (encapsulate(ai, (etherHead *)buffer, &pMic, len - sizeof(etherHead)) != SUCCESS)
return ERROR;
*payloadLen = cpu_to_le16(len-sizeof(etherHead)+sizeof(pMic));
ai->txfids[0].tx_desc.len += sizeof(pMic);
/* copy data into airo dma buffer */
memcpy (sendbuf, buffer, sizeof(etherHead));
buffer += sizeof(etherHead);
sendbuf += sizeof(etherHead);
memcpy (sendbuf, &pMic, sizeof(pMic));
sendbuf += sizeof(pMic);
memcpy (sendbuf, buffer, len - sizeof(etherHead));
} else {
*payloadLen = cpu_to_le16(len - sizeof(etherHead));
dev->trans_start = jiffies;
/* copy data into airo dma buffer */
memcpy(sendbuf, buffer, len);
}
memcpy_toio(ai->txfids[0].card_ram_off,
&ai->txfids[0].tx_desc, sizeof(TxFid));
OUT4500(ai, EVACK, 8);
dev_kfree_skb_any(skb);
return 1;
}
| 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | //! Load image from a RAW Color Camera file, using external tool 'dcraw' \newinstance.
static CImg<T> get_load_dcraw_external(const char *const filename) {
return CImg<T>().load_dcraw_external(filename); | 0 |
Chrome | eea3300239f0b53e172a320eb8de59d0bea65f27 | NOT_APPLICABLE | NOT_APPLICABLE | WebContents* DevToolsWindow::OpenURLFromTab(
WebContents* source,
const content::OpenURLParams& params) {
DCHECK(source == main_web_contents_);
if (!params.url.SchemeIs(content::kChromeDevToolsScheme)) {
WebContents* inspected_web_contents = GetInspectedWebContents();
return inspected_web_contents ?
inspected_web_contents->OpenURL(params) : NULL;
}
bindings_->Reload();
return main_web_contents_;
}
| 0 |
linux | 81f9c4e4177d31ced6f52a89bb70e93bfb77ca03 | NOT_APPLICABLE | NOT_APPLICABLE | static int __init set_buf_size(char *str)
{
unsigned long buf_size;
if (!str)
return 0;
buf_size = memparse(str, &str);
/* nr_entries can not be zero */
if (buf_size == 0)
return 0;
trace_buf_size = buf_size;
return 1;
}
| 0 |
shapelib | c75b9281a5b9452d92e1682bdfe6019a13ed819f | NOT_APPLICABLE | NOT_APPLICABLE | static struct DataStruct * build_index (SHPHandle shp, DBFHandle dbf) {
struct DataStruct *data = malloc (sizeof *data * nShapes);
if (!data) {
fputs("malloc failed!\n", stderr);
exit(EXIT_FAILURE);
}
/* populate array */
for (int i = 0; i < nShapes; i++) {
data[i].value = malloc(sizeof data[0].value[0] * nFields);
if (0 == data[i].value) {
fputs("malloc failed!\n", stderr);
exit(EXIT_FAILURE);
}
data[i].record = i;
for (int j = 0; j < nFields; j++) {
data[i].value[j].null = 0;
switch (fldType[j]) {
case FIDType:
data[i].value[j].u.i = i;
break;
case SHPType:
{
SHPObject *feat = SHPReadObject(shp, i);
switch (feat->nSHPType) {
case SHPT_NULL:
fprintf(stderr, "Shape %d is a null feature!\n", i);
data[i].value[j].null = 1;
break;
case SHPT_POINT:
case SHPT_POINTZ:
case SHPT_POINTM:
case SHPT_MULTIPOINT:
case SHPT_MULTIPOINTZ:
case SHPT_MULTIPOINTM:
case SHPT_MULTIPATCH:
/* Y-sort bounds */
data[i].value[j].u.d = feat->dfYMax;
break;
case SHPT_ARC:
case SHPT_ARCZ:
case SHPT_ARCM:
data[i].value[j].u.d = shp_length(feat);
break;
case SHPT_POLYGON:
case SHPT_POLYGONZ:
case SHPT_POLYGONM:
data[i].value[j].u.d = shp_area(feat);
break;
default:
fputs("Can't sort on Shapefile feature type!\n", stderr);
exit(EXIT_FAILURE);
}
SHPDestroyObject(feat);
break;
}
case FTString:
data[i].value[j].null = DBFIsAttributeNULL(dbf, i, fldIdx[j]);
if (!data[i].value[j].null) {
data[i].value[j].u.s = dupstr(DBFReadStringAttribute(dbf, i, fldIdx[j]));
}
break;
case FTInteger:
case FTLogical:
data[i].value[j].null = DBFIsAttributeNULL(dbf, i, fldIdx[j]);
if (!data[i].value[j].null) {
data[i].value[j].u.i = DBFReadIntegerAttribute(dbf, i, fldIdx[j]);
}
break;
case FTDouble:
data[i].value[j].null = DBFIsAttributeNULL(dbf, i, fldIdx[j]);
if (!data[i].value[j].null) {
data[i].value[j].u.d = DBFReadDoubleAttribute(dbf, i, fldIdx[j]);
}
break;
}
}
}
#ifdef DEBUG
PrintDataStruct(data);
fputs("build_index: sorting array\n", stdout);
#endif
qsort (data, nShapes, sizeof data[0], compare);
#ifdef DEBUG
PrintDataStruct(data);
fputs("build_index: returning array\n", stdout);
#endif
return data;
} | 0 |
linux | d50f2ab6f050311dbf7b8f5501b25f0bf64a439b | NOT_APPLICABLE | NOT_APPLICABLE | static void ext4_destroy_lazyinit_thread(void)
{
/*
* If thread exited earlier
* there's nothing to be done.
*/
if (!ext4_li_info || !ext4_lazyinit_task)
return;
kthread_stop(ext4_lazyinit_task);
}
| 0 |
server | 01b39b7b0730102b88d8ea43ec719a75e9316a1e | NOT_APPLICABLE | NOT_APPLICABLE | void handle_command_error(struct st_command *command, uint error,
int sys_errno)
{
DBUG_ENTER("handle_command_error");
DBUG_PRINT("enter", ("error: %d", error));
var_set_int("$sys_errno",sys_errno);
var_set_int("$errno",error);
if (error != 0)
{
int i;
if (command->abort_on_error)
{
report_or_die("command \"%.*s\" failed with error: %u my_errno: %d "
"errno: %d",
command->first_word_len, command->query, error, my_errno,
sys_errno);
DBUG_VOID_RETURN;
}
i= match_expected_error(command, error, NULL);
if (i >= 0)
{
DBUG_PRINT("info", ("command \"%.*s\" failed with expected error: %u, errno: %d",
command->first_word_len, command->query, error,
sys_errno));
revert_properties();
DBUG_VOID_RETURN;
}
if (command->expected_errors.count > 0)
report_or_die("command \"%.*s\" failed with wrong error: %u "
"my_errno: %d errno: %d",
command->first_word_len, command->query, error, my_errno,
sys_errno);
}
else if (command->expected_errors.err[0].type == ERR_ERRNO &&
command->expected_errors.err[0].code.errnum != 0)
{
/* Error code we wanted was != 0, i.e. not an expected success */
report_or_die("command \"%.*s\" succeeded - should have failed with "
"errno %d...",
command->first_word_len, command->query,
command->expected_errors.err[0].code.errnum);
}
revert_properties();
DBUG_VOID_RETURN;
} | 0 |
libndp | a4892df306e0532487f1634ba6d4c6d4bb381c7f | NOT_APPLICABLE | NOT_APPLICABLE | int ndp_get_eventfd(struct ndp *ndp)
{
return ndp->sock;
}
| 0 |
Chrome | ee7579229ff7e9e5ae28bf53aea069251499d7da | NOT_APPLICABLE | NOT_APPLICABLE | explicit RenderbufferAttachment(
Renderbuffer* renderbuffer)
: renderbuffer_(renderbuffer) {
}
| 0 |
php-src | 426aeb2808955ee3d3f52e0cfb102834cdb836a5?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | static void php_wddx_pop_element(void *user_data, const XML_Char *name)
{
st_entry *ent1, *ent2;
wddx_stack *stack = (wddx_stack *)user_data;
HashTable *target_hash;
zend_class_entry **pce;
zval *obj;
zval *tmp;
TSRMLS_FETCH();
/* OBJECTS_FIXME */
if (stack->top == 0) {
return;
}
if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||
!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||
!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||
!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||
!strcmp(name, EL_DATETIME)) {
wddx_stack_top(stack, (void**)&ent1);
if (!ent1->data) {
if (stack->top > 1) {
stack->top--;
} else {
stack->done = 1;
}
efree(ent1);
return;
}
if (!strcmp(name, EL_BINARY)) {
int new_len=0;
unsigned char *new_str;
new_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);
STR_FREE(Z_STRVAL_P(ent1->data));
Z_STRVAL_P(ent1->data) = new_str;
Z_STRLEN_P(ent1->data) = new_len;
}
/* Call __wakeup() method on the object. */
if (Z_TYPE_P(ent1->data) == IS_OBJECT) {
zval *fname, *retval = NULL;
MAKE_STD_ZVAL(fname);
ZVAL_STRING(fname, "__wakeup", 1);
call_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);
zval_dtor(fname);
FREE_ZVAL(fname);
if (retval) {
zval_ptr_dtor(&retval);
}
}
if (stack->top > 1) {
stack->top--;
wddx_stack_top(stack, (void**)&ent2);
/* if non-existent field */
if (ent2->type == ST_FIELD && ent2->data == NULL) {
zval_ptr_dtor(&ent1->data);
efree(ent1);
return;
}
if (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {
target_hash = HASH_OF(ent2->data);
if (ent1->varname) {
if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&
Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&
ent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {
zend_bool incomplete_class = 0;
zend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));
if (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),
Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {
incomplete_class = 1;
pce = &PHP_IC_ENTRY;
}
/* Initialize target object */
MAKE_STD_ZVAL(obj);
object_init_ex(obj, *pce);
/* Merge current hashtable with object's default properties */
zend_hash_merge(Z_OBJPROP_P(obj),
Z_ARRVAL_P(ent2->data),
(void (*)(void *)) zval_add_ref,
(void *) &tmp, sizeof(zval *), 0);
if (incomplete_class) {
php_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));
}
/* Clean up old array entry */
zval_ptr_dtor(&ent2->data);
/* Set stack entry to point to the newly created object */
ent2->data = obj;
/* Clean up class name var entry */
zval_ptr_dtor(&ent1->data);
} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {
zend_class_entry *old_scope = EG(scope);
EG(scope) = Z_OBJCE_P(ent2->data);
Z_DELREF_P(ent1->data);
add_property_zval(ent2->data, ent1->varname, ent1->data);
EG(scope) = old_scope;
} else {
zend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);
}
efree(ent1->varname);
} else {
zend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);
}
}
efree(ent1);
} else {
stack->done = 1;
}
} else if (!strcmp(name, EL_VAR) && stack->varname) {
efree(stack->varname);
stack->varname = NULL;
} else if (!strcmp(name, EL_FIELD)) {
st_entry *ent;
wddx_stack_top(stack, (void **)&ent);
efree(ent);
stack->top--;
}
}
| 0 |
linux | a8b0ca17b80e92faab46ee7179ba9e99ccb61233 | NOT_APPLICABLE | NOT_APPLICABLE | task_function_call(struct task_struct *p, int (*func) (void *info), void *info)
{
struct remote_function_call data = {
.p = p,
.func = func,
.info = info,
.ret = -ESRCH, /* No such (running) process */
};
if (task_curr(p))
smp_call_function_single(task_cpu(p), remote_function, &data, 1);
return data.ret;
}
| 0 |
Chrome | 7614790c80996d32a28218f4d1605b0908e9ddf6 | NOT_APPLICABLE | NOT_APPLICABLE | WebContentsDestroyedObserver::~WebContentsDestroyedObserver() {}
| 0 |
qemu_qemu | bedd7e93d01961fcb16a97ae45d93acf357e11f6 | NOT_APPLICABLE | NOT_APPLICABLE | static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
{
VirtIONet *n = VIRTIO_NET(vdev);
struct virtio_net_config netcfg;
NetClientState *nc = qemu_get_queue(n->nic);
static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
int ret = 0;
memset(&netcfg, 0 , sizeof(struct virtio_net_config));
virtio_stw_p(vdev, &netcfg.status, n->status);
virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues);
virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu);
memcpy(netcfg.mac, n->mac, ETH_ALEN);
virtio_stl_p(vdev, &netcfg.speed, n->net_conf.speed);
netcfg.duplex = n->net_conf.duplex;
netcfg.rss_max_key_size = VIRTIO_NET_RSS_MAX_KEY_SIZE;
virtio_stw_p(vdev, &netcfg.rss_max_indirection_table_length,
virtio_host_has_feature(vdev, VIRTIO_NET_F_RSS) ?
VIRTIO_NET_RSS_MAX_TABLE_LEN : 1);
virtio_stl_p(vdev, &netcfg.supported_hash_types,
VIRTIO_NET_RSS_SUPPORTED_HASHES);
memcpy(config, &netcfg, n->config_size);
/*
* Is this VDPA? No peer means not VDPA: there's no way to
* disconnect/reconnect a VDPA peer.
*/
if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
n->config_size);
if (ret != -1) {
/*
* Some NIC/kernel combinations present 0 as the mac address. As
* that is not a legal address, try to proceed with the
* address from the QEMU command line in the hope that the
* address has been configured correctly elsewhere - just not
* reported by the device.
*/
if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
info_report("Zero hardware mac address detected. Ignoring.");
memcpy(netcfg.mac, n->mac, ETH_ALEN);
}
memcpy(config, &netcfg, n->config_size);
}
}
} | 0 |
linux | 3a9b153c5591548612c3955c9600a98150c81875 | NOT_APPLICABLE | NOT_APPLICABLE | mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,
struct mwifiex_private **priv, int *tid)
{
struct mwifiex_private *priv_tmp;
struct mwifiex_ra_list_tbl *ptr;
struct mwifiex_tid_tbl *tid_ptr;
atomic_t *hqp;
int i, j;
/* check the BSS with highest priority first */
for (j = adapter->priv_num - 1; j >= 0; --j) {
/* iterate over BSS with the equal priority */
list_for_each_entry(adapter->bss_prio_tbl[j].bss_prio_cur,
&adapter->bss_prio_tbl[j].bss_prio_head,
list) {
try_again:
priv_tmp = adapter->bss_prio_tbl[j].bss_prio_cur->priv;
if (((priv_tmp->bss_mode != NL80211_IFTYPE_ADHOC) &&
!priv_tmp->port_open) ||
(atomic_read(&priv_tmp->wmm.tx_pkts_queued) == 0))
continue;
if (adapter->if_ops.is_port_ready &&
!adapter->if_ops.is_port_ready(priv_tmp))
continue;
/* iterate over the WMM queues of the BSS */
hqp = &priv_tmp->wmm.highest_queued_prio;
for (i = atomic_read(hqp); i >= LOW_PRIO_TID; --i) {
spin_lock_bh(&priv_tmp->wmm.ra_list_spinlock);
tid_ptr = &(priv_tmp)->wmm.
tid_tbl_ptr[tos_to_tid[i]];
/* iterate over receiver addresses */
list_for_each_entry(ptr, &tid_ptr->ra_list,
list) {
if (!ptr->tx_paused &&
!skb_queue_empty(&ptr->skb_head))
/* holds both locks */
goto found;
}
spin_unlock_bh(&priv_tmp->wmm.ra_list_spinlock);
}
if (atomic_read(&priv_tmp->wmm.tx_pkts_queued) != 0) {
atomic_set(&priv_tmp->wmm.highest_queued_prio,
HIGH_PRIO_TID);
/* Iterate current private once more, since
* there still exist packets in data queue
*/
goto try_again;
} else
atomic_set(&priv_tmp->wmm.highest_queued_prio,
NO_PKT_PRIO_TID);
}
}
return NULL;
found:
/* holds ra_list_spinlock */
if (atomic_read(hqp) > i)
atomic_set(hqp, i);
spin_unlock_bh(&priv_tmp->wmm.ra_list_spinlock);
*priv = priv_tmp;
*tid = tos_to_tid[i];
return ptr;
} | 0 |
jdk11u | 6c0ba0785a2f0900be301f72764cf4dcfa720991 | NOT_APPLICABLE | NOT_APPLICABLE | void ciEnv::dump_inline_data(int compile_id) {
static char buffer[O_BUFLEN];
int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id);
if (ret > 0) {
int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd != -1) {
FILE* inline_data_file = os::open(fd, "w");
if (inline_data_file != NULL) {
fileStream replay_data_stream(inline_data_file, /*need_close=*/true);
GUARDED_VM_ENTRY(
MutexLocker ml(Compile_lock);
dump_compile_data(&replay_data_stream);
)
replay_data_stream.flush();
tty->print("# Compiler inline data is saved as: ");
tty->print_cr("%s", buffer);
} else {
tty->print_cr("# Can't open file to dump inline data.");
}
}
}
} | 0 |
php-src | 0216630ea2815a5789a24279a1211ac398d4de79 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_MINIT_FUNCTION(openssl)
{
char * config_filename;
le_key = zend_register_list_destructors_ex(php_openssl_pkey_free, NULL, "OpenSSL key", module_number);
le_x509 = zend_register_list_destructors_ex(php_openssl_x509_free, NULL, "OpenSSL X.509", module_number);
le_csr = zend_register_list_destructors_ex(php_openssl_csr_free, NULL, "OpenSSL X.509 CSR", module_number);
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
OPENSSL_config(NULL);
SSL_library_init();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
OpenSSL_add_all_algorithms();
#if !defined(OPENSSL_NO_AES) && defined(EVP_CIPH_CCM_MODE) && OPENSSL_VERSION_NUMBER < 0x100020000
EVP_add_cipher(EVP_aes_128_ccm());
EVP_add_cipher(EVP_aes_192_ccm());
EVP_add_cipher(EVP_aes_256_ccm());
#endif
SSL_load_error_strings();
#else
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
#endif
/* register a resource id number with OpenSSL so that we can map SSL -> stream structures in
* OpenSSL callbacks */
ssl_stream_data_index = SSL_get_ex_new_index(0, "PHP stream index", NULL, NULL, NULL);
REGISTER_STRING_CONSTANT("OPENSSL_VERSION_TEXT", OPENSSL_VERSION_TEXT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_VERSION_NUMBER", OPENSSL_VERSION_NUMBER, CONST_CS|CONST_PERSISTENT);
/* purposes for cert purpose checking */
REGISTER_LONG_CONSTANT("X509_PURPOSE_SSL_CLIENT", X509_PURPOSE_SSL_CLIENT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("X509_PURPOSE_SSL_SERVER", X509_PURPOSE_SSL_SERVER, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("X509_PURPOSE_NS_SSL_SERVER", X509_PURPOSE_NS_SSL_SERVER, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("X509_PURPOSE_SMIME_SIGN", X509_PURPOSE_SMIME_SIGN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("X509_PURPOSE_SMIME_ENCRYPT", X509_PURPOSE_SMIME_ENCRYPT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("X509_PURPOSE_CRL_SIGN", X509_PURPOSE_CRL_SIGN, CONST_CS|CONST_PERSISTENT);
#ifdef X509_PURPOSE_ANY
REGISTER_LONG_CONSTANT("X509_PURPOSE_ANY", X509_PURPOSE_ANY, CONST_CS|CONST_PERSISTENT);
#endif
/* signature algorithm constants */
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA1", OPENSSL_ALGO_SHA1, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD5", OPENSSL_ALGO_MD5, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD4", OPENSSL_ALGO_MD4, CONST_CS|CONST_PERSISTENT);
#ifdef HAVE_OPENSSL_MD2_H
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT);
#endif
#if PHP_OPENSSL_API_VERSION < 0x10100
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA224", OPENSSL_ALGO_SHA224, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA256", OPENSSL_ALGO_SHA256, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA384", OPENSSL_ALGO_SHA384, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA512", OPENSSL_ALGO_SHA512, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ALGO_RMD160", OPENSSL_ALGO_RMD160, CONST_CS|CONST_PERSISTENT);
/* flags for S/MIME */
REGISTER_LONG_CONSTANT("PKCS7_DETACHED", PKCS7_DETACHED, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_TEXT", PKCS7_TEXT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_NOINTERN", PKCS7_NOINTERN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_NOVERIFY", PKCS7_NOVERIFY, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_NOCHAIN", PKCS7_NOCHAIN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_NOCERTS", PKCS7_NOCERTS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_NOATTR", PKCS7_NOATTR, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_BINARY", PKCS7_BINARY, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PKCS7_NOSIGS", PKCS7_NOSIGS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_PKCS1_PADDING", RSA_PKCS1_PADDING, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_SSLV23_PADDING", RSA_SSLV23_PADDING, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_NO_PADDING", RSA_NO_PADDING, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_PKCS1_OAEP_PADDING", RSA_PKCS1_OAEP_PADDING, CONST_CS|CONST_PERSISTENT);
/* Informational stream wrapper constants */
REGISTER_STRING_CONSTANT("OPENSSL_DEFAULT_STREAM_CIPHERS", OPENSSL_DEFAULT_STREAM_CIPHERS, CONST_CS|CONST_PERSISTENT);
/* Ciphers */
#ifndef OPENSSL_NO_RC2
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_RC2_40", PHP_OPENSSL_CIPHER_RC2_40, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_RC2_128", PHP_OPENSSL_CIPHER_RC2_128, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_RC2_64", PHP_OPENSSL_CIPHER_RC2_64, CONST_CS|CONST_PERSISTENT);
#endif
#ifndef OPENSSL_NO_DES
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_DES", PHP_OPENSSL_CIPHER_DES, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_3DES", PHP_OPENSSL_CIPHER_3DES, CONST_CS|CONST_PERSISTENT);
#endif
#ifndef OPENSSL_NO_AES
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_128_CBC", PHP_OPENSSL_CIPHER_AES_128_CBC, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_192_CBC", PHP_OPENSSL_CIPHER_AES_192_CBC, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_256_CBC", PHP_OPENSSL_CIPHER_AES_256_CBC, CONST_CS|CONST_PERSISTENT);
#endif
/* Values for key types */
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_RSA", OPENSSL_KEYTYPE_RSA, CONST_CS|CONST_PERSISTENT);
#ifndef NO_DSA
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DSA", OPENSSL_KEYTYPE_DSA, CONST_CS|CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DH", OPENSSL_KEYTYPE_DH, CONST_CS|CONST_PERSISTENT);
#ifdef HAVE_EVP_PKEY_EC
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_EC", OPENSSL_KEYTYPE_EC, CONST_CS|CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("OPENSSL_RAW_DATA", OPENSSL_RAW_DATA, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_ZERO_PADDING", OPENSSL_ZERO_PADDING, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OPENSSL_DONT_ZERO_PAD_KEY", OPENSSL_DONT_ZERO_PAD_KEY, CONST_CS|CONST_PERSISTENT);
#ifndef OPENSSL_NO_TLSEXT
/* SNI support included */
REGISTER_LONG_CONSTANT("OPENSSL_TLSEXT_SERVER_NAME", 1, CONST_CS|CONST_PERSISTENT);
#endif
/* Determine default SSL configuration file */
config_filename = getenv("OPENSSL_CONF");
if (config_filename == NULL) {
config_filename = getenv("SSLEAY_CONF");
}
/* default to 'openssl.cnf' if no environment variable is set */
if (config_filename == NULL) {
snprintf(default_ssl_conf_filename, sizeof(default_ssl_conf_filename), "%s/%s",
X509_get_default_cert_area(),
"openssl.cnf");
} else {
strlcpy(default_ssl_conf_filename, config_filename, sizeof(default_ssl_conf_filename));
}
php_stream_xport_register("ssl", php_openssl_ssl_socket_factory);
#ifndef OPENSSL_NO_SSL3
php_stream_xport_register("sslv3", php_openssl_ssl_socket_factory);
#endif
php_stream_xport_register("tls", php_openssl_ssl_socket_factory);
php_stream_xport_register("tlsv1.0", php_openssl_ssl_socket_factory);
php_stream_xport_register("tlsv1.1", php_openssl_ssl_socket_factory);
php_stream_xport_register("tlsv1.2", php_openssl_ssl_socket_factory);
/* override the default tcp socket provider */
php_stream_xport_register("tcp", php_openssl_ssl_socket_factory);
php_register_url_stream_wrapper("https", &php_stream_http_wrapper);
php_register_url_stream_wrapper("ftps", &php_stream_ftp_wrapper);
REGISTER_INI_ENTRIES();
return SUCCESS;
} | 0 |
php-src | 06d309fd7a917575d65c7a6f4f57b0e6bb0f9711 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_FUNCTION(iconv_mime_decode_headers)
{
const char *encoded_str;
int encoded_str_len;
char *charset = get_internal_encoding(TSRMLS_C);
int charset_len = 0;
long mode = 0;
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
&encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
}
if (charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}
array_init(return_value);
while (encoded_str_len > 0) {
smart_str decoded_header = {0};
char *header_name = NULL;
size_t header_name_len = 0;
char *header_value = NULL;
size_t header_value_len = 0;
char *p, *limit;
const char *next_pos;
if (PHP_ICONV_ERR_SUCCESS != (err = _php_iconv_mime_decode(&decoded_header, encoded_str, encoded_str_len, charset, &next_pos, mode))) {
smart_str_free(&decoded_header);
break;
}
if (decoded_header.c == NULL) {
break;
}
limit = decoded_header.c + decoded_header.len;
for (p = decoded_header.c; p < limit; p++) {
if (*p == ':') {
*p = '\0';
header_name = decoded_header.c;
header_name_len = (p - decoded_header.c) + 1;
while (++p < limit) {
if (*p != ' ' && *p != '\t') {
break;
}
}
header_value = p;
header_value_len = limit - p;
break;
}
}
if (header_name != NULL) {
zval **elem, *new_elem;
if (zend_hash_find(Z_ARRVAL_P(return_value), header_name, header_name_len, (void **)&elem) == SUCCESS) {
if (Z_TYPE_PP(elem) != IS_ARRAY) {
MAKE_STD_ZVAL(new_elem);
array_init(new_elem);
Z_ADDREF_PP(elem);
add_next_index_zval(new_elem, *elem);
zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL);
elem = &new_elem;
}
add_next_index_stringl(*elem, header_value, header_value_len, 1);
} else {
add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len, 1);
}
}
encoded_str_len -= next_pos - encoded_str;
encoded_str = next_pos;
smart_str_free(&decoded_header);
}
if (err != PHP_ICONV_ERR_SUCCESS) {
_php_iconv_show_error(err, charset, "???" TSRMLS_CC);
zval_dtor(return_value);
RETVAL_FALSE;
}
} | 0 |
FreeRDP | 2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6 | CVE-2018-8789 | CWE-125 | void ntlm_write_message_fields(wStream* s, NTLM_MESSAGE_FIELDS* fields)
{
if (fields->MaxLen < 1)
fields->MaxLen = fields->Len;
Stream_Write_UINT16(s, fields->Len); /* Len (2 bytes) */
Stream_Write_UINT16(s, fields->MaxLen); /* MaxLen (2 bytes) */
Stream_Write_UINT32(s, fields->BufferOffset); /* BufferOffset (4 bytes) */
}
| 1 |
linux | f63a8daa5812afef4f06c962351687e1ff9ccb2b | NOT_APPLICABLE | NOT_APPLICABLE | static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
{
struct vm_area_struct *vma = mmap_event->vma;
struct file *file = vma->vm_file;
int maj = 0, min = 0;
u64 ino = 0, gen = 0;
u32 prot = 0, flags = 0;
unsigned int size;
char tmp[16];
char *buf = NULL;
char *name;
if (file) {
struct inode *inode;
dev_t dev;
buf = kmalloc(PATH_MAX, GFP_KERNEL);
if (!buf) {
name = "//enomem";
goto cpy_name;
}
/*
* d_path() works from the end of the rb backwards, so we
* need to add enough zero bytes after the string to handle
* the 64bit alignment we do later.
*/
name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
if (IS_ERR(name)) {
name = "//toolong";
goto cpy_name;
}
inode = file_inode(vma->vm_file);
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
gen = inode->i_generation;
maj = MAJOR(dev);
min = MINOR(dev);
if (vma->vm_flags & VM_READ)
prot |= PROT_READ;
if (vma->vm_flags & VM_WRITE)
prot |= PROT_WRITE;
if (vma->vm_flags & VM_EXEC)
prot |= PROT_EXEC;
if (vma->vm_flags & VM_MAYSHARE)
flags = MAP_SHARED;
else
flags = MAP_PRIVATE;
if (vma->vm_flags & VM_DENYWRITE)
flags |= MAP_DENYWRITE;
if (vma->vm_flags & VM_MAYEXEC)
flags |= MAP_EXECUTABLE;
if (vma->vm_flags & VM_LOCKED)
flags |= MAP_LOCKED;
if (vma->vm_flags & VM_HUGETLB)
flags |= MAP_HUGETLB;
goto got_name;
} else {
if (vma->vm_ops && vma->vm_ops->name) {
name = (char *) vma->vm_ops->name(vma);
if (name)
goto cpy_name;
}
name = (char *)arch_vma_name(vma);
if (name)
goto cpy_name;
if (vma->vm_start <= vma->vm_mm->start_brk &&
vma->vm_end >= vma->vm_mm->brk) {
name = "[heap]";
goto cpy_name;
}
if (vma->vm_start <= vma->vm_mm->start_stack &&
vma->vm_end >= vma->vm_mm->start_stack) {
name = "[stack]";
goto cpy_name;
}
name = "//anon";
goto cpy_name;
}
cpy_name:
strlcpy(tmp, name, sizeof(tmp));
name = tmp;
got_name:
/*
* Since our buffer works in 8 byte units we need to align our string
* size to a multiple of 8. However, we must guarantee the tail end is
* zero'd out to avoid leaking random bits to userspace.
*/
size = strlen(name)+1;
while (!IS_ALIGNED(size, sizeof(u64)))
name[size++] = '\0';
mmap_event->file_name = name;
mmap_event->file_size = size;
mmap_event->maj = maj;
mmap_event->min = min;
mmap_event->ino = ino;
mmap_event->ino_generation = gen;
mmap_event->prot = prot;
mmap_event->flags = flags;
if (!(vma->vm_flags & VM_EXEC))
mmap_event->event_id.header.misc |= PERF_RECORD_MISC_MMAP_DATA;
mmap_event->event_id.header.size = sizeof(mmap_event->event_id) + size;
perf_event_aux(perf_event_mmap_output,
mmap_event,
NULL);
kfree(buf);
}
| 0 |
Chrome | 11a4cc4a6d6e665d9a118fada4b7c658d6f70d95 | NOT_APPLICABLE | NOT_APPLICABLE | IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const
{
return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutSize) : m_layoutSize;
}
| 0 |
xrdb | 1027d5df07398c1507fb1fe3a9981aa6b4bc3a56 | NOT_APPLICABLE | NOT_APPLICABLE | AppendEntryToBuffer(Buffer *buffer, Entry *entry)
{
AppendToBuffer(buffer, entry->tag, strlen(entry->tag));
AppendToBuffer(buffer, ":\t", 2);
AppendToBuffer(buffer, entry->value, strlen(entry->value));
AppendToBuffer(buffer, "\n", 1);
}
| 0 |
linux | 637b58c2887e5e57850865839cc75f59184b23d1 | NOT_APPLICABLE | NOT_APPLICABLE | static void iov_fault_in_pages_read(struct iovec *iov, unsigned long len)
{
while (!iov->iov_len)
iov++;
while (len > 0) {
unsigned long this_len;
this_len = min_t(unsigned long, len, iov->iov_len);
fault_in_pages_readable(iov->iov_base, this_len);
len -= this_len;
iov++;
}
}
| 0 |
linux | c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81 | NOT_APPLICABLE | NOT_APPLICABLE | idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
{
struct idmap_legacy_upcalldata *data = container_of(msg,
struct idmap_legacy_upcalldata,
pipe_msg);
struct idmap *idmap = data->idmap;
if (msg->errno)
nfs_idmap_abort_pipe_upcall(idmap, msg->errno);
}
| 0 |
linux | c444eb564fb16645c172d550359cb3d75fe8a040 | NOT_APPLICABLE | NOT_APPLICABLE | spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
{
spinlock_t *ptl;
ptl = pmd_lock(vma->vm_mm, pmd);
if (likely(is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) ||
pmd_devmap(*pmd)))
return ptl;
spin_unlock(ptl);
return NULL;
} | 0 |
ImageMagick | f391a5f4554fe47eb56d6277ac32d1f698572f0e | NOT_APPLICABLE | NOT_APPLICABLE | MagickExport void XRetainWindowColors(Display *display,const Window window)
{
Atom
property;
Pixmap
pixmap;
/*
Put property on the window.
*/
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(display != (Display *) NULL);
assert(window != (Window) NULL);
property=XInternAtom(display,"_XSETROOT_ID",MagickFalse);
if (property == (Atom) NULL)
{
ThrowXWindowException(XServerError,"UnableToCreateProperty",
"_XSETROOT_ID");
return;
}
pixmap=XCreatePixmap(display,window,1,1,1);
if (pixmap == (Pixmap) NULL)
{
ThrowXWindowException(XServerError,"UnableToCreateBitmap","");
return;
}
(void) XChangeProperty(display,window,property,XA_PIXMAP,32,PropModeReplace,
(unsigned char *) &pixmap,1);
(void) XSetCloseDownMode(display,RetainPermanent);
} | 0 |
Subsets and Splits