project
stringclasses 788
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 126
values | func
stringlengths 14
482k
| vul
int8 0
1
|
---|---|---|---|---|---|
linux | 60a2362f769cf549dc466134efe71c8bf9fbaaba | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t regulator_suspend_mem_state_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct regulator_dev *rdev = dev_get_drvdata(dev);
return regulator_print_state(buf,
rdev->constraints->state_mem.enabled);
}
| 0 |
linux | 6f24f892871acc47b40dd594c63606a17c714f77 | NOT_APPLICABLE | NOT_APPLICABLE | static int hfsplus_cat_build_record(hfsplus_cat_entry *entry,
u32 cnid, struct inode *inode)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
if (S_ISDIR(inode->i_mode)) {
struct hfsplus_cat_folder *folder;
folder = &entry->folder;
memset(folder, 0, sizeof(*folder));
folder->type = cpu_to_be16(HFSPLUS_FOLDER);
folder->id = cpu_to_be32(inode->i_ino);
HFSPLUS_I(inode)->create_date =
folder->create_date =
folder->content_mod_date =
folder->attribute_mod_date =
folder->access_date = hfsp_now2mt();
hfsplus_cat_set_perms(inode, &folder->permissions);
if (inode == sbi->hidden_dir)
/* invisible and namelocked */
folder->user_info.frFlags = cpu_to_be16(0x5000);
return sizeof(*folder);
} else {
struct hfsplus_cat_file *file;
file = &entry->file;
memset(file, 0, sizeof(*file));
file->type = cpu_to_be16(HFSPLUS_FILE);
file->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS);
file->id = cpu_to_be32(cnid);
HFSPLUS_I(inode)->create_date =
file->create_date =
file->content_mod_date =
file->attribute_mod_date =
file->access_date = hfsp_now2mt();
if (cnid == inode->i_ino) {
hfsplus_cat_set_perms(inode, &file->permissions);
if (S_ISLNK(inode->i_mode)) {
file->user_info.fdType =
cpu_to_be32(HFSP_SYMLINK_TYPE);
file->user_info.fdCreator =
cpu_to_be32(HFSP_SYMLINK_CREATOR);
} else {
file->user_info.fdType =
cpu_to_be32(sbi->type);
file->user_info.fdCreator =
cpu_to_be32(sbi->creator);
}
if (HFSPLUS_FLG_IMMUTABLE &
(file->permissions.rootflags |
file->permissions.userflags))
file->flags |=
cpu_to_be16(HFSPLUS_FILE_LOCKED);
} else {
file->user_info.fdType =
cpu_to_be32(HFSP_HARDLINK_TYPE);
file->user_info.fdCreator =
cpu_to_be32(HFSP_HFSPLUS_CREATOR);
file->user_info.fdFlags =
cpu_to_be16(0x100);
file->create_date =
HFSPLUS_I(sbi->hidden_dir)->create_date;
file->permissions.dev =
cpu_to_be32(HFSPLUS_I(inode)->linkid);
}
return sizeof(*file);
}
}
| 0 |
linux-2.6 | 822191a2fa1584a29c3224ab328507adcaeac1ab | NOT_APPLICABLE | NOT_APPLICABLE | asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
unsigned int nfds, struct compat_timespec __user *tsp,
const compat_sigset_t __user *sigmask, compat_size_t sigsetsize)
{
compat_sigset_t ss32;
sigset_t ksigmask, sigsaved;
struct compat_timespec ts;
s64 timeout = -1;
int ret;
if (tsp) {
if (copy_from_user(&ts, tsp, sizeof(ts)))
return -EFAULT;
/* We assume that ts.tv_sec is always lower than
the number of seconds that can be expressed in
an s64. Otherwise the compiler bitches at us */
timeout = ROUND_UP(ts.tv_nsec, 1000000000/HZ);
timeout += ts.tv_sec * HZ;
}
if (sigmask) {
if (sigsetsize != sizeof(compat_sigset_t))
return -EINVAL;
if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
return -EFAULT;
sigset_from_compat(&ksigmask, &ss32);
sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
}
ret = do_sys_poll(ufds, nfds, &timeout);
/* We can restart this syscall, usually */
if (ret == -EINTR) {
/*
* Don't restore the signal mask yet. Let do_signal() deliver
* the signal on the way back to userspace, before the signal
* mask is restored.
*/
if (sigmask) {
memcpy(¤t->saved_sigmask, &sigsaved,
sizeof(sigsaved));
set_thread_flag(TIF_RESTORE_SIGMASK);
}
ret = -ERESTARTNOHAND;
} else if (sigmask)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
if (tsp && timeout >= 0) {
struct compat_timespec rts;
if (current->personality & STICKY_TIMEOUTS)
goto sticky;
/* Yes, we know it's actually an s64, but it's also positive. */
rts.tv_nsec = jiffies_to_usecs(do_div((*(u64*)&timeout), HZ)) *
1000;
rts.tv_sec = timeout;
if (compat_timespec_compare(&rts, &ts) >= 0)
rts = ts;
if (copy_to_user(tsp, &rts, sizeof(rts))) {
sticky:
/*
* If an application puts its timeval in read-only
* memory, we don't want the Linux-specific update to
* the timeval to cause a fault after the select has
* completed successfully. However, because we're not
* updating the timeval, we can't restart the system
* call.
*/
if (ret == -ERESTARTNOHAND && timeout >= 0)
ret = -EINTR;
}
}
return ret;
} | 0 |
curl | 75ca568fa1c19de4c5358fed246686de8467c238 | NOT_APPLICABLE | NOT_APPLICABLE | char *curl_unescape(const char *string, int length)
{
return curl_easy_unescape(NULL, string, length, NULL);
}
| 0 |
ImageMagick | ce08a3691a8ac29125e29fc41967b3737fa3f425 | NOT_APPLICABLE | NOT_APPLICABLE | static Image *SparseColorOption(const Image *image,
const SparseColorMethod method,const char *arguments,ExceptionInfo *exception)
{
char
token[MagickPathExtent];
const char
*p;
double
*sparse_arguments;
Image
*sparse_image;
PixelInfo
color;
MagickBooleanType
error;
register size_t
x;
size_t
number_arguments,
number_colors;
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
/*
Limit channels according to image
add up number of values needed per color.
*/
number_colors=0;
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
number_colors++;
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
number_colors++;
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
number_colors++;
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
(image->colorspace == CMYKColorspace))
number_colors++;
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
image->alpha_trait != UndefinedPixelTrait)
number_colors++;
/*
Read string, to determine number of arguments needed,
*/
p=arguments;
x=0;
while( *p != '\0' )
{
GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == ',' ) continue;
if ( isalpha((int) token[0]) || token[0] == '#' )
x += number_colors; /* color argument found */
else
x++; /* floating point argument */
}
/* control points and color values */
if ((x % (2+number_colors)) != 0)
{
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"InvalidArgument","'%s': %s", "sparse-color",
"Invalid number of Arguments");
return( (Image *) NULL);
}
error=MagickFalse;
number_arguments=x;
/* Allocate and fill in the floating point arguments */
sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
sizeof(*sparse_arguments));
if (sparse_arguments == (double *) NULL) {
(void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
"MemoryAllocationFailed","%s","SparseColorOption");
return( (Image *) NULL);
}
(void) memset(sparse_arguments,0,number_arguments*
sizeof(*sparse_arguments));
p=arguments;
x=0;
while( *p != '\0' && x < number_arguments ) {
/* X coordinate */
token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' ) break;
if ( isalpha((int) token[0]) || token[0] == '#' ) {
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
"Color found, instead of X-coord");
error=MagickTrue;
break;
}
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
/* Y coordinate */
token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' ) break;
if ( isalpha((int) token[0]) || token[0] == '#' ) {
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError, "InvalidArgument", "'%s': %s", "sparse-color",
"Color found, instead of Y-coord");
error=MagickTrue;
break;
}
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
/* color name or function given in string argument */
token[0]=','; while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' ) break;
if ( isalpha((int) token[0]) || token[0] == '#' ) {
/* Color string given */
(void) QueryColorCompliance(token,AllCompliance,&color,
exception);
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
sparse_arguments[x++] = QuantumScale*color.red;
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
sparse_arguments[x++] = QuantumScale*color.green;
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
sparse_arguments[x++] = QuantumScale*color.blue;
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
(image->colorspace == CMYKColorspace))
sparse_arguments[x++] = QuantumScale*color.black;
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
image->alpha_trait != UndefinedPixelTrait)
sparse_arguments[x++] = QuantumScale*color.alpha;
}
else {
/* Colors given as a set of floating point values - experimental */
/* NB: token contains the first floating point value to use! */
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
{
while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
break;
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
token[0] = ','; /* used this token - get another */
}
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
{
while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
break;
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
token[0] = ','; /* used this token - get another */
}
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
{
while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
break;
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
token[0] = ','; /* used this token - get another */
}
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
(image->colorspace == CMYKColorspace))
{
while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
break;
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
token[0] = ','; /* used this token - get another */
}
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
image->alpha_trait != UndefinedPixelTrait)
{
while ( token[0] == ',' ) GetNextToken(p,&p,MagickPathExtent,token);
if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
break;
sparse_arguments[x++]=StringToDouble(token,(char **) NULL);
token[0] = ','; /* used this token - get another */
}
}
}
if (error != MagickFalse)
{
sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
return((Image *) NULL);
}
if (number_arguments != x)
{
sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"InvalidArgument","'%s': %s","sparse-color","Argument Parsing Error");
return((Image *) NULL);
}
/* Call the Sparse Color Interpolation function with the parsed arguments */
sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments,
exception);
sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
return( sparse_image );
}
| 0 |
mbedtls | 83c9f495ffe70c7dd280b41fdfd4881485a3bc28 | NOT_APPLICABLE | NOT_APPLICABLE | static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl,
unsigned char *buf,
size_t *olen )
{
unsigned char *p = buf;
if( ssl->session_negotiate->mfl_code == MBEDTLS_SSL_MAX_FRAG_LEN_NONE )
{
*olen = 0;
return;
}
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, max_fragment_length extension" ) );
*p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH >> 8 ) & 0xFF );
*p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH ) & 0xFF );
*p++ = 0x00;
*p++ = 1;
*p++ = ssl->session_negotiate->mfl_code;
*olen = 5;
}
| 0 |
tensorflow | 8c6f391a2282684a25cbfec7687bd5d35261a209 | NOT_APPLICABLE | NOT_APPLICABLE | gemmlowp::FixedPoint<tRawType, tIntegerBits> SaturatingAddNonGemmlowp(
gemmlowp::FixedPoint<tRawType, tIntegerBits> a,
gemmlowp::FixedPoint<tRawType, tIntegerBits> b) {
return gemmlowp::FixedPoint<tRawType, tIntegerBits>::FromRaw(
SaturatingAddNonGemmlowp(a.raw(), b.raw()));
} | 0 |
grub | 451d80e52d851432e109771bb8febafca7a5f1f2 | NOT_APPLICABLE | NOT_APPLICABLE | grub_crypto_lookup_cipher_by_name (const char *name)
{
const gcry_cipher_spec_t *ciph;
int first = 1;
while (1)
{
for (ciph = grub_ciphers; ciph; ciph = ciph->next)
{
const char **alias;
if (grub_strcasecmp (name, ciph->name) == 0)
return ciph;
if (!ciph->aliases)
continue;
for (alias = ciph->aliases; *alias; alias++)
if (grub_strcasecmp (name, *alias) == 0)
return ciph;
}
if (grub_crypto_autoload_hook && first)
grub_crypto_autoload_hook (name);
else
return NULL;
first = 0;
}
} | 0 |
xserver | d088e3c1286b548a58e62afdc70bb40981cdb9e8 | NOT_APPLICABLE | NOT_APPLICABLE | sort_min_max(INT16 *a, INT16 *b)
{
INT16 A, B;
if (*a < 0 || *b < 0)
return;
A = *a;
B = *b;
*a = min(A, B);
*b = max(A, B);
}
| 0 |
linux | e4f3aa2e1e67bb48dfbaaf1cad59013d5a5bc276 | NOT_APPLICABLE | NOT_APPLICABLE | static int cdrom_ioctl_closetray(struct cdrom_device_info *cdi)
{
cd_dbg(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n");
if (!CDROM_CAN(CDC_CLOSE_TRAY))
return -ENOSYS;
return cdi->ops->tray_move(cdi, 0);
}
| 0 |
linux | 84c4e1f89fefe70554da0ab33be72c9be7994379 | NOT_APPLICABLE | NOT_APPLICABLE | static void free_ioctx_reqs(struct percpu_ref *ref)
{
struct kioctx *ctx = container_of(ref, struct kioctx, reqs);
/* At this point we know that there are no any in-flight requests */
if (ctx->rq_wait && atomic_dec_and_test(&ctx->rq_wait->count))
complete(&ctx->rq_wait->comp);
/* Synchronize against RCU protected table->table[] dereferences */
INIT_RCU_WORK(&ctx->free_rwork, free_ioctx);
queue_rcu_work(system_wq, &ctx->free_rwork);
} | 0 |
libguestfs | ae8bb84ecd46d7b6ef557a87725923ac8d09dce0 | NOT_APPLICABLE | NOT_APPLICABLE | resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table *md_map)
{
char *device = NULL;
char *type, *slice, *disk, *part;
int r;
if (STRPREFIX (spec, "/dev/mapper/") && guestfs_exists (g, spec) > 0) {
/* LVM2 does some strange munging on /dev/mapper paths for VGs and
* LVs which contain '-' character:
*
* ><fs> lvcreate LV--test VG--test 32
* ><fs> debug ls /dev/mapper
* VG----test-LV----test
*
* This makes it impossible to reverse those paths directly, so
* we have implemented lvm_canonical_lv_name in the daemon.
*/
device = guestfs_lvm_canonical_lv_name (g, spec);
}
else if (match3 (g, spec, re_xdev, &type, &disk, &part)) {
r = resolve_fstab_device_xdev (g, type, disk, part, &device);
free (type);
free (disk);
free (part);
if (r == -1)
return NULL;
}
else if (match2 (g, spec, re_cciss, &disk, &part)) {
r = resolve_fstab_device_cciss (g, disk, part, &device);
free (disk);
free (part);
if (r == -1)
return NULL;
}
else if (md_map && (disk = match1 (g, spec, re_mdN)) != NULL) {
mdadm_app entry;
entry.mdadm = disk;
mdadm_app *app = hash_lookup (md_map, &entry);
if (app) device = safe_strdup (g, app->app);
free (disk);
}
else if (match3 (g, spec, re_freebsd, &disk, &slice, &part)) {
/* FreeBSD disks are organized quite differently. See:
* http://www.freebsd.org/doc/handbook/disk-organization.html
* FreeBSD "partitions" are exposed as quasi-extended partitions
* numbered from 5 in Linux. I have no idea what happens when you
* have multiple "slices" (the FreeBSD term for MBR partitions).
*/
int disk_i = guestfs___parse_unsigned_int (g, disk);
int slice_i = guestfs___parse_unsigned_int (g, slice);
int part_i = part[0] - 'a' /* counting from 0 */;
free (disk);
free (slice);
free (part);
if (disk_i != -1 && disk_i <= 26 &&
slice_i > 0 && slice_i <= 1 /* > 4 .. see comment above */ &&
part_i >= 0 && part_i < 26) {
device = safe_asprintf (g, "/dev/sd%c%d", disk_i + 'a', part_i + 5);
}
}
else if ((part = match1 (g, spec, re_diskbyid)) != NULL) {
r = resolve_fstab_device_diskbyid (g, part, &device);
free (part);
if (r == -1)
return NULL;
}
/* Didn't match device pattern, return original spec unchanged. */
if (device == NULL)
device = safe_strdup (g, spec);
return device;
} | 0 |
Android | 295c883fe3105b19bcd0f9e07d54c6b589fc5bff | CVE-2016-2476 | CWE-119 | OMX_ERRORTYPE SoftGSM::internalSetParameter(
OMX_INDEXTYPE index, const OMX_PTR params) {
switch (index) {
case OMX_IndexParamAudioPcm:
{
OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
(OMX_AUDIO_PARAM_PCMMODETYPE *)params;
if (pcmParams->nPortIndex != 0 && pcmParams->nPortIndex != 1) {
return OMX_ErrorUndefined;
}
if (pcmParams->nChannels != 1) {
return OMX_ErrorUndefined;
}
if (pcmParams->nSamplingRate != 8000) {
return OMX_ErrorUndefined;
}
return OMX_ErrorNone;
}
case OMX_IndexParamStandardComponentRole:
{
const OMX_PARAM_COMPONENTROLETYPE *roleParams =
(const OMX_PARAM_COMPONENTROLETYPE *)params;
if (strncmp((const char *)roleParams->cRole,
"audio_decoder.gsm",
OMX_MAX_STRINGNAME_SIZE - 1)) {
return OMX_ErrorUndefined;
}
return OMX_ErrorNone;
}
default:
return SimpleSoftOMXComponent::internalSetParameter(index, params);
}
}
| 1 |
Android | e999f077f6ef59d20282f1e04786816a31fb8be6 | NOT_APPLICABLE | NOT_APPLICABLE | static EAS_RESULT Parse_wsmp (SDLS_SYNTHESIZER_DATA *pDLSData, EAS_I32 pos, S_WSMP_DATA *p)
{
EAS_RESULT result;
EAS_U16 wtemp;
EAS_U32 ltemp;
EAS_U32 cbSize;
/* seek to start of chunk */
if ((result = EAS_HWFileSeek(pDLSData->hwInstData, pDLSData->fileHandle, pos)) != EAS_SUCCESS)
return result;
/* get structure size */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, &cbSize, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* get unity note */
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &wtemp, EAS_FALSE)) != EAS_SUCCESS)
return result;
if (wtemp <= 127)
p->unityNote = (EAS_U8) wtemp;
else
{
p->unityNote = 60;
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Invalid unity note [%u] in DLS wsmp ignored, set to 60\n", wtemp); */ }
}
/* get fine tune */
if ((result = EAS_HWGetWord(pDLSData->hwInstData, pDLSData->fileHandle, &p->fineTune, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* get gain */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, &p->gain, EAS_FALSE)) != EAS_SUCCESS)
return result;
if (p->gain > 0)
{
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Positive gain [%ld] in DLS wsmp ignored, set to 0dB\n", p->gain); */ }
p->gain = 0;
}
/* option flags */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, <emp, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* sample loops */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, <emp, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* if looped sample, get loop data */
if (ltemp)
{
if (ltemp > 1)
{ /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "DLS sample with %lu loops, ignoring extra loops\n", ltemp); */ }
/* skip ahead to loop data */
if ((result = EAS_HWFileSeek(pDLSData->hwInstData, pDLSData->fileHandle, pos + (EAS_I32) cbSize)) != EAS_SUCCESS)
return result;
/* get structure size */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, <emp, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* get loop type */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, <emp, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* get loop start */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, &p->loopStart, EAS_FALSE)) != EAS_SUCCESS)
return result;
/* get loop length */
if ((result = EAS_HWGetDWord(pDLSData->hwInstData, pDLSData->fileHandle, &p->loopLength, EAS_FALSE)) != EAS_SUCCESS)
return result;
}
return EAS_SUCCESS;
}
| 0 |
haproxy | b4d05093bc89f71377230228007e69a1434c1a0c | NOT_APPLICABLE | NOT_APPLICABLE | int apply_filter_to_req_line(struct session *s, struct channel *req, struct hdr_exp *exp)
{
char *cur_ptr, *cur_end;
int done;
struct http_txn *txn = &s->txn;
int delta;
if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT)))
return 1;
else if (unlikely(txn->flags & TX_CLALLOW) &&
(exp->action == ACT_ALLOW ||
exp->action == ACT_DENY ||
exp->action == ACT_TARPIT))
return 0;
else if (exp->action == ACT_REMOVE)
return 0;
done = 0;
cur_ptr = req->buf->p;
cur_end = cur_ptr + txn->req.sl.rq.l;
/* Now we have the request line between cur_ptr and cur_end */
if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) {
switch (exp->action) {
case ACT_SETBE:
/* It is not possible to jump a second time.
* FIXME: should we return an HTTP/500 here so that
* the admin knows there's a problem ?
*/
if (s->be != s->fe)
break;
/* Swithing Proxy */
session_set_backend(s, (struct proxy *)exp->replace);
done = 1;
break;
case ACT_ALLOW:
txn->flags |= TX_CLALLOW;
done = 1;
break;
case ACT_DENY:
txn->flags |= TX_CLDENY;
done = 1;
break;
case ACT_TARPIT:
txn->flags |= TX_CLTARPIT;
done = 1;
break;
case ACT_REPLACE:
trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch);
if (trash.len < 0)
return -1;
delta = buffer_replace2(req->buf, cur_ptr, cur_end, trash.str, trash.len);
/* FIXME: if the user adds a newline in the replacement, the
* index will not be recalculated for now, and the new line
* will not be counted as a new header.
*/
http_msg_move_end(&txn->req, delta);
cur_end += delta;
cur_end = (char *)http_parse_reqline(&txn->req,
HTTP_MSG_RQMETH,
cur_ptr, cur_end + 1,
NULL, NULL);
if (unlikely(!cur_end))
return -1;
/* we have a full request and we know that we have either a CR
* or an LF at <ptr>.
*/
txn->meth = find_http_meth(cur_ptr, txn->req.sl.rq.m_l);
hdr_idx_set_start(&txn->hdr_idx, txn->req.sl.rq.l, *cur_end == '\r');
/* there is no point trying this regex on headers */
return 1;
}
}
return done;
}
| 0 |
php-src | 8947fd9e9fdce87cd6c59817b1db58e789538fe9 | NOT_APPLICABLE | NOT_APPLICABLE | static SLJIT_INLINE void read_char(compiler_common *common)
{
read_char_range(common, 0, READ_CHAR_MAX, TRUE);
} | 0 |
Chrome | ef97ce340c462d5212336f09bf8075d1cb10faa4 | NOT_APPLICABLE | NOT_APPLICABLE | void PpapiPluginProcessHost::DidCreateOutOfProcessInstance(
int plugin_process_id,
int32 pp_instance,
int render_process_id,
int render_view_id) {
for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) {
if (iter->process_.get() &&
iter->process_->GetData().id == plugin_process_id) {
iter->host_impl_->AddInstanceForView(pp_instance,
render_process_id, render_view_id);
return;
}
}
DCHECK(plugin_process_id == 0)
<< "Renderer sent a bad plugin process host ID";
}
| 0 |
tcpdump | e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d | CVE-2017-13039 | CWE-125 | ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len,
const u_char *ep, uint32_t phase _U_, uint32_t doi0 _U_,
uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_n *p;
struct ikev1_pl_n n;
const u_char *cp;
const u_char *ep2;
uint32_t doi;
uint32_t proto;
static const char *notify_error_str[] = {
NULL, "INVALID-PAYLOAD-TYPE",
"DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED",
"INVALID-COOKIE", "INVALID-MAJOR-VERSION",
"INVALID-MINOR-VERSION", "INVALID-EXCHANGE-TYPE",
"INVALID-FLAGS", "INVALID-MESSAGE-ID",
"INVALID-PROTOCOL-ID", "INVALID-SPI",
"INVALID-TRANSFORM-ID", "ATTRIBUTES-NOT-SUPPORTED",
"NO-PROPOSAL-CHOSEN", "BAD-PROPOSAL-SYNTAX",
"PAYLOAD-MALFORMED", "INVALID-KEY-INFORMATION",
"INVALID-ID-INFORMATION", "INVALID-CERT-ENCODING",
"INVALID-CERTIFICATE", "CERT-TYPE-UNSUPPORTED",
"INVALID-CERT-AUTHORITY", "INVALID-HASH-INFORMATION",
"AUTHENTICATION-FAILED", "INVALID-SIGNATURE",
"ADDRESS-NOTIFICATION", "NOTIFY-SA-LIFETIME",
"CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE",
"UNEQUAL-PAYLOAD-LENGTHS",
};
static const char *ipsec_notify_error_str[] = {
"RESERVED",
};
static const char *notify_status_str[] = {
"CONNECTED",
};
static const char *ipsec_notify_status_str[] = {
"RESPONDER-LIFETIME", "REPLAY-STATUS",
"INITIAL-CONTACT",
};
/* NOTE: these macro must be called with x in proper range */
/* 0 - 8191 */
#define NOTIFY_ERROR_STR(x) \
STR_OR_ID((x), notify_error_str)
/* 8192 - 16383 */
#define IPSEC_NOTIFY_ERROR_STR(x) \
STR_OR_ID((u_int)((x) - 8192), ipsec_notify_error_str)
/* 16384 - 24575 */
#define NOTIFY_STATUS_STR(x) \
STR_OR_ID((u_int)((x) - 16384), notify_status_str)
/* 24576 - 32767 */
#define IPSEC_NOTIFY_STATUS_STR(x) \
STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str)
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_N)));
p = (const struct ikev1_pl_n *)ext;
ND_TCHECK(*p);
UNALIGNED_MEMCPY(&n, ext, sizeof(n));
doi = ntohl(n.doi);
proto = n.prot_id;
if (doi != 1) {
ND_PRINT((ndo," doi=%d", doi));
ND_PRINT((ndo," proto=%d", proto));
if (ntohs(n.type) < 8192)
ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type))));
else if (ntohs(n.type) < 16384)
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
else if (ntohs(n.type) < 24576)
ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type))));
else
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
if (n.spi_size) {
ND_PRINT((ndo," spi="));
if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size))
goto trunc;
}
return (const u_char *)(p + 1) + n.spi_size;
}
ND_PRINT((ndo," doi=ipsec"));
ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto)));
if (ntohs(n.type) < 8192)
ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type))));
else if (ntohs(n.type) < 16384)
ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type))));
else if (ntohs(n.type) < 24576)
ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type))));
else if (ntohs(n.type) < 32768)
ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type))));
else
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
if (n.spi_size) {
ND_PRINT((ndo," spi="));
if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size))
goto trunc;
}
cp = (const u_char *)(p + 1) + n.spi_size;
ep2 = (const u_char *)p + item_len;
if (cp < ep) {
switch (ntohs(n.type)) {
case IPSECDOI_NTYPE_RESPONDER_LIFETIME:
{
const struct attrmap *map = oakley_t_map;
size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
ND_PRINT((ndo," attrs=("));
while (cp < ep && cp < ep2) {
cp = ikev1_attrmap_print(ndo, cp,
(ep < ep2) ? ep : ep2, map, nmap);
}
ND_PRINT((ndo,")"));
break;
}
case IPSECDOI_NTYPE_REPLAY_STATUS:
ND_PRINT((ndo," status=("));
ND_PRINT((ndo,"replay detection %sabled",
EXTRACT_32BITS(cp) ? "en" : "dis"));
ND_PRINT((ndo,")"));
break;
default:
/*
* XXX - fill in more types here; see, for example,
* draft-ietf-ipsec-notifymsg-04.
*/
if (ndo->ndo_vflag > 3) {
ND_PRINT((ndo," data=("));
if (!rawprint(ndo, (const uint8_t *)(cp), ep - cp))
goto trunc;
ND_PRINT((ndo,")"));
} else {
if (!ike_show_somedata(ndo, cp, ep))
goto trunc;
}
break;
}
}
return (const u_char *)ext + item_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N)));
return NULL;
}
| 1 |
Chrome | 3d41e77125f3de8d722b6d8303599abaf2a91667 | NOT_APPLICABLE | NOT_APPLICABLE | void Resize() {
if (wcv_resize_insets_.IsEmpty())
return;
gfx::Rect bounds(browser_window_->GetBounds());
gfx::Size size(bounds.size());
size.Enlarge(wcv_resize_insets_.width(), wcv_resize_insets_.height());
bounds.set_size(size);
browser_window_->SetBounds(bounds);
content::RunAllPendingInMessageLoop();
}
| 0 |
linux | 950336ba3e4a1ffd2ca60d29f6ef386dd2c7351d | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t ati_remote2_show_mode_mask(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct usb_device *udev = to_usb_device(dev);
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
return sprintf(buf, "0x%02x\n", ar2->mode_mask);
}
| 0 |
gimp | ace45631595e8781a1420842582d67160097163c | NOT_APPLICABLE | NOT_APPLICABLE | static FITS_FILE *fits_new_filestruct (void)
{FITS_FILE *ff;
ff = (FITS_FILE *)malloc (sizeof (FITS_FILE));
if (ff == NULL) return (NULL);
memset ((char *)ff, 0, sizeof (*ff));
return (ff);
} | 0 |
mbed-coap | 4647a68e364401e81dbd370728127d844f221d93 | NOT_APPLICABLE | NOT_APPLICABLE | static int8_t sn_coap_parser_options_parse(struct coap_s *handle, uint8_t **packet_data_pptr, sn_coap_hdr_s *dst_coap_msg_ptr, uint8_t *packet_data_start_ptr, uint16_t packet_len)
{
uint8_t previous_option_number = 0;
int8_t ret_status = 0;
uint16_t message_left = sn_coap_parser_move_packet_ptr(packet_data_pptr,
packet_data_start_ptr,
packet_len,
0);
/* Parse token, if exists */
dst_coap_msg_ptr->token_len = *packet_data_start_ptr & COAP_HEADER_TOKEN_LENGTH_MASK;
if (dst_coap_msg_ptr->token_len) {
int8_t ptr_check_result;
if ((dst_coap_msg_ptr->token_len > 8) || dst_coap_msg_ptr->token_ptr) {
tr_error("sn_coap_parser_options_parse - token not valid!");
return -1;
}
ptr_check_result = sn_coap_parser_check_packet_ptr(*packet_data_pptr, packet_data_start_ptr, packet_len, dst_coap_msg_ptr->token_len);
if (0 != ptr_check_result) {
tr_error("sn_coap_parser_options_parse - **packet_data_pptr overflow !");
return -1;
}
dst_coap_msg_ptr->token_ptr = sn_coap_protocol_malloc_copy(handle, *packet_data_pptr, dst_coap_msg_ptr->token_len);
if (dst_coap_msg_ptr->token_ptr == NULL) {
tr_error("sn_coap_parser_options_parse - failed to allocate token!");
return -1;
}
message_left = sn_coap_parser_move_packet_ptr(packet_data_pptr,
packet_data_start_ptr,
packet_len,
dst_coap_msg_ptr->token_len);
}
/* Loop all Options */
while (message_left && (**packet_data_pptr != 0xff)) {
/* Get option length WITHOUT extensions */
uint16_t option_len = (**packet_data_pptr & 0x0F);
/* Get option number WITHOUT extensions */
uint16_t option_number = (**packet_data_pptr >> COAP_OPTIONS_OPTION_NUMBER_SHIFT);
message_left = sn_coap_parser_move_packet_ptr(packet_data_pptr, packet_data_start_ptr, packet_len, 1);
int8_t option_parse_result;
/* Add possible option delta extension */
option_parse_result = parse_ext_option(&option_number,
packet_data_pptr,
packet_data_start_ptr,
packet_len,
&message_left);
if (option_parse_result != 0) {
return -1;
}
/* Add previous option to option delta and get option number */
if(sn_coap_parser_add_u16_limit(option_number, previous_option_number, &option_number) != 0)
{
return -1;
}
/* Add possible option length extension to resolve full length of the option */
option_parse_result = parse_ext_option(&option_len,
packet_data_pptr,
packet_data_start_ptr,
packet_len,
&message_left);
if (option_parse_result != 0) {
return -1;
}
/* * * Parse option itself * * */
/* Some options are handled independently in own functions */
previous_option_number = option_number;
/* Allocate options_list_ptr if needed */
switch (option_number) {
case COAP_OPTION_MAX_AGE:
case COAP_OPTION_PROXY_URI:
case COAP_OPTION_ETAG:
case COAP_OPTION_URI_HOST:
case COAP_OPTION_LOCATION_PATH:
case COAP_OPTION_URI_PORT:
case COAP_OPTION_LOCATION_QUERY:
case COAP_OPTION_OBSERVE:
case COAP_OPTION_URI_QUERY:
case COAP_OPTION_BLOCK2:
case COAP_OPTION_BLOCK1:
case COAP_OPTION_ACCEPT:
case COAP_OPTION_SIZE1:
case COAP_OPTION_SIZE2:
if (sn_coap_parser_alloc_options(handle, dst_coap_msg_ptr) == NULL) {
tr_error("sn_coap_parser_options_parse - failed to allocate options!");
return -1;
}
break;
}
if (message_left < option_len){
/* packet_data_pptr would overflow! */
tr_error("sn_coap_parser_options_parse - **packet_data_pptr would overflow when parsing options!");
return -1;
}
/* Parse option */
switch (option_number) {
case COAP_OPTION_CONTENT_FORMAT:
if ((option_len > 2) || (dst_coap_msg_ptr->content_format != COAP_CT_NONE)) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_CONTENT_FORMAT not valid!");
return -1;
}
dst_coap_msg_ptr->content_format = (sn_coap_content_format_e) sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_MAX_AGE:
if (option_len > 4) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_MAX_AGE not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->max_age = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_PROXY_URI:
if ((option_len > 1034) || (option_len < 1) || dst_coap_msg_ptr->options_list_ptr->proxy_uri_ptr) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_PROXY_URI not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->proxy_uri_len = option_len;
dst_coap_msg_ptr->options_list_ptr->proxy_uri_ptr = sn_coap_protocol_malloc_copy(handle, *packet_data_pptr, option_len);
if (dst_coap_msg_ptr->options_list_ptr->proxy_uri_ptr == NULL) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_PROXY_URI allocation failed!");
return -1;
}
message_left = sn_coap_parser_move_packet_ptr(packet_data_pptr, packet_data_start_ptr, packet_len, option_len);
break;
case COAP_OPTION_ETAG:
if (dst_coap_msg_ptr->options_list_ptr->etag_ptr)
{
tr_error("sn_coap_parser_options_parse - COAP_OPTION_ETAG exists!");
return -1;
}
/* This is managed independently because User gives this option in one character table */
ret_status = sn_coap_parser_options_parse_multiple_options(handle, packet_data_pptr,
message_left,
&dst_coap_msg_ptr->options_list_ptr->etag_ptr,
(uint16_t *)&dst_coap_msg_ptr->options_list_ptr->etag_len,
COAP_OPTION_ETAG, option_len);
if (ret_status < 0) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_ETAG not valid!");
return -1;
}
break;
case COAP_OPTION_URI_HOST:
if ((option_len > 255) || (option_len < 1) || dst_coap_msg_ptr->options_list_ptr->uri_host_ptr) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_URI_HOST not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->uri_host_len = option_len;
dst_coap_msg_ptr->options_list_ptr->uri_host_ptr = sn_coap_protocol_malloc_copy(handle, *packet_data_pptr, option_len);
if (dst_coap_msg_ptr->options_list_ptr->uri_host_ptr == NULL) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_URI_HOST allocation failed!");
return -1;
}
message_left = sn_coap_parser_move_packet_ptr(packet_data_pptr, packet_data_start_ptr, packet_len, option_len);
break;
case COAP_OPTION_LOCATION_PATH:
if (dst_coap_msg_ptr->options_list_ptr->location_path_ptr) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_LOCATION_PATH exists!");
return -1;
}
/* This is managed independently because User gives this option in one character table */
ret_status = sn_coap_parser_options_parse_multiple_options(handle, packet_data_pptr, message_left,
&dst_coap_msg_ptr->options_list_ptr->location_path_ptr, &dst_coap_msg_ptr->options_list_ptr->location_path_len,
COAP_OPTION_LOCATION_PATH, option_len);
if (ret_status <0) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_LOCATION_PATH not valid!");
return -1;
}
break;
case COAP_OPTION_URI_PORT:
if ((option_len > 2) || dst_coap_msg_ptr->options_list_ptr->uri_port != COAP_OPTION_URI_PORT_NONE) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_URI_PORT not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->uri_port = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_LOCATION_QUERY:
if (dst_coap_msg_ptr->options_list_ptr->location_query_ptr)
{
tr_error("sn_coap_parser_options_parse - COAP_OPTION_LOCATION_QUERY exists!");
return -1;
}
ret_status = sn_coap_parser_options_parse_multiple_options(handle, packet_data_pptr, message_left,
&dst_coap_msg_ptr->options_list_ptr->location_query_ptr, &dst_coap_msg_ptr->options_list_ptr->location_query_len,
COAP_OPTION_LOCATION_QUERY, option_len);
if (ret_status < 0) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_LOCATION_QUERY not valid!");
return -1;
}
break;
case COAP_OPTION_URI_PATH:
if (dst_coap_msg_ptr->uri_path_ptr)
{
tr_error("sn_coap_parser_options_parse - COAP_OPTION_URI_PATH exists!");
return -1;
}
ret_status = sn_coap_parser_options_parse_multiple_options(handle, packet_data_pptr, message_left,
&dst_coap_msg_ptr->uri_path_ptr, &dst_coap_msg_ptr->uri_path_len,
COAP_OPTION_URI_PATH, option_len);
if (ret_status < 0) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_URI_PATH not valid!");
return -1;
}
break;
case COAP_OPTION_OBSERVE:
if ((option_len > 2) || dst_coap_msg_ptr->options_list_ptr->observe != COAP_OBSERVE_NONE) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_OBSERVE not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->observe = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_URI_QUERY:
ret_status = sn_coap_parser_options_parse_multiple_options(handle, packet_data_pptr, message_left,
&dst_coap_msg_ptr->options_list_ptr->uri_query_ptr, &dst_coap_msg_ptr->options_list_ptr->uri_query_len,
COAP_OPTION_URI_QUERY, option_len);
if (ret_status < 0) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_URI_QUERY not valid!");
return -1;
}
break;
case COAP_OPTION_BLOCK2:
if ((option_len > 3) || dst_coap_msg_ptr->options_list_ptr->block2 != COAP_OPTION_BLOCK_NONE) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_BLOCK2 not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->block2 = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_BLOCK1:
if ((option_len > 3) || dst_coap_msg_ptr->options_list_ptr->block1 != COAP_OPTION_BLOCK_NONE) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_BLOCK1 not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->block1 = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_ACCEPT:
if ((option_len > 2) || (dst_coap_msg_ptr->options_list_ptr->accept != COAP_CT_NONE)) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_ACCEPT not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->accept = (sn_coap_content_format_e) sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_SIZE1:
if ((option_len > 4) || dst_coap_msg_ptr->options_list_ptr->use_size1) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_SIZE1 not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->use_size1 = true;
dst_coap_msg_ptr->options_list_ptr->size1 = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
case COAP_OPTION_SIZE2:
if ((option_len > 4) || dst_coap_msg_ptr->options_list_ptr->use_size2) {
tr_error("sn_coap_parser_options_parse - COAP_OPTION_SIZE2 not valid!");
return -1;
}
dst_coap_msg_ptr->options_list_ptr->use_size2 = true;
dst_coap_msg_ptr->options_list_ptr->size2 = sn_coap_parser_options_parse_uint(packet_data_pptr, option_len);
break;
default:
tr_error("sn_coap_parser_options_parse - unknown option!");
return -1;
}
/* Check for overflow */
if ((*packet_data_pptr - packet_data_start_ptr) > packet_len) {
return -1;
}
message_left = sn_coap_parser_move_packet_ptr(packet_data_pptr,
packet_data_start_ptr,
packet_len,
0);
}
return 0;
} | 0 |
linux | 36ae3c0a36b7456432fedce38ae2f7bd3e01a563 | NOT_APPLICABLE | NOT_APPLICABLE | void kvm_irqfd_exit(void)
{
destroy_workqueue(irqfd_cleanup_wq);
}
| 0 |
Chrome | 07fbae50670ea44e35e1d554db1bbece7fe3711f | NOT_APPLICABLE | NOT_APPLICABLE | void NavigationRequest::OnResponseStarted(
const scoped_refptr<network::ResourceResponse>& response,
network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints,
std::unique_ptr<NavigationData> navigation_data,
const GlobalRequestID& request_id,
bool is_download,
bool is_stream,
base::Optional<SubresourceLoaderParams> subresource_loader_params) {
DCHECK(state_ == STARTED);
DCHECK(response);
TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationRequest", this,
"OnResponseStarted");
state_ = RESPONSE_STARTED;
response_should_be_rendered_ =
!is_download && (!response->head.headers.get() ||
(response->head.headers->response_code() != 204 &&
response->head.headers->response_code() != 205));
if (!response_should_be_rendered_) {
navigation_handle_->set_net_error_code(net::ERR_ABORTED);
net_error_ = net::ERR_ABORTED;
}
request_params_.service_worker_provider_id =
navigation_handle_->service_worker_handle()
? navigation_handle_->service_worker_handle()
->service_worker_provider_host_id()
: kInvalidServiceWorkerProviderId;
request_params_.appcache_host_id =
navigation_handle_->appcache_handle()
? navigation_handle_->appcache_handle()->appcache_host_id()
: kAppCacheNoHostId;
request_params_.was_activated = false;
if (navigation_handle_->IsRendererInitiated() &&
frame_tree_node_->has_received_user_gesture() &&
ShouldPropagateUserActivation(
frame_tree_node_->current_origin(),
url::Origin::Create(navigation_handle_->GetURL()))) {
request_params_.was_activated = true;
} else if (((navigation_handle_->HasUserGesture() &&
navigation_handle_->IsRendererInitiated()) ||
navigation_handle_->WasStartedFromContextMenu()) &&
ShouldPropagateUserActivation(
url::Origin::Create(navigation_handle_->GetReferrer().url),
url::Origin::Create(navigation_handle_->GetURL()))) {
request_params_.was_activated = true;
}
common_params_.previews_state =
static_cast<PreviewsState>(response->head.previews_state);
RenderFrameHostImpl* render_frame_host = nullptr;
if (response_should_be_rendered_) {
render_frame_host =
frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this);
NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(
render_frame_host, common_params_.url);
}
DCHECK(render_frame_host || !response_should_be_rendered_);
if (!browser_initiated_ && render_frame_host &&
render_frame_host != frame_tree_node_->current_frame_host()) {
common_params_.source_location.reset();
if (!frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation(
frame_tree_node_->IsMainFrame())) {
navigation_handle_->set_net_error_code(net::ERR_ABORTED);
frame_tree_node_->ResetNavigationRequest(false, true);
return;
}
}
if (navigation_data)
navigation_handle_->set_navigation_data(std::move(navigation_data));
response_ = response;
url_loader_client_endpoints_ = std::move(url_loader_client_endpoints);
ssl_info_ = response->head.ssl_info.has_value() ? *response->head.ssl_info
: net::SSLInfo();
is_download_ = is_download;
subresource_loader_params_ = std::move(subresource_loader_params);
if (render_frame_host &&
SiteInstanceImpl::ShouldAssignSiteForURL(common_params_.url)) {
render_frame_host->GetProcess()->SetIsUsed();
SiteInstanceImpl* instance = render_frame_host->GetSiteInstance();
if (!instance->HasSite() &&
SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
instance->GetBrowserContext(), common_params_.url)) {
instance->SetSite(common_params_.url);
}
}
RenderFrameDevToolsAgentHost::OnNavigationResponseReceived(*this, *response);
if (is_download && (response->head.headers.get() &&
(response->head.headers->response_code() / 100 != 2))) {
navigation_handle_->set_net_error_code(net::ERR_INVALID_RESPONSE);
frame_tree_node_->ResetNavigationRequest(false, true);
return;
}
navigation_handle_->WillProcessResponse(
render_frame_host, response->head.headers.get(),
response->head.connection_info, response->head.socket_address, ssl_info_,
request_id, common_params_.should_replace_current_entry, is_download,
is_stream,
base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete,
base::Unretained(this)));
}
| 0 |
ImageMagick | f68a98a9d385838a1c73ec960a14102949940a64 | NOT_APPLICABLE | NOT_APPLICABLE | static inline size_t GetPSDRowSize(Image *image)
{
if (image->depth == 1)
return(((image->columns+7)/8)*GetPSDPacketSize(image));
else
return(image->columns*GetPSDPacketSize(image));
}
| 0 |
tensorflow | e6a7c7cc18c3aaad1ae0872cb0a959f5c923d2bd | CVE-2021-29530 | CWE-476 | void ValidateInputs(OpKernelContext* ctx,
const CSRSparseMatrix& sparse_matrix,
const Tensor& permutation_indices, int* batch_size,
int64* num_rows) {
OP_REQUIRES(ctx, sparse_matrix.dtype() == DataTypeToEnum<T>::value,
errors::InvalidArgument(
"Asked for a CSRSparseMatrix of type ",
DataTypeString(DataTypeToEnum<T>::value),
" but saw dtype: ", DataTypeString(sparse_matrix.dtype())));
const Tensor& dense_shape = sparse_matrix.dense_shape();
const int rank = dense_shape.dim_size(0);
OP_REQUIRES(ctx, rank == 2 || rank == 3,
errors::InvalidArgument("sparse matrix must have rank 2 or 3; ",
"but dense_shape has size ", rank));
const int row_dim = (rank == 2) ? 0 : 1;
auto dense_shape_vec = dense_shape.vec<int64>();
*num_rows = dense_shape_vec(row_dim);
const int64 num_cols = dense_shape_vec(row_dim + 1);
OP_REQUIRES(ctx, *num_rows == num_cols,
errors::InvalidArgument("sparse matrix must be square; got: ",
*num_rows, " != ", num_cols));
const TensorShape& perm_shape = permutation_indices.shape();
OP_REQUIRES(
ctx, perm_shape.dims() + 1 == rank,
errors::InvalidArgument(
"sparse matrix must have the same rank as permutation; got: ", rank,
" != ", perm_shape.dims(), " + 1."));
OP_REQUIRES(
ctx, perm_shape.dim_size(rank - 2) == *num_rows,
errors::InvalidArgument(
"permutation must have the same number of elements in each batch "
"as the number of rows in sparse matrix; got: ",
perm_shape.dim_size(rank - 2), " != ", *num_rows));
*batch_size = sparse_matrix.batch_size();
if (*batch_size > 1) {
OP_REQUIRES(
ctx, perm_shape.dim_size(0) == *batch_size,
errors::InvalidArgument("permutation must have the same batch size "
"as sparse matrix; got: ",
perm_shape.dim_size(0), " != ", *batch_size));
}
} | 1 |
Chrome | 1948aefa8901dca0ccb993753fca00b15d2a6e25 | NOT_APPLICABLE | NOT_APPLICABLE | bool HTMLAnchorElement::hasLegalLinkAttribute(const QualifiedName& name) const
{
return name == hrefAttr || HTMLElement::hasLegalLinkAttribute(name);
}
| 0 |
haproxy | 58df5aea0a0c926b2238f65908f5e9f83d1cca25 | NOT_APPLICABLE | NOT_APPLICABLE | void dns_trigger_resolution(struct dns_requester *req)
{
struct dns_resolvers *resolvers;
struct dns_resolution *res;
int exp;
if (!req || !req->resolution)
return;
res = req->resolution;
resolvers = res->resolvers;
/* The resolution must not be triggered yet. Use the cached response, if
* valid */
exp = tick_add(res->last_resolution, resolvers->hold.valid);
if (resolvers->t && (res->status != RSLV_STATUS_VALID ||
!tick_isset(res->last_resolution) || tick_is_expired(exp, now_ms)))
task_wakeup(resolvers->t, TASK_WOKEN_OTHER);
}
| 0 |
Chrome | 12baa2097220e33c12b60aa5e6da6701637761bf | NOT_APPLICABLE | NOT_APPLICABLE | void BookmarksIOFunction::MultiFilesSelected(
const std::vector<base::FilePath>& files, void* params) {
Release(); // Balanced in BookmarsIOFunction::SelectFile()
NOTREACHED() << "Should not be able to select multiple files";
}
| 0 |
systemd | 4dac5eaba4e419b29c97da38a8b1f82336c2c892 | CVE-2018-15688 | CWE-120 | int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia) {
uint16_t len;
uint8_t *ia_hdr;
size_t iaid_offset, ia_buflen, ia_addrlen = 0;
DHCP6Address *addr;
int r;
assert_return(buf, -EINVAL);
assert_return(*buf, -EINVAL);
assert_return(buflen, -EINVAL);
assert_return(ia, -EINVAL);
switch (ia->type) {
case SD_DHCP6_OPTION_IA_NA:
len = DHCP6_OPTION_IA_NA_LEN;
iaid_offset = offsetof(DHCP6IA, ia_na);
break;
case SD_DHCP6_OPTION_IA_TA:
len = DHCP6_OPTION_IA_TA_LEN;
iaid_offset = offsetof(DHCP6IA, ia_ta);
break;
default:
return -EINVAL;
}
if (*buflen < len)
return -ENOBUFS;
ia_hdr = *buf;
ia_buflen = *buflen;
*buf += sizeof(DHCP6Option);
*buflen -= sizeof(DHCP6Option);
memcpy(*buf, (char*) ia + iaid_offset, len);
*buf += len;
*buflen -= len;
LIST_FOREACH(addresses, addr, ia->addresses) {
r = option_append_hdr(buf, buflen, SD_DHCP6_OPTION_IAADDR,
sizeof(addr->iaaddr));
if (r < 0)
return r;
memcpy(*buf, &addr->iaaddr, sizeof(addr->iaaddr));
*buf += sizeof(addr->iaaddr);
*buflen -= sizeof(addr->iaaddr);
ia_addrlen += sizeof(DHCP6Option) + sizeof(addr->iaaddr);
}
r = option_append_hdr(&ia_hdr, &ia_buflen, ia->type, len + ia_addrlen);
if (r < 0)
return r;
return 0;
} | 1 |
linux | 132c94e31b8bca8ea921f9f96a57d684fa4ae0a9 | NOT_APPLICABLE | NOT_APPLICABLE | int generic_show_options(struct seq_file *m, struct dentry *root)
{
const char *options;
rcu_read_lock();
options = rcu_dereference(root->d_sb->s_options);
if (options != NULL && options[0]) {
seq_putc(m, ',');
mangle(m, options);
}
rcu_read_unlock();
return 0;
}
| 0 |
ghostscript | 0d3901189f245232f0161addf215d7268c4d05a3 | NOT_APPLICABLE | NOT_APPLICABLE | zfilenamesplit(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
check_read_type(*op, t_string);
/****** NOT IMPLEMENTED YET ******/
return_error(gs_error_undefined);
}
| 0 |
linux | 6e8ab72a812396996035a37e5ca4b3b99b5d214b | NOT_APPLICABLE | NOT_APPLICABLE | static int ext4_add_dirent_to_inline(handle_t *handle,
struct ext4_filename *fname,
struct inode *dir,
struct inode *inode,
struct ext4_iloc *iloc,
void *inline_start, int inline_size)
{
int err;
struct ext4_dir_entry_2 *de;
err = ext4_find_dest_de(dir, inode, iloc->bh, inline_start,
inline_size, fname, &de);
if (err)
return err;
BUFFER_TRACE(iloc->bh, "get_write_access");
err = ext4_journal_get_write_access(handle, iloc->bh);
if (err)
return err;
ext4_insert_dentry(inode, de, inline_size, fname);
ext4_show_inline_dir(dir, iloc->bh, inline_start, inline_size);
/*
* XXX shouldn't update any times until successful
* completion of syscall, but too many callers depend
* on this.
*
* XXX similarly, too many callers depend on
* ext4_new_inode() setting the times, but error
* recovery deletes the inode, so the worst that can
* happen is that the times are slightly out of date
* and/or different from the directory change time.
*/
dir->i_mtime = dir->i_ctime = current_time(dir);
ext4_update_dx_flag(dir);
inode_inc_iversion(dir);
return 1;
} | 0 |
linux | 76597cd31470fa130784c78fadb4dab2e624a723 | NOT_APPLICABLE | NOT_APPLICABLE | static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
struct mm_walk *walk)
{
struct vm_area_struct *vma;
struct pagemapread *pm = walk->private;
pte_t *pte;
int err = 0;
split_huge_page_pmd(walk->mm, pmd);
/* find the first VMA at or above 'addr' */
vma = find_vma(walk->mm, addr);
for (; addr != end; addr += PAGE_SIZE) {
u64 pfn = PM_NOT_PRESENT;
/* check to see if we've left 'vma' behind
* and need a new, higher one */
if (vma && (addr >= vma->vm_end))
vma = find_vma(walk->mm, addr);
/* check that 'vma' actually covers this address,
* and that it isn't a huge page vma */
if (vma && (vma->vm_start <= addr) &&
!is_vm_hugetlb_page(vma)) {
pte = pte_offset_map(pmd, addr);
pfn = pte_to_pagemap_entry(*pte);
/* unmap before userspace copy */
pte_unmap(pte);
}
err = add_to_pagemap(addr, pfn, pm);
if (err)
return err;
}
cond_resched();
return err;
}
| 0 |
linux | c290f8358acaeffd8e0c551ddcc24d1206143376 | NOT_APPLICABLE | NOT_APPLICABLE | long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct tty_struct *tty = file_tty(file);
struct tty_struct *real_tty;
void __user *p = (void __user *)arg;
int retval;
struct tty_ldisc *ld;
struct inode *inode = file->f_dentry->d_inode;
if (tty_paranoia_check(tty, inode, "tty_ioctl"))
return -EINVAL;
real_tty = tty_pair_get_tty(tty);
/*
* Factor out some common prep work
*/
switch (cmd) {
case TIOCSETD:
case TIOCSBRK:
case TIOCCBRK:
case TCSBRK:
case TCSBRKP:
retval = tty_check_change(tty);
if (retval)
return retval;
if (cmd != TIOCCBRK) {
tty_wait_until_sent(tty, 0);
if (signal_pending(current))
return -EINTR;
}
break;
}
/*
* Now do the stuff.
*/
switch (cmd) {
case TIOCSTI:
return tiocsti(tty, p);
case TIOCGWINSZ:
return tiocgwinsz(real_tty, p);
case TIOCSWINSZ:
return tiocswinsz(real_tty, p);
case TIOCCONS:
return real_tty != tty ? -EINVAL : tioccons(file);
case FIONBIO:
return fionbio(file, p);
case TIOCEXCL:
set_bit(TTY_EXCLUSIVE, &tty->flags);
return 0;
case TIOCNXCL:
clear_bit(TTY_EXCLUSIVE, &tty->flags);
return 0;
case TIOCNOTTY:
if (current->signal->tty != tty)
return -ENOTTY;
no_tty();
return 0;
case TIOCSCTTY:
return tiocsctty(tty, arg);
case TIOCGPGRP:
return tiocgpgrp(tty, real_tty, p);
case TIOCSPGRP:
return tiocspgrp(tty, real_tty, p);
case TIOCGSID:
return tiocgsid(tty, real_tty, p);
case TIOCGETD:
return put_user(tty->ldisc->ops->num, (int __user *)p);
case TIOCSETD:
return tiocsetd(tty, p);
case TIOCVHANGUP:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
tty_vhangup(tty);
return 0;
case TIOCGDEV:
{
unsigned int ret = new_encode_dev(tty_devnum(real_tty));
return put_user(ret, (unsigned int __user *)p);
}
/*
* Break handling
*/
case TIOCSBRK: /* Turn break on, unconditionally */
if (tty->ops->break_ctl)
return tty->ops->break_ctl(tty, -1);
return 0;
case TIOCCBRK: /* Turn break off, unconditionally */
if (tty->ops->break_ctl)
return tty->ops->break_ctl(tty, 0);
return 0;
case TCSBRK: /* SVID version: non-zero arg --> no break */
/* non-zero arg means wait for all output data
* to be sent (performed above) but don't send break.
* This is used by the tcdrain() termios function.
*/
if (!arg)
return send_break(tty, 250);
return 0;
case TCSBRKP: /* support for POSIX tcsendbreak() */
return send_break(tty, arg ? arg*100 : 250);
case TIOCMGET:
return tty_tiocmget(tty, p);
case TIOCMSET:
case TIOCMBIC:
case TIOCMBIS:
return tty_tiocmset(tty, cmd, p);
case TIOCGICOUNT:
retval = tty_tiocgicount(tty, p);
/* For the moment allow fall through to the old method */
if (retval != -EINVAL)
return retval;
break;
case TCFLSH:
switch (arg) {
case TCIFLUSH:
case TCIOFLUSH:
/* flush tty buffer and allow ldisc to process ioctl */
tty_buffer_flush(tty);
break;
}
break;
}
if (tty->ops->ioctl) {
retval = (tty->ops->ioctl)(tty, cmd, arg);
if (retval != -ENOIOCTLCMD)
return retval;
}
ld = tty_ldisc_ref_wait(tty);
retval = -EINVAL;
if (ld->ops->ioctl) {
retval = ld->ops->ioctl(tty, file, cmd, arg);
if (retval == -ENOIOCTLCMD)
retval = -EINVAL;
}
tty_ldisc_deref(ld);
return retval;
}
| 0 |
Chrome | 0bd1a6ddb5fb23dfea3e72d60e5e8df4cf5826bc | NOT_APPLICABLE | NOT_APPLICABLE | void BackingStoreGtk::XShowRect(const gfx::Point &origin,
const gfx::Rect& rect, XID target) {
XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_),
rect.x(), rect.y(), rect.width(), rect.height(),
rect.x() + origin.x(), rect.y() + origin.y());
}
| 0 |
mutt | 3287534daa3beac68e2e83ca4b4fe8a3148ff870 | NOT_APPLICABLE | NOT_APPLICABLE | static FILE* msg_cache_put (IMAP_DATA* idata, HEADER* h)
{
char id[_POSIX_PATH_MAX];
if (!idata || !h)
return NULL;
idata->bcache = msg_cache_open (idata);
snprintf (id, sizeof (id), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid);
return mutt_bcache_put (idata->bcache, id, 1);
} | 0 |
libvirt | a4947e8f63c3e6b7b067b444f3d6cf674c0d7f36 | NOT_APPLICABLE | NOT_APPLICABLE | nwfilterDriverRemoveDBusMatches(void)
{
GDBusConnection *sysbus;
sysbus = virGDBusGetSystemBus();
if (sysbus) {
g_dbus_connection_signal_unsubscribe(sysbus, restartID);
g_dbus_connection_signal_unsubscribe(sysbus, reloadID);
}
} | 0 |
flac | e1575e4a7c5157cbf4e4a16dbd39b74f7174c7be | NOT_APPLICABLE | NOT_APPLICABLE | void set_defaults_(FLAC__StreamEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
#ifdef FLAC__MANDATORY_VERIFY_WHILE_ENCODING
encoder->protected_->verify = true;
#else
encoder->protected_->verify = false;
#endif
encoder->protected_->streamable_subset = true;
encoder->protected_->do_md5 = true;
encoder->protected_->do_mid_side_stereo = false;
encoder->protected_->loose_mid_side_stereo = false;
encoder->protected_->channels = 2;
encoder->protected_->bits_per_sample = 16;
encoder->protected_->sample_rate = 44100;
encoder->protected_->blocksize = 0;
#ifndef FLAC__INTEGER_ONLY_LIBRARY
encoder->protected_->num_apodizations = 1;
encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY;
encoder->protected_->apodizations[0].parameters.tukey.p = 0.5;
#endif
encoder->protected_->max_lpc_order = 0;
encoder->protected_->qlp_coeff_precision = 0;
encoder->protected_->do_qlp_coeff_prec_search = false;
encoder->protected_->do_exhaustive_model_search = false;
encoder->protected_->do_escape_coding = false;
encoder->protected_->min_residual_partition_order = 0;
encoder->protected_->max_residual_partition_order = 0;
encoder->protected_->rice_parameter_search_dist = 0;
encoder->protected_->total_samples_estimate = 0;
encoder->protected_->metadata = 0;
encoder->protected_->num_metadata_blocks = 0;
encoder->private_->seek_table = 0;
encoder->private_->disable_constant_subframes = false;
encoder->private_->disable_fixed_subframes = false;
encoder->private_->disable_verbatim_subframes = false;
encoder->private_->is_ogg = false;
encoder->private_->read_callback = 0;
encoder->private_->write_callback = 0;
encoder->private_->seek_callback = 0;
encoder->private_->tell_callback = 0;
encoder->private_->metadata_callback = 0;
encoder->private_->progress_callback = 0;
encoder->private_->client_data = 0;
#if FLAC__HAS_OGG
FLAC__ogg_encoder_aspect_set_defaults(&encoder->protected_->ogg_encoder_aspect);
#endif
FLAC__stream_encoder_set_compression_level(encoder, 5);
} | 0 |
php-src | ef8fc4b53d92fbfcd8ef1abbd6f2f5fe2c4a11e5 | NOT_APPLICABLE | NOT_APPLICABLE | _zip_d2u_time(int dtime, int ddate)
{
struct tm tm;
memset(&tm, 0, sizeof(tm));
/* let mktime decide if DST is in effect */
tm.tm_isdst = -1;
tm.tm_year = ((ddate>>9)&127) + 1980 - 1900;
tm.tm_mon = ((ddate>>5)&15) - 1;
tm.tm_mday = ddate&31;
tm.tm_hour = (dtime>>11)&31;
tm.tm_min = (dtime>>5)&63;
tm.tm_sec = (dtime<<1)&62;
return mktime(&tm);
} | 0 |
linux | 9e3f7a29694049edd728e2400ab57ad7553e5aa9 | NOT_APPLICABLE | NOT_APPLICABLE | static int walk_sys_regs(struct kvm_vcpu *vcpu, u64 __user *uind)
{
const struct sys_reg_desc *i1, *i2, *end1, *end2;
unsigned int total = 0;
size_t num;
/* We check for duplicates here, to allow arch-specific overrides. */
i1 = get_target_table(vcpu->arch.target, true, &num);
end1 = i1 + num;
i2 = sys_reg_descs;
end2 = sys_reg_descs + ARRAY_SIZE(sys_reg_descs);
BUG_ON(i1 == end1 || i2 == end2);
/* Walk carefully, as both tables may refer to the same register. */
while (i1 || i2) {
int cmp = cmp_sys_reg(i1, i2);
/* target-specific overrides generic entry. */
if (cmp <= 0) {
/* Ignore registers we trap but don't save. */
if (i1->reg) {
if (!copy_reg_to_user(i1, &uind))
return -EFAULT;
total++;
}
} else {
/* Ignore registers we trap but don't save. */
if (i2->reg) {
if (!copy_reg_to_user(i2, &uind))
return -EFAULT;
total++;
}
}
if (cmp <= 0 && ++i1 == end1)
i1 = NULL;
if (cmp >= 0 && ++i2 == end2)
i2 = NULL;
}
return total;
}
| 0 |
wireshark | b8e0d416898bb975a02c1b55883342edc5b4c9c0 | NOT_APPLICABLE | NOT_APPLICABLE | sic10_opaque_binary_attr(tvbuff_t *tvb, guint32 offset,
guint8 token, guint8 codepage, guint32 *length)
{
guint32 data_len = tvb_get_guintvar(tvb, offset, length);
char *str = NULL;
switch (codepage) {
case 0: /* Only valid codepage for SI */
switch (token) {
case 0x0A: /* created= */
case 0x10: /* si-expires= */
str = date_time_from_opaque(tvb,
offset + *length, data_len);
break;
default:
break;
}
break;
default:
break;
}
if (str == NULL) { /* Error, or not parsed */
str = wmem_strdup_printf(wmem_packet_scope(), "(%d bytes of unparsed opaque data)", data_len);
}
*length += data_len;
return str;
}
| 0 |
ghostscript | 5008105780c0b0182ea6eda83ad5598f225be3ee | NOT_APPLICABLE | NOT_APPLICABLE | static void cunary(JF, js_Ast *exp, int opcode)
{
cexp(J, F, exp->a);
emit(J, F, opcode);
}
| 0 |
poppler | fc071d800cb4329a3ccf898d7bf16b4db7323ad8 | CVE-2010-5110 | CWE-20 | static boolean str_fill_input_buffer(j_decompress_ptr cinfo)
{
int c;
struct str_src_mgr * src = (struct str_src_mgr *)cinfo->src;
if (src->abort) return FALSE;
if (src->index == 0) {
c = 0xFF;
src->index++;
src->index++;
}
else if (src->index == 1) {
c = 0xD8;
src->index++;
}
else c = src->str->getChar();
if (c != EOF)
{
src->buffer = c;
src->pub.next_input_byte = &src->buffer;
src->pub.bytes_in_buffer = 1;
return TRUE;
}
else return FALSE;
}
| 1 |
krb5 | e6ae703ae597d798e310368d52b8f38ee11c6a73 | NOT_APPLICABLE | NOT_APPLICABLE | krb5_gss_unwrap_iov(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
int *conf_state,
gss_qop_t *qop_state,
gss_iov_buffer_desc *iov,
int iov_count)
{
OM_uint32 major_status;
major_status = kg_unseal_iov(minor_status, context_handle,
conf_state, qop_state,
iov, iov_count, KG_TOK_WRAP_MSG);
return major_status;
}
| 0 |
linux | fda4e2e85589191b123d31cdc21fd33ee70f50fd | NOT_APPLICABLE | NOT_APPLICABLE | void kvm_arch_memslots_updated(struct kvm *kvm)
{
/*
* memslots->generation has been incremented.
* mmio generation may have reached its maximum value.
*/
kvm_mmu_invalidate_mmio_sptes(kvm);
}
| 0 |
bluez | e2b0f0d8d63e1223bb714a9efb37e2257818268b | NOT_APPLICABLE | NOT_APPLICABLE | static void avrcp_change_path(struct avrcp *session, uint8_t direction,
uint64_t uid)
{
struct avrcp_player *player = session->controller->player;
uint8_t buf[AVRCP_BROWSING_HEADER_LENGTH + 11];
struct avrcp_browsing_header *pdu = (void *) buf;
memset(buf, 0, sizeof(buf));
put_be16(player->uid_counter, &pdu->params[0]);
pdu->params[2] = direction;
put_be64(uid, &pdu->params[3]);
pdu->pdu_id = AVRCP_CHANGE_PATH;
pdu->param_len = htons(11);
avctp_send_browsing_req(session->conn, buf, sizeof(buf),
avrcp_change_path_rsp, session);
} | 0 |
Little-CMS | d41071eb8cfea7aa10a9262c12bd95d5d9d81c8f | NOT_APPLICABLE | NOT_APPLICABLE | cmsBool WriteSeqID(struct _cms_typehandler_struct* self,
cmsIOHANDLER* io,
void* Cargo,
cmsUInt32Number n,
cmsUInt32Number SizeOfTag)
{
cmsSEQ* Seq = (cmsSEQ*) Cargo;
if (!io ->Write(io, 16, Seq ->seq[n].ProfileID.ID8)) return FALSE;
// Store here the MLU
if (!SaveDescription(self, io, Seq ->seq[n].Description)) return FALSE;
return TRUE;
cmsUNUSED_PARAMETER(SizeOfTag);
} | 0 |
polarssl | 43c3b28ca6d22f51951e2bd563df039a9f4289ab | NOT_APPLICABLE | NOT_APPLICABLE | static int ssl_parse_alpn_ext( ssl_context *ssl,
const unsigned char *buf, size_t len )
{
size_t list_len, cur_len, ours_len;
const unsigned char *theirs, *start, *end;
const char **ours;
/* If ALPN not configured, just ignore the extension */
if( ssl->alpn_list == NULL )
return( 0 );
/*
* opaque ProtocolName<1..2^8-1>;
*
* struct {
* ProtocolName protocol_name_list<2..2^16-1>
* } ProtocolNameList;
*/
/* Min length is 2 (list_len) + 1 (name_len) + 1 (name) */
if( len < 4 )
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
list_len = ( buf[0] << 8 ) | buf[1];
if( list_len != len - 2 )
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
/*
* Use our order of preference
*/
start = buf + 2;
end = buf + len;
for( ours = ssl->alpn_list; *ours != NULL; ours++ )
{
ours_len = strlen( *ours );
for( theirs = start; theirs != end; theirs += cur_len )
{
/* If the list is well formed, we should get equality first */
if( theirs > end )
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
cur_len = *theirs++;
/* Empty strings MUST NOT be included */
if( cur_len == 0 )
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
if( cur_len == ours_len &&
memcmp( theirs, *ours, cur_len ) == 0 )
{
ssl->alpn_chosen = *ours;
return( 0 );
}
}
}
/* If we get there, no match was found */
ssl_send_alert_message( ssl, SSL_ALERT_LEVEL_FATAL,
SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL );
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
} | 0 |
Chrome | e755d9faf5c7d75a8ea290892cb1b5cc07c412ec | NOT_APPLICABLE | NOT_APPLICABLE | bool PluginSelectionPolicy::InitFromFile(const FilePath& policy_file) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
string data;
if (!file_util::ReadFileToString(policy_file, &data)) {
LOG(ERROR) << "Unable to read plugin policy file \""
<< policy_file.value() << "\".";
init_from_file_finished_ = true;
return false;
}
std::istringstream input_stream(data);
string line;
map<string, Policy> policies;
Policy policy;
string last_plugin;
while (std::getline(input_stream, line)) {
string::size_type pos = line.find("#");
if (pos != string::npos) {
line = line.substr(0, pos);
}
TrimWhitespaceASCII(line, TRIM_ALL, &line);
if (line.find("allow") == 0) {
if (last_plugin.empty()) {
LOG(ERROR) << "Plugin policy file error: 'allow' out of context.";
init_from_file_finished_ = true;
return false;
}
line = line.substr(5);
TrimWhitespaceASCII(line, TRIM_ALL, &line);
line = StringToLowerASCII(line);
policy.push_back(make_pair(true, line));
}
if (line.find("deny") == 0) {
if (last_plugin.empty()) {
LOG(ERROR) << "Plugin policy file error: 'deny' out of context.";
init_from_file_finished_ = true;
return false;
}
line = line.substr(4);
TrimWhitespaceASCII(line, TRIM_ALL, &line);
line = StringToLowerASCII(line);
policy.push_back(make_pair(false, line));
}
if (line.find("plugin") == 0) {
line = line.substr(6);
TrimWhitespaceASCII(line, TRIM_ALL, &line);
if (!policy.empty() && !last_plugin.empty())
policies.insert(make_pair(last_plugin, policy));
last_plugin = line;
policy.clear();
}
}
if (!last_plugin.empty())
policies.insert(make_pair(last_plugin, policy));
policies_.swap(policies);
init_from_file_finished_ = true;
return true;
}
| 0 |
Chrome | d27468a832d5316884bd02f459cbf493697fd7e1 | CVE-2015-1274 | CWE-254 | bool AXObject::isHiddenForTextAlternativeCalculation() const {
if (equalIgnoringCase(getAttribute(aria_hiddenAttr), "false"))
return false;
if (getLayoutObject())
return getLayoutObject()->style()->visibility() != EVisibility::kVisible;
Document* document = getDocument();
if (!document || !document->frame())
return false;
if (Node* node = getNode()) {
if (node->isConnected() && node->isElementNode()) {
RefPtr<ComputedStyle> style =
document->ensureStyleResolver().styleForElement(toElement(node));
return style->display() == EDisplay::kNone ||
style->visibility() != EVisibility::kVisible;
}
}
return false;
}
| 1 |
linux-2.6 | efc7ffcb4237f8cb9938909041c4ed38f6e1bf40 | NOT_APPLICABLE | NOT_APPLICABLE | static void hfsplus_cat_build_key_uni(hfsplus_btree_key *key, u32 parent,
struct hfsplus_unistr *name)
{
int ustrlen;
ustrlen = be16_to_cpu(name->length);
key->cat.parent = cpu_to_be32(parent);
key->cat.name.length = cpu_to_be16(ustrlen);
ustrlen *= 2;
memcpy(key->cat.name.unicode, name->unicode, ustrlen);
key->key_len = cpu_to_be16(6 + ustrlen);
} | 0 |
ImageMagick | 948356eec65aea91995d4b7cc487d197d2c5f602 | NOT_APPLICABLE | NOT_APPLICABLE | static MagickBooleanType JPEGWarningHandler(j_common_ptr jpeg_info,int level)
{
#define JPEGExcessiveWarnings 1000
char
message[JMSG_LENGTH_MAX];
ErrorManager
*error_manager;
Image
*image;
*message='\0';
error_manager=(ErrorManager *) jpeg_info->client_data;
image=error_manager->image;
if (level < 0)
{
/*
Process warning message.
*/
(jpeg_info->err->format_message)(jpeg_info,message);
if (jpeg_info->err->num_warnings++ < JPEGExcessiveWarnings)
ThrowBinaryException(CorruptImageWarning,(char *) message,
image->filename);
}
else
if ((image->debug != MagickFalse) && (level >= jpeg_info->err->trace_level))
{
/*
Process trace message.
*/
(jpeg_info->err->format_message)(jpeg_info,message);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"[%s] JPEG Trace: \"%s\"",image->filename,message);
}
return(MagickTrue);
}
| 0 |
v4l2loopback | e4cd225557486c420f6a34411f98c575effd43dd | NOT_APPLICABLE | NOT_APPLICABLE | static void init_buffers(struct v4l2_loopback_device *dev)
{
int i;
int buffer_size;
int bytesused;
MARK();
buffer_size = dev->buffer_size;
bytesused = dev->pix_format.sizeimage;
for (i = 0; i < dev->buffers_number; ++i) {
struct v4l2_buffer *b = &dev->buffers[i].buffer;
b->index = i;
b->bytesused = bytesused;
b->length = buffer_size;
b->field = V4L2_FIELD_NONE;
b->flags = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 1)
b->input = 0;
#endif
b->m.offset = i * buffer_size;
b->memory = V4L2_MEMORY_MMAP;
b->sequence = 0;
b->timestamp.tv_sec = 0;
b->timestamp.tv_usec = 0;
b->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2l_get_timestamp(b);
}
dev->timeout_image_buffer = dev->buffers[0];
dev->timeout_image_buffer.buffer.m.offset = MAX_BUFFERS * buffer_size;
MARK();
} | 0 |
libjpeg-turbo | aa7459050d7a50e1d8a99488902d41fbc118a50f | NOT_APPLICABLE | NOT_APPLICABLE | put_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
JDIMENSION rows_supplied)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
register char *bufferptr;
register JSAMPROW ptr;
register JDIMENSION col;
register int rindex = rgb_red[cinfo->out_color_space];
register int gindex = rgb_green[cinfo->out_color_space];
register int bindex = rgb_blue[cinfo->out_color_space];
register int ps = rgb_pixelsize[cinfo->out_color_space];
ptr = dest->pub.buffer[0];
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
PUTPPMSAMPLE(bufferptr, ptr[rindex]);
PUTPPMSAMPLE(bufferptr, ptr[gindex]);
PUTPPMSAMPLE(bufferptr, ptr[bindex]);
ptr += ps;
}
(void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
} | 0 |
Android | 1f4b49e64adf4623eefda503bca61e253597b9bf | NOT_APPLICABLE | NOT_APPLICABLE | status_t Parcel::readDoubleVector(std::vector<double>* val) const {
return readTypedVector(val, &Parcel::readDouble);
}
| 0 |
ImageMagick | e9438e2a82d35b6657e908ff38ec0303f432b655 | NOT_APPLICABLE | NOT_APPLICABLE | static cmsHTRANSFORM *AcquireTransformThreadSet(Image *image,
const cmsHPROFILE source_profile,const cmsUInt32Number source_type,
const cmsHPROFILE target_profile,const cmsUInt32Number target_type,
const int intent,const cmsUInt32Number flags)
{
cmsHTRANSFORM
*transform;
register ssize_t
i;
size_t
number_threads;
number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
transform=(cmsHTRANSFORM *) AcquireQuantumMemory(number_threads,
sizeof(*transform));
if (transform == (cmsHTRANSFORM *) NULL)
return((cmsHTRANSFORM *) NULL);
(void) ResetMagickMemory(transform,0,number_threads*sizeof(*transform));
for (i=0; i < (ssize_t) number_threads; i++)
{
transform[i]=cmsCreateTransformTHR(image,source_profile,source_type,
target_profile,target_type,intent,flags);
if (transform[i] == (cmsHTRANSFORM) NULL)
return(DestroyTransformThreadSet(transform));
}
return(transform);
} | 0 |
poppler | a205e71a2dbe0c8d4f4905a76a3f79ec522eacec | NOT_APPLICABLE | NOT_APPLICABLE | static inline int imgCoordMungeUpper(SplashCoord x) {
return splashCeil(x + 0.5) - 1;
}
| 0 |
ext-http | 17137d4ab1ce81a2cee0fae842340a344ef3da83 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_METHOD(HttpParams, offsetExists)
{
char *name_str;
int name_len;
zval **zparam, *zparams;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len)) {
return;
}
zparams = php_http_ztyp(IS_ARRAY, zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC));
if (SUCCESS == zend_symtable_find(Z_ARRVAL_P(zparams), name_str, name_len + 1, (void *) &zparam)) {
RETVAL_BOOL(Z_TYPE_PP(zparam) != IS_NULL);
} else {
RETVAL_FALSE;
}
zval_ptr_dtor(&zparams);
}
| 0 |
vim | e2bd8600b873d2cd1f9d667c28cba8b1dba18839 | NOT_APPLICABLE | NOT_APPLICABLE | do_ecmd(
int fnum,
char_u *ffname,
char_u *sfname,
exarg_T *eap, // can be NULL!
linenr_T newlnum,
int flags,
win_T *oldwin)
{
int other_file; // TRUE if editing another file
int oldbuf; // TRUE if using existing buffer
int auto_buf = FALSE; // TRUE if autocommands brought us
// into the buffer unexpectedly
char_u *new_name = NULL;
#if defined(FEAT_EVAL)
int did_set_swapcommand = FALSE;
#endif
buf_T *buf;
bufref_T bufref;
bufref_T old_curbuf;
char_u *free_fname = NULL;
#ifdef FEAT_BROWSE
char_u dot_path[] = ".";
char_u *browse_file = NULL;
#endif
int retval = FAIL;
long n;
pos_T orig_pos;
linenr_T topline = 0;
int newcol = -1;
int solcol = -1;
pos_T *pos;
char_u *command = NULL;
#ifdef FEAT_SPELL
int did_get_winopts = FALSE;
#endif
int readfile_flags = 0;
int did_inc_redrawing_disabled = FALSE;
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
#ifdef FEAT_PROP_POPUP
if (ERROR_IF_TERM_POPUP_WINDOW)
return FAIL;
#endif
if (eap != NULL)
command = eap->do_ecmd_cmd;
set_bufref(&old_curbuf, curbuf);
if (fnum != 0)
{
if (fnum == curbuf->b_fnum) // file is already being edited
return OK; // nothing to do
other_file = TRUE;
}
else
{
#ifdef FEAT_BROWSE
if ((cmdmod.cmod_flags & CMOD_BROWSE) && !exiting)
{
if (
# ifdef FEAT_GUI
!gui.in_use &&
# endif
au_has_group((char_u *)"FileExplorer"))
{
// No browsing supported but we do have the file explorer:
// Edit the directory.
if (ffname == NULL || !mch_isdir(ffname))
ffname = dot_path;
}
else
{
browse_file = do_browse(0, (char_u *)_("Edit File"), ffname,
NULL, NULL, NULL, curbuf);
if (browse_file == NULL)
goto theend;
ffname = browse_file;
}
}
#endif
// if no short name given, use ffname for short name
if (sfname == NULL)
sfname = ffname;
#ifdef USE_FNAME_CASE
if (sfname != NULL)
fname_case(sfname, 0); // set correct case for sfname
#endif
if ((flags & (ECMD_ADDBUF | ECMD_ALTBUF))
&& (ffname == NULL || *ffname == NUL))
goto theend;
if (ffname == NULL)
other_file = TRUE;
// there is no file name
else if (*ffname == NUL && curbuf->b_ffname == NULL)
other_file = FALSE;
else
{
if (*ffname == NUL) // re-edit with same file name
{
ffname = curbuf->b_ffname;
sfname = curbuf->b_fname;
}
free_fname = fix_fname(ffname); // may expand to full path name
if (free_fname != NULL)
ffname = free_fname;
other_file = otherfile(ffname);
}
}
/*
* If the file was changed we may not be allowed to abandon it:
* - if we are going to re-edit the same file
* - or if we are the only window on this file and if ECMD_HIDE is FALSE
*/
if ( ((!other_file && !(flags & ECMD_OLDBUF))
|| (curbuf->b_nwindows == 1
&& !(flags & (ECMD_HIDE | ECMD_ADDBUF | ECMD_ALTBUF))))
&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
| (other_file ? 0 : CCGD_MULTWIN)
| ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0)
| (eap == NULL ? 0 : CCGD_EXCMD)))
{
if (fnum == 0 && other_file && ffname != NULL)
(void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
goto theend;
}
/*
* End Visual mode before switching to another buffer, so the text can be
* copied into the GUI selection buffer.
*/
reset_VIsual();
#if defined(FEAT_EVAL)
if ((command != NULL || newlnum > (linenr_T)0)
&& *get_vim_var_str(VV_SWAPCOMMAND) == NUL)
{
int len;
char_u *p;
// Set v:swapcommand for the SwapExists autocommands.
if (command != NULL)
len = (int)STRLEN(command) + 3;
else
len = 30;
p = alloc(len);
if (p != NULL)
{
if (command != NULL)
vim_snprintf((char *)p, len, ":%s\r", command);
else
vim_snprintf((char *)p, len, "%ldG", (long)newlnum);
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
did_set_swapcommand = TRUE;
vim_free(p);
}
}
#endif
/*
* If we are starting to edit another file, open a (new) buffer.
* Otherwise we re-use the current buffer.
*/
if (other_file)
{
int prev_alt_fnum = curwin->w_alt_fnum;
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF)))
{
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
curwin->w_alt_fnum = curbuf->b_fnum;
if (oldwin != NULL)
buflist_altfpos(oldwin);
}
if (fnum)
buf = buflist_findnr(fnum);
else
{
if (flags & (ECMD_ADDBUF | ECMD_ALTBUF))
{
// Default the line number to zero to avoid that a wininfo item
// is added for the current window.
linenr_T tlnum = 0;
buf_T *newbuf;
if (command != NULL)
{
tlnum = atol((char *)command);
if (tlnum <= 0)
tlnum = 1L;
}
// Add BLN_NOCURWIN to avoid a new wininfo items are associated
// with the current window.
newbuf = buflist_new(ffname, sfname, tlnum,
BLN_LISTED | BLN_NOCURWIN);
if (newbuf != NULL && (flags & ECMD_ALTBUF))
curwin->w_alt_fnum = newbuf->b_fnum;
goto theend;
}
buf = buflist_new(ffname, sfname, 0L,
BLN_CURBUF | ((flags & ECMD_SET_HELP) ? 0 : BLN_LISTED));
// autocommands may change curwin and curbuf
if (oldwin != NULL)
oldwin = curwin;
set_bufref(&old_curbuf, curbuf);
}
if (buf == NULL)
goto theend;
if (curwin->w_alt_fnum == buf->b_fnum && prev_alt_fnum != 0)
// reusing the buffer, keep the old alternate file
curwin->w_alt_fnum = prev_alt_fnum;
if (buf->b_ml.ml_mfp == NULL) // no memfile yet
{
oldbuf = FALSE;
}
else // existing memfile
{
oldbuf = TRUE;
set_bufref(&bufref, buf);
(void)buf_check_timestamp(buf, FALSE);
// Check if autocommands made the buffer invalid or changed the
// current buffer.
if (!bufref_valid(&bufref) || curbuf != old_curbuf.br_buf)
goto theend;
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
goto theend;
#endif
}
// May jump to last used line number for a loaded buffer or when asked
// for explicitly
if ((oldbuf && newlnum == ECMD_LASTL) || newlnum == ECMD_LAST)
{
pos = buflist_findfpos(buf);
newlnum = pos->lnum;
solcol = pos->col;
}
/*
* Make the (new) buffer the one used by the current window.
* If the old buffer becomes unused, free it if ECMD_HIDE is FALSE.
* If the current buffer was empty and has no file name, curbuf
* is returned by buflist_new(), nothing to do here.
*/
if (buf != curbuf)
{
bufref_T save_au_new_curbuf;
#ifdef FEAT_CMDWIN
int save_cmdwin_type = cmdwin_type;
// BufLeave applies to the old buffer.
cmdwin_type = 0;
#endif
/*
* Be careful: The autocommands may delete any buffer and change
* the current buffer.
* - If the buffer we are going to edit is deleted, give up.
* - If the current buffer is deleted, prefer to load the new
* buffer when loading a buffer is required. This avoids
* loading another buffer which then must be closed again.
* - If we ended up in the new buffer already, need to skip a few
* things, set auto_buf.
*/
if (buf->b_fname != NULL)
new_name = vim_strsave(buf->b_fname);
save_au_new_curbuf = au_new_curbuf;
set_bufref(&au_new_curbuf, buf);
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_CMDWIN
cmdwin_type = save_cmdwin_type;
#endif
if (!bufref_valid(&au_new_curbuf))
{
// new buffer has been deleted
delbuf_msg(new_name); // frees new_name
au_new_curbuf = save_au_new_curbuf;
goto theend;
}
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
{
vim_free(new_name);
au_new_curbuf = save_au_new_curbuf;
goto theend;
}
#endif
if (buf == curbuf) // already in new buffer
auto_buf = TRUE;
else
{
win_T *the_curwin = curwin;
int did_decrement;
buf_T *was_curbuf = curbuf;
// Set the w_closing flag to avoid that autocommands close the
// window. And set b_locked for the same reason.
the_curwin->w_closing = TRUE;
++buf->b_locked;
if (curbuf == old_curbuf.br_buf)
buf_copy_options(buf, BCO_ENTER);
// Close the link to the current buffer. This will set
// oldwin->w_buffer to NULL.
u_sync(FALSE);
did_decrement = close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE);
// Autocommands may have closed the window.
if (win_valid(the_curwin))
the_curwin->w_closing = FALSE;
--buf->b_locked;
#ifdef FEAT_EVAL
// autocmds may abort script processing
if (aborting() && curwin->w_buffer != NULL)
{
vim_free(new_name);
au_new_curbuf = save_au_new_curbuf;
goto theend;
}
#endif
// Be careful again, like above.
if (!bufref_valid(&au_new_curbuf))
{
// new buffer has been deleted
delbuf_msg(new_name); // frees new_name
au_new_curbuf = save_au_new_curbuf;
goto theend;
}
if (buf == curbuf) // already in new buffer
{
// close_buffer() has decremented the window count,
// increment it again here and restore w_buffer.
if (did_decrement && buf_valid(was_curbuf))
++was_curbuf->b_nwindows;
if (win_valid_any_tab(oldwin) && oldwin->w_buffer == NULL)
oldwin->w_buffer = was_curbuf;
auto_buf = TRUE;
}
else
{
#ifdef FEAT_SYN_HL
/*
* <VN> We could instead free the synblock
* and re-attach to buffer, perhaps.
*/
if (curwin->w_buffer == NULL
|| curwin->w_s == &(curwin->w_buffer->b_s))
curwin->w_s = &(buf->b_s);
#endif
curwin->w_buffer = buf;
curbuf = buf;
++curbuf->b_nwindows;
// Set 'fileformat', 'binary' and 'fenc' when forced.
if (!oldbuf && eap != NULL)
{
set_file_options(TRUE, eap);
set_forced_fenc(eap);
}
}
// May get the window options from the last time this buffer
// was in this window (or another window). If not used
// before, reset the local window options to the global
// values. Also restores old folding stuff.
get_winopts(curbuf);
#ifdef FEAT_SPELL
did_get_winopts = TRUE;
#endif
}
vim_free(new_name);
au_new_curbuf = save_au_new_curbuf;
}
curwin->w_pcmark.lnum = 1;
curwin->w_pcmark.col = 0;
}
else // !other_file
{
if ((flags & (ECMD_ADDBUF | ECMD_ALTBUF)) || check_fname() == FAIL)
goto theend;
oldbuf = (flags & ECMD_OLDBUF);
}
// Don't redraw until the cursor is in the right line, otherwise
// autocommands may cause ml_get errors.
++RedrawingDisabled;
did_inc_redrawing_disabled = TRUE;
buf = curbuf;
if ((flags & ECMD_SET_HELP) || keep_help_flag)
{
prepare_help_buffer();
}
else
{
// Don't make a buffer listed if it's a help buffer. Useful when
// using CTRL-O to go back to a help file.
if (!curbuf->b_help)
set_buflisted(TRUE);
}
// If autocommands change buffers under our fingers, forget about
// editing the file.
if (buf != curbuf)
goto theend;
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
goto theend;
#endif
// Since we are starting to edit a file, consider the filetype to be
// unset. Helps for when an autocommand changes files and expects syntax
// highlighting to work in the other file.
did_filetype = FALSE;
/*
* other_file oldbuf
* FALSE FALSE re-edit same file, buffer is re-used
* FALSE TRUE re-edit same file, nothing changes
* TRUE FALSE start editing new file, new buffer
* TRUE TRUE start editing in existing buffer (nothing to do)
*/
if (!other_file && !oldbuf) // re-use the buffer
{
set_last_cursor(curwin); // may set b_last_cursor
if (newlnum == ECMD_LAST || newlnum == ECMD_LASTL)
{
newlnum = curwin->w_cursor.lnum;
solcol = curwin->w_cursor.col;
}
buf = curbuf;
if (buf->b_fname != NULL)
new_name = vim_strsave(buf->b_fname);
else
new_name = NULL;
set_bufref(&bufref, buf);
// If the buffer was used before, store the current contents so that
// the reload can be undone. Do not do this if the (empty) buffer is
// being re-used for another file.
if (!(curbuf->b_flags & BF_NEVERLOADED)
&& (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur))
{
// Sync first so that this is a separate undo-able action.
u_sync(FALSE);
if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE)
== FAIL)
{
vim_free(new_name);
goto theend;
}
u_unchanged(curbuf);
buf_freeall(curbuf, BFA_KEEP_UNDO);
// tell readfile() not to clear or reload undo info
readfile_flags = READ_KEEP_UNDO;
}
else
buf_freeall(curbuf, 0); // free all things for buffer
// If autocommands deleted the buffer we were going to re-edit, give
// up and jump to the end.
if (!bufref_valid(&bufref))
{
delbuf_msg(new_name); // frees new_name
goto theend;
}
vim_free(new_name);
// If autocommands change buffers under our fingers, forget about
// re-editing the file. Should do the buf_clear_file(), but perhaps
// the autocommands changed the buffer...
if (buf != curbuf)
goto theend;
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
goto theend;
#endif
buf_clear_file(curbuf);
curbuf->b_op_start.lnum = 0; // clear '[ and '] marks
curbuf->b_op_end.lnum = 0;
}
/*
* If we get here we are sure to start editing
*/
// Assume success now
retval = OK;
/*
* Check if we are editing the w_arg_idx file in the argument list.
*/
check_arg_idx(curwin);
if (!auto_buf)
{
/*
* Set cursor and init window before reading the file and executing
* autocommands. This allows for the autocommands to position the
* cursor.
*/
curwin_init();
#ifdef FEAT_FOLDING
// It's possible that all lines in the buffer changed. Need to update
// automatic folding for all windows where it's used.
{
win_T *win;
tabpage_T *tp;
FOR_ALL_TAB_WINDOWS(tp, win)
if (win->w_buffer == curbuf)
foldUpdateAll(win);
}
#endif
// Change directories when the 'acd' option is set.
DO_AUTOCHDIR;
/*
* Careful: open_buffer() and apply_autocmds() may change the current
* buffer and window.
*/
orig_pos = curwin->w_cursor;
topline = curwin->w_topline;
if (!oldbuf) // need to read the file
{
#ifdef FEAT_PROP_POPUP
// Don't use the swap-exists dialog for a popup window, can't edit
// the buffer.
if (WIN_IS_POPUP(curwin))
curbuf->b_flags |= BF_NO_SEA;
#endif
swap_exists_action = SEA_DIALOG;
curbuf->b_flags |= BF_CHECK_RO; // set/reset 'ro' flag
/*
* Open the buffer and read the file.
*/
if (flags & ECMD_NOWINENTER)
readfile_flags |= READ_NOWINENTER;
#if defined(FEAT_EVAL)
if (should_abort(open_buffer(FALSE, eap, readfile_flags)))
retval = FAIL;
#else
(void)open_buffer(FALSE, eap, readfile_flags);
#endif
#ifdef FEAT_PROP_POPUP
curbuf->b_flags &= ~BF_NO_SEA;
#endif
if (swap_exists_action == SEA_QUIT)
retval = FAIL;
handle_swap_exists(&old_curbuf);
}
else
{
// Read the modelines, but only to set window-local options. Any
// buffer-local options have already been set and may have been
// changed by the user.
do_modelines(OPT_WINONLY);
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE,
curbuf, &retval);
if ((flags & ECMD_NOWINENTER) == 0)
apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE,
curbuf, &retval);
}
check_arg_idx(curwin);
// If autocommands change the cursor position or topline, we should
// keep it. Also when it moves within a line. But not when it moves
// to the first non-blank.
if (!EQUAL_POS(curwin->w_cursor, orig_pos))
{
char_u *text = ml_get_curline();
if (curwin->w_cursor.lnum != orig_pos.lnum
|| curwin->w_cursor.col != (int)(skipwhite(text) - text))
{
newlnum = curwin->w_cursor.lnum;
newcol = curwin->w_cursor.col;
}
}
if (curwin->w_topline == topline)
topline = 0;
// Even when cursor didn't move we need to recompute topline.
changed_line_abv_curs();
maketitle();
#if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)
if (WIN_IS_POPUP(curwin) && curwin->w_p_pvw && retval != FAIL)
popup_set_title(curwin);
#endif
}
#ifdef FEAT_DIFF
// Tell the diff stuff that this buffer is new and/or needs updating.
// Also needed when re-editing the same buffer, because unloading will
// have removed it as a diff buffer.
if (curwin->w_p_diff)
{
diff_buf_add(curbuf);
diff_invalidate(curbuf);
}
#endif
#ifdef FEAT_SPELL
// If the window options were changed may need to set the spell language.
// Can only do this after the buffer has been properly setup.
if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
(void)did_set_spelllang(curwin);
#endif
if (command == NULL)
{
if (newcol >= 0) // position set by autocommands
{
curwin->w_cursor.lnum = newlnum;
curwin->w_cursor.col = newcol;
check_cursor();
}
else if (newlnum > 0) // line number from caller or old position
{
curwin->w_cursor.lnum = newlnum;
check_cursor_lnum();
if (solcol >= 0 && !p_sol)
{
// 'sol' is off: Use last known column.
curwin->w_cursor.col = solcol;
check_cursor_col();
curwin->w_cursor.coladd = 0;
curwin->w_set_curswant = TRUE;
}
else
beginline(BL_SOL | BL_FIX);
}
else // no line number, go to last line in Ex mode
{
if (exmode_active)
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
beginline(BL_WHITE | BL_FIX);
}
}
// Check if cursors in other windows on the same buffer are still valid
check_lnums(FALSE);
/*
* Did not read the file, need to show some info about the file.
* Do this after setting the cursor.
*/
if (oldbuf && !auto_buf)
{
int msg_scroll_save = msg_scroll;
// Obey the 'O' flag in 'cpoptions': overwrite any previous file
// message.
if (shortmess(SHM_OVERALL) && !exiting && p_verbose == 0)
msg_scroll = FALSE;
if (!msg_scroll) // wait a bit when overwriting an error msg
check_for_delay(FALSE);
msg_start();
msg_scroll = msg_scroll_save;
msg_scrolled_ign = TRUE;
if (!shortmess(SHM_FILEINFO))
fileinfo(FALSE, TRUE, FALSE);
msg_scrolled_ign = FALSE;
}
#ifdef FEAT_VIMINFO
curbuf->b_last_used = vim_time();
#endif
if (command != NULL)
do_cmdline(command, NULL, NULL, DOCMD_VERBOSE|DOCMD_RANGEOK);
#ifdef FEAT_KEYMAP
if (curbuf->b_kmap_state & KEYMAP_INIT)
(void)keymap_init();
#endif
--RedrawingDisabled;
did_inc_redrawing_disabled = FALSE;
if (!skip_redraw)
{
n = *so_ptr;
if (topline == 0 && command == NULL)
*so_ptr = 9999; // force cursor halfway the window
update_topline();
curwin->w_scbind_pos = curwin->w_topline;
*so_ptr = n;
redraw_curbuf_later(NOT_VALID); // redraw this buffer later
}
if (p_im && (State & MODE_INSERT) == 0)
need_start_insertmode = TRUE;
#ifdef FEAT_AUTOCHDIR
// Change directories when the 'acd' option is set and we aren't already in
// that directory (should already be done above). Expect getcwd() to be
// faster than calling shorten_fnames() unnecessarily.
if (p_acd && curbuf->b_ffname != NULL)
{
char_u curdir[MAXPATHL];
char_u filedir[MAXPATHL];
vim_strncpy(filedir, curbuf->b_ffname, MAXPATHL - 1);
*gettail_sep(filedir) = NUL;
if (mch_dirname(curdir, MAXPATHL) != FAIL
&& vim_fnamecmp(curdir, filedir) != 0)
do_autochdir();
}
#endif
#if defined(FEAT_NETBEANS_INTG)
if (curbuf->b_ffname != NULL)
{
# ifdef FEAT_NETBEANS_INTG
if ((flags & ECMD_SET_HELP) != ECMD_SET_HELP)
netbeans_file_opened(curbuf);
# endif
}
#endif
theend:
if (did_inc_redrawing_disabled)
--RedrawingDisabled;
#if defined(FEAT_EVAL)
if (did_set_swapcommand)
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
#endif
#ifdef FEAT_BROWSE
vim_free(browse_file);
#endif
vim_free(free_fname);
return retval;
} | 0 |
OpenSC | 8fe377e93b4b56060e5bbfb6f3142ceaeca744fa | CVE-2018-16427 | CWE-125 | auth_select_file(struct sc_card *card, const struct sc_path *in_path,
struct sc_file **file_out)
{
struct sc_path path;
struct sc_file *tmp_file = NULL;
size_t offs, ii;
int rv;
LOG_FUNC_CALLED(card->ctx);
assert(card != NULL && in_path != NULL);
memcpy(&path, in_path, sizeof(struct sc_path));
sc_log(card->ctx, "in_path; type=%d, path=%s, out %p",
in_path->type, sc_print_path(in_path), file_out);
sc_log(card->ctx, "current path; type=%d, path=%s",
auth_current_df->path.type, sc_print_path(&auth_current_df->path));
if (auth_current_ef)
sc_log(card->ctx, "current file; type=%d, path=%s",
auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
sc_file_free(auth_current_ef);
auth_current_ef = NULL;
rv = iso_ops->select_file(card, &path, &tmp_file);
LOG_TEST_RET(card->ctx, rv, "select file failed");
if (!tmp_file)
return SC_ERROR_OBJECT_NOT_FOUND;
if (path.type == SC_PATH_TYPE_PARENT) {
memcpy(&tmp_file->path, &auth_current_df->path, sizeof(struct sc_path));
if (tmp_file->path.len > 2)
tmp_file->path.len -= 2;
sc_file_free(auth_current_df);
sc_file_dup(&auth_current_df, tmp_file);
}
else {
if (tmp_file->type == SC_FILE_TYPE_DF) {
sc_concatenate_path(&tmp_file->path, &auth_current_df->path, &path);
sc_file_free(auth_current_df);
sc_file_dup(&auth_current_df, tmp_file);
}
else {
sc_file_free(auth_current_ef);
sc_file_dup(&auth_current_ef, tmp_file);
sc_concatenate_path(&auth_current_ef->path, &auth_current_df->path, &path);
}
}
if (file_out)
sc_file_dup(file_out, tmp_file);
sc_file_free(tmp_file);
}
else if (path.type == SC_PATH_TYPE_DF_NAME) {
rv = iso_ops->select_file(card, &path, NULL);
if (rv) {
sc_file_free(auth_current_ef);
auth_current_ef = NULL;
}
LOG_TEST_RET(card->ctx, rv, "select file failed");
}
else {
for (offs = 0; offs < path.len && offs < auth_current_df->path.len; offs += 2)
if (path.value[offs] != auth_current_df->path.value[offs] ||
path.value[offs + 1] != auth_current_df->path.value[offs + 1])
break;
sc_log(card->ctx, "offs %"SC_FORMAT_LEN_SIZE_T"u", offs);
if (offs && offs < auth_current_df->path.len) {
size_t deep = auth_current_df->path.len - offs;
sc_log(card->ctx, "deep %"SC_FORMAT_LEN_SIZE_T"u",
deep);
for (ii=0; ii<deep; ii+=2) {
struct sc_path tmp_path;
memcpy(&tmp_path, &auth_current_df->path, sizeof(struct sc_path));
tmp_path.type = SC_PATH_TYPE_PARENT;
rv = auth_select_file (card, &tmp_path, file_out);
LOG_TEST_RET(card->ctx, rv, "select file failed");
}
}
if (path.len - offs > 0) {
struct sc_path tmp_path;
memset(&tmp_path, 0, sizeof(struct sc_path));
tmp_path.type = SC_PATH_TYPE_FILE_ID;
tmp_path.len = 2;
for (ii=0; ii < path.len - offs; ii+=2) {
memcpy(tmp_path.value, path.value + offs + ii, 2);
rv = auth_select_file(card, &tmp_path, file_out);
LOG_TEST_RET(card->ctx, rv, "select file failed");
}
}
else if (path.len - offs == 0 && file_out) {
if (sc_compare_path(&path, &auth_current_df->path))
sc_file_dup(file_out, auth_current_df);
else if (auth_current_ef)
sc_file_dup(file_out, auth_current_ef);
else
LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "No current EF");
}
}
LOG_FUNC_RETURN(card->ctx, 0);
}
| 1 |
Chrome | eaf2e8bce3855d362e53034bd83f0e3aff8714e4 | NOT_APPLICABLE | NOT_APPLICABLE | Status IndexedDBDatabase::VersionChangeOperation(
int64_t version,
scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction) {
IDB_TRACE1(
"IndexedDBDatabase::VersionChangeOperation", "txn.id", transaction->id());
int64_t old_version = metadata_.version;
DCHECK_GT(version, old_version);
metadata_coding_->SetDatabaseVersion(
transaction->BackingStoreTransaction()->transaction(), id(), version,
&metadata_);
transaction->ScheduleAbortTask(base::BindOnce(
&IndexedDBDatabase::VersionChangeAbortOperation, this, old_version));
active_request_->UpgradeTransactionStarted(old_version);
return Status::OK();
}
| 0 |
linux | 5a0fdfada3a2aa50d7b947a2e958bf00cbe0d830 | NOT_APPLICABLE | NOT_APPLICABLE | static void __do_kernel_fault(struct mm_struct *mm, unsigned long addr,
unsigned int esr, struct pt_regs *regs)
{
/*
* Are we prepared to handle this kernel fault?
*/
if (fixup_exception(regs))
return;
/*
* No handler, we'll have to terminate things with extreme prejudice.
*/
bust_spinlocks(1);
pr_alert("Unable to handle kernel %s at virtual address %08lx\n",
(addr < PAGE_SIZE) ? "NULL pointer dereference" :
"paging request", addr);
show_pte(mm, addr);
die("Oops", regs, esr);
bust_spinlocks(0);
do_exit(SIGKILL);
}
| 0 |
jasper | d42b2388f7f8e0332c846675133acea151fc557a | NOT_APPLICABLE | NOT_APPLICABLE | int jas_getdbglevel()
{
return jas_dbglevel;
}
| 0 |
php-src | 24125f0f26f3787c006e4a51611ba33ee3b841cb | NOT_APPLICABLE | NOT_APPLICABLE | void zend_ts_hash_display_pListTail(TsHashTable *ht)
{
begin_read(ht);
zend_hash_display_pListTail(TS_HASH(ht));
end_read(ht);
} | 0 |
git | e904deb89d9a9669a76a426182506a084d3f6308 | NOT_APPLICABLE | NOT_APPLICABLE | static int name_and_item_from_var(const char *var, struct strbuf *name,
struct strbuf *item)
{
const char *subsection, *key;
int subsection_len, parse;
parse = parse_config_key(var, "submodule", &subsection,
&subsection_len, &key);
if (parse < 0 || !subsection)
return 0;
strbuf_add(name, subsection, subsection_len);
if (check_submodule_name(name->buf) < 0) {
warning(_("ignoring suspicious submodule name: %s"), name->buf);
strbuf_release(name);
return 0;
}
strbuf_addstr(item, key);
return 1;
} | 0 |
linux | 550fd08c2cebad61c548def135f67aba284c6162 | NOT_APPLICABLE | NOT_APPLICABLE | static void addr_hash_set(u32 *mask, const u8 *addr)
{
int n = ether_crc(ETH_ALEN, addr) >> 26;
mask[n >> 5] |= (1 << (n & 31));
}
| 0 |
linux | 2b7e8665b4ff51c034c55df3cff76518d1a9ee3a | NOT_APPLICABLE | NOT_APPLICABLE | void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file)
{
struct file *old_exe_file;
/*
* It is safe to dereference the exe_file without RCU as
* this function is only called if nobody else can access
* this mm -- see comment above for justification.
*/
old_exe_file = rcu_dereference_raw(mm->exe_file);
if (new_exe_file)
get_file(new_exe_file);
rcu_assign_pointer(mm->exe_file, new_exe_file);
if (old_exe_file)
fput(old_exe_file);
}
| 0 |
Chrome | 3a766e0115e9799db766a88554b9ab12ee5bf2a4 | CVE-2011-2834 | CWE-399 | xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
{
int total = 0;
int equal, ret;
xmlXPathCompExprPtr comp;
xmlXPathObjectPtr arg1, arg2;
xmlNodePtr bak;
xmlDocPtr bakd;
int pp;
int cs;
CHECK_ERROR0;
comp = ctxt->comp;
switch (op->op) {
case XPATH_OP_END:
return (0);
case XPATH_OP_AND:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
xmlXPathBooleanFunction(ctxt, 1);
if ((ctxt->value == NULL) || (ctxt->value->boolval == 0))
return (total);
arg2 = valuePop(ctxt);
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
if (ctxt->error) {
xmlXPathFreeObject(arg2);
return(0);
}
xmlXPathBooleanFunction(ctxt, 1);
arg1 = valuePop(ctxt);
arg1->boolval &= arg2->boolval;
valuePush(ctxt, arg1);
xmlXPathReleaseObject(ctxt->context, arg2);
return (total);
case XPATH_OP_OR:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
xmlXPathBooleanFunction(ctxt, 1);
if ((ctxt->value == NULL) || (ctxt->value->boolval == 1))
return (total);
arg2 = valuePop(ctxt);
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
if (ctxt->error) {
xmlXPathFreeObject(arg2);
return(0);
}
xmlXPathBooleanFunction(ctxt, 1);
arg1 = valuePop(ctxt);
arg1->boolval |= arg2->boolval;
valuePush(ctxt, arg1);
xmlXPathReleaseObject(ctxt->context, arg2);
return (total);
case XPATH_OP_EQUAL:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
if (op->value)
equal = xmlXPathEqualValues(ctxt);
else
equal = xmlXPathNotEqualValues(ctxt);
valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal));
return (total);
case XPATH_OP_CMP:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
ret = xmlXPathCompareValues(ctxt, op->value, op->value2);
valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
return (total);
case XPATH_OP_PLUS:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
if (op->ch2 != -1) {
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
}
CHECK_ERROR0;
if (op->value == 0)
xmlXPathSubValues(ctxt);
else if (op->value == 1)
xmlXPathAddValues(ctxt);
else if (op->value == 2)
xmlXPathValueFlipSign(ctxt);
else if (op->value == 3) {
CAST_TO_NUMBER;
CHECK_TYPE0(XPATH_NUMBER);
}
return (total);
case XPATH_OP_MULT:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
if (op->value == 0)
xmlXPathMultValues(ctxt);
else if (op->value == 1)
xmlXPathDivValues(ctxt);
else if (op->value == 2)
xmlXPathModValues(ctxt);
return (total);
case XPATH_OP_UNION:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
ctxt->context->doc = bakd;
ctxt->context->node = bak;
ctxt->context->proximityPosition = pp;
ctxt->context->contextSize = cs;
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
CHECK_TYPE0(XPATH_NODESET);
arg2 = valuePop(ctxt);
CHECK_TYPE0(XPATH_NODESET);
arg1 = valuePop(ctxt);
if ((arg1->nodesetval == NULL) ||
((arg2->nodesetval != NULL) &&
(arg2->nodesetval->nodeNr != 0)))
{
arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval,
arg2->nodesetval);
}
valuePush(ctxt, arg1);
xmlXPathReleaseObject(ctxt->context, arg2);
return (total);
case XPATH_OP_ROOT:
xmlXPathRoot(ctxt);
return (total);
case XPATH_OP_NODE:
if (op->ch1 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
if (op->ch2 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node));
return (total);
case XPATH_OP_RESET:
if (op->ch1 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
if (op->ch2 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
ctxt->context->node = NULL;
return (total);
case XPATH_OP_COLLECT:{
if (op->ch1 == -1)
return (total);
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 0);
return (total);
}
case XPATH_OP_VALUE:
valuePush(ctxt,
xmlXPathCacheObjectCopy(ctxt->context,
(xmlXPathObjectPtr) op->value4));
return (total);
case XPATH_OP_VARIABLE:{
xmlXPathObjectPtr val;
if (op->ch1 != -1)
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
if (op->value5 == NULL) {
val = xmlXPathVariableLookup(ctxt->context, op->value4);
if (val == NULL) {
ctxt->error = XPATH_UNDEF_VARIABLE_ERROR;
return(0);
}
valuePush(ctxt, val);
} else {
const xmlChar *URI;
URI = xmlXPathNsLookup(ctxt->context, op->value5);
if (URI == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n",
(char *) op->value4, (char *)op->value5);
return (total);
}
val = xmlXPathVariableLookupNS(ctxt->context,
op->value4, URI);
if (val == NULL) {
ctxt->error = XPATH_UNDEF_VARIABLE_ERROR;
return(0);
}
valuePush(ctxt, val);
}
return (total);
}
case XPATH_OP_FUNCTION:{
xmlXPathFunction func;
const xmlChar *oldFunc, *oldFuncURI;
int i;
if (op->ch1 != -1)
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
if (ctxt->valueNr < op->value) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: parameter error\n");
ctxt->error = XPATH_INVALID_OPERAND;
return (total);
}
for (i = 0; i < op->value; i++)
if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: parameter error\n");
ctxt->error = XPATH_INVALID_OPERAND;
return (total);
}
if (op->cache != NULL)
XML_CAST_FPTR(func) = op->cache;
else {
const xmlChar *URI = NULL;
if (op->value5 == NULL)
func =
xmlXPathFunctionLookup(ctxt->context,
op->value4);
else {
URI = xmlXPathNsLookup(ctxt->context, op->value5);
if (URI == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: function %s bound to undefined prefix %s\n",
(char *)op->value4, (char *)op->value5);
return (total);
}
func = xmlXPathFunctionLookupNS(ctxt->context,
op->value4, URI);
}
if (func == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: function %s not found\n",
(char *)op->value4);
XP_ERROR0(XPATH_UNKNOWN_FUNC_ERROR);
}
op->cache = XML_CAST_FPTR(func);
op->cacheURI = (void *) URI;
}
oldFunc = ctxt->context->function;
oldFuncURI = ctxt->context->functionURI;
ctxt->context->function = op->value4;
ctxt->context->functionURI = op->cacheURI;
func(ctxt, op->value);
ctxt->context->function = oldFunc;
ctxt->context->functionURI = oldFuncURI;
return (total);
}
case XPATH_OP_ARG:
bakd = ctxt->context->doc;
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
if (op->ch1 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
ctxt->context->contextSize = cs;
ctxt->context->proximityPosition = pp;
ctxt->context->node = bak;
ctxt->context->doc = bakd;
CHECK_ERROR0;
if (op->ch2 != -1) {
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
ctxt->context->doc = bakd;
ctxt->context->node = bak;
CHECK_ERROR0;
}
return (total);
case XPATH_OP_PREDICATE:
case XPATH_OP_FILTER:{
xmlXPathObjectPtr res;
xmlXPathObjectPtr obj, tmp;
xmlNodeSetPtr newset = NULL;
xmlNodeSetPtr oldset;
xmlNodePtr oldnode;
xmlDocPtr oldDoc;
int i;
/*
* Optimization for ()[1] selection i.e. the first elem
*/
if ((op->ch1 != -1) && (op->ch2 != -1) &&
#ifdef XP_OPTIMIZED_FILTER_FIRST
/*
* FILTER TODO: Can we assume that the inner processing
* will result in an ordered list if we have an
* XPATH_OP_FILTER?
* What about an additional field or flag on
* xmlXPathObject like @sorted ? This way we wouln'd need
* to assume anything, so it would be more robust and
* easier to optimize.
*/
((comp->steps[op->ch1].op == XPATH_OP_SORT) || /* 18 */
(comp->steps[op->ch1].op == XPATH_OP_FILTER)) && /* 17 */
#else
(comp->steps[op->ch1].op == XPATH_OP_SORT) &&
#endif
(comp->steps[op->ch2].op == XPATH_OP_VALUE)) { /* 12 */
xmlXPathObjectPtr val;
val = comp->steps[op->ch2].value4;
if ((val != NULL) && (val->type == XPATH_NUMBER) &&
(val->floatval == 1.0)) {
xmlNodePtr first = NULL;
total +=
xmlXPathCompOpEvalFirst(ctxt,
&comp->steps[op->ch1],
&first);
CHECK_ERROR0;
/*
* The nodeset should be in document order,
* Keep only the first value
*/
if ((ctxt->value != NULL) &&
(ctxt->value->type == XPATH_NODESET) &&
(ctxt->value->nodesetval != NULL) &&
(ctxt->value->nodesetval->nodeNr > 1))
ctxt->value->nodesetval->nodeNr = 1;
return (total);
}
}
/*
* Optimization for ()[last()] selection i.e. the last elem
*/
if ((op->ch1 != -1) && (op->ch2 != -1) &&
(comp->steps[op->ch1].op == XPATH_OP_SORT) &&
(comp->steps[op->ch2].op == XPATH_OP_SORT)) {
int f = comp->steps[op->ch2].ch1;
if ((f != -1) &&
(comp->steps[f].op == XPATH_OP_FUNCTION) &&
(comp->steps[f].value5 == NULL) &&
(comp->steps[f].value == 0) &&
(comp->steps[f].value4 != NULL) &&
(xmlStrEqual
(comp->steps[f].value4, BAD_CAST "last"))) {
xmlNodePtr last = NULL;
total +=
xmlXPathCompOpEvalLast(ctxt,
&comp->steps[op->ch1],
&last);
CHECK_ERROR0;
/*
* The nodeset should be in document order,
* Keep only the last value
*/
if ((ctxt->value != NULL) &&
(ctxt->value->type == XPATH_NODESET) &&
(ctxt->value->nodesetval != NULL) &&
(ctxt->value->nodesetval->nodeTab != NULL) &&
(ctxt->value->nodesetval->nodeNr > 1)) {
ctxt->value->nodesetval->nodeTab[0] =
ctxt->value->nodesetval->nodeTab[ctxt->
value->
nodesetval->
nodeNr -
1];
ctxt->value->nodesetval->nodeNr = 1;
}
return (total);
}
}
/*
* Process inner predicates first.
* Example "index[parent::book][1]":
* ...
* PREDICATE <-- we are here "[1]"
* PREDICATE <-- process "[parent::book]" first
* SORT
* COLLECT 'parent' 'name' 'node' book
* NODE
* ELEM Object is a number : 1
*/
if (op->ch1 != -1)
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
if (op->ch2 == -1)
return (total);
if (ctxt->value == NULL)
return (total);
oldnode = ctxt->context->node;
#ifdef LIBXML_XPTR_ENABLED
/*
* Hum are we filtering the result of an XPointer expression
*/
if (ctxt->value->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr newlocset = NULL;
xmlLocationSetPtr oldlocset;
/*
* Extract the old locset, and then evaluate the result of the
* expression for all the element in the locset. use it to grow
* up a new locset.
*/
CHECK_TYPE0(XPATH_LOCATIONSET);
obj = valuePop(ctxt);
oldlocset = obj->user;
ctxt->context->node = NULL;
if ((oldlocset == NULL) || (oldlocset->locNr == 0)) {
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
res = valuePop(ctxt);
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
valuePush(ctxt, obj);
CHECK_ERROR0;
return (total);
}
newlocset = xmlXPtrLocationSetCreate(NULL);
for (i = 0; i < oldlocset->locNr; i++) {
/*
* Run the evaluation with a node list made of a
* single item in the nodelocset.
*/
ctxt->context->node = oldlocset->locTab[i]->user;
ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1;
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPathFreeObject(obj);
return(0);
}
/*
* The result of the evaluation need to be tested to
* decided whether the filter succeeded or not
*/
res = valuePop(ctxt);
if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
xmlXPtrLocationSetAdd(newlocset,
xmlXPathObjectCopy
(oldlocset->locTab[i]));
}
/*
* Cleanup
*/
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
if (ctxt->value == tmp) {
res = valuePop(ctxt);
xmlXPathReleaseObject(ctxt->context, res);
}
ctxt->context->node = NULL;
}
/*
* The result is used as the new evaluation locset.
*/
xmlXPathReleaseObject(ctxt->context, obj);
ctxt->context->node = NULL;
ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1;
valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
ctxt->context->node = oldnode;
return (total);
}
#endif /* LIBXML_XPTR_ENABLED */
/*
* Extract the old set, and then evaluate the result of the
* expression for all the element in the set. use it to grow
* up a new set.
*/
CHECK_TYPE0(XPATH_NODESET);
obj = valuePop(ctxt);
oldset = obj->nodesetval;
oldnode = ctxt->context->node;
oldDoc = ctxt->context->doc;
ctxt->context->node = NULL;
if ((oldset == NULL) || (oldset->nodeNr == 0)) {
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
/*
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
CHECK_ERROR0;
res = valuePop(ctxt);
if (res != NULL)
xmlXPathFreeObject(res);
*/
valuePush(ctxt, obj);
ctxt->context->node = oldnode;
CHECK_ERROR0;
} else {
tmp = NULL;
/*
* Initialize the new set.
* Also set the xpath document in case things like
* key() evaluation are attempted on the predicate
*/
newset = xmlXPathNodeSetCreate(NULL);
/*
* SPEC XPath 1.0:
* "For each node in the node-set to be filtered, the
* PredicateExpr is evaluated with that node as the
* context node, with the number of nodes in the
* node-set as the context size, and with the proximity
* position of the node in the node-set with respect to
* the axis as the context position;"
* @oldset is the node-set" to be filtered.
*
* SPEC XPath 1.0:
* "only predicates change the context position and
* context size (see [2.4 Predicates])."
* Example:
* node-set context pos
* nA 1
* nB 2
* nC 3
* After applying predicate [position() > 1] :
* node-set context pos
* nB 1
* nC 2
*
* removed the first node in the node-set, then
* the context position of the
*/
for (i = 0; i < oldset->nodeNr; i++) {
/*
* Run the evaluation with a node list made of
* a single item in the nodeset.
*/
ctxt->context->node = oldset->nodeTab[i];
if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) &&
(oldset->nodeTab[i]->doc != NULL))
ctxt->context->doc = oldset->nodeTab[i]->doc;
if (tmp == NULL) {
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
} else {
xmlXPathNodeSetAddUnique(tmp->nodesetval,
ctxt->context->node);
}
valuePush(ctxt, tmp);
ctxt->context->contextSize = oldset->nodeNr;
ctxt->context->proximityPosition = i + 1;
/*
* Evaluate the predicate against the context node.
* Can/should we optimize position() predicates
* here (e.g. "[1]")?
*/
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPathFreeNodeSet(newset);
xmlXPathFreeObject(obj);
return(0);
}
/*
* The result of the evaluation needs to be tested to
* decide whether the filter succeeded or not
*/
/*
* OPTIMIZE TODO: Can we use
* xmlXPathNodeSetAdd*Unique()* instead?
*/
res = valuePop(ctxt);
if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]);
}
/*
* Cleanup
*/
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
if (ctxt->value == tmp) {
valuePop(ctxt);
xmlXPathNodeSetClear(tmp->nodesetval, 1);
/*
* Don't free the temporary nodeset
* in order to avoid massive recreation inside this
* loop.
*/
} else
tmp = NULL;
ctxt->context->node = NULL;
}
if (tmp != NULL)
xmlXPathReleaseObject(ctxt->context, tmp);
/*
* The result is used as the new evaluation set.
*/
xmlXPathReleaseObject(ctxt->context, obj);
ctxt->context->node = NULL;
ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1;
/* may want to move this past the '}' later */
ctxt->context->doc = oldDoc;
valuePush(ctxt,
xmlXPathCacheWrapNodeSet(ctxt->context, newset));
}
ctxt->context->node = oldnode;
return (total);
}
case XPATH_OP_SORT:
if (op->ch1 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
if ((ctxt->value != NULL) &&
(ctxt->value->type == XPATH_NODESET) &&
(ctxt->value->nodesetval != NULL) &&
(ctxt->value->nodesetval->nodeNr > 1))
{
xmlXPathNodeSetSort(ctxt->value->nodesetval);
}
return (total);
#ifdef LIBXML_XPTR_ENABLED
case XPATH_OP_RANGETO:{
xmlXPathObjectPtr range;
xmlXPathObjectPtr res, obj;
xmlXPathObjectPtr tmp;
xmlLocationSetPtr newlocset = NULL;
xmlLocationSetPtr oldlocset;
xmlNodeSetPtr oldset;
int i, j;
if (op->ch1 != -1)
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
if (op->ch2 == -1)
return (total);
if (ctxt->value->type == XPATH_LOCATIONSET) {
/*
* Extract the old locset, and then evaluate the result of the
* expression for all the element in the locset. use it to grow
* up a new locset.
*/
CHECK_TYPE0(XPATH_LOCATIONSET);
obj = valuePop(ctxt);
oldlocset = obj->user;
if ((oldlocset == NULL) || (oldlocset->locNr == 0)) {
ctxt->context->node = NULL;
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
total += xmlXPathCompOpEval(ctxt,&comp->steps[op->ch2]);
res = valuePop(ctxt);
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
valuePush(ctxt, obj);
CHECK_ERROR0;
return (total);
}
newlocset = xmlXPtrLocationSetCreate(NULL);
for (i = 0; i < oldlocset->locNr; i++) {
/*
* Run the evaluation with a node list made of a
* single item in the nodelocset.
*/
ctxt->context->node = oldlocset->locTab[i]->user;
ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1;
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPathFreeObject(obj);
return(0);
}
res = valuePop(ctxt);
if (res->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr rloc =
(xmlLocationSetPtr)res->user;
for (j=0; j<rloc->locNr; j++) {
range = xmlXPtrNewRange(
oldlocset->locTab[i]->user,
oldlocset->locTab[i]->index,
rloc->locTab[j]->user2,
rloc->locTab[j]->index2);
if (range != NULL) {
xmlXPtrLocationSetAdd(newlocset, range);
}
}
} else {
range = xmlXPtrNewRangeNodeObject(
(xmlNodePtr)oldlocset->locTab[i]->user, res);
if (range != NULL) {
xmlXPtrLocationSetAdd(newlocset,range);
}
}
/*
* Cleanup
*/
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
if (ctxt->value == tmp) {
res = valuePop(ctxt);
xmlXPathReleaseObject(ctxt->context, res);
}
ctxt->context->node = NULL;
}
} else { /* Not a location set */
CHECK_TYPE0(XPATH_NODESET);
obj = valuePop(ctxt);
oldset = obj->nodesetval;
ctxt->context->node = NULL;
newlocset = xmlXPtrLocationSetCreate(NULL);
if (oldset != NULL) {
for (i = 0; i < oldset->nodeNr; i++) {
/*
* Run the evaluation with a node list made of a single item
* in the nodeset.
*/
ctxt->context->node = oldset->nodeTab[i];
/*
* OPTIMIZE TODO: Avoid recreation for every iteration.
*/
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
&comp->steps[op->ch2]);
if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPathFreeObject(obj);
return(0);
}
res = valuePop(ctxt);
range =
xmlXPtrNewRangeNodeObject(oldset->nodeTab[i],
res);
if (range != NULL) {
xmlXPtrLocationSetAdd(newlocset, range);
}
/*
* Cleanup
*/
if (res != NULL) {
xmlXPathReleaseObject(ctxt->context, res);
}
if (ctxt->value == tmp) {
res = valuePop(ctxt);
xmlXPathReleaseObject(ctxt->context, res);
}
ctxt->context->node = NULL;
}
}
}
/*
* The result is used as the new evaluation set.
*/
xmlXPathReleaseObject(ctxt->context, obj);
ctxt->context->node = NULL;
ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1;
valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
return (total);
}
#endif /* LIBXML_XPTR_ENABLED */
}
| 1 |
LuaJIT | e296f56b825c688c3530a981dc6b495d972f3d01 | NOT_APPLICABLE | NOT_APPLICABLE | static void trace_unpatch(jit_State *J, GCtrace *T)
{
BCOp op = bc_op(T->startins);
BCIns *pc = mref(T->startpc, BCIns);
UNUSED(J);
if (op == BC_JMP)
return; /* No need to unpatch branches in parent traces (yet). */
switch (bc_op(*pc)) {
case BC_JFORL:
lua_assert(traceref(J, bc_d(*pc)) == T);
*pc = T->startins;
pc += bc_j(T->startins);
lua_assert(bc_op(*pc) == BC_JFORI);
setbc_op(pc, BC_FORI);
break;
case BC_JITERL:
case BC_JLOOP:
lua_assert(op == BC_ITERL || op == BC_LOOP || bc_isret(op));
*pc = T->startins;
break;
case BC_JMP:
lua_assert(op == BC_ITERL);
pc += bc_j(*pc)+2;
if (bc_op(*pc) == BC_JITERL) {
lua_assert(traceref(J, bc_d(*pc)) == T);
*pc = T->startins;
}
break;
case BC_JFUNCF:
lua_assert(op == BC_FUNCF);
*pc = T->startins;
break;
default: /* Already unpatched. */
break;
}
} | 0 |
linux | abd39c6ded9db53aa44c2540092bdd5fb6590fa8 | NOT_APPLICABLE | NOT_APPLICABLE | static void rsi_mac80211_stop(struct ieee80211_hw *hw)
{
struct rsi_hw *adapter = hw->priv;
struct rsi_common *common = adapter->priv;
rsi_dbg(ERR_ZONE, "===> Interface DOWN <===\n");
mutex_lock(&common->mutex);
common->iface_down = true;
wiphy_rfkill_stop_polling(hw->wiphy);
/* Block all rx frames */
rsi_send_rx_filter_frame(common, 0xffff);
mutex_unlock(&common->mutex);
} | 0 |
LuaJIT | 53f82e6e2e858a0a62fd1a2ff47e9866693382e6 | NOT_APPLICABLE | NOT_APPLICABLE | static ptrdiff_t finderrfunc(lua_State *L)
{
cTValue *frame = L->base-1, *bot = tvref(L->stack);
void *cf = L->cframe;
while (frame > bot && cf) {
while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */
if (frame >= restorestack(L, -cframe_nres(cf)))
break;
if (cframe_errfunc(cf) >= 0) /* Error handler not inherited (-1)? */
return cframe_errfunc(cf);
cf = cframe_prev(cf); /* Else unwind cframe and continue searching. */
if (cf == NULL)
return 0;
}
switch (frame_typep(frame)) {
case FRAME_LUA:
case FRAME_LUAP:
frame = frame_prevl(frame);
break;
case FRAME_C:
cf = cframe_prev(cf);
/* fallthrough */
case FRAME_VARG:
frame = frame_prevd(frame);
break;
case FRAME_CONT:
#if LJ_HASFFI
if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK)
cf = cframe_prev(cf);
#endif
frame = frame_prevd(frame);
break;
case FRAME_CP:
if (cframe_canyield(cf)) return 0;
if (cframe_errfunc(cf) >= 0)
return cframe_errfunc(cf);
cf = cframe_prev(cf);
frame = frame_prevd(frame);
break;
case FRAME_PCALL:
case FRAME_PCALLH:
if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue))) /* xpcall? */
return savestack(L, frame-1); /* Point to xpcall's errorfunc. */
return 0;
default:
lua_assert(0);
return 0;
}
}
return 0;
} | 0 |
Chrome | 7f0126ff011142c8619b10a6e64d04d1745c503a | CVE-2012-5157 | CWE-119 | void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& result, Element* element, Namespaces* namespaces)
{
if (!element->isFrameOwnerElement())
return;
HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(element);
Frame* frame = frameOwner->contentFrame();
if (!frame)
return;
KURL url = frame->document()->url();
if (url.isValid() && !url.isBlankURL())
return;
url = m_serializer->urlForBlankFrame(frame);
appendAttribute(result, element, Attribute(frameOwnerURLAttributeName(*frameOwner), url.string()), namespaces);
}
| 1 |
linux | ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5 | NOT_APPLICABLE | NOT_APPLICABLE | static void loop_reread_partitions(struct loop_device *lo,
struct block_device *bdev)
{
int rc;
/*
* bd_mutex has been held already in release path, so don't
* acquire it if this function is called in such case.
*
* If the reread partition isn't from release path, lo_refcnt
* must be at least one and it can only become zero when the
* current holder is released.
*/
if (!atomic_read(&lo->lo_refcnt))
rc = __blkdev_reread_part(bdev);
else
rc = blkdev_reread_part(bdev);
if (rc)
pr_warn("%s: partition scan of loop%d (%s) failed (rc=%d)\n",
__func__, lo->lo_number, lo->lo_file_name, rc);
}
| 0 |
libvncserver | 3fd03977c9b35800d73a865f167338cb4d05b0c1 | NOT_APPLICABLE | NOT_APPLICABLE | ConnectClientToUnixSock(const char *sockFile)
{
#ifdef WIN32
rfbClientErr("Windows doesn't support UNIX sockets\n");
return -1;
#else
int sock;
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
if(strlen(sockFile) + 1 > sizeof(addr.sun_path)) {
rfbClientErr("ConnectToUnixSock: socket file name too long\n");
return -1;
}
strcpy(addr.sun_path, sockFile);
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
rfbClientErr("ConnectToUnixSock: socket (%s)\n",strerror(errno));
return -1;
}
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path)) < 0) {
rfbClientErr("ConnectToUnixSock: connect\n");
close(sock);
return -1;
}
return sock;
#endif
} | 0 |
linux | a2b9e6c1a35afcc0973acb72e591c714e78885ff | NOT_APPLICABLE | NOT_APPLICABLE | static void kvm_vcpu_ioctl_x86_get_debugregs(struct kvm_vcpu *vcpu,
struct kvm_debugregs *dbgregs)
{
unsigned long val;
memcpy(dbgregs->db, vcpu->arch.db, sizeof(vcpu->arch.db));
_kvm_get_dr(vcpu, 6, &val);
dbgregs->dr6 = val;
dbgregs->dr7 = vcpu->arch.dr7;
dbgregs->flags = 0;
memset(&dbgregs->reserved, 0, sizeof(dbgregs->reserved));
}
| 0 |
proxygen | 52cf331743ebd74194d6343a6c2ec52bb917c982 | NOT_APPLICABLE | NOT_APPLICABLE | TEST_F(HTTP2CodecTest, TrailersReplyWithPseudoHeaders) {
SetUpUpstreamTest();
HTTPMessage resp;
resp.setStatusCode(200);
resp.setStatusMessage("nifty-nice");
resp.getHeaders().add(HTTP_HEADER_CONTENT_TYPE, "x-coolio");
downstreamCodec_.generateHeader(output_, 1, resp);
string data("abcde");
auto buf = folly::IOBuf::copyBuffer(data.data(), data.length());
downstreamCodec_.generateBody(
output_, 1, std::move(buf), HTTPCodec::NoPadding, false);
HPACKCodec headerCodec(TransportDirection::DOWNSTREAM);
std::string post("POST");
std::vector<proxygen::compress::Header> trailers = {
Header::makeHeaderForTest(headers::kMethod, post)};
auto encodedTrailers = headerCodec.encode(trailers);
http2::writeHeaders(output_,
std::move(encodedTrailers),
1,
folly::none,
http2::kNoPadding,
true,
true);
parseUpstream();
EXPECT_EQ(callbacks_.messageBegin, 1);
EXPECT_EQ(callbacks_.headersComplete, 1);
EXPECT_EQ(callbacks_.trailers, 0);
EXPECT_EQ(nullptr, callbacks_.msg->getTrailers());
EXPECT_EQ(callbacks_.streamErrors, 1);
EXPECT_EQ(callbacks_.sessionErrors, 0);
} | 0 |
Chrome | 31b81d4cf8b6a063391839816c82fc61c8272e53 | NOT_APPLICABLE | NOT_APPLICABLE | base::string16 GetEnterUnifiedModeMessage() {
return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
}
| 0 |
linux | 34b2cef20f19c87999fff3da4071e66937db9644 | CVE-2017-5970 | CWE-476 | void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
{
struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
ipv6_sk_rxinfo(sk);
if (prepare && skb_rtable(skb)) {
/* skb->cb is overloaded: prior to this point it is IP{6}CB
* which has interface index (iif) as the first member of the
* underlying inet{6}_skb_parm struct. This code then overlays
* PKTINFO_SKB_CB and in_pktinfo also has iif as the first
* element so the iif is picked up from the prior IPCB. If iif
* is the loopback interface, then return the sending interface
* (e.g., process binds socket to eth0 for Tx which is
* redirected to loopback in the rtable/dst).
*/
if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
pktinfo->ipi_ifindex = inet_iif(skb);
pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
} else {
pktinfo->ipi_ifindex = 0;
pktinfo->ipi_spec_dst.s_addr = 0;
}
skb_dst_drop(skb);
}
| 1 |
hexchat | 15600f405f2d5bda6ccf0dd73957395716e0d4d3 | CVE-2016-2087 | CWE-22 | scrollback_get_filename (session *sess)
{
char *net, *chan, *buf, *ret = NULL;
net = server_get_network (sess->server, FALSE);
if (!net)
return NULL;
buf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "scrollback" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.txt", get_xdir (), net, "");
mkdir_p (buf);
g_free (buf);
chan = log_create_filename (sess->channel);
if (chan[0])
buf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "scrollback" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.txt", get_xdir (), net, chan);
else
buf = NULL;
g_free (chan);
if (buf)
{
ret = g_filename_from_utf8 (buf, -1, NULL, NULL, NULL);
g_free (buf);
}
return ret;
} | 1 |
linux | 01310bb7c9c98752cc763b36532fab028e0f8f81 | NOT_APPLICABLE | NOT_APPLICABLE | is_create_with_attrs(struct nfsd4_open *open)
{
return open->op_create == NFS4_OPEN_CREATE
&& (open->op_createmode == NFS4_CREATE_UNCHECKED
|| open->op_createmode == NFS4_CREATE_GUARDED
|| open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1);
} | 0 |
Chrome | 9965adea952e84c925de418e971b204dfda7d6e0 | NOT_APPLICABLE | NOT_APPLICABLE | MockNetworkTransaction::~MockNetworkTransaction() {}
| 0 |
poppler | b224e2f5739fe61de9fa69955d016725b2a4b78d | NOT_APPLICABLE | NOT_APPLICABLE | void SplashOutputDev::clearPatternOpacity(GfxState *state) {
splash->clearPatternAlpha();
} | 0 |
linux | 9d2231c5d74e13b2a0546fee6737ee4446017903 | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t pipe_get_pages(struct iov_iter *i,
struct page **pages, size_t maxsize, unsigned maxpages,
size_t *start)
{
unsigned int iter_head, npages;
size_t capacity;
if (!sanity(i))
return -EFAULT;
data_start(i, &iter_head, start);
/* Amount of free space: some of this one + all after this one */
npages = pipe_space_for_user(iter_head, i->pipe->tail, i->pipe);
capacity = min(npages, maxpages) * PAGE_SIZE - *start;
return __pipe_get_pages(i, min(maxsize, capacity), pages, iter_head, start);
} | 0 |
openssl | c5b831f21d0d29d1e517d139d9d101763f60c9a2 | NOT_APPLICABLE | NOT_APPLICABLE | int ssl3_pending(const SSL *s)
{
if (s->rstate == SSL_ST_READ_BODY)
return 0;
return (s->s3->rrec.type ==
SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
}
| 0 |
linux | 864745d291b5ba80ea0bd0edcbe67273de368836 | NOT_APPLICABLE | NOT_APPLICABLE | static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
struct xfrm_algo_desc *(*get_byname)(const char *, int),
struct nlattr *rta)
{
struct xfrm_algo *p, *ualg;
struct xfrm_algo_desc *algo;
if (!rta)
return 0;
ualg = nla_data(rta);
algo = get_byname(ualg->alg_name, 1);
if (!algo)
return -ENOSYS;
*props = algo->desc.sadb_alg_id;
p = kmemdup(ualg, xfrm_alg_len(ualg), GFP_KERNEL);
if (!p)
return -ENOMEM;
strcpy(p->alg_name, algo->name);
*algpp = p;
return 0;
}
| 0 |
ImageMagick | d4fc44b58a14f76b1ac997517d742ee12c9dc5d3 | NOT_APPLICABLE | NOT_APPLICABLE | MagickExport MagickBooleanType ClutImage(Image *image,const Image *clut_image,
const PixelInterpolateMethod method,ExceptionInfo *exception)
{
#define ClutImageTag "Clut/Image"
CacheView
*clut_view,
*image_view;
MagickBooleanType
status;
MagickOffsetType
progress;
PixelInfo
*clut_map;
register ssize_t
i;
ssize_t adjust,
y;
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(clut_image != (Image *) NULL);
assert(clut_image->signature == MagickCoreSignature);
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
return(MagickFalse);
if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
(IsGrayColorspace(clut_image->colorspace) == MagickFalse))
(void) SetImageColorspace(image,sRGBColorspace,exception);
clut_map=(PixelInfo *) AcquireQuantumMemory(MaxMap+1UL,sizeof(*clut_map));
if (clut_map == (PixelInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
/*
Clut image.
*/
status=MagickTrue;
progress=0;
adjust=(ssize_t) (clut_image->interpolate == IntegerInterpolatePixel ? 0 : 1);
clut_view=AcquireVirtualCacheView(clut_image,exception);
for (i=0; i <= (ssize_t) MaxMap; i++)
{
GetPixelInfo(clut_image,clut_map+i);
status=InterpolatePixelInfo(clut_image,clut_view,method,
(double) i*(clut_image->columns-adjust)/MaxMap,(double) i*
(clut_image->rows-adjust)/MaxMap,clut_map+i,exception);
if (status == MagickFalse)
break;
}
clut_view=DestroyCacheView(clut_view);
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,image,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
PixelInfo
pixel;
register Quantum
*magick_restrict q;
register ssize_t
x;
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
GetPixelInfo(image,&pixel);
for (x=0; x < (ssize_t) image->columns; x++)
{
PixelTrait
traits;
GetPixelInfoPixel(image,q,&pixel);
traits=GetPixelChannelTraits(image,RedPixelChannel);
if ((traits & UpdatePixelTrait) != 0)
pixel.red=clut_map[ScaleQuantumToMap(ClampToQuantum(
pixel.red))].red;
traits=GetPixelChannelTraits(image,GreenPixelChannel);
if ((traits & UpdatePixelTrait) != 0)
pixel.green=clut_map[ScaleQuantumToMap(ClampToQuantum(
pixel.green))].green;
traits=GetPixelChannelTraits(image,BluePixelChannel);
if ((traits & UpdatePixelTrait) != 0)
pixel.blue=clut_map[ScaleQuantumToMap(ClampToQuantum(
pixel.blue))].blue;
traits=GetPixelChannelTraits(image,BlackPixelChannel);
if ((traits & UpdatePixelTrait) != 0)
pixel.black=clut_map[ScaleQuantumToMap(ClampToQuantum(
pixel.black))].black;
traits=GetPixelChannelTraits(image,AlphaPixelChannel);
if ((traits & UpdatePixelTrait) != 0)
pixel.alpha=clut_map[ScaleQuantumToMap(ClampToQuantum(
pixel.alpha))].alpha;
SetPixelViaPixelInfo(image,&pixel,q);
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,ClutImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
image_view=DestroyCacheView(image_view);
clut_map=(PixelInfo *) RelinquishMagickMemory(clut_map);
if ((clut_image->alpha_trait != UndefinedPixelTrait) &&
((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0))
(void) SetImageAlphaChannel(image,ActivateAlphaChannel,exception);
return(status);
}
| 0 |
linux | 050fad7c4534c13c8eb1d9c2ba66012e014773cb | NOT_APPLICABLE | NOT_APPLICABLE | void bpf_warn_invalid_xdp_action(u32 act)
{
const u32 act_max = XDP_REDIRECT;
WARN_ONCE(1, "%s XDP return value %u, expect packet loss!\n",
act > act_max ? "Illegal" : "Driver unsupported",
act);
} | 0 |
Chrome | fbeba958bb83c05ec8cc54e285a4a9ca10d1b311 | CVE-2018-6178 | CWE-254 | ConfirmInfoBar::ConfirmInfoBar(std::unique_ptr<ConfirmInfoBarDelegate> delegate)
: InfoBarView(std::move(delegate)) {
auto* delegate_ptr = GetDelegate();
label_ = CreateLabel(delegate_ptr->GetMessageText());
AddChildView(label_);
const auto buttons = delegate_ptr->GetButtons();
if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) {
ok_button_ = CreateButton(ConfirmInfoBarDelegate::BUTTON_OK);
ok_button_->SetProminent(true);
if (delegate_ptr->OKButtonTriggersUACPrompt()) {
elevation_icon_setter_.reset(new ElevationIconSetter(
ok_button_,
base::BindOnce(&ConfirmInfoBar::Layout, base::Unretained(this))));
}
}
if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) {
cancel_button_ = CreateButton(ConfirmInfoBarDelegate::BUTTON_CANCEL);
if (buttons == ConfirmInfoBarDelegate::BUTTON_CANCEL)
cancel_button_->SetProminent(true);
}
link_ = CreateLink(delegate_ptr->GetLinkText(), this);
AddChildView(link_);
}
| 1 |
Chrome | 8ae91350332f188ef711228aa61b7809b74aa3a7 | NOT_APPLICABLE | NOT_APPLICABLE | virtual void GotFocus() {}
| 0 |
open-vm-tools | 70a74758bfe0042c27f15ce590fb21a2bc54d745 | NOT_APPLICABLE | NOT_APPLICABLE | Proto_EndElement(GMarkupParseContext *parseContext,
const gchar *elementName,
gpointer userData,
GError **error)
{
ProtoRequest *req = (ProtoRequest *) userData;
#if VGAUTH_PROTO_TRACE
Debug("%s: elementName '%s'\n", __FUNCTION__, elementName);
#endif
switch (req->parseState) {
case PARSE_STATE_SEQNO:
case PARSE_STATE_REQNAME:
case PARSE_STATE_VERSION:
case PARSE_STATE_USERNAME:
case PARSE_STATE_ADDLINK:
case PARSE_STATE_TICKET:
case PARSE_STATE_PID:
case PARSE_STATE_TOKEN:
case PARSE_STATE_SAMLTOKEN:
case PARSE_STATE_SAML_VALIDATE_ONLY:
case PARSE_STATE_USERHANDLEINFO:
req->parseState = PARSE_STATE_REQUEST;
break;
case PARSE_STATE_ALIASINFO:
if (req->reqType == PROTO_REQUEST_ADDALIAS) {
req->parseState = PARSE_STATE_REQUEST;
} else if (req->reqType == PROTO_REQUEST_CREATETICKET) {
req->parseState = PARSE_STATE_USERHANDLESAMLINFO;
} else {
g_set_error(error, G_MARKUP_ERROR_PARSE, VGAUTH_E_INVALID_ARGUMENT,
"Bad parse state, popping aliasInfo in req type %d",
req->reqType);
}
break;
case PARSE_STATE_REQUEST:
req->complete = TRUE;
req->parseState = PARSE_STATE_NONE;
break;
case PARSE_STATE_PEMCERT:
if (req->reqType == PROTO_REQUEST_ADDALIAS) {
req->parseState = PARSE_STATE_REQUEST;
} else if (req->reqType == PROTO_REQUEST_REMOVEALIAS) {
req->parseState = PARSE_STATE_REQUEST;
} else {
g_set_error(error, G_MARKUP_ERROR_PARSE, VGAUTH_E_INVALID_ARGUMENT,
"Bad parse state, popping pemCert in req type %d",
req->reqType);
}
break;
case PARSE_STATE_COMMENT:
req->parseState = PARSE_STATE_ALIASINFO;
break;
case PARSE_STATE_SUBJECT:
case PARSE_STATE_ANYSUBJECT:
if (req->reqType == PROTO_REQUEST_ADDALIAS) {
req->parseState = PARSE_STATE_ALIASINFO;
} else if (req->reqType == PROTO_REQUEST_REMOVEALIAS) {
req->parseState = PARSE_STATE_REQUEST;
} else if (req->reqType == PROTO_REQUEST_CREATETICKET) {
req->parseState = PARSE_STATE_ALIASINFO;
} else {
g_set_error(error, G_MARKUP_ERROR_PARSE, VGAUTH_E_INVALID_ARGUMENT,
"Bad parse state, popping (any)subject state %d",
req->parseState);
}
break;
case PARSE_STATE_USERHANDLESAMLINFO:
case PARSE_STATE_USERHANDLETYPE:
req->parseState = PARSE_STATE_USERHANDLEINFO;
break;
case PARSE_STATE_USERHANDLESAMLSUBJECT:
req->parseState = PARSE_STATE_USERHANDLESAMLINFO;
break;
default:
g_set_error(error, G_MARKUP_ERROR_PARSE, VGAUTH_E_INVALID_ARGUMENT,
"Bad parse state, popping unknown parse state %d",
req->parseState);
ASSERT(0);
}
} | 0 |
faad2 | 942c3e0aee748ea6fe97cb2c1aa5893225316174 | NOT_APPLICABLE | NOT_APPLICABLE | void DRM_aac_scalable_main_element(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
{
uint8_t retval = 0;
uint8_t channels = hDecoder->fr_channels = 0;
uint8_t ch;
uint8_t this_layer_stereo = (hDecoder->channelConfiguration > 1) ? 1 : 0;
element cpe = {0};
ic_stream *ics1 = &(cpe.ics1);
ic_stream *ics2 = &(cpe.ics2);
int16_t *spec_data;
ALIGN int16_t spec_data1[1024] = {0};
ALIGN int16_t spec_data2[1024] = {0};
hDecoder->fr_ch_ele = 0;
hInfo->error = DRM_aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo);
if (hInfo->error > 0)
return;
cpe.common_window = 1;
if (this_layer_stereo)
{
hDecoder->element_id[0] = ID_CPE;
if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2;
} else {
hDecoder->element_id[0] = ID_SCE;
}
if (this_layer_stereo)
{
cpe.channel = 0;
cpe.paired_channel = 1;
}
/* Stereo2 / Mono1 */
ics1->tns_data_present = faad_get1bit(ld);
#if defined(LTP_DEC)
ics1->ltp.data_present = faad_get1bit(ld);
#elif defined (DRM)
if(faad_get1bit(ld)) {
hInfo->error = 26;
return;
}
#else
faad_get1bit(ld);
#endif
hInfo->error = side_info(hDecoder, &cpe, ld, ics1, 1);
if (hInfo->error > 0)
return;
if (this_layer_stereo)
{
/* Stereo3 */
ics2->tns_data_present = faad_get1bit(ld);
#ifdef LTP_DEC
ics1->ltp.data_present =
#endif
faad_get1bit(ld);
hInfo->error = side_info(hDecoder, &cpe, ld, ics2, 1);
if (hInfo->error > 0)
return;
}
/* Stereo4 / Mono2 */
if (ics1->tns_data_present)
tns_data(ics1, &(ics1->tns), ld);
if (this_layer_stereo)
{
/* Stereo5 */
if (ics2->tns_data_present)
tns_data(ics2, &(ics2->tns), ld);
}
#ifdef DRM
/* CRC check */
if (hDecoder->object_type == DRM_ER_LC)
{
if ((hInfo->error = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0)
return;
}
#endif
/* Stereo6 / Mono3 */
/* error resilient spectral data decoding */
if ((hInfo->error = reordered_spectral_data(hDecoder, ics1, ld, spec_data1)) > 0)
{
return;
}
if (this_layer_stereo)
{
/* Stereo7 */
/* error resilient spectral data decoding */
if ((hInfo->error = reordered_spectral_data(hDecoder, ics2, ld, spec_data2)) > 0)
{
return;
}
}
#ifdef DRM
#ifdef SBR_DEC
/* In case of DRM we need to read the SBR info before channel reconstruction */
if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC))
{
bitfile ld_sbr = {0};
uint32_t i;
uint16_t count = 0;
uint8_t *revbuffer;
uint8_t *prevbufstart;
uint8_t *pbufend;
/* all forward bitreading should be finished at this point */
uint32_t bitsconsumed = faad_get_processed_bits(ld);
uint32_t buffer_size = faad_origbitbuffer_size(ld);
uint8_t *buffer = (uint8_t*)faad_origbitbuffer(ld);
if (bitsconsumed + 8 > buffer_size*8)
{
hInfo->error = 14;
return;
}
if (!hDecoder->sbr[0])
{
hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0],
2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1);
}
/* Reverse bit reading of SBR data in DRM audio frame */
revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t));
prevbufstart = revbuffer;
pbufend = &buffer[buffer_size - 1];
for (i = 0; i < buffer_size; i++)
*prevbufstart++ = tabFlipbits[*pbufend--];
/* Set SBR data */
/* consider 8 bits from AAC-CRC */
/* SBR buffer size is original buffer size minus AAC buffer size */
count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed);
faad_initbits(&ld_sbr, revbuffer, count);
hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index);
hDecoder->sbr[0]->sample_rate *= 2;
faad_getbits(&ld_sbr, 8); /* Skip 8-bit CRC */
hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count, hDecoder->postSeekResetFlag);
#if (defined(PS_DEC) || defined(DRM_PS))
if (hDecoder->sbr[0]->ps_used)
{
hDecoder->ps_used[0] = 1;
hDecoder->ps_used_global = 1;
}
#endif
if (ld_sbr.error)
{
hDecoder->sbr[0]->ret = 1;
}
/* check CRC */
/* no need to check it if there was already an error */
if (hDecoder->sbr[0]->ret == 0)
hDecoder->sbr[0]->ret = (uint8_t)faad_check_CRC(&ld_sbr, (uint16_t)faad_get_processed_bits(&ld_sbr) - 8);
/* SBR data was corrupted, disable it until the next header */
if (hDecoder->sbr[0]->ret != 0)
{
hDecoder->sbr[0]->header_count = 0;
}
faad_endbits(&ld_sbr);
if (revbuffer)
faad_free(revbuffer);
}
#endif
#endif
if (this_layer_stereo)
{
hInfo->error = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2);
if (hInfo->error > 0)
return;
} else {
hInfo->error = reconstruct_single_channel(hDecoder, ics1, &cpe, spec_data1);
if (hInfo->error > 0)
return;
}
/* map output channels position to internal data channels */
if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2)
{
/* this might be faulty when pce_set is true */
hDecoder->internal_channel[channels] = channels;
hDecoder->internal_channel[channels+1] = channels+1;
} else {
hDecoder->internal_channel[channels] = channels;
}
hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele];
hDecoder->fr_ch_ele++;
return;
}
| 0 |
curl | 6efd2fa529a189bf41736a610f6184cd8ad94b4d | NOT_APPLICABLE | NOT_APPLICABLE | int Curl_mbedtls_data_pending(const struct connectdata *conn, int sockindex)
{
mbedtls_ssl_context *ssl =
(mbedtls_ssl_context *)&conn->ssl[sockindex].ssl;
return ssl->in_msglen != 0;
} | 0 |
Chrome | f2d26633cbd50735ac2af30436888b71ac0abad3 | NOT_APPLICABLE | NOT_APPLICABLE | PopupItemLayoutType AutofillPopupFooterView::GetLayoutType() const {
return frontend_id() ==
autofill::PopupItemId::POPUP_ITEM_ID_SHOW_ACCOUNT_CARDS
? PopupItemLayoutType::kLeadingIcon
: PopupItemLayoutType::kTrailingIcon;
}
| 0 |
mujs | 5008105780c0b0182ea6eda83ad5598f225be3ee | NOT_APPLICABLE | NOT_APPLICABLE | static void cassignforin(JF, js_Ast *stm)
{
js_Ast *lhs = stm->a;
if (stm->type == STM_FOR_IN_VAR) {
if (lhs->b)
jsC_error(J, lhs->b, "more than one loop variable in for-in statement");
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs->a->a); /* list(var-init(ident)) */
emit(J, F, OP_POP);
return;
}
switch (lhs->type) {
case EXP_IDENTIFIER:
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
emit(J, F, OP_POP);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
emit(J, F, OP_ROT3);
emit(J, F, OP_SETPROP);
emit(J, F, OP_POP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
emit(J, F, OP_ROT2);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
emit(J, F, OP_POP);
break;
default:
jsC_error(J, lhs, "invalid l-value in for-in loop assignment");
}
} | 0 |
linux | 9e3f7a29694049edd728e2400ab57ad7553e5aa9 | NOT_APPLICABLE | NOT_APPLICABLE | void kvm_reset_sys_regs(struct kvm_vcpu *vcpu)
{
size_t num;
const struct sys_reg_desc *table;
/* Catch someone adding a register without putting in reset entry. */
memset(&vcpu->arch.ctxt.sys_regs, 0x42, sizeof(vcpu->arch.ctxt.sys_regs));
/* Generic chip reset first (so target could override). */
reset_sys_reg_descs(vcpu, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
table = get_target_table(vcpu->arch.target, true, &num);
reset_sys_reg_descs(vcpu, table, num);
for (num = 1; num < NR_SYS_REGS; num++)
if (vcpu_sys_reg(vcpu, num) == 0x4242424242424242)
panic("Didn't reset vcpu_sys_reg(%zi)", num);
}
| 0 |
ImageMagick | 4e8c2ed53fcb54a34b3a6185b2584f26cf6874a3 | NOT_APPLICABLE | NOT_APPLICABLE | MagickExport MagickBooleanType WriteStream(const ImageInfo *image_info,
Image *image,StreamHandler stream,ExceptionInfo *exception)
{
ImageInfo
*write_info;
MagickBooleanType
status;
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
write_info=CloneImageInfo(image_info);
*write_info->magick='\0';
write_info->stream=stream;
status=WriteImage(write_info,image,exception);
write_info=DestroyImageInfo(write_info);
return(status);
} | 0 |
qemu | 915976bd98a9286efe6f2e573cb4f1360603adf9 | NOT_APPLICABLE | NOT_APPLICABLE | static void dp8393x_set_next_tick(dp8393xState *s)
{
uint32_t ticks;
int64_t delay;
if (s->regs[SONIC_CR] & SONIC_CR_STP) {
timer_del(s->watchdog);
return;
}
ticks = dp8393x_wt(s);
s->wt_last_update = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
delay = NANOSECONDS_PER_SECOND * ticks / 5000000;
timer_mod(s->watchdog, s->wt_last_update + delay);
} | 0 |
libarchive | 98dcbbf0bf4854bf987557e55e55fff7abbf3ea9 | NOT_APPLICABLE | NOT_APPLICABLE | archive_read_format_lha_read_data_skip(struct archive_read *a)
{
struct lha *lha;
int64_t bytes_skipped;
lha = (struct lha *)(a->format->data);
if (lha->entry_unconsumed) {
/* Consume as much as the decompressor actually used. */
__archive_read_consume(a, lha->entry_unconsumed);
lha->entry_unconsumed = 0;
}
/* if we've already read to end of data, we're done. */
if (lha->end_of_entry_cleanup)
return (ARCHIVE_OK);
/*
* If the length is at the beginning, we can skip the
* compressed data much more quickly.
*/
bytes_skipped = __archive_read_consume(a, lha->entry_bytes_remaining);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
/* This entry is finished and done. */
lha->end_of_entry_cleanup = lha->end_of_entry = 1;
return (ARCHIVE_OK);
}
| 0 |
openjpeg | e5285319229a5d77bf316bb0d3a6cbd3cb8666d9 | NOT_APPLICABLE | NOT_APPLICABLE | int imagetoraw(opj_image_t * image, const char *outfile)
{
return imagetoraw_common(image, outfile, OPJ_TRUE);
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.