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
|
---|---|---|---|---|---|
Chrome | 73edae623529f04c668268de49d00324b96166a2 | NOT_APPLICABLE | NOT_APPLICABLE | AttributeChange(PassRefPtr<Element> element, const QualifiedName& name, const String& value)
: m_element(element), m_name(name), m_value(value)
{
}
| 0 |
systemd | 6d586a13717ae057aa1b4127400c3de61cd5b9e7 | NOT_APPLICABLE | NOT_APPLICABLE | static int bus_socket_inotify_setup(sd_bus *b) {
_cleanup_free_ int *new_watches = NULL;
_cleanup_free_ char *absolute = NULL;
size_t n_allocated = 0, n = 0, done = 0, i;
unsigned max_follow = 32;
const char *p;
int wd, r;
assert(b);
assert(b->watch_bind);
assert(b->sockaddr.sa.sa_family == AF_UNIX);
assert(b->sockaddr.un.sun_path[0] != 0);
/* Sets up an inotify fd in case watch_bind is enabled: wait until the configured AF_UNIX file system socket
* appears before connecting to it. The implemented is pretty simplistic: we just subscribe to relevant changes
* to all prefix components of the path, and every time we get an event for that we try to reconnect again,
* without actually caring what precisely the event we got told us. If we still can't connect we re-subscribe
* to all relevant changes of anything in the path, so that our watches include any possibly newly created path
* components. */
if (b->inotify_fd < 0) {
b->inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
if (b->inotify_fd < 0)
return -errno;
b->inotify_fd = fd_move_above_stdio(b->inotify_fd);
}
/* Make sure the path is NUL terminated */
p = strndupa(b->sockaddr.un.sun_path, sizeof(b->sockaddr.un.sun_path));
/* Make sure the path is absolute */
r = path_make_absolute_cwd(p, &absolute);
if (r < 0)
goto fail;
/* Watch all parent directories, and don't mind any prefix that doesn't exist yet. For the innermost directory
* that exists we want to know when files are created or moved into it. For all parents of it we just care if
* they are removed or renamed. */
if (!GREEDY_REALLOC(new_watches, n_allocated, n + 1)) {
r = -ENOMEM;
goto fail;
}
/* Start with the top-level directory, which is a bit simpler than the rest, since it can't be a symlink, and
* always exists */
wd = inotify_add_watch(b->inotify_fd, "/", IN_CREATE|IN_MOVED_TO);
if (wd < 0) {
r = log_debug_errno(errno, "Failed to add inotify watch on /: %m");
goto fail;
} else
new_watches[n++] = wd;
for (;;) {
_cleanup_free_ char *component = NULL, *prefix = NULL, *destination = NULL;
size_t n_slashes, n_component;
char *c = NULL;
n_slashes = strspn(absolute + done, "/");
n_component = n_slashes + strcspn(absolute + done + n_slashes, "/");
if (n_component == 0) /* The end */
break;
component = strndup(absolute + done, n_component);
if (!component) {
r = -ENOMEM;
goto fail;
}
/* A trailing slash? That's a directory, and not a socket then */
if (path_equal(component, "/")) {
r = -EISDIR;
goto fail;
}
/* A single dot? Let's eat this up */
if (path_equal(component, "/.")) {
done += n_component;
continue;
}
prefix = strndup(absolute, done + n_component);
if (!prefix) {
r = -ENOMEM;
goto fail;
}
if (!GREEDY_REALLOC(new_watches, n_allocated, n + 1)) {
r = -ENOMEM;
goto fail;
}
wd = inotify_add_watch(b->inotify_fd, prefix, IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CREATE|IN_MOVED_TO|IN_DONT_FOLLOW);
log_debug("Added inotify watch for %s on bus %s: %i", prefix, strna(b->description), wd);
if (wd < 0) {
if (IN_SET(errno, ENOENT, ELOOP))
break; /* This component doesn't exist yet, or the path contains a cyclic symlink right now */
r = log_debug_errno(errno, "Failed to add inotify watch on %s: %m", empty_to_root(prefix));
goto fail;
} else
new_watches[n++] = wd;
/* Check if this is possibly a symlink. If so, let's follow it and watch it too. */
r = readlink_malloc(prefix, &destination);
if (r == -EINVAL) { /* not a symlink */
done += n_component;
continue;
}
if (r < 0)
goto fail;
if (isempty(destination)) { /* Empty symlink target? Yuck! */
r = -EINVAL;
goto fail;
}
if (max_follow <= 0) { /* Let's make sure we don't follow symlinks forever */
r = -ELOOP;
goto fail;
}
if (path_is_absolute(destination)) {
/* For absolute symlinks we build the new path and start anew */
c = strjoin(destination, absolute + done + n_component);
done = 0;
} else {
_cleanup_free_ char *t = NULL;
/* For relative symlinks we replace the last component, and try again */
t = strndup(absolute, done);
if (!t)
return -ENOMEM;
c = strjoin(t, "/", destination, absolute + done + n_component);
}
if (!c) {
r = -ENOMEM;
goto fail;
}
free(absolute);
absolute = c;
max_follow--;
}
/* And now, let's remove all watches from the previous iteration we don't need anymore */
for (i = 0; i < b->n_inotify_watches; i++) {
bool found = false;
size_t j;
for (j = 0; j < n; j++)
if (new_watches[j] == b->inotify_watches[i]) {
found = true;
break;
}
if (found)
continue;
(void) inotify_rm_watch(b->inotify_fd, b->inotify_watches[i]);
}
free_and_replace(b->inotify_watches, new_watches);
b->n_inotify_watches = n;
return 0;
fail:
bus_close_inotify_fd(b);
return r;
} | 0 |
curl | 31be461c6b659312100c47be6ddd5f0f569290f6 | NOT_APPLICABLE | NOT_APPLICABLE | static void Curl_printPipeline(struct curl_llist *pipeline)
{
struct curl_llist_element *curr;
curr = pipeline->head;
while(curr) {
struct SessionHandle *data = (struct SessionHandle *) curr->ptr;
infof(data, "Handle in pipeline: %s\n", data->state.path);
curr = curr->next;
}
} | 0 |
linux | b5b515445f4f5a905c5dd27e6e682868ccd6c09d | NOT_APPLICABLE | NOT_APPLICABLE | void pmcraid_return_cmd(struct pmcraid_cmd *cmd)
{
struct pmcraid_instance *pinstance = cmd->drv_inst;
unsigned long lock_flags;
spin_lock_irqsave(&pinstance->free_pool_lock, lock_flags);
list_add_tail(&cmd->free_list, &pinstance->free_cmd_pool);
spin_unlock_irqrestore(&pinstance->free_pool_lock, lock_flags);
}
| 0 |
linux | 9804501fa1228048857910a6bf23e085aade37cc | NOT_APPLICABLE | NOT_APPLICABLE | int __init aarp_proto_init(void)
{
int rc;
aarp_dl = register_snap_client(aarp_snap_id, aarp_rcv);
if (!aarp_dl) {
printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
return -ENOMEM;
}
timer_setup(&aarp_timer, aarp_expire_timeout, 0);
aarp_timer.expires = jiffies + sysctl_aarp_expiry_time;
add_timer(&aarp_timer);
rc = register_netdevice_notifier(&aarp_notifier);
if (rc) {
del_timer_sync(&aarp_timer);
unregister_snap_client(aarp_dl);
}
return rc;
} | 0 |
Chrome | faaa2fd0a05f1622d9a8806da118d4f3b602e707 | NOT_APPLICABLE | NOT_APPLICABLE | void HTMLMediaElement::mediaEngineError(MediaError* err) {
DCHECK_GE(m_readyState, kHaveMetadata);
BLINK_MEDIA_LOG << "mediaEngineError(" << (void*)this << ", "
<< static_cast<int>(err->code()) << ")";
stopPeriodicTimers();
m_loadState = WaitingForSource;
m_error = err;
scheduleEvent(EventTypeNames::error);
setNetworkState(kNetworkIdle);
setShouldDelayLoadEvent(false);
m_currentSourceNode = nullptr;
}
| 0 |
Chrome | 5fb88938e3210391f8c948f127fd96d9c2979119 | NOT_APPLICABLE | NOT_APPLICABLE | ExtensionService::ExtensionRuntimeData::ExtensionRuntimeData()
: background_page_ready(false),
being_upgraded(false) {
}
| 0 |
glib | d8f8f4d637ce43f8699ba94c9b7648beda0ca174 | NOT_APPLICABLE | NOT_APPLICABLE | g_file_read_async (GFile *file,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GFileIface *iface;
g_return_if_fail (G_IS_FILE (file));
iface = G_FILE_GET_IFACE (file);
(* iface->read_async) (file,
io_priority,
cancellable,
callback,
user_data);
} | 0 |
OpenJK | b173ac05993f634a42be3d3535e1b158de0c3372 | NOT_APPLICABLE | NOT_APPLICABLE | int Com_Milliseconds (void) {
sysEvent_t ev;
do {
ev = Com_GetRealEvent();
if ( ev.evType != SE_NONE ) {
Com_PushEvent( &ev );
}
} while ( ev.evType != SE_NONE );
return ev.evTime;
}
| 0 |
ImageMagick6 | 0812674565df667b1b3e4122ad259096de311c6c | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t parse8BIM(Image *ifile, Image *ofile)
{
char
brkused,
quoted,
*line,
*token,
*newstr,
*name;
int
state,
next;
unsigned char
dataset;
unsigned int
recnum;
int
inputlen = MaxTextExtent;
MagickOffsetType
savedpos,
currentpos;
ssize_t
savedolen = 0L,
outputlen = 0L;
TokenInfo
*token_info;
dataset = 0;
recnum = 0;
line = (char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*line));
if (line == (char *) NULL)
return(-1);
newstr = name = token = (char *) NULL;
savedpos = 0;
token_info=AcquireTokenInfo();
while (super_fgets(&line,&inputlen,ifile)!=NULL)
{
state=0;
next=0;
token=(char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*token));
if (token == (char *) NULL)
break;
newstr=(char *) AcquireQuantumMemory((size_t) inputlen,sizeof(*newstr));
if (newstr == (char *) NULL)
break;
while (Tokenizer(token_info,0,token,(size_t) inputlen,line,"","=","\"",0,
&brkused,&next,"ed)==0)
{
if (state == 0)
{
int
state,
next;
char
brkused,
quoted;
state=0;
next=0;
while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,"","#",
"", 0,&brkused,&next,"ed)==0)
{
switch (state)
{
case 0:
if (strcmp(newstr,"8BIM")==0)
dataset = 255;
else
dataset = (unsigned char) StringToLong(newstr);
break;
case 1:
recnum = (unsigned int) StringToUnsignedLong(newstr);
break;
case 2:
name=(char *) AcquireQuantumMemory(strlen(newstr)+MaxTextExtent,
sizeof(*name));
if (name)
(void) strcpy(name,newstr);
break;
}
state++;
}
}
else
if (state == 1)
{
int
next;
ssize_t
len;
char
brkused,
quoted;
next=0;
len = (ssize_t) strlen(token);
while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,"","&",
"",0,&brkused,&next,"ed)==0)
{
if (brkused && next > 0)
{
size_t
codes_length;
char
*s = &token[next-1];
codes_length=convertHTMLcodes(s, strlen(s));
if ((ssize_t) codes_length > len)
len=0;
else
len-=codes_length;
}
}
if (dataset == 255)
{
unsigned char
nlen = 0;
int
i;
if (savedolen > 0)
{
MagickOffsetType
offset;
ssize_t diff = outputlen - savedolen;
currentpos = TellBlob(ofile);
if (currentpos < 0)
{
line=DestroyString(line);
return(-1);
}
offset=SeekBlob(ofile,savedpos,SEEK_SET);
if (offset < 0)
{
line=DestroyString(line);
return(-1);
}
(void) WriteBlobMSBLong(ofile,(unsigned int) diff);
offset=SeekBlob(ofile,currentpos,SEEK_SET);
if (offset < 0)
{
line=DestroyString(line);
return(-1);
}
savedolen = 0L;
}
if (outputlen & 1)
{
(void) WriteBlobByte(ofile,0x00);
outputlen++;
}
(void) WriteBlobString(ofile,"8BIM");
(void) WriteBlobMSBShort(ofile,(unsigned short) recnum);
outputlen += 6;
if (name)
nlen = (unsigned char) strlen(name);
(void) WriteBlobByte(ofile,nlen);
outputlen++;
for (i=0; i<nlen; i++)
(void) WriteBlobByte(ofile,(unsigned char) name[i]);
outputlen += nlen;
if ((nlen & 0x01) == 0)
{
(void) WriteBlobByte(ofile,0x00);
outputlen++;
}
if (recnum != IPTC_ID)
{
(void) WriteBlobMSBLong(ofile, (unsigned int) len);
outputlen += 4;
next=0;
outputlen += len;
while (len-- > 0)
(void) WriteBlobByte(ofile,(unsigned char) token[next++]);
if (outputlen & 1)
{
(void) WriteBlobByte(ofile,0x00);
outputlen++;
}
}
else
{
/* patch in a fake length for now and fix it later */
savedpos = TellBlob(ofile);
if (savedpos < 0)
return(-1);
(void) WriteBlobMSBLong(ofile,0xFFFFFFFFU);
outputlen += 4;
savedolen = outputlen;
}
}
else
{
if (len <= 0x7FFF)
{
(void) WriteBlobByte(ofile,0x1c);
(void) WriteBlobByte(ofile,(unsigned char) dataset);
(void) WriteBlobByte(ofile,(unsigned char) (recnum & 0xff));
(void) WriteBlobMSBShort(ofile,(unsigned short) len);
outputlen += 5;
next=0;
outputlen += len;
while (len-- > 0)
(void) WriteBlobByte(ofile,(unsigned char) token[next++]);
}
}
}
state++;
}
if (token != (char *) NULL)
token=DestroyString(token);
if (newstr != (char *) NULL)
newstr=DestroyString(newstr);
if (name != (char *) NULL)
name=DestroyString(name);
}
token_info=DestroyTokenInfo(token_info);
if (token != (char *) NULL)
token=DestroyString(token);
if (newstr != (char *) NULL)
newstr=DestroyString(newstr);
if (name != (char *) NULL)
name=DestroyString(name);
line=DestroyString(line);
if (savedolen > 0)
{
MagickOffsetType
offset;
ssize_t diff = outputlen - savedolen;
currentpos = TellBlob(ofile);
if (currentpos < 0)
return(-1);
offset=SeekBlob(ofile,savedpos,SEEK_SET);
if (offset < 0)
return(-1);
(void) WriteBlobMSBLong(ofile,(unsigned int) diff);
offset=SeekBlob(ofile,currentpos,SEEK_SET);
if (offset < 0)
return(-1);
savedolen = 0L;
}
return(outputlen);
} | 0 |
suricata | d8634daf74c882356659addb65fb142b738a186b | NOT_APPLICABLE | NOT_APPLICABLE | static DetectTransaction GetDetectTx(const uint8_t ipproto, const AppProto alproto,
void *alstate, const uint64_t tx_id, void *tx_ptr, const int tx_end_state,
const uint8_t flow_flags)
{
const uint64_t detect_flags = AppLayerParserGetTxDetectFlags(ipproto, alproto, tx_ptr, flow_flags);
if (detect_flags & APP_LAYER_TX_INSPECTED_FLAG) {
SCLogDebug("%"PRIu64" tx already fully inspected for %s. Flags %016"PRIx64,
tx_id, flow_flags & STREAM_TOSERVER ? "toserver" : "toclient",
detect_flags);
DetectTransaction no_tx = { NULL, 0, NULL, 0, 0, 0, 0, 0, };
return no_tx;
}
const int tx_progress = AppLayerParserGetStateProgress(ipproto, alproto, tx_ptr, flow_flags);
const int dir_int = (flow_flags & STREAM_TOSERVER) ? 0 : 1;
DetectEngineState *tx_de_state = AppLayerParserGetTxDetectState(ipproto, alproto, tx_ptr);
DetectEngineStateDirection *tx_dir_state = tx_de_state ? &tx_de_state->dir_state[dir_int] : NULL;
uint64_t prefilter_flags = detect_flags & APP_LAYER_TX_PREFILTER_MASK;
DetectTransaction tx = {
.tx_ptr = tx_ptr,
.tx_id = tx_id,
.de_state = tx_dir_state,
.detect_flags = detect_flags,
.prefilter_flags = prefilter_flags,
.prefilter_flags_orig = prefilter_flags,
.tx_progress = tx_progress,
.tx_end_state = tx_end_state,
};
return tx;
}
| 0 |
exempi | c26d5beb60a5a85f76259f50ed3e08c8169b0a0c | NOT_APPLICABLE | NOT_APPLICABLE | XmpPtr xmp_new_empty()
{
RESET_ERROR;
SXMPMeta *txmp = new SXMPMeta;
return (XmpPtr)txmp;
}
| 0 |
tcpdump | 6f5ba2b651cd9d4b7fa8ee5c4f94460645877c45 | NOT_APPLICABLE | NOT_APPLICABLE | name_ptr(netdissect_options *ndo,
const u_char *buf, int ofs, const u_char *maxbuf)
{
const u_char *p;
u_char c;
p = buf + ofs;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
ND_TCHECK2(*p, 1);
c = *p;
/* XXX - this should use the same code that the DNS dissector does */
if ((c & 0xC0) == 0xC0) {
uint16_t l;
ND_TCHECK2(*p, 2);
if ((p + 1) >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
l = EXTRACT_16BITS(p) & 0x3FFF;
if (l == 0) {
/* We have a pointer that points to itself. */
return(NULL);
}
p = buf + l;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
ND_TCHECK2(*p, 1);
}
return(p);
trunc:
return(NULL); /* name goes past the end of the buffer */
}
| 0 |
librsvg | ecf9267a24b2c3c0cd211dbdfa9ef2232511972a | NOT_APPLICABLE | NOT_APPLICABLE | rsvg_filter_set_atts (RsvgNode *node, gpointer impl, RsvgHandle *handle, RsvgPropertyBag *atts)
{
RsvgFilter *filter = impl;
const char *value;
if ((value = rsvg_property_bag_lookup (atts, "filterUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
filter->filterunits = userSpaceOnUse;
else
filter->filterunits = objectBoundingBox;
}
if ((value = rsvg_property_bag_lookup (atts, "primitiveUnits"))) {
if (!strcmp (value, "objectBoundingBox"))
filter->primitiveunits = objectBoundingBox;
else
filter->primitiveunits = userSpaceOnUse;
}
if ((value = rsvg_property_bag_lookup (atts, "x")))
filter->x = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "y")))
filter->y = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
if ((value = rsvg_property_bag_lookup (atts, "width")))
filter->width = rsvg_length_parse (value, LENGTH_DIR_HORIZONTAL);
if ((value = rsvg_property_bag_lookup (atts, "height")))
filter->height = rsvg_length_parse (value, LENGTH_DIR_VERTICAL);
} | 0 |
php-src | 75f40ae1f3a7ca837d230f099627d121f9b3a32f | NOT_APPLICABLE | NOT_APPLICABLE | static xmlNodePtr to_xml_gmonth(encodeTypePtr type, zval *data, int style, xmlNodePtr parent TSRMLS_DC)
{
return to_xml_datetime_ex(type, data, "--%m--", style, parent TSRMLS_CC);
} | 0 |
linux | 5d81de8e8667da7135d3a32a964087c0faf5483f | NOT_APPLICABLE | NOT_APPLICABLE | cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
bool wait_flag, bool posix_lck, unsigned int xid)
{
int rc = 0;
__u64 length = 1 + flock->fl_end - flock->fl_start;
struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data;
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
struct TCP_Server_Info *server = tcon->ses->server;
__u16 netfid = cfile->fid.netfid;
if (posix_lck) {
int posix_lock_type;
rc = cifs_posix_lock_test(file, flock);
if (!rc)
return rc;
if (type & server->vals->shared_lock_type)
posix_lock_type = CIFS_RDLCK;
else
posix_lock_type = CIFS_WRLCK;
rc = CIFSSMBPosixLock(xid, tcon, netfid, current->tgid,
flock->fl_start, length, flock,
posix_lock_type, wait_flag);
return rc;
}
rc = cifs_lock_test(cfile, flock->fl_start, length, type, flock);
if (!rc)
return rc;
/* BB we could chain these into one lock request BB */
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type,
1, 0, false);
if (rc == 0) {
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
type, 0, 1, false);
flock->fl_type = F_UNLCK;
if (rc != 0)
cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n",
rc);
return 0;
}
if (type & server->vals->shared_lock_type) {
flock->fl_type = F_WRLCK;
return 0;
}
type &= ~server->vals->exclusive_lock_type;
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
type | server->vals->shared_lock_type,
1, 0, false);
if (rc == 0) {
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
type | server->vals->shared_lock_type, 0, 1, false);
flock->fl_type = F_RDLCK;
if (rc != 0)
cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n",
rc);
} else
flock->fl_type = F_WRLCK;
return 0;
}
| 0 |
gpac | 984787de3d414a5f7d43d0b4584d9469dff2a5a5 | NOT_APPLICABLE | NOT_APPLICABLE | GF_EXPORT
GF_Err gf_isom_reset_tables(GF_ISOFile *movie, Bool reset_sample_count)
{
#ifndef GPAC_DISABLE_ISOM_FRAGMENTS
u32 i, j;
if (!movie || !movie->moov || !movie->moov->mvex) return GF_BAD_PARAM;
for (i=0; i<gf_list_count(movie->moov->trackList); i++) {
GF_Box *a;
GF_TrackBox *trak = (GF_TrackBox *)gf_list_get(movie->moov->trackList, i);
u32 type, dur;
u64 dts;
GF_SampleTableBox *stbl = trak->Media->information->sampleTable;
trak->sample_count_at_seg_start += stbl->SampleSize->sampleCount;
if (trak->sample_count_at_seg_start) {
GF_Err e;
e = stbl_GetSampleDTS_and_Duration(stbl->TimeToSample, stbl->SampleSize->sampleCount, &dts, &dur);
if (e == GF_OK) {
trak->dts_at_seg_start += dts + dur;
}
}
RECREATE_BOX(stbl->ChunkOffset, (GF_Box *));
RECREATE_BOX(stbl->CompositionOffset, (GF_CompositionOffsetBox *));
RECREATE_BOX(stbl->DegradationPriority, (GF_DegradationPriorityBox *));
RECREATE_BOX(stbl->PaddingBits, (GF_PaddingBitsBox *));
RECREATE_BOX(stbl->SampleDep, (GF_SampleDependencyTypeBox *));
RECREATE_BOX(stbl->SampleSize, (GF_SampleSizeBox *));
RECREATE_BOX(stbl->SampleToChunk, (GF_SampleToChunkBox *));
RECREATE_BOX(stbl->ShadowSync, (GF_ShadowSyncBox *));
RECREATE_BOX(stbl->SyncSample, (GF_SyncSampleBox *));
RECREATE_BOX(stbl->TimeToSample, (GF_TimeToSampleBox *));
gf_isom_box_array_del_parent(&stbl->child_boxes, stbl->sai_offsets);
stbl->sai_offsets = NULL;
gf_isom_box_array_del_parent(&stbl->child_boxes, stbl->sai_sizes);
stbl->sai_sizes = NULL;
gf_isom_box_array_del_parent(&stbl->child_boxes, stbl->sampleGroups);
stbl->sampleGroups = NULL;
j = stbl->nb_sgpd_in_stbl;
while ((a = (GF_Box *)gf_list_enum(stbl->sampleGroupsDescription, &j))) {
gf_isom_box_del_parent(&stbl->child_boxes, a);
j--;
gf_list_rem(stbl->sampleGroupsDescription, j);
}
#if 0
j = stbl->nb_stbl_boxes;
while ((a = (GF_Box *)gf_list_enum(stbl->child_boxes, &j))) {
gf_isom_box_del_parent(&stbl->child_boxes, a);
j--;
}
#endif
if (reset_sample_count) {
trak->Media->information->sampleTable->SampleSize->sampleCount = 0;
#ifndef GPAC_DISABLE_ISOM_FRAGMENTS
trak->sample_count_at_seg_start = 0;
trak->dts_at_seg_start = 0;
trak->first_traf_merged = GF_FALSE;
#endif
}
}
if (reset_sample_count) {
movie->NextMoofNumber = 0;
}
#endif
return GF_OK;
| 0 |
libevent | 20d6d4458bee5d88bda1511c225c25b2d3198d6c | NOT_APPLICABLE | NOT_APPLICABLE | advance_last_with_data(struct evbuffer *buf)
{
int n = 0;
ASSERT_EVBUFFER_LOCKED(buf);
if (!*buf->last_with_datap)
return 0;
while ((*buf->last_with_datap)->next && (*buf->last_with_datap)->next->off) {
buf->last_with_datap = &(*buf->last_with_datap)->next;
++n;
}
return n;
} | 0 |
savannah | 81f3472c0ba7b8f6466e2e214fa8c1c17fade975 | NOT_APPLICABLE | NOT_APPLICABLE | FT_Stream_New( FT_Library library,
const FT_Open_Args* args,
FT_Stream *astream )
{
FT_Error error;
FT_Memory memory;
FT_Stream stream;
*astream = 0;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !args )
return FT_Err_Invalid_Argument;
memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
stream->memory = memory;
if ( args->flags & FT_OPEN_MEMORY )
{
/* create a memory-based stream */
FT_Stream_OpenMemory( stream,
(const FT_Byte*)args->memory_base,
args->memory_size );
}
else if ( args->flags & FT_OPEN_PATHNAME )
{
/* create a normal system stream */
error = FT_Stream_Open( stream, args->pathname );
stream->pathname.pointer = args->pathname;
}
else if ( ( args->flags & FT_OPEN_STREAM ) && args->stream )
{
/* use an existing, user-provided stream */
/* in this case, we do not need to allocate a new stream object */
/* since the caller is responsible for closing it himself */
FT_FREE( stream );
stream = args->stream;
}
else
error = FT_Err_Invalid_Argument;
if ( error )
FT_FREE( stream );
else
stream->memory = memory; /* just to be certain */
*astream = stream;
Exit:
return error;
}
| 0 |
Android | 03a53d1c7765eeb3af0bc34c3dff02ada1953fbf | NOT_APPLICABLE | NOT_APPLICABLE | void InputDispatcher::traceOutboundQueueLengthLocked(const sp<Connection>& connection) {
if (ATRACE_ENABLED()) {
char counterName[40];
snprintf(counterName, sizeof(counterName), "oq:%s", connection->getWindowName());
ATRACE_INT(counterName, connection->outboundQueue.count());
}
}
| 0 |
php-src | 6045de69c7dedcba3eadf7c4bba424b19c81d00d | NOT_APPLICABLE | NOT_APPLICABLE | static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value TSRMLS_DC) /* {{{ */
{
if (Z_TYPE(stmt->lazy_object_ref) == IS_NULL) {
Z_TYPE(stmt->lazy_object_ref) = IS_OBJECT;
Z_OBJ_HANDLE(stmt->lazy_object_ref) = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_row_free_storage, NULL TSRMLS_CC);
Z_OBJ_HT(stmt->lazy_object_ref) = &pdo_row_object_handlers;
stmt->refcount++;
}
Z_TYPE_P(return_value) = IS_OBJECT;
Z_OBJ_HANDLE_P(return_value) = Z_OBJ_HANDLE(stmt->lazy_object_ref);
Z_OBJ_HT_P(return_value) = Z_OBJ_HT(stmt->lazy_object_ref);
zend_objects_store_add_ref(return_value TSRMLS_CC);
}
/* }}} */
| 0 |
php-src | da3886de6dc8edab3da14331227816d6ca8e9b96 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_MINIT_FUNCTION(filter)
{
ZEND_INIT_MODULE_GLOBALS(filter, php_filter_init_globals, NULL);
REGISTER_INI_ENTRIES();
REGISTER_LONG_CONSTANT("INPUT_POST", PARSE_POST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INPUT_GET", PARSE_GET, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INPUT_COOKIE", PARSE_COOKIE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INPUT_ENV", PARSE_ENV, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INPUT_SERVER", PARSE_SERVER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INPUT_SESSION", PARSE_SESSION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INPUT_REQUEST", PARSE_REQUEST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_NONE", FILTER_FLAG_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_REQUIRE_SCALAR", FILTER_REQUIRE_SCALAR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_REQUIRE_ARRAY", FILTER_REQUIRE_ARRAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FORCE_ARRAY", FILTER_FORCE_ARRAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_NULL_ON_FAILURE", FILTER_NULL_ON_FAILURE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_INT", FILTER_VALIDATE_INT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_BOOLEAN", FILTER_VALIDATE_BOOLEAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_FLOAT", FILTER_VALIDATE_FLOAT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_REGEXP", FILTER_VALIDATE_REGEXP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_URL", FILTER_VALIDATE_URL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_EMAIL", FILTER_VALIDATE_EMAIL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_VALIDATE_IP", FILTER_VALIDATE_IP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_DEFAULT", FILTER_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_UNSAFE_RAW", FILTER_UNSAFE_RAW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRING", FILTER_SANITIZE_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRIPPED", FILTER_SANITIZE_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_ENCODED", FILTER_SANITIZE_ENCODED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_SPECIAL_CHARS", FILTER_SANITIZE_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_FULL_SPECIAL_CHARS", FILTER_SANITIZE_FULL_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_EMAIL", FILTER_SANITIZE_EMAIL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_URL", FILTER_SANITIZE_URL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_NUMBER_INT", FILTER_SANITIZE_NUMBER_INT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_NUMBER_FLOAT", FILTER_SANITIZE_NUMBER_FLOAT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_SANITIZE_MAGIC_QUOTES", FILTER_SANITIZE_MAGIC_QUOTES, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_CALLBACK", FILTER_CALLBACK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_OCTAL", FILTER_FLAG_ALLOW_OCTAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_HEX", FILTER_FLAG_ALLOW_HEX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_LOW", FILTER_FLAG_STRIP_LOW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_HIGH", FILTER_FLAG_STRIP_HIGH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_BACKTICK", FILTER_FLAG_STRIP_BACKTICK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_LOW", FILTER_FLAG_ENCODE_LOW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_HIGH", FILTER_FLAG_ENCODE_HIGH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_AMP", FILTER_FLAG_ENCODE_AMP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_ENCODE_QUOTES", FILTER_FLAG_NO_ENCODE_QUOTES, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_EMPTY_STRING_NULL", FILTER_FLAG_EMPTY_STRING_NULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_FRACTION", FILTER_FLAG_ALLOW_FRACTION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_THOUSAND", FILTER_FLAG_ALLOW_THOUSAND, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_SCIENTIFIC", FILTER_FLAG_ALLOW_SCIENTIFIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_SCHEME_REQUIRED", FILTER_FLAG_SCHEME_REQUIRED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_HOST_REQUIRED", FILTER_FLAG_HOST_REQUIRED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_PATH_REQUIRED", FILTER_FLAG_PATH_REQUIRED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_QUERY_REQUIRED", FILTER_FLAG_QUERY_REQUIRED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_IPV4", FILTER_FLAG_IPV4, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_IPV6", FILTER_FLAG_IPV6, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT);
sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init TSRMLS_CC);
return SUCCESS;
} | 0 |
systemd | bf65b7e0c9fc215897b676ab9a7c9d1c688143ba | NOT_APPLICABLE | NOT_APPLICABLE | int unit_add_name(Unit *u, const char *text) {
_cleanup_free_ char *s = NULL, *i = NULL;
UnitType t;
int r;
assert(u);
assert(text);
if (unit_name_is_valid(text, UNIT_NAME_TEMPLATE)) {
if (!u->instance)
return -EINVAL;
r = unit_name_replace_instance(text, u->instance, &s);
if (r < 0)
return r;
} else {
s = strdup(text);
if (!s)
return -ENOMEM;
}
if (set_contains(u->names, s))
return 0;
if (hashmap_contains(u->manager->units, s))
return -EEXIST;
if (!unit_name_is_valid(s, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
return -EINVAL;
t = unit_name_to_type(s);
if (t < 0)
return -EINVAL;
if (u->type != _UNIT_TYPE_INVALID && t != u->type)
return -EINVAL;
r = unit_name_to_instance(s, &i);
if (r < 0)
return r;
if (i && !unit_type_may_template(t))
return -EINVAL;
/* Ensure that this unit is either instanced or not instanced,
* but not both. Note that we do allow names with different
* instance names however! */
if (u->type != _UNIT_TYPE_INVALID && !u->instance != !i)
return -EINVAL;
if (!unit_type_may_alias(t) && !set_isempty(u->names))
return -EEXIST;
if (hashmap_size(u->manager->units) >= MANAGER_MAX_NAMES)
return -E2BIG;
r = set_put(u->names, s);
if (r < 0)
return r;
assert(r > 0);
r = hashmap_put(u->manager->units, s, u);
if (r < 0) {
(void) set_remove(u->names, s);
return r;
}
if (u->type == _UNIT_TYPE_INVALID) {
u->type = t;
u->id = s;
u->instance = TAKE_PTR(i);
LIST_PREPEND(units_by_type, u->manager->units_by_type[t], u);
unit_init(u);
}
s = NULL;
unit_add_to_dbus_queue(u);
return 0;
} | 0 |
linux | 55f0fc7a02de8f12757f4937143d8d5091b2e40b | NOT_APPLICABLE | NOT_APPLICABLE | static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
struct flowi4 *fl4, struct sk_buff *skb, u32 portid,
u32 seq, int event, int nowait, unsigned int flags)
{
struct rtable *rt = skb_rtable(skb);
struct rtmsg *r;
struct nlmsghdr *nlh;
unsigned long expires = 0;
u32 error;
u32 metrics[RTAX_MAX];
nlh = nlmsg_put(skb, portid, seq, event, sizeof(*r), flags);
if (nlh == NULL)
return -EMSGSIZE;
r = nlmsg_data(nlh);
r->rtm_family = AF_INET;
r->rtm_dst_len = 32;
r->rtm_src_len = 0;
r->rtm_tos = fl4->flowi4_tos;
r->rtm_table = RT_TABLE_MAIN;
if (nla_put_u32(skb, RTA_TABLE, RT_TABLE_MAIN))
goto nla_put_failure;
r->rtm_type = rt->rt_type;
r->rtm_scope = RT_SCOPE_UNIVERSE;
r->rtm_protocol = RTPROT_UNSPEC;
r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED;
if (rt->rt_flags & RTCF_NOTIFY)
r->rtm_flags |= RTM_F_NOTIFY;
if (IPCB(skb)->flags & IPSKB_DOREDIRECT)
r->rtm_flags |= RTCF_DOREDIRECT;
if (nla_put_be32(skb, RTA_DST, dst))
goto nla_put_failure;
if (src) {
r->rtm_src_len = 32;
if (nla_put_be32(skb, RTA_SRC, src))
goto nla_put_failure;
}
if (rt->dst.dev &&
nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
goto nla_put_failure;
#ifdef CONFIG_IP_ROUTE_CLASSID
if (rt->dst.tclassid &&
nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid))
goto nla_put_failure;
#endif
if (!rt_is_input_route(rt) &&
fl4->saddr != src) {
if (nla_put_be32(skb, RTA_PREFSRC, fl4->saddr))
goto nla_put_failure;
}
if (rt->rt_uses_gateway &&
nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway))
goto nla_put_failure;
expires = rt->dst.expires;
if (expires) {
unsigned long now = jiffies;
if (time_before(now, expires))
expires -= now;
else
expires = 0;
}
memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics));
if (rt->rt_pmtu && expires)
metrics[RTAX_MTU - 1] = rt->rt_pmtu;
if (rtnetlink_put_metrics(skb, metrics) < 0)
goto nla_put_failure;
if (fl4->flowi4_mark &&
nla_put_u32(skb, RTA_MARK, fl4->flowi4_mark))
goto nla_put_failure;
error = rt->dst.error;
if (rt_is_input_route(rt)) {
#ifdef CONFIG_IP_MROUTE
if (ipv4_is_multicast(dst) && !ipv4_is_local_multicast(dst) &&
IPV4_DEVCONF_ALL(net, MC_FORWARDING)) {
int err = ipmr_get_route(net, skb,
fl4->saddr, fl4->daddr,
r, nowait, portid);
if (err <= 0) {
if (!nowait) {
if (err == 0)
return 0;
goto nla_put_failure;
} else {
if (err == -EMSGSIZE)
goto nla_put_failure;
error = err;
}
}
} else
#endif
if (nla_put_u32(skb, RTA_IIF, skb->dev->ifindex))
goto nla_put_failure;
}
if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0)
goto nla_put_failure;
return nlmsg_end(skb, nlh);
nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
| 0 |
linux | 05692d7005a364add85c6e25a6c4447ce08f913a | NOT_APPLICABLE | NOT_APPLICABLE | static ssize_t vfio_pci_rw(void *device_data, char __user *buf,
size_t count, loff_t *ppos, bool iswrite)
{
unsigned int index = VFIO_PCI_OFFSET_TO_INDEX(*ppos);
struct vfio_pci_device *vdev = device_data;
if (index >= VFIO_PCI_NUM_REGIONS + vdev->num_regions)
return -EINVAL;
switch (index) {
case VFIO_PCI_CONFIG_REGION_INDEX:
return vfio_pci_config_rw(vdev, buf, count, ppos, iswrite);
case VFIO_PCI_ROM_REGION_INDEX:
if (iswrite)
return -EINVAL;
return vfio_pci_bar_rw(vdev, buf, count, ppos, false);
case VFIO_PCI_BAR0_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX:
return vfio_pci_bar_rw(vdev, buf, count, ppos, iswrite);
case VFIO_PCI_VGA_REGION_INDEX:
return vfio_pci_vga_rw(vdev, buf, count, ppos, iswrite);
default:
index -= VFIO_PCI_NUM_REGIONS;
return vdev->region[index].ops->rw(vdev, buf,
count, ppos, iswrite);
}
return -EINVAL;
}
| 0 |
OpenJK | b173ac05993f634a42be3d3535e1b158de0c3372 | NOT_APPLICABLE | NOT_APPLICABLE | void Con_DrawInput (void) {
int y;
if ( clc.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) {
return;
}
y = con.vislines - ( SMALLCHAR_HEIGHT * 2 );
re.SetColor( con.color );
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, ']' );
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y,
SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue );
}
| 0 |
linux | e0bccd315db0c2f919e7fcf9cb60db21d9986f52 | NOT_APPLICABLE | NOT_APPLICABLE | __acquires(rose_node_list_lock)
{
struct rose_node *rose_node;
int i = 1;
spin_lock_bh(&rose_node_list_lock);
if (*pos == 0)
return SEQ_START_TOKEN;
for (rose_node = rose_node_list; rose_node && i < *pos;
rose_node = rose_node->next, ++i);
return (i == *pos) ? rose_node : NULL;
}
| 0 |
linux | b860d3cc62877fad02863e2a08efff69a19382d2 | NOT_APPLICABLE | NOT_APPLICABLE | static int l2tp_ip6_connect(struct sock *sk, struct sockaddr *uaddr,
int addr_len)
{
struct sockaddr_l2tpip6 *lsa = (struct sockaddr_l2tpip6 *) uaddr;
struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
struct in6_addr *daddr;
int addr_type;
int rc;
if (sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
return -EINVAL;
if (addr_len < sizeof(*lsa))
return -EINVAL;
addr_type = ipv6_addr_type(&usin->sin6_addr);
if (addr_type & IPV6_ADDR_MULTICAST)
return -EINVAL;
if (addr_type & IPV6_ADDR_MAPPED) {
daddr = &usin->sin6_addr;
if (ipv4_is_multicast(daddr->s6_addr32[3]))
return -EINVAL;
}
rc = ip6_datagram_connect(sk, uaddr, addr_len);
lock_sock(sk);
l2tp_ip6_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
write_lock_bh(&l2tp_ip6_lock);
hlist_del_init(&sk->sk_bind_node);
sk_add_bind_node(sk, &l2tp_ip6_bind_table);
write_unlock_bh(&l2tp_ip6_lock);
release_sock(sk);
return rc;
}
| 0 |
server | ff77a09bda884fe6bf3917eb29b9d3a2f53f919b | NOT_APPLICABLE | NOT_APPLICABLE | test_if_quick_select(JOIN_TAB *tab)
{
DBUG_EXECUTE_IF("show_explain_probe_test_if_quick_select",
if (dbug_user_var_equals_int(tab->join->thd,
"show_explain_probe_select_id",
tab->join->select_lex->select_number))
dbug_serve_apcs(tab->join->thd, 1);
);
delete tab->select->quick;
tab->select->quick=0;
if (tab->table->file->inited != handler::NONE)
tab->table->file->ha_index_or_rnd_end();
int res= tab->select->test_quick_select(tab->join->thd, tab->keys,
(table_map) 0, HA_POS_ERROR, 0,
FALSE, /*remove where parts*/FALSE);
if (tab->explain_plan && tab->explain_plan->range_checked_fer)
tab->explain_plan->range_checked_fer->collect_data(tab->select->quick);
return res;
} | 0 |
linux | f0fe970df3838c202ef6c07a4c2b36838ef0a88b | NOT_APPLICABLE | NOT_APPLICABLE | static int ecryptfs_readdir(struct file *file, struct dir_context *ctx)
{
int rc;
struct file *lower_file;
struct inode *inode = file_inode(file);
struct ecryptfs_getdents_callback buf = {
.ctx.actor = ecryptfs_filldir,
.caller = ctx,
.sb = inode->i_sb,
};
lower_file = ecryptfs_file_to_lower(file);
rc = iterate_dir(lower_file, &buf.ctx);
ctx->pos = buf.ctx.pos;
if (rc < 0)
goto out;
if (buf.filldir_called && !buf.entries_written)
goto out;
if (rc >= 0)
fsstack_copy_attr_atime(inode,
file_inode(lower_file));
out:
return rc;
}
| 0 |
Chrome | ee7579229ff7e9e5ae28bf53aea069251499d7da | NOT_APPLICABLE | NOT_APPLICABLE | void GLES2DecoderImpl::DoSwapBuffers() {
bool is_offscreen = !!offscreen_target_frame_buffer_.get();
int this_frame_number = frame_number_++;
TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency",
TRACE_EVENT_SCOPE_THREAD,
"GLImpl", static_cast<int>(gfx::GetGLImplementation()),
"width", (is_offscreen ? offscreen_size_.width() :
surface_->GetSize().width()));
TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers",
"offscreen", is_offscreen,
"frame", this_frame_number);
{
TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame");
}
bool is_tracing;
TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"),
&is_tracing);
if (is_tracing) {
ScopedFrameBufferBinder binder(this, GetBackbufferServiceId());
gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer(
is_offscreen ? offscreen_size_ : surface_->GetSize());
}
if (is_offscreen) {
TRACE_EVENT2("gpu", "Offscreen",
"width", offscreen_size_.width(), "height", offscreen_size_.height());
if (offscreen_size_ != offscreen_saved_color_texture_->size()) {
if (workarounds().needs_offscreen_buffer_workaround) {
offscreen_saved_frame_buffer_->Create();
glFinish();
}
DCHECK(offscreen_saved_color_format_);
offscreen_saved_color_texture_->AllocateStorage(
offscreen_size_, offscreen_saved_color_format_, false);
offscreen_saved_frame_buffer_->AttachRenderTexture(
offscreen_saved_color_texture_.get());
if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) {
if (offscreen_saved_frame_buffer_->CheckStatus() !=
GL_FRAMEBUFFER_COMPLETE) {
LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
<< "because offscreen saved FBO was incomplete.";
LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
return;
}
{
ScopedFrameBufferBinder binder(this,
offscreen_saved_frame_buffer_->id());
glClearColor(0, 0, 0, 0);
state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
glClear(GL_COLOR_BUFFER_BIT);
RestoreClearState();
}
}
UpdateParentTextureInfo();
}
if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0)
return;
ScopedGLErrorSuppressor suppressor(
"GLES2DecoderImpl::DoSwapBuffers", GetErrorState());
if (IsOffscreenBufferMultisampled()) {
ScopedResolvedFrameBufferBinder binder(this, true, false);
} else {
ScopedFrameBufferBinder binder(this,
offscreen_target_frame_buffer_->id());
if (offscreen_target_buffer_preserved_) {
offscreen_saved_color_texture_->Copy(
offscreen_saved_color_texture_->size(),
offscreen_saved_color_format_);
} else {
if (!!offscreen_saved_color_texture_info_.get())
offscreen_saved_color_texture_info_->texture()->
SetServiceId(offscreen_target_color_texture_->id());
offscreen_saved_color_texture_.swap(offscreen_target_color_texture_);
offscreen_target_frame_buffer_->AttachRenderTexture(
offscreen_target_color_texture_.get());
}
if (!feature_info_->feature_flags().is_angle)
glFlush();
}
} else {
if (!surface_->SwapBuffers()) {
LOG(ERROR) << "Context lost because SwapBuffers failed.";
LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
}
}
}
| 0 |
php-src | 72dbb7f416160f490c4e9987040989a10ad431c7?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_FUNCTION(curl_getinfo)
{
zval *zid;
php_curl *ch;
zend_long option = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zid, &option) == FAILURE) {
return;
}
if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) {
RETURN_FALSE;
}
if (ZEND_NUM_ARGS() < 2) {
char *s_code;
/* libcurl expects long datatype. So far no cases are known where
it would be an issue. Using zend_long would truncate a 64-bit
var on Win64, so the exact long datatype fits everywhere, as
long as there's no 32-bit int overflow. */
long l_code;
double d_code;
#if LIBCURL_VERSION_NUM > 0x071301
struct curl_certinfo *ci = NULL;
zval listcode;
#endif
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) {
CAAS("url", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) {
if (s_code != NULL) {
CAAS("content_type", s_code);
} else {
zval retnull;
ZVAL_NULL(&retnull);
CAAZ("content_type", &retnull);
}
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) {
CAAL("http_code", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) {
CAAL("header_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) {
CAAL("request_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) {
CAAL("filetime", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) {
CAAL("ssl_verify_result", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) {
CAAL("redirect_count", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) {
CAAD("total_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) {
CAAD("namelookup_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) {
CAAD("connect_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("pretransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) {
CAAD("size_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("size_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("speed_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) {
CAAD("speed_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("download_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) {
CAAD("upload_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("starttransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
CAAD("redirect_time", d_code);
}
#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
CAAS("redirect_url", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
CAAS("primary_ip", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
array_init(&listcode);
create_certinfo(ci, &listcode);
CAAZ("certinfo", &listcode);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) {
CAAL("primary_port", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) {
CAAS("local_ip", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) {
CAAL("local_port", l_code);
}
#endif
if (ch->header.str) {
CAASTR("request_header", ch->header.str);
}
} else {
switch (option) {
case CURLINFO_HEADER_OUT:
if (ch->header.str) {
RETURN_STR_COPY(ch->header.str);
} else {
RETURN_FALSE;
}
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLINFO_CERTINFO: {
struct curl_certinfo *ci = NULL;
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
create_certinfo(ci, return_value);
} else {
RETURN_FALSE;
}
break;
}
#endif
default: {
int type = CURLINFO_TYPEMASK & option;
switch (type) {
case CURLINFO_STRING:
{
char *s_code = NULL;
if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
RETURN_STRING(s_code);
} else {
RETURN_FALSE;
}
break;
}
case CURLINFO_LONG:
{
zend_long code = 0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_LONG(code);
} else {
RETURN_FALSE;
}
break;
}
case CURLINFO_DOUBLE:
{
double code = 0.0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_DOUBLE(code);
} else {
RETURN_FALSE;
}
break;
}
#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
case CURLINFO_SLIST:
{
struct curl_slist *slist;
array_init(return_value);
if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) {
while (slist) {
add_next_index_string(return_value, slist->data);
slist = slist->next;
}
curl_slist_free_all(slist);
} else {
RETURN_FALSE;
}
break;
}
#endif
default:
RETURN_FALSE;
}
}
}
}
}
| 0 |
librsvg | ecf9267a24b2c3c0cd211dbdfa9ef2232511972a | NOT_APPLICABLE | NOT_APPLICABLE | rsvg_new_filter_primitive_displacement_map (const char *element_name, RsvgNode *parent)
{
RsvgFilterPrimitiveDisplacementMap *filter;
filter = g_new0 (RsvgFilterPrimitiveDisplacementMap, 1);
filter->super.in = g_string_new ("none");
filter->in2 = g_string_new ("none");
filter->super.result = g_string_new ("none");
filter->xChannelSelector = ' ';
filter->yChannelSelector = ' ';
filter->scale = 0;
filter->super.render = rsvg_filter_primitive_displacement_map_render;
return rsvg_rust_cnode_new (RSVG_NODE_TYPE_FILTER_PRIMITIVE_DISPLACEMENT_MAP,
parent,
rsvg_state_new (),
filter,
rsvg_filter_primitive_displacement_map_set_atts,
rsvg_filter_draw,
rsvg_filter_primitive_displacement_map_free);
} | 0 |
postgres | 1dc75515868454c645ded22d38054ec693e23ec6 | NOT_APPLICABLE | NOT_APPLICABLE | pushf_write(PushFilter *mp, const uint8 *data, int len)
{
int need,
res;
/*
* no buffering
*/
if (mp->block_size <= 0)
return wrap_process(mp, data, len);
/*
* try to empty buffer
*/
need = mp->block_size - mp->pos;
if (need > 0)
{
if (len < need)
{
memcpy(mp->buf + mp->pos, data, len);
mp->pos += len;
return 0;
}
memcpy(mp->buf + mp->pos, data, need);
len -= need;
data += need;
}
/*
* buffer full, process
*/
res = wrap_process(mp, mp->buf, mp->block_size);
if (res < 0)
return res;
mp->pos = 0;
/*
* now process directly from data
*/
while (len > 0)
{
if (len > mp->block_size)
{
res = wrap_process(mp, data, mp->block_size);
if (res < 0)
return res;
data += mp->block_size;
len -= mp->block_size;
}
else
{
memcpy(mp->buf, data, len);
mp->pos += len;
break;
}
}
return 0;
} | 0 |
Chrome | 828eab2216a765dea92575c290421c115b8ad028 | NOT_APPLICABLE | NOT_APPLICABLE | void ForceGoogleSafeSearchCallbackWrapper(
const net::CompletionCallback& callback,
net::URLRequest* request,
GURL* new_url,
int rv) {
if (rv == net::OK && new_url->is_empty())
ForceGoogleSafeSearch(request, new_url);
callback.Run(rv);
}
| 0 |
vim | c6fdb15d423df22e1776844811d082322475e48a | NOT_APPLICABLE | NOT_APPLICABLE | changedir_func(
char_u *new_dir,
int forceit,
cdscope_T scope)
{
char_u *pdir = NULL;
int dir_differs;
char_u *acmd_fname = NULL;
char_u **pp;
char_u *tofree;
if (new_dir == NULL || allbuf_locked())
return FALSE;
if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged() && !forceit)
{
emsg(_(e_cannot_change_directory_buffer_is_modified_add_bang_to_override));
return FALSE;
}
// ":cd -": Change to previous directory
if (STRCMP(new_dir, "-") == 0)
{
pdir = get_prevdir(scope);
if (pdir == NULL)
{
emsg(_(e_no_previous_directory));
return FALSE;
}
new_dir = pdir;
}
// Save current directory for next ":cd -"
if (mch_dirname(NameBuff, MAXPATHL) == OK)
pdir = vim_strsave(NameBuff);
else
pdir = NULL;
// For UNIX ":cd" means: go to home directory.
// On other systems too if 'cdhome' is set.
#if defined(UNIX) || defined(VMS)
if (*new_dir == NUL)
#else
if (*new_dir == NUL && p_cdh)
#endif
{
// use NameBuff for home directory name
# ifdef VMS
char_u *p;
p = mch_getenv((char_u *)"SYS$LOGIN");
if (p == NULL || *p == NUL) // empty is the same as not set
NameBuff[0] = NUL;
else
vim_strncpy(NameBuff, p, MAXPATHL - 1);
# else
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
# endif
new_dir = NameBuff;
}
dir_differs = pdir == NULL
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
if (dir_differs)
{
if (scope == CDSCOPE_WINDOW)
acmd_fname = (char_u *)"window";
else if (scope == CDSCOPE_TABPAGE)
acmd_fname = (char_u *)"tabpage";
else
acmd_fname = (char_u *)"global";
trigger_DirChangedPre(acmd_fname, new_dir);
if (vim_chdir(new_dir))
{
emsg(_(e_command_failed));
vim_free(pdir);
return FALSE;
}
}
if (scope == CDSCOPE_WINDOW)
pp = &curwin->w_prevdir;
else if (scope == CDSCOPE_TABPAGE)
pp = &curtab->tp_prevdir;
else
pp = &prev_dir;
tofree = *pp; // new_dir may use this
*pp = pdir;
post_chdir(scope);
if (dir_differs)
apply_autocmds(EVENT_DIRCHANGED, acmd_fname, new_dir, FALSE, curbuf);
vim_free(tofree);
return TRUE;
} | 0 |
tcpdump | f4b9e24c7384d882a7f434cc7413925bf871d63e | NOT_APPLICABLE | NOT_APPLICABLE | icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
{
const struct icmp6_router_renum *rr6;
const char *cp;
const struct rr_pco_match *match;
const struct rr_pco_use *use;
char hbuf[NI_MAXHOST];
int n;
if (ep < bp)
return;
rr6 = (const struct icmp6_router_renum *)bp;
cp = (const char *)(rr6 + 1);
ND_TCHECK(rr6->rr_reserved);
switch (rr6->rr_code) {
case ICMP6_ROUTER_RENUMBERING_COMMAND:
ND_PRINT((ndo,"router renum: command"));
break;
case ICMP6_ROUTER_RENUMBERING_RESULT:
ND_PRINT((ndo,"router renum: result"));
break;
case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
ND_PRINT((ndo,"router renum: sequence number reset"));
break;
default:
ND_PRINT((ndo,"router renum: code-#%d", rr6->rr_code));
break;
}
ND_PRINT((ndo,", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum)));
if (ndo->ndo_vflag) {
#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
ND_PRINT((ndo,"[")); /*]*/
if (rr6->rr_flags) {
ND_PRINT((ndo,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
F(ICMP6_RR_FLAGS_REQRESULT, "R"),
F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
F(ICMP6_RR_FLAGS_SPECSITE, "S"),
F(ICMP6_RR_FLAGS_PREVDONE, "P")));
}
ND_PRINT((ndo,"seg=%u,", rr6->rr_segnum));
ND_PRINT((ndo,"maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay)));
if (rr6->rr_reserved)
ND_PRINT((ndo,"rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved)));
/*[*/
ND_PRINT((ndo,"]"));
#undef F
}
if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) {
match = (const struct rr_pco_match *)cp;
cp = (const char *)(match + 1);
ND_TCHECK(match->rpm_prefix);
if (ndo->ndo_vflag > 1)
ND_PRINT((ndo,"\n\t"));
else
ND_PRINT((ndo," "));
ND_PRINT((ndo,"match(")); /*)*/
switch (match->rpm_code) {
case RPM_PCO_ADD: ND_PRINT((ndo,"add")); break;
case RPM_PCO_CHANGE: ND_PRINT((ndo,"change")); break;
case RPM_PCO_SETGLOBAL: ND_PRINT((ndo,"setglobal")); break;
default: ND_PRINT((ndo,"#%u", match->rpm_code)); break;
}
if (ndo->ndo_vflag) {
ND_PRINT((ndo,",ord=%u", match->rpm_ordinal));
ND_PRINT((ndo,",min=%u", match->rpm_minlen));
ND_PRINT((ndo,",max=%u", match->rpm_maxlen));
}
if (addrtostr6(&match->rpm_prefix, hbuf, sizeof(hbuf)))
ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen));
else
ND_PRINT((ndo,",?/%u", match->rpm_matchlen));
/*(*/
ND_PRINT((ndo,")"));
n = match->rpm_len - 3;
if (n % 4)
goto trunc;
n /= 4;
while (n-- > 0) {
use = (const struct rr_pco_use *)cp;
cp = (const char *)(use + 1);
ND_TCHECK(use->rpu_prefix);
if (ndo->ndo_vflag > 1)
ND_PRINT((ndo,"\n\t"));
else
ND_PRINT((ndo," "));
ND_PRINT((ndo,"use(")); /*)*/
if (use->rpu_flags) {
#define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
ND_PRINT((ndo,"%s%s,",
F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P")));
#undef F
}
if (ndo->ndo_vflag) {
ND_PRINT((ndo,"mask=0x%x,", use->rpu_ramask));
ND_PRINT((ndo,"raflags=0x%x,", use->rpu_raflags));
if (~use->rpu_vltime == 0)
ND_PRINT((ndo,"vltime=infty,"));
else
ND_PRINT((ndo,"vltime=%u,",
EXTRACT_32BITS(&use->rpu_vltime)));
if (~use->rpu_pltime == 0)
ND_PRINT((ndo,"pltime=infty,"));
else
ND_PRINT((ndo,"pltime=%u,",
EXTRACT_32BITS(&use->rpu_pltime)));
}
if (addrtostr6(&use->rpu_prefix, hbuf, sizeof(hbuf)))
ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen,
use->rpu_keeplen));
else
ND_PRINT((ndo,"?/%u/%u", use->rpu_uselen,
use->rpu_keeplen));
/*(*/
ND_PRINT((ndo,")"));
}
}
return;
trunc:
ND_PRINT((ndo,"[|icmp6]"));
}
| 0 |
Chrome | 0b694217046d6b2bfa5814676e8615c18e6a45ff | NOT_APPLICABLE | NOT_APPLICABLE | String SystemClipboard::ReadPlainText() {
return ReadPlainText(buffer_);
}
| 0 |
mongo | 64095239f41e9f3841d8be9088347db56d35c891 | NOT_APPLICABLE | NOT_APPLICABLE | TEST(GtOp, MatchesArrayValue) {
BSONObj operand = BSON("$gt" << 5);
GTMatchExpression gt("a", operand["$gt"]);
ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(3 << 5.5)), NULL));
ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(2 << 4)), NULL));
} | 0 |
Chrome | fd6a5115103b3e6a52ce15858c5ad4956df29300 | NOT_APPLICABLE | NOT_APPLICABLE | String AudioNode::channelCountMode() const {
return Handler().GetChannelCountMode();
}
| 0 |
php-src | 777c39f4042327eac4b63c7ee87dc1c7a09a3115 | NOT_APPLICABLE | NOT_APPLICABLE | void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
{
zend_hash_index_update_ptr(&xlat_table, (zend_ulong)old, (void*)new);
} | 0 |
pgbouncer | edab5be6665b9e8de66c25ba527509b229468573 | NOT_APPLICABLE | NOT_APPLICABLE | bool handle_auth_response(PgSocket *client, PktHdr *pkt) {
uint16_t columns;
uint32_t length;
const char *username, *password;
PgUser user;
PgSocket *server = client->link;
switch(pkt->type) {
case 'T': /* RowDescription */
if (!mbuf_get_uint16be(&pkt->data, &columns)) {
disconnect_server(server, false, "bad packet");
return false;
}
if (columns != 2u) {
disconnect_server(server, false, "expected 1 column from login query, not %hu", columns);
return false;
}
break;
case 'D': /* DataRow */
memset(&user, 0, sizeof(user));
if (!mbuf_get_uint16be(&pkt->data, &columns)) {
disconnect_server(server, false, "bad packet");
return false;
}
if (columns != 2u) {
disconnect_server(server, false, "expected 1 column from login query, not %hu", columns);
return false;
}
if (!mbuf_get_uint32be(&pkt->data, &length)) {
disconnect_server(server, false, "bad packet");
return false;
}
if (!mbuf_get_chars(&pkt->data, length, &username)) {
disconnect_server(server, false, "bad packet");
return false;
}
if (sizeof(user.name) - 1 < length)
length = sizeof(user.name) - 1;
memcpy(user.name, username, length);
if (!mbuf_get_uint32be(&pkt->data, &length)) {
disconnect_server(server, false, "bad packet");
return false;
}
if (length == (uint32_t)-1) {
/*
* NULL - set an md5 password with an impossible value,
* so that nothing will ever match
*/
password = "md5";
length = 3;
} else {
if (!mbuf_get_chars(&pkt->data, length, &password)) {
disconnect_server(server, false, "bad packet");
return false;
}
}
if (sizeof(user.passwd) - 1 < length)
length = sizeof(user.passwd) - 1;
memcpy(user.passwd, password, length);
client->auth_user = add_db_user(client->db, user.name, user.passwd);
if (!client->auth_user) {
disconnect_server(server, false, "unable to allocate new user for auth");
return false;
}
break;
case 'C': /* CommandComplete */
break;
case '1': /* ParseComplete */
break;
case '2': /* BindComplete */
break;
case 'Z': /* ReadyForQuery */
sbuf_prepare_skip(&client->link->sbuf, pkt->len);
if (!client->auth_user) {
if (cf_log_connections)
slog_info(client, "login failed: db=%s", client->db->name);
disconnect_client(client, true, "No such user");
} else {
slog_noise(client, "auth query complete");
client->link->resetting = true;
sbuf_continue(&client->sbuf);
}
/*
* either sbuf_continue or disconnect_client could disconnect the server
* way down in their bowels of other callbacks. so check that, and
* return appropriately (similar to reuse_on_release)
*/
if (server->state == SV_FREE || server->state == SV_JUSTFREE)
return false;
return true;
default:
disconnect_server(server, false, "unexpected response from login query");
return false;
}
sbuf_prepare_skip(&server->sbuf, pkt->len);
return true;
}
| 0 |
Chrome | c7a90019bf7054145b11d2577b851cf2779d3d79 | NOT_APPLICABLE | NOT_APPLICABLE | GtkPrinter* GetPrinterWithName(const char* name) {
if (!name || !*name)
return NULL;
for (std::vector<GtkPrinter*>::iterator it = printers_.begin();
it < printers_.end(); ++it) {
if (strcmp(name, gtk_printer_get_name(*it)) == 0) {
return *it;
}
}
return NULL;
}
| 0 |
tcpdump | 3a76fd7c95fced2c2f8c8148a9055c3a542eff29 | NOT_APPLICABLE | NOT_APPLICABLE | blabel_print(netdissect_options *ndo,
const u_char *cp)
{
int bitlen, slen, b;
const u_char *bitp, *lim;
char tc;
if (!ND_TTEST2(*cp, 1))
return(NULL);
if ((bitlen = *cp) == 0)
bitlen = 256;
slen = (bitlen + 3) / 4;
lim = cp + 1 + slen;
/* print the bit string as a hex string */
ND_PRINT((ndo, "\\[x"));
for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) {
ND_TCHECK(*bitp);
ND_PRINT((ndo, "%02x", *bitp));
}
if (b > 4) {
ND_TCHECK(*bitp);
tc = *bitp++;
ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b))));
} else if (b > 0) {
ND_TCHECK(*bitp);
tc = *bitp++;
ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
}
ND_PRINT((ndo, "/%d]", bitlen));
return lim;
trunc:
ND_PRINT((ndo, ".../%d]", bitlen));
return NULL;
}
| 0 |
savannah | 9bd20b7304aae61de5d50ac359cf27132bafd4c1 | NOT_APPLICABLE | NOT_APPLICABLE | tt_cmap10_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 10;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
| 0 |
libxml2 | a436374994c47b12d5de1b8b1d191a098fa23594 | NOT_APPLICABLE | NOT_APPLICABLE |
static int
xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
xmlXPathStepOpPtr op,
xmlNodePtr * first, xmlNodePtr * last,
int toBool)
{
#define XP_TEST_HIT \
if (hasAxisRange != 0) { \
if (++pos == maxPos) { \
if (addNode(seq, cur) < 0) \
ctxt->error = XPATH_MEMORY_ERROR; \
goto axis_range_end; } \
} else { \
if (addNode(seq, cur) < 0) \
ctxt->error = XPATH_MEMORY_ERROR; \
if (breakOnFirstHit) goto first_hit; }
#define XP_TEST_HIT_NS \
if (hasAxisRange != 0) { \
if (++pos == maxPos) { \
hasNsNodes = 1; \
if (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \
ctxt->error = XPATH_MEMORY_ERROR; \
goto axis_range_end; } \
} else { \
hasNsNodes = 1; \
if (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \
ctxt->error = XPATH_MEMORY_ERROR; \
if (breakOnFirstHit) goto first_hit; }
xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value;
xmlXPathTestVal test = (xmlXPathTestVal) op->value2;
xmlXPathTypeVal type = (xmlXPathTypeVal) op->value3;
const xmlChar *prefix = op->value4;
const xmlChar *name = op->value5;
const xmlChar *URI = NULL;
#ifdef DEBUG_STEP
int nbMatches = 0, prevMatches = 0;
#endif
int total = 0, hasNsNodes = 0;
/* The popped object holding the context nodes */
xmlXPathObjectPtr obj;
/* The set of context nodes for the node tests */
xmlNodeSetPtr contextSeq;
int contextIdx;
xmlNodePtr contextNode;
/* The final resulting node set wrt to all context nodes */
xmlNodeSetPtr outSeq;
/*
* The temporary resulting node set wrt 1 context node.
* Used to feed predicate evaluation.
*/
xmlNodeSetPtr seq;
xmlNodePtr cur;
/* First predicate operator */
xmlXPathStepOpPtr predOp;
int maxPos; /* The requested position() (when a "[n]" predicate) */
int hasPredicateRange, hasAxisRange, pos, size, newSize;
int breakOnFirstHit;
xmlXPathTraversalFunction next = NULL;
int (*addNode) (xmlNodeSetPtr, xmlNodePtr);
xmlXPathNodeSetMergeFunction mergeAndClear;
xmlNodePtr oldContextNode;
xmlXPathContextPtr xpctxt = ctxt->context;
CHECK_TYPE0(XPATH_NODESET);
obj = valuePop(ctxt);
/*
* Setup namespaces.
*/
if (prefix != NULL) {
URI = xmlXPathNsLookup(xpctxt, prefix);
if (URI == NULL) {
xmlXPathReleaseObject(xpctxt, obj);
XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR);
}
}
/*
* Setup axis.
*
* MAYBE FUTURE TODO: merging optimizations:
* - If the nodes to be traversed wrt to the initial nodes and
* the current axis cannot overlap, then we could avoid searching
* for duplicates during the merge.
* But the question is how/when to evaluate if they cannot overlap.
* Example: if we know that for two initial nodes, the one is
* not in the ancestor-or-self axis of the other, then we could safely
* avoid a duplicate-aware merge, if the axis to be traversed is e.g.
* the descendant-or-self axis.
*/
mergeAndClear = xmlXPathNodeSetMergeAndClear;
switch (axis) {
case AXIS_ANCESTOR:
first = NULL;
next = xmlXPathNextAncestor;
break;
case AXIS_ANCESTOR_OR_SELF:
first = NULL;
next = xmlXPathNextAncestorOrSelf;
break;
case AXIS_ATTRIBUTE:
first = NULL;
last = NULL;
next = xmlXPathNextAttribute;
mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;
break;
case AXIS_CHILD:
last = NULL;
if (((test == NODE_TEST_NAME) || (test == NODE_TEST_ALL)) &&
(type == NODE_TYPE_NODE))
{
/*
* Optimization if an element node type is 'element'.
*/
next = xmlXPathNextChildElement;
} else
next = xmlXPathNextChild;
mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;
break;
case AXIS_DESCENDANT:
last = NULL;
next = xmlXPathNextDescendant;
break;
case AXIS_DESCENDANT_OR_SELF:
last = NULL;
next = xmlXPathNextDescendantOrSelf;
break;
case AXIS_FOLLOWING:
last = NULL;
next = xmlXPathNextFollowing;
break;
case AXIS_FOLLOWING_SIBLING:
last = NULL;
next = xmlXPathNextFollowingSibling;
break;
case AXIS_NAMESPACE:
first = NULL;
last = NULL;
next = (xmlXPathTraversalFunction) xmlXPathNextNamespace;
mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;
break;
case AXIS_PARENT:
first = NULL;
next = xmlXPathNextParent;
break;
case AXIS_PRECEDING:
first = NULL;
next = xmlXPathNextPrecedingInternal;
break;
case AXIS_PRECEDING_SIBLING:
first = NULL;
next = xmlXPathNextPrecedingSibling;
break;
case AXIS_SELF:
first = NULL;
last = NULL;
next = xmlXPathNextSelf;
mergeAndClear = xmlXPathNodeSetMergeAndClearNoDupls;
break;
}
#ifdef DEBUG_STEP
xmlXPathDebugDumpStepAxis(op,
(obj->nodesetval != NULL) ? obj->nodesetval->nodeNr : 0);
#endif
if (next == NULL) {
xmlXPathReleaseObject(xpctxt, obj);
return(0);
}
contextSeq = obj->nodesetval;
if ((contextSeq == NULL) || (contextSeq->nodeNr <= 0)) {
xmlXPathReleaseObject(xpctxt, obj);
valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));
return(0);
}
/*
* Predicate optimization ---------------------------------------------
* If this step has a last predicate, which contains a position(),
* then we'll optimize (although not exactly "position()", but only
* the short-hand form, i.e., "[n]".
*
* Example - expression "/foo[parent::bar][1]":
*
* COLLECT 'child' 'name' 'node' foo -- op (we are here)
* ROOT -- op->ch1
* PREDICATE -- op->ch2 (predOp)
* PREDICATE -- predOp->ch1 = [parent::bar]
* SORT
* COLLECT 'parent' 'name' 'node' bar
* NODE
* ELEM Object is a number : 1 -- predOp->ch2 = [1]
*
*/
maxPos = 0;
predOp = NULL;
hasPredicateRange = 0;
hasAxisRange = 0;
if (op->ch2 != -1) {
/*
* There's at least one predicate. 16 == XPATH_OP_PREDICATE
*/
predOp = &ctxt->comp->steps[op->ch2];
if (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) {
if (predOp->ch1 != -1) {
/*
* Use the next inner predicate operator.
*/
predOp = &ctxt->comp->steps[predOp->ch1];
hasPredicateRange = 1;
} else {
/*
* There's no other predicate than the [n] predicate.
*/
predOp = NULL;
hasAxisRange = 1;
}
}
}
breakOnFirstHit = ((toBool) && (predOp == NULL)) ? 1 : 0;
/*
* Axis traversal -----------------------------------------------------
*/
/*
* 2.3 Node Tests
* - For the attribute axis, the principal node type is attribute.
* - For the namespace axis, the principal node type is namespace.
* - For other axes, the principal node type is element.
*
* A node test * is true for any node of the
* principal node type. For example, child::* will
* select all element children of the context node
*/
oldContextNode = xpctxt->node;
addNode = xmlXPathNodeSetAddUnique;
outSeq = NULL;
seq = NULL;
contextNode = NULL;
contextIdx = 0;
while (((contextIdx < contextSeq->nodeNr) || (contextNode != NULL)) &&
(ctxt->error == XPATH_EXPRESSION_OK)) {
xpctxt->node = contextSeq->nodeTab[contextIdx++];
if (seq == NULL) {
seq = xmlXPathNodeSetCreate(NULL);
if (seq == NULL) {
total = 0;
goto error;
}
}
/*
* Traverse the axis and test the nodes.
*/
pos = 0;
cur = NULL;
hasNsNodes = 0;
do {
cur = next(ctxt, cur);
if (cur == NULL)
break;
/*
* QUESTION TODO: What does the "first" and "last" stuff do?
*/
if ((first != NULL) && (*first != NULL)) {
if (*first == cur)
break;
if (((total % 256) == 0) &&
#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
(xmlXPathCmpNodesExt(*first, cur) >= 0))
#else
(xmlXPathCmpNodes(*first, cur) >= 0))
#endif
{
break;
}
}
if ((last != NULL) && (*last != NULL)) {
if (*last == cur)
break;
if (((total % 256) == 0) &&
#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
(xmlXPathCmpNodesExt(cur, *last) >= 0))
#else
(xmlXPathCmpNodes(cur, *last) >= 0))
#endif
{
break;
}
}
total++;
#ifdef DEBUG_STEP
xmlGenericError(xmlGenericErrorContext, " %s", cur->name);
#endif
switch (test) {
case NODE_TEST_NONE:
total = 0;
STRANGE
goto error;
case NODE_TEST_TYPE:
if (type == NODE_TYPE_NODE) {
switch (cur->type) {
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
XP_TEST_HIT
break;
case XML_NAMESPACE_DECL: {
if (axis == AXIS_NAMESPACE) {
XP_TEST_HIT_NS
} else {
hasNsNodes = 1;
XP_TEST_HIT
}
break;
}
default:
break;
}
} else if (cur->type == (xmlElementType) type) {
if (cur->type == XML_NAMESPACE_DECL)
XP_TEST_HIT_NS
else
XP_TEST_HIT
} else if ((type == NODE_TYPE_TEXT) &&
(cur->type == XML_CDATA_SECTION_NODE))
{
XP_TEST_HIT
}
break;
case NODE_TEST_PI:
if ((cur->type == XML_PI_NODE) &&
((name == NULL) || xmlStrEqual(name, cur->name)))
{
XP_TEST_HIT
}
break;
case NODE_TEST_ALL:
if (axis == AXIS_ATTRIBUTE) {
if (cur->type == XML_ATTRIBUTE_NODE)
{
if (prefix == NULL)
{
XP_TEST_HIT
} else if ((cur->ns != NULL) &&
(xmlStrEqual(URI, cur->ns->href)))
{
XP_TEST_HIT
}
}
} else if (axis == AXIS_NAMESPACE) {
if (cur->type == XML_NAMESPACE_DECL)
{
XP_TEST_HIT_NS
}
} else {
if (cur->type == XML_ELEMENT_NODE) {
if (prefix == NULL)
{
XP_TEST_HIT
} else if ((cur->ns != NULL) &&
(xmlStrEqual(URI, cur->ns->href)))
{
XP_TEST_HIT
}
}
}
break;
case NODE_TEST_NS:{
TODO;
break;
}
case NODE_TEST_NAME:
if (axis == AXIS_ATTRIBUTE) {
if (cur->type != XML_ATTRIBUTE_NODE)
break;
} else if (axis == AXIS_NAMESPACE) {
if (cur->type != XML_NAMESPACE_DECL)
break;
} else {
if (cur->type != XML_ELEMENT_NODE)
break;
}
switch (cur->type) {
case XML_ELEMENT_NODE:
if (xmlStrEqual(name, cur->name)) {
if (prefix == NULL) {
if (cur->ns == NULL)
{
XP_TEST_HIT
}
} else {
if ((cur->ns != NULL) &&
(xmlStrEqual(URI, cur->ns->href)))
{
XP_TEST_HIT
}
}
}
break;
case XML_ATTRIBUTE_NODE:{
xmlAttrPtr attr = (xmlAttrPtr) cur;
if (xmlStrEqual(name, attr->name)) {
if (prefix == NULL) {
if ((attr->ns == NULL) ||
(attr->ns->prefix == NULL))
{
XP_TEST_HIT
}
} else {
if ((attr->ns != NULL) &&
(xmlStrEqual(URI,
attr->ns->href)))
{
XP_TEST_HIT
}
}
}
break;
}
case XML_NAMESPACE_DECL:
if (cur->type == XML_NAMESPACE_DECL) {
xmlNsPtr ns = (xmlNsPtr) cur;
if ((ns->prefix != NULL) && (name != NULL)
&& (xmlStrEqual(ns->prefix, name)))
{
XP_TEST_HIT_NS
}
}
break;
default:
break;
}
break;
} /* switch(test) */
} while ((cur != NULL) && (ctxt->error == XPATH_EXPRESSION_OK));
goto apply_predicates;
axis_range_end: /* ----------------------------------------------------- */
/*
* We have a "/foo[n]", and position() = n was reached.
* Note that we can have as well "/foo/::parent::foo[1]", so
* a duplicate-aware merge is still needed.
* Merge with the result.
*/
if (outSeq == NULL) {
outSeq = seq;
seq = NULL;
} else
outSeq = mergeAndClear(outSeq, seq, 0);
/*
* Break if only a true/false result was requested.
*/
if (toBool)
break;
continue;
first_hit: /* ---------------------------------------------------------- */
/*
* Break if only a true/false result was requested and
* no predicates existed and a node test succeeded.
*/
if (outSeq == NULL) {
outSeq = seq;
seq = NULL;
} else
outSeq = mergeAndClear(outSeq, seq, 0);
break;
#ifdef DEBUG_STEP
if (seq != NULL)
nbMatches += seq->nodeNr;
#endif
apply_predicates: /* --------------------------------------------------- */
if (ctxt->error != XPATH_EXPRESSION_OK)
goto error;
/*
* Apply predicates.
*/
if ((predOp != NULL) && (seq->nodeNr > 0)) {
/*
* E.g. when we have a "/foo[some expression][n]".
*/
/*
* QUESTION TODO: The old predicate evaluation took into
* account location-sets.
* (E.g. ctxt->value->type == XPATH_LOCATIONSET)
* Do we expect such a set here?
* All what I learned now from the evaluation semantics
* does not indicate that a location-set will be processed
* here, so this looks OK.
*/
/*
* Iterate over all predicates, starting with the outermost
* predicate.
* TODO: Problem: we cannot execute the inner predicates first
* since we cannot go back *up* the operator tree!
* Options we have:
* 1) Use of recursive functions (like is it currently done
* via xmlXPathCompOpEval())
* 2) Add a predicate evaluation information stack to the
* context struct
* 3) Change the way the operators are linked; we need a
* "parent" field on xmlXPathStepOp
*
* For the moment, I'll try to solve this with a recursive
* function: xmlXPathCompOpEvalPredicate().
*/
size = seq->nodeNr;
if (hasPredicateRange != 0)
newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,
predOp, seq, size, maxPos, maxPos, hasNsNodes);
else
newSize = xmlXPathCompOpEvalPredicate(ctxt,
predOp, seq, size, hasNsNodes);
if (ctxt->error != XPATH_EXPRESSION_OK) {
total = 0;
goto error;
}
/*
* Add the filtered set of nodes to the result node set.
*/
if (newSize == 0) {
/*
* The predicates filtered all nodes out.
*/
xmlXPathNodeSetClear(seq, hasNsNodes);
} else if (seq->nodeNr > 0) {
/*
* Add to result set.
*/
if (outSeq == NULL) {
if (size != newSize) {
/*
* We need to merge and clear here, since
* the sequence will contained NULLed entries.
*/
outSeq = mergeAndClear(NULL, seq, 1);
} else {
outSeq = seq;
seq = NULL;
}
} else
outSeq = mergeAndClear(outSeq, seq,
(size != newSize) ? 1: 0);
/*
* Break if only a true/false result was requested.
*/
if (toBool)
break;
}
} else if (seq->nodeNr > 0) {
/*
* Add to result set.
*/
if (outSeq == NULL) {
outSeq = seq;
seq = NULL;
} else {
outSeq = mergeAndClear(outSeq, seq, 0);
}
}
}
error:
if ((obj->boolval) && (obj->user != NULL)) {
/*
* QUESTION TODO: What does this do and why?
* TODO: Do we have to do this also for the "error"
* cleanup further down?
*/
ctxt->value->boolval = 1;
ctxt->value->user = obj->user;
obj->user = NULL;
obj->boolval = 0;
}
xmlXPathReleaseObject(xpctxt, obj);
/*
* Ensure we return at least an emtpy set.
*/
if (outSeq == NULL) {
if ((seq != NULL) && (seq->nodeNr == 0))
outSeq = seq;
else
outSeq = xmlXPathNodeSetCreate(NULL);
/* XXX what if xmlXPathNodeSetCreate returned NULL here? */
}
if ((seq != NULL) && (seq != outSeq)) {
xmlXPathFreeNodeSet(seq);
}
/*
* Hand over the result. Better to push the set also in
* case of errors.
*/
valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq));
/*
* Reset the context node.
*/
xpctxt->node = oldContextNode;
/*
* When traversing the namespace axis in "toBool" mode, it's
* possible that tmpNsList wasn't freed.
*/
if (xpctxt->tmpNsList != NULL) {
xmlFree(xpctxt->tmpNsList);
xpctxt->tmpNsList = NULL;
}
#ifdef DEBUG_STEP
xmlGenericError(xmlGenericErrorContext,
"\nExamined %d nodes, found %d nodes at that step\n",
total, nbMatches);
#endif
| 0 |
Chrome | d926098e2e2be270c80a5ba25ab8a611b80b8556 | NOT_APPLICABLE | NOT_APPLICABLE | uint32 RenderViewTest::GetNavigationIPCType() {
return FrameHostMsg_DidCommitProvisionalLoad::ID;
}
| 0 |
libconfuse | d73777c2c3566fb2647727bb56d9a2295b81669b | NOT_APPLICABLE | NOT_APPLICABLE | static cfg_opt_t *cfg_getopt_leaf(cfg_t *cfg, const char *name)
{
unsigned int i;
for (i = 0; cfg->opts && cfg->opts[i].name; i++) {
if (is_set(CFGF_NOCASE, cfg->flags)) {
if (strcasecmp(cfg->opts[i].name, name) == 0)
return &cfg->opts[i];
} else {
if (strcmp(cfg->opts[i].name, name) == 0)
return &cfg->opts[i];
}
}
return NULL;
} | 0 |
Chrome | 2400ef7b592c31c9883fd1cd60bdea0622e69db3 | NOT_APPLICABLE | NOT_APPLICABLE | bool SerializedScriptValue::containsTransferableArrayBuffer() const
{
return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty();
}
| 0 |
savannah | 18a8f0d9943369449bc4de92d411c78fb08d616c | NOT_APPLICABLE | NOT_APPLICABLE | lookup_lwfn_by_fond( const UInt8* path_fond,
ConstStr255Param base_lwfn,
UInt8* path_lwfn,
size_t path_size )
{
FSRef ref, par_ref;
size_t dirname_len;
/* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
/* We should not extract parent directory by string manipulation. */
if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
return FT_THROW( Invalid_Argument );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, &par_ref ) )
return FT_THROW( Invalid_Argument );
if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
return FT_THROW( Invalid_Argument );
if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
return FT_THROW( Invalid_Argument );
/* now we have absolute dirname in path_lwfn */
ft_strcat( (char *)path_lwfn, "/" );
dirname_len = ft_strlen( (char *)path_lwfn );
ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
path_lwfn[dirname_len + base_lwfn[0]] = '\0';
if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
return FT_THROW( Cannot_Open_Resource );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, NULL ) )
return FT_THROW( Cannot_Open_Resource );
return FT_Err_Ok;
}
| 0 |
server | c05fd700970ad45735caed3a6f9930d4ce19a3bd | NOT_APPLICABLE | NOT_APPLICABLE | bool sys_var_pluginvar::session_update(THD *thd, set_var *var)
{
DBUG_ASSERT(!is_readonly());
DBUG_ASSERT(plugin_var->flags & PLUGIN_VAR_THDLOCAL);
DBUG_ASSERT(thd == current_thd);
mysql_mutex_lock(&LOCK_global_system_variables);
void *tgt= real_value_ptr(thd, OPT_SESSION);
const void *src= var->value ? (void*)&var->save_result
: (void*)real_value_ptr(thd, OPT_GLOBAL);
mysql_mutex_unlock(&LOCK_global_system_variables);
plugin_var->update(thd, plugin_var, tgt, src);
return false;
} | 0 |
Chrome | f85a87ec670ad0fce9d98d90c9a705b72a288154 | CVE-2014-1713 | CWE-399 | static void locationAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TestObjectPython* proxyImp = V8TestObjectPython::toNative(info.Holder());
TestNode* imp = WTF::getPtr(proxyImp->location());
if (!imp)
return;
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
imp->setHref(cppValue);
}
| 1 |
curl | 9069838b30fb3b48af0123e39f664cea683254a5 | NOT_APPLICABLE | NOT_APPLICABLE | Curl_sec_end(struct connectdata *conn)
{
if(conn->mech != NULL && conn->mech->end)
conn->mech->end(conn->app_data);
free(conn->app_data);
conn->app_data = NULL;
if(conn->in_buffer.data) {
free(conn->in_buffer.data);
conn->in_buffer.data = NULL;
conn->in_buffer.size = 0;
conn->in_buffer.index = 0;
conn->in_buffer.eof_flag = 0;
}
conn->sec_complete = 0;
conn->data_prot = PROT_CLEAR;
conn->mech = NULL;
} | 0 |
Chrome | 697cd7e2ce2535696f1b9e5cfb474cc36a734747 | NOT_APPLICABLE | NOT_APPLICABLE | bool Extension::HasEffectiveAccessToAllHosts(
const URLPatternSet& effective_host_permissions,
const std::set<std::string>& api_permissions) {
const URLPatternList patterns = effective_host_permissions.patterns();
for (URLPatternList::const_iterator host = patterns.begin();
host != patterns.end(); ++host) {
if (host->match_all_urls() ||
(host->match_subdomains() && host->host().empty()))
return true;
}
return false;
}
| 0 |
pjproject | 560a1346f87aabe126509bb24930106dea292b00 | NOT_APPLICABLE | NOT_APPLICABLE | PJ_DEF(pj_status_t) pjmedia_sdp_media_add_attr( pjmedia_sdp_media *m,
pjmedia_sdp_attr *attr)
{
return pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr);
} | 0 |
Chrome | f85a87ec670ad0fce9d98d90c9a705b72a288154 | NOT_APPLICABLE | NOT_APPLICABLE | static void nullableStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
bool isNull = false;
String jsValue = imp->nullableStringAttribute(isNull);
if (isNull) {
v8SetReturnValueNull(info);
return;
}
v8SetReturnValueString(info, jsValue, info.GetIsolate());
}
| 0 |
openmpt | 927688ddab43c2b203569de79407a899e734fabe | NOT_APPLICABLE | NOT_APPLICABLE | LIBOPENMPT_MODPLUG_API void ModPlug_UnloadMixerCallback(ModPlugFile* file)
{
if(!file) return;
file->mixerproc = NULL;
if(file->mixerbuf){
free(file->mixerbuf);
file->mixerbuf = NULL;
}
}
| 0 |
linux | 27ae357fa82be5ab73b2ef8d39dcb8ca2563483a | NOT_APPLICABLE | NOT_APPLICABLE | int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long addr, int new_below)
{
struct vm_area_struct *new;
int err;
if (vma->vm_ops && vma->vm_ops->split) {
err = vma->vm_ops->split(vma, addr);
if (err)
return err;
}
new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
if (!new)
return -ENOMEM;
/* most fields are the same, copy all, and then fixup */
*new = *vma;
INIT_LIST_HEAD(&new->anon_vma_chain);
if (new_below)
new->vm_end = addr;
else {
new->vm_start = addr;
new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
}
err = vma_dup_policy(vma, new);
if (err)
goto out_free_vma;
err = anon_vma_clone(new, vma);
if (err)
goto out_free_mpol;
if (new->vm_file)
get_file(new->vm_file);
if (new->vm_ops && new->vm_ops->open)
new->vm_ops->open(new);
if (new_below)
err = vma_adjust(vma, addr, vma->vm_end, vma->vm_pgoff +
((addr - new->vm_start) >> PAGE_SHIFT), new);
else
err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
/* Success. */
if (!err)
return 0;
/* Clean everything up if vma_adjust failed. */
if (new->vm_ops && new->vm_ops->close)
new->vm_ops->close(new);
if (new->vm_file)
fput(new->vm_file);
unlink_anon_vmas(new);
out_free_mpol:
mpol_put(vma_policy(new));
out_free_vma:
kmem_cache_free(vm_area_cachep, new);
return err;
} | 0 |
qemu | 3de46e6fc489c52c9431a8a832ad8170a7569bd8 | NOT_APPLICABLE | NOT_APPLICABLE | e1000_flush_queue_timer(void *opaque)
{
E1000State *s = opaque;
qemu_flush_queued_packets(qemu_get_queue(s->nic));
} | 0 |
Chrome | b2dfe7c175fb21263f06eb586f1ed235482a3281 | NOT_APPLICABLE | NOT_APPLICABLE | Eina_Bool ewk_frame_feed_focus_in(Evas_Object* ewkFrame)
{
EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, false);
WebCore::FocusController* focusController = smartData->frame->page()->focusController();
focusController->setFocusedFrame(smartData->frame);
return true;
}
| 0 |
php | 4435b9142ff9813845d5c97ab29a5d637bedb257 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_METHOD(domdocument, registerNodeClass)
{
zval *id;
xmlDoc *docp;
char *baseclass = NULL, *extendedclass = NULL;
int baseclass_len = 0, extendedclass_len = 0;
zend_class_entry *basece = NULL, *ce = NULL;
dom_object *intern;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss!", &id, dom_document_class_entry, &baseclass, &baseclass_len, &extendedclass, &extendedclass_len) == FAILURE) {
return;
}
if (baseclass_len) {
zend_class_entry **pce;
if (zend_lookup_class(baseclass, baseclass_len, &pce TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not exist", baseclass);
return;
}
basece = *pce;
}
if (basece == NULL || ! instanceof_function(basece, dom_node_class_entry TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s is not derived from DOMNode.", baseclass);
return;
}
if (extendedclass_len) {
zend_class_entry **pce;
if (zend_lookup_class(extendedclass, extendedclass_len, &pce TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not exist", extendedclass);
}
ce = *pce;
}
if (ce == NULL || instanceof_function(ce, basece TSRMLS_CC)) {
DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
if (dom_set_doc_classmap(intern->document, basece, ce TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be registered.", extendedclass);
}
RETURN_TRUE;
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s is not derived from %s.", extendedclass, baseclass);
}
RETURN_FALSE;
}
| 0 |
linux | 9f645bcc566a1e9f921bdae7528a01ced5bc3713 | NOT_APPLICABLE | NOT_APPLICABLE | static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
{
unsigned int size_vmode;
unsigned int size_remap;
unsigned int size_total;
struct uvesafb_par *par = info->par;
int i, h;
info->pseudo_palette = ((u8 *)info->par + sizeof(struct uvesafb_par));
info->fix = uvesafb_fix;
info->fix.ypanstep = par->ypan ? 1 : 0;
info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
/* Disable blanking if the user requested so. */
if (!blank)
info->fbops->fb_blank = NULL;
/*
* Find out how much IO memory is required for the mode with
* the highest resolution.
*/
size_remap = 0;
for (i = 0; i < par->vbe_modes_cnt; i++) {
h = par->vbe_modes[i].bytes_per_scan_line *
par->vbe_modes[i].y_res;
if (h > size_remap)
size_remap = h;
}
size_remap *= 2;
/*
* size_vmode -- that is the amount of memory needed for the
* used video mode, i.e. the minimum amount of
* memory we need.
*/
size_vmode = info->var.yres * mode->bytes_per_scan_line;
/*
* size_total -- all video memory we have. Used for mtrr
* entries, resource allocation and bounds
* checking.
*/
size_total = par->vbe_ib.total_memory * 65536;
if (vram_total)
size_total = vram_total * 1024 * 1024;
if (size_total < size_vmode)
size_total = size_vmode;
/*
* size_remap -- the amount of video memory we are going to
* use for vesafb. With modern cards it is no
* option to simply use size_total as th
* wastes plenty of kernel address space.
*/
if (vram_remap)
size_remap = vram_remap * 1024 * 1024;
if (size_remap < size_vmode)
size_remap = size_vmode;
if (size_remap > size_total)
size_remap = size_total;
info->fix.smem_len = size_remap;
info->fix.smem_start = mode->phys_base_ptr;
/*
* We have to set yres_virtual here because when setup_var() was
* called, smem_len wasn't defined yet.
*/
info->var.yres_virtual = info->fix.smem_len /
mode->bytes_per_scan_line;
if (par->ypan && info->var.yres_virtual > info->var.yres) {
pr_info("scrolling: %s using protected mode interface, yres_virtual=%d\n",
(par->ypan > 1) ? "ywrap" : "ypan",
info->var.yres_virtual);
} else {
pr_info("scrolling: redraw\n");
info->var.yres_virtual = info->var.yres;
par->ypan = 0;
}
info->flags = FBINFO_FLAG_DEFAULT |
(par->ypan ? FBINFO_HWACCEL_YPAN : 0);
if (!par->ypan)
info->fbops->fb_pan_display = NULL;
}
| 0 |
tensorflow | efea03b38fb8d3b81762237dc85e579cc5fc6e87 | NOT_APPLICABLE | NOT_APPLICABLE | void Compute(OpKernelContext* context) override {
const Tensor& x = context->input(0);
const Tensor& y = context->input(1);
auto& min_x_tensor = context->input(2);
OP_REQUIRES(context, TensorShapeUtils::IsScalar(min_x_tensor.shape()),
errors::InvalidArgument("min_x must be a scalar"));
const float min_x = min_x_tensor.flat<float>()(0);
auto& max_x_tensor = context->input(3);
OP_REQUIRES(context, TensorShapeUtils::IsScalar(max_x_tensor.shape()),
errors::InvalidArgument("max_x must be a scalar"));
const float max_x = max_x_tensor.flat<float>()(0);
auto& min_y_tensor = context->input(4);
OP_REQUIRES(context, TensorShapeUtils::IsScalar(min_y_tensor.shape()),
errors::InvalidArgument("min_y must be a scalar"));
const float min_y = min_y_tensor.flat<float>()(0);
auto& max_y_tensor = context->input(5);
OP_REQUIRES(context, TensorShapeUtils::IsScalar(max_y_tensor.shape()),
errors::InvalidArgument("max_y must be a scalar"));
const float max_y = max_y_tensor.flat<float>()(0);
BCast bcast(BCast::FromShape(x.shape()), BCast::FromShape(y.shape()));
if (!bcast.IsValid()) {
context->SetStatus(errors::InvalidArgument(
"Incompatible shapes: ", x.shape().DebugString(), " vs. ",
y.shape().DebugString()));
return;
}
Tensor* z;
OP_REQUIRES_OK(context, context->allocate_output(
0, BCast::ToShape(bcast.output_shape()), &z));
// Make sure that we have valid quantization ranges for the input buffers.
// If the difference between the min and max is negative or zero, it makes
// it hard to do meaningful intermediate operations on the values.
OP_REQUIRES(context, (max_x > min_x),
errors::InvalidArgument("max_x must be larger than min_a."));
OP_REQUIRES(context, (max_y > min_y),
errors::InvalidArgument("max_x must be larger than min_b."));
const int32 offset_x = FloatToQuantizedUnclamped<T>(0.0f, min_x, max_x);
const int32 offset_y = FloatToQuantizedUnclamped<T>(0.0f, min_y, max_y);
const T* x_data = x.flat<T>().data();
const T* y_data = y.flat<T>().data();
Toutput* z_data = z->flat<Toutput>().data();
const int ndims = bcast.x_reshape().size();
if (ndims <= 1) {
if (x.NumElements() == 1) {
ScalarMultiply<T, Toutput>(context, y_data, offset_y, y.NumElements(),
x_data[0], offset_x, z_data);
} else if (y.NumElements() == 1) {
ScalarMultiply<T, Toutput>(context, x_data, offset_x, x.NumElements(),
y_data[0], offset_y, z_data);
} else {
VectorMultiply<T, Toutput>(context, x_data, offset_x, y_data, offset_y,
x.NumElements(), z_data);
}
} else if (ndims == 2) {
const T* vector_data;
int64 vector_num_elements;
int32 vector_offset;
const T* tensor_data;
int64 tensor_num_elements;
int32 tensor_offset;
if (x.NumElements() < y.NumElements()) {
vector_data = x_data;
vector_num_elements = x.NumElements();
vector_offset = offset_x;
tensor_data = y_data;
tensor_num_elements = y.NumElements();
tensor_offset = offset_y;
} else {
vector_data = y_data;
vector_num_elements = y.NumElements();
vector_offset = offset_y;
tensor_data = x_data;
tensor_num_elements = x.NumElements();
tensor_offset = offset_x;
}
if (vector_num_elements == 0) {
context->SetStatus(
errors::InvalidArgument("vector must have at least 1 element"));
return;
}
VectorTensorMultiply<T, Toutput>(
vector_data, vector_offset, vector_num_elements, tensor_data,
tensor_offset, tensor_num_elements, z_data);
} else {
LOG(INFO) << "ndims=" << ndims;
LOG(INFO) << "bcast.x_reshape()="
<< TensorShape(bcast.x_reshape()).DebugString();
LOG(INFO) << "bcast.y_reshape()="
<< TensorShape(bcast.y_reshape()).DebugString();
LOG(INFO) << "bcast.x_bcast()="
<< TensorShape(bcast.x_bcast()).DebugString();
LOG(INFO) << "bcast.y_bcast()="
<< TensorShape(bcast.y_bcast()).DebugString();
context->SetStatus(errors::Unimplemented(
"Broadcast between ", context->input(0).shape().DebugString(),
" and ", context->input(1).shape().DebugString(),
" is not supported yet."));
return;
}
float min_z_value;
float max_z_value;
QuantizationRangeForMultiplication<T, T, Toutput>(
min_x, max_x, min_y, max_y, &min_z_value, &max_z_value);
Tensor* z_min = nullptr;
OP_REQUIRES_OK(context, context->allocate_output(1, {}, &z_min));
z_min->flat<float>()(0) = min_z_value;
Tensor* z_max = nullptr;
OP_REQUIRES_OK(context, context->allocate_output(2, {}, &z_max));
z_max->flat<float>()(0) = max_z_value;
} | 0 |
libplist | 7a28a14cf6ed547dfd2e52a4db17f47242bfdef9 | NOT_APPLICABLE | NOT_APPLICABLE | static void write_array(bytearray_t * bplist, node_t* node, hashtable_t* ref_table, uint8_t dict_param_size)
{
uint64_t idx = 0;
uint8_t *buff = NULL;
node_t* cur = NULL;
uint64_t i = 0;
uint64_t size = node_n_children(node);
uint8_t marker = BPLIST_ARRAY | (size < 15 ? size : 0xf);
byte_array_append(bplist, &marker, sizeof(uint8_t));
if (size >= 15)
{
bytearray_t *int_buff = byte_array_new();
write_int(int_buff, size);
byte_array_append(bplist, int_buff->data, int_buff->len);
byte_array_free(int_buff);
}
buff = (uint8_t *) malloc(size * dict_param_size);
for (i = 0, cur = node_first_child(node); cur && i < size; cur = node_next_sibling(cur), i++)
{
idx = *(uint64_t *) (hash_table_lookup(ref_table, cur));
#ifdef __BIG_ENDIAN__
idx = idx << ((sizeof(uint64_t) - dict_param_size) * 8);
#endif
memcpy(buff + i * dict_param_size, &idx, dict_param_size);
byte_convert(buff + i * dict_param_size, dict_param_size);
}
//now append to bplist
byte_array_append(bplist, buff, size * dict_param_size);
free(buff);
} | 0 |
Chrome | 783c28d59c4c748ef9b787d4717882c90c5b227b | NOT_APPLICABLE | NOT_APPLICABLE | double ScriptProcessorHandler::LatencyTime() const {
return std::numeric_limits<double>::infinity();
}
| 0 |
libtasn1 | 5520704d075802df25ce4ffccc010ba1641bd484 | NOT_APPLICABLE | NOT_APPLICABLE | _asn1_type_set_config (asn1_node node)
{
asn1_node p, p2;
int move;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if (type_field (p->type) == ASN1_ETYPE_SET)
{
p2 = p->down;
while (p2)
{
if (type_field (p2->type) != ASN1_ETYPE_TAG)
p2->type |= CONST_SET | CONST_NOT_USED;
p2 = p2->right;
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p && p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_find_up (p);
}
return ASN1_SUCCESS;
} | 0 |
jabberd2 | 8416ae54ecefa670534f27a31db71d048b9c7f16 | NOT_APPLICABLE | NOT_APPLICABLE | static void _sx_sasl_free(sx_t s, sx_plugin_t p) {
Gsasl_session *sd = (Gsasl_session *) s->plugin_data[p->index];
_sx_sasl_sess_t sctx;
if(sd == NULL)
return;
_sx_debug(ZONE, "cleaning up conn state");
/* we need to clean up our per session context but keep sasl ctx */
sctx = gsasl_session_hook_get(sd);
if (sctx != NULL){
free(sctx);
gsasl_session_hook_set(sd, (void *) NULL);
}
gsasl_finish(sd);
s->plugin_data[p->index] = NULL;
}
| 0 |
linux | 983d8e60f50806f90534cc5373d0ce867e5aaf79 | NOT_APPLICABLE | NOT_APPLICABLE | xfs_fs_eofblocks_from_user(
struct xfs_fs_eofblocks *src,
struct xfs_icwalk *dst)
{
if (src->eof_version != XFS_EOFBLOCKS_VERSION)
return -EINVAL;
if (src->eof_flags & ~XFS_EOF_FLAGS_VALID)
return -EINVAL;
if (memchr_inv(&src->pad32, 0, sizeof(src->pad32)) ||
memchr_inv(src->pad64, 0, sizeof(src->pad64)))
return -EINVAL;
dst->icw_flags = 0;
if (src->eof_flags & XFS_EOF_FLAGS_SYNC)
dst->icw_flags |= XFS_ICWALK_FLAG_SYNC;
if (src->eof_flags & XFS_EOF_FLAGS_UID)
dst->icw_flags |= XFS_ICWALK_FLAG_UID;
if (src->eof_flags & XFS_EOF_FLAGS_GID)
dst->icw_flags |= XFS_ICWALK_FLAG_GID;
if (src->eof_flags & XFS_EOF_FLAGS_PRID)
dst->icw_flags |= XFS_ICWALK_FLAG_PRID;
if (src->eof_flags & XFS_EOF_FLAGS_MINFILESIZE)
dst->icw_flags |= XFS_ICWALK_FLAG_MINFILESIZE;
dst->icw_prid = src->eof_prid;
dst->icw_min_file_size = src->eof_min_file_size;
dst->icw_uid = INVALID_UID;
if (src->eof_flags & XFS_EOF_FLAGS_UID) {
dst->icw_uid = make_kuid(current_user_ns(), src->eof_uid);
if (!uid_valid(dst->icw_uid))
return -EINVAL;
}
dst->icw_gid = INVALID_GID;
if (src->eof_flags & XFS_EOF_FLAGS_GID) {
dst->icw_gid = make_kgid(current_user_ns(), src->eof_gid);
if (!gid_valid(dst->icw_gid))
return -EINVAL;
}
return 0;
} | 0 |
Android | a24543157ae2cdd25da43e20f4e48a07481e6ceb | NOT_APPLICABLE | NOT_APPLICABLE | static void ReconfigureImpl(Handle<JSObject> object,
Handle<FixedArrayBase> store, uint32_t entry,
Handle<Object> value,
PropertyAttributes attributes) {
SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(*store);
if (attributes != NONE) object->RequireSlowElements(dictionary);
dictionary->ValueAtPut(entry, *value);
PropertyDetails details = dictionary->DetailsAt(entry);
details = PropertyDetails(kData, attributes, details.dictionary_index(),
PropertyCellType::kNoCell);
dictionary->DetailsAtPut(entry, details);
}
| 0 |
squidclamav | 80f74451f628264d1d9a1f1c0bbcebc932ba5e00 | NOT_APPLICABLE | NOT_APPLICABLE | void cfgreload_command(char *name, int type, char **argv)
{
ci_debug_printf(1, "DEBUG cfgreload_command: reload configuration command received\n");
free_global();
free_pipe();
debug = 0;
statit = 0;
pattc = 0;
current_pattern_size = 0;
maxsize = 0;
logredir = 0;
dnslookup = 1;
clamd_curr_ip = (char *) malloc (sizeof (char) * 128);
memset(clamd_curr_ip, 0, sizeof(clamd_curr_ip));
if (load_patterns() == 0)
ci_debug_printf(0, "FATAL cfgreload_command: reload configuration command failed!\n");
if (squidclamav_xdata)
set_istag(squidclamav_xdata);
if (squidguard != NULL) {
ci_debug_printf(1, "DEBUG cfgreload_command: reopening pipe to %s\n", squidguard);
create_pipe(squidguard);
}
} | 0 |
Chrome | ff4330a2ca6bf69d24f9f9fb6f12dc81387b205a | NOT_APPLICABLE | NOT_APPLICABLE | void AdjustNavigateParamsForURL(browser::NavigateParams* params) {
if (!params->target_contents &&
browser::IsURLAllowedInIncognito(params->url)) {
Profile* profile =
params->browser ? params->browser->profile() : params->profile;
if ((profile->IsOffTheRecord() && !Profile::IsGuestSession()) ||
params->disposition == OFF_THE_RECORD) {
profile = profile->GetOriginalProfile();
params->disposition = SINGLETON_TAB;
params->profile = profile;
params->browser = Browser::GetOrCreateTabbedBrowser(profile);
params->window_action = browser::NavigateParams::SHOW_WINDOW;
}
}
}
| 0 |
ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | NOT_APPLICABLE | NOT_APPLICABLE | NCURSES_SP_NAME(_nc_mvcur_wrap) (NCURSES_SP_DCL0)
/* wrap up cursor-addressing mode */
{
/* leave cursor at screen bottom */
TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0);
if (!SP_PARM || !IsTermInfo(SP_PARM))
return;
/* set cursor to normal mode */
if (SP_PARM->_cursor != -1) {
int cursor = SP_PARM->_cursor;
NCURSES_SP_NAME(curs_set) (NCURSES_SP_ARGx 1);
SP_PARM->_cursor = cursor;
}
if (exit_ca_mode) {
NCURSES_PUTP2("exit_ca_mode", exit_ca_mode);
}
/*
* Reset terminal's tab counter. There's a long-time bug that
* if you exit a "curses" program such as vi or more, tab
* forward, and then backspace, the cursor doesn't go to the
* right place. The problem is that the kernel counts the
* escape sequences that reset things as column positions.
* Utter a \r to reset this invisibly.
*/
NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx '\r');
} | 0 |
FFmpeg | 6e42ccb9dbc13836cd52cda594f819d17af9afa2 | NOT_APPLICABLE | NOT_APPLICABLE | static av_always_inline float flt16_even(float pf)
{
union av_intfloat32 tmp;
tmp.f = pf;
tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
return tmp.f;
} | 0 |
linux | 1fd819ecb90cc9b822cd84d3056ddba315d3340f | NOT_APPLICABLE | NOT_APPLICABLE | struct sk_buff *skb_segment(struct sk_buff *head_skb,
netdev_features_t features)
{
struct sk_buff *segs = NULL;
struct sk_buff *tail = NULL;
struct sk_buff *list_skb = skb_shinfo(head_skb)->frag_list;
skb_frag_t *frag = skb_shinfo(head_skb)->frags;
unsigned int mss = skb_shinfo(head_skb)->gso_size;
unsigned int doffset = head_skb->data - skb_mac_header(head_skb);
struct sk_buff *frag_skb = head_skb;
unsigned int offset = doffset;
unsigned int tnl_hlen = skb_tnl_header_len(head_skb);
unsigned int headroom;
unsigned int len;
__be16 proto;
bool csum;
int sg = !!(features & NETIF_F_SG);
int nfrags = skb_shinfo(head_skb)->nr_frags;
int err = -ENOMEM;
int i = 0;
int pos;
proto = skb_network_protocol(head_skb);
if (unlikely(!proto))
return ERR_PTR(-EINVAL);
csum = !!can_checksum_protocol(features, proto);
__skb_push(head_skb, doffset);
headroom = skb_headroom(head_skb);
pos = skb_headlen(head_skb);
do {
struct sk_buff *nskb;
skb_frag_t *nskb_frag;
int hsize;
int size;
len = head_skb->len - offset;
if (len > mss)
len = mss;
hsize = skb_headlen(head_skb) - offset;
if (hsize < 0)
hsize = 0;
if (hsize > len || !sg)
hsize = len;
if (!hsize && i >= nfrags && skb_headlen(list_skb) &&
(skb_headlen(list_skb) == len || sg)) {
BUG_ON(skb_headlen(list_skb) > len);
i = 0;
nfrags = skb_shinfo(list_skb)->nr_frags;
frag = skb_shinfo(list_skb)->frags;
frag_skb = list_skb;
pos += skb_headlen(list_skb);
while (pos < offset + len) {
BUG_ON(i >= nfrags);
size = skb_frag_size(frag);
if (pos + size > offset + len)
break;
i++;
pos += size;
frag++;
}
nskb = skb_clone(list_skb, GFP_ATOMIC);
list_skb = list_skb->next;
if (unlikely(!nskb))
goto err;
if (unlikely(pskb_trim(nskb, len))) {
kfree_skb(nskb);
goto err;
}
hsize = skb_end_offset(nskb);
if (skb_cow_head(nskb, doffset + headroom)) {
kfree_skb(nskb);
goto err;
}
nskb->truesize += skb_end_offset(nskb) - hsize;
skb_release_head_state(nskb);
__skb_push(nskb, doffset);
} else {
nskb = __alloc_skb(hsize + doffset + headroom,
GFP_ATOMIC, skb_alloc_rx_flag(head_skb),
NUMA_NO_NODE);
if (unlikely(!nskb))
goto err;
skb_reserve(nskb, headroom);
__skb_put(nskb, doffset);
}
if (segs)
tail->next = nskb;
else
segs = nskb;
tail = nskb;
__copy_skb_header(nskb, head_skb);
nskb->mac_len = head_skb->mac_len;
skb_headers_offset_update(nskb, skb_headroom(nskb) - headroom);
skb_copy_from_linear_data_offset(head_skb, -tnl_hlen,
nskb->data - tnl_hlen,
doffset + tnl_hlen);
if (nskb->len == len + doffset)
goto perform_csum_check;
if (!sg) {
nskb->ip_summed = CHECKSUM_NONE;
nskb->csum = skb_copy_and_csum_bits(head_skb, offset,
skb_put(nskb, len),
len, 0);
continue;
}
nskb_frag = skb_shinfo(nskb)->frags;
skb_copy_from_linear_data_offset(head_skb, offset,
skb_put(nskb, hsize), hsize);
skb_shinfo(nskb)->tx_flags = skb_shinfo(head_skb)->tx_flags &
SKBTX_SHARED_FRAG;
while (pos < offset + len) {
if (i >= nfrags) {
BUG_ON(skb_headlen(list_skb));
i = 0;
nfrags = skb_shinfo(list_skb)->nr_frags;
frag = skb_shinfo(list_skb)->frags;
frag_skb = list_skb;
BUG_ON(!nfrags);
list_skb = list_skb->next;
}
if (unlikely(skb_shinfo(nskb)->nr_frags >=
MAX_SKB_FRAGS)) {
net_warn_ratelimited(
"skb_segment: too many frags: %u %u\n",
pos, mss);
goto err;
}
if (unlikely(skb_orphan_frags(frag_skb, GFP_ATOMIC)))
goto err;
*nskb_frag = *frag;
__skb_frag_ref(nskb_frag);
size = skb_frag_size(nskb_frag);
if (pos < offset) {
nskb_frag->page_offset += offset - pos;
skb_frag_size_sub(nskb_frag, offset - pos);
}
skb_shinfo(nskb)->nr_frags++;
if (pos + size <= offset + len) {
i++;
frag++;
pos += size;
} else {
skb_frag_size_sub(nskb_frag, pos + size - (offset + len));
goto skip_fraglist;
}
nskb_frag++;
}
skip_fraglist:
nskb->data_len = len - hsize;
nskb->len += nskb->data_len;
nskb->truesize += nskb->data_len;
perform_csum_check:
if (!csum) {
nskb->csum = skb_checksum(nskb, doffset,
nskb->len - doffset, 0);
nskb->ip_summed = CHECKSUM_NONE;
}
} while ((offset += len) < head_skb->len);
return segs;
err:
kfree_skb_list(segs);
return ERR_PTR(err);
}
| 0 |
Chrome | e34e01b1b0987e418bc22e3ef1cf2e4ecaead264 | NOT_APPLICABLE | NOT_APPLICABLE | void RendererSchedulerImpl::CreateTraceEventObjectSnapshot() const {
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug"),
"RendererScheduler", this, AsValue(helper_.NowTicks()));
}
| 0 |
zlib | eff308af425b67093bab25f80f1ae950166bece1 | NOT_APPLICABLE | NOT_APPLICABLE | int ZEXPORT inflatePrime(strm, bits, value)
z_streamp strm;
int bits;
int value;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (bits < 0) {
state->hold = 0;
state->bits = 0;
return Z_OK;
}
if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
state->hold += (unsigned)value << state->bits;
state->bits += (uInt)bits;
return Z_OK;
} | 0 |
FFmpeg | 95556e27e2c1d56d9e18f5db34d6f756f3011148 | CVE-2018-13300 | CWE-125 | static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
{
AC3HeaderInfo *hdr = NULL;
struct eac3_info *info;
int num_blocks, ret;
if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info))))
return AVERROR(ENOMEM);
info = track->eac3_priv;
if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) < 0) {
/* drop the packets until we see a good one */
if (!track->entry) {
av_log(mov, AV_LOG_WARNING, "Dropping invalid packet from start of the stream\n");
ret = 0;
} else
ret = AVERROR_INVALIDDATA;
goto end;
}
info->data_rate = FFMAX(info->data_rate, hdr->bit_rate / 1000);
num_blocks = hdr->num_blocks;
if (!info->ec3_done) {
/* AC-3 substream must be the first one */
if (hdr->bitstream_id <= 10 && hdr->substreamid != 0) {
ret = AVERROR(EINVAL);
goto end;
}
/* this should always be the case, given that our AC-3 parser
* concatenates dependent frames to their independent parent */
if (hdr->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
/* substream ids must be incremental */
if (hdr->substreamid > info->num_ind_sub + 1) {
ret = AVERROR(EINVAL);
goto end;
}
if (hdr->substreamid == info->num_ind_sub + 1) {
avpriv_request_sample(track->par, "Multiple independent substreams");
ret = AVERROR_PATCHWELCOME;
goto end;
} else if (hdr->substreamid < info->num_ind_sub ||
hdr->substreamid == 0 && info->substream[0].bsid) {
info->ec3_done = 1;
goto concatenate;
}
} else {
if (hdr->substreamid != 0) {
avpriv_request_sample(mov->fc, "Multiple non EAC3 independent substreams");
ret = AVERROR_PATCHWELCOME;
goto end;
}
}
/* fill the info needed for the "dec3" atom */
info->substream[hdr->substreamid].fscod = hdr->sr_code;
info->substream[hdr->substreamid].bsid = hdr->bitstream_id;
info->substream[hdr->substreamid].bsmod = hdr->bitstream_mode;
info->substream[hdr->substreamid].acmod = hdr->channel_mode;
info->substream[hdr->substreamid].lfeon = hdr->lfe_on;
/* Parse dependent substream(s), if any */
if (pkt->size != hdr->frame_size) {
int cumul_size = hdr->frame_size;
int parent = hdr->substreamid;
while (cumul_size != pkt->size) {
GetBitContext gbc;
int i;
ret = avpriv_ac3_parse_header(&hdr, pkt->data + cumul_size, pkt->size - cumul_size);
if (ret < 0)
goto end;
if (hdr->frame_type != EAC3_FRAME_TYPE_DEPENDENT) {
ret = AVERROR(EINVAL);
goto end;
}
info->substream[parent].num_dep_sub++;
ret /= 8;
/* header is parsed up to lfeon, but custom channel map may be needed */
init_get_bits8(&gbc, pkt->data + cumul_size + ret, pkt->size - cumul_size - ret);
/* skip bsid */
skip_bits(&gbc, 5);
/* skip volume control params */
for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {
skip_bits(&gbc, 5); // skip dialog normalization
if (get_bits1(&gbc)) {
skip_bits(&gbc, 8); // skip compression gain word
}
}
/* get the dependent stream channel map, if exists */
if (get_bits1(&gbc))
info->substream[parent].chan_loc |= (get_bits(&gbc, 16) >> 5) & 0x1f;
else
info->substream[parent].chan_loc |= hdr->channel_mode;
cumul_size += hdr->frame_size;
}
}
}
concatenate:
if (!info->num_blocks && num_blocks == 6) {
ret = pkt->size;
goto end;
}
else if (info->num_blocks + num_blocks > 6) {
ret = AVERROR_INVALIDDATA;
goto end;
}
if (!info->num_blocks) {
ret = av_packet_ref(&info->pkt, pkt);
if (!ret)
info->num_blocks = num_blocks;
goto end;
} else {
if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0)
goto end;
memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, pkt->size);
info->num_blocks += num_blocks;
info->pkt.duration += pkt->duration;
if ((ret = av_copy_packet_side_data(&info->pkt, pkt)) < 0)
goto end;
if (info->num_blocks != 6)
goto end;
av_packet_unref(pkt);
av_packet_move_ref(pkt, &info->pkt);
info->num_blocks = 0;
}
ret = pkt->size;
end:
av_free(hdr);
return ret;
}
| 1 |
gnome-bluetooth | 6b5086d42ea64d46277f3c93b43984f331d12f89 | NOT_APPLICABLE | NOT_APPLICABLE | connect_callback (GDBusProxy *proxy,
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
gboolean retval;
GError *error = NULL;
retval = device1_call_connect_finish (DEVICE1(proxy), res, &error);
if (retval == FALSE) {
g_debug ("Connect failed for %s: %s",
g_dbus_proxy_get_object_path (proxy), error->message);
g_simple_async_result_take_error (simple, error);
} else {
g_debug ("Connect succeeded for %s",
g_dbus_proxy_get_object_path (proxy));
g_simple_async_result_set_op_res_gboolean (simple, retval);
}
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
} | 0 |
linux | 04f25edb48c441fc278ecc154c270f16966cbb90 | NOT_APPLICABLE | NOT_APPLICABLE | static int hclge_tm_schd_info_init(struct hclge_dev *hdev)
{
if ((hdev->tx_sch_mode != HCLGE_FLAG_TC_BASE_SCH_MODE) &&
(hdev->tm_info.num_pg != 1))
return -EINVAL;
hclge_tm_pg_info_init(hdev);
hclge_tm_tc_info_init(hdev);
hclge_tm_vport_info_update(hdev);
hclge_pfc_info_init(hdev);
return 0;
} | 0 |
busybox | 352f79acbd759c14399e39baef21fc4ffe180ac2 | NOT_APPLICABLE | NOT_APPLICABLE | static char *allocate_tempopt_if_needed(
const struct dhcp_optflag *optflag,
char *buffer,
int *length_p)
{
char *allocated = NULL;
if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_BIN) {
const char *end;
allocated = xstrdup(buffer); /* more than enough */
end = hex2bin(allocated, buffer, 255);
if (errno)
bb_error_msg_and_die("malformed hex string '%s'", buffer);
*length_p = end - allocated;
}
return allocated;
}
| 0 |
qcad | 1eeffc5daf5a06cf6213ffc19e95923cdebb2eb8 | NOT_APPLICABLE | NOT_APPLICABLE | bool DL_Dxf::handleMTextData(DL_CreationInterface* creationInterface) {
// Special handling of text chunks for MTEXT entities:
if (groupCode==3) {
creationInterface->addMTextChunk(groupValue);
return true;
}
return false;
} | 0 |
linux | cae13fe4cc3f24820ffb990c09110626837e85d4 | NOT_APPLICABLE | NOT_APPLICABLE | static bool ldm_validate_privheads(struct parsed_partitions *state,
struct privhead *ph1)
{
static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 };
struct privhead *ph[3] = { ph1 };
Sector sect;
u8 *data;
bool result = false;
long num_sects;
int i;
BUG_ON (!state || !ph1);
ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
if (!ph[1] || !ph[2]) {
ldm_crit ("Out of memory.");
goto out;
}
/* off[1 & 2] are relative to ph[0]->config_start */
ph[0]->config_start = 0;
/* Read and parse privheads */
for (i = 0; i < 3; i++) {
data = read_part_sector(state, ph[0]->config_start + off[i],
§);
if (!data) {
ldm_crit ("Disk read failed.");
goto out;
}
result = ldm_parse_privhead (data, ph[i]);
put_dev_sector (sect);
if (!result) {
ldm_error ("Cannot find PRIVHEAD %d.", i+1); /* Log again */
if (i < 2)
goto out; /* Already logged */
else
break; /* FIXME ignore for now, 3rd PH can fail on odd-sized disks */
}
}
num_sects = state->bdev->bd_inode->i_size >> 9;
if ((ph[0]->config_start > num_sects) ||
((ph[0]->config_start + ph[0]->config_size) > num_sects)) {
ldm_crit ("Database extends beyond the end of the disk.");
goto out;
}
if ((ph[0]->logical_disk_start > ph[0]->config_start) ||
((ph[0]->logical_disk_start + ph[0]->logical_disk_size)
> ph[0]->config_start)) {
ldm_crit ("Disk and database overlap.");
goto out;
}
if (!ldm_compare_privheads (ph[0], ph[1])) {
ldm_crit ("Primary and backup PRIVHEADs don't match.");
goto out;
}
/* FIXME ignore this for now
if (!ldm_compare_privheads (ph[0], ph[2])) {
ldm_crit ("Primary and backup PRIVHEADs don't match.");
goto out;
}*/
ldm_debug ("Validated PRIVHEADs successfully.");
result = true;
out:
kfree (ph[1]);
kfree (ph[2]);
return result;
}
| 0 |
Chrome | 20a9e39a925dd0fb183acb61bb7b87f29abea83f | NOT_APPLICABLE | NOT_APPLICABLE | void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) {
auto it = tracing_uis_.find(tracing_ui);
DCHECK(it != tracing_uis_.end());
tracing_uis_.erase(it);
}
| 0 |
openssl | 4924b37ee01f71ae19c94a8934b80eeb2f677932 | NOT_APPLICABLE | NOT_APPLICABLE | int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
BN_CTX *ctx)
{
int i, ret = 0;
BIGNUM *s;
bn_check_top(a);
BN_CTX_start(ctx);
if ((s = BN_CTX_get(ctx)) == NULL)
return 0;
if (!bn_wexpand(s, 2 * a->top))
goto err;
for (i = a->top - 1; i >= 0; i--) {
s->d[2 * i + 1] = SQR1(a->d[i]);
s->d[2 * i] = SQR0(a->d[i]);
}
s->top = 2 * a->top;
bn_correct_top(s);
if (!BN_GF2m_mod_arr(r, s, p))
goto err;
bn_check_top(r);
ret = 1;
err:
BN_CTX_end(ctx);
return ret;
}
| 0 |
vim | b55986c52d4cd88a22d0b0b0e8a79547ba13e1d5 | NOT_APPLICABLE | NOT_APPLICABLE | restore_subexpr(regbehind_T *bp)
{
int i;
// Only need to restore saved values when they are not to be cleared.
rex.need_clear_subexpr = bp->save_need_clear_subexpr;
if (!rex.need_clear_subexpr)
{
for (i = 0; i < NSUBEXP; ++i)
{
if (REG_MULTI)
{
rex.reg_startpos[i] = bp->save_start[i].se_u.pos;
rex.reg_endpos[i] = bp->save_end[i].se_u.pos;
}
else
{
rex.reg_startp[i] = bp->save_start[i].se_u.ptr;
rex.reg_endp[i] = bp->save_end[i].se_u.ptr;
}
}
}
} | 0 |
linux | 5872331b3d91820e14716632ebb56b1399b34fe1 | NOT_APPLICABLE | NOT_APPLICABLE | static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
struct inode *inode)
{
struct inode *dir = d_inode(dentry->d_parent);
struct buffer_head *bh = NULL;
struct ext4_dir_entry_2 *de;
struct super_block *sb;
#ifdef CONFIG_UNICODE
struct ext4_sb_info *sbi;
#endif
struct ext4_filename fname;
int retval;
int dx_fallback=0;
unsigned blocksize;
ext4_lblk_t block, blocks;
int csum_size = 0;
if (ext4_has_metadata_csum(inode->i_sb))
csum_size = sizeof(struct ext4_dir_entry_tail);
sb = dir->i_sb;
blocksize = sb->s_blocksize;
if (!dentry->d_name.len)
return -EINVAL;
#ifdef CONFIG_UNICODE
sbi = EXT4_SB(sb);
if (ext4_has_strict_mode(sbi) && IS_CASEFOLDED(dir) &&
sbi->s_encoding && utf8_validate(sbi->s_encoding, &dentry->d_name))
return -EINVAL;
#endif
retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname);
if (retval)
return retval;
if (ext4_has_inline_data(dir)) {
retval = ext4_try_add_inline_entry(handle, &fname, dir, inode);
if (retval < 0)
goto out;
if (retval == 1) {
retval = 0;
goto out;
}
}
if (is_dx(dir)) {
retval = ext4_dx_add_entry(handle, &fname, dir, inode);
if (!retval || (retval != ERR_BAD_DX_DIR))
goto out;
/* Can we just ignore htree data? */
if (ext4_has_metadata_csum(sb)) {
EXT4_ERROR_INODE(dir,
"Directory has corrupted htree index.");
retval = -EFSCORRUPTED;
goto out;
}
ext4_clear_inode_flag(dir, EXT4_INODE_INDEX);
dx_fallback++;
retval = ext4_mark_inode_dirty(handle, dir);
if (unlikely(retval))
goto out;
}
blocks = dir->i_size >> sb->s_blocksize_bits;
for (block = 0; block < blocks; block++) {
bh = ext4_read_dirblock(dir, block, DIRENT);
if (bh == NULL) {
bh = ext4_bread(handle, dir, block,
EXT4_GET_BLOCKS_CREATE);
goto add_to_new_block;
}
if (IS_ERR(bh)) {
retval = PTR_ERR(bh);
bh = NULL;
goto out;
}
retval = add_dirent_to_buf(handle, &fname, dir, inode,
NULL, bh);
if (retval != -ENOSPC)
goto out;
if (blocks == 1 && !dx_fallback &&
ext4_has_feature_dir_index(sb)) {
retval = make_indexed_dir(handle, &fname, dir,
inode, bh);
bh = NULL; /* make_indexed_dir releases bh */
goto out;
}
brelse(bh);
}
bh = ext4_append(handle, dir, &block);
add_to_new_block:
if (IS_ERR(bh)) {
retval = PTR_ERR(bh);
bh = NULL;
goto out;
}
de = (struct ext4_dir_entry_2 *) bh->b_data;
de->inode = 0;
de->rec_len = ext4_rec_len_to_disk(blocksize - csum_size, blocksize);
if (csum_size)
ext4_initialize_dirent_tail(bh, blocksize);
retval = add_dirent_to_buf(handle, &fname, dir, inode, de, bh);
out:
ext4_fname_free_filename(&fname);
brelse(bh);
if (retval == 0)
ext4_set_inode_state(inode, EXT4_STATE_NEWENTRY);
return retval;
} | 0 |
linux | f43bfaeddc79effbf3d0fcb53ca477cca66f3db8 | NOT_APPLICABLE | NOT_APPLICABLE | static int atl2_get_regs_len(struct net_device *netdev)
{
#define ATL2_REGS_LEN 42
return sizeof(u32) * ATL2_REGS_LEN;
}
| 0 |
Espruino | a0d7f432abee692402c00e8b615ff5982dde9780 | NOT_APPLICABLE | NOT_APPLICABLE | void vcbprintf(
vcbprintf_callback user_callback, //!< Unknown
void *user_data, //!< Unknown
const char *fmt, //!< The format specified
va_list argp //!< List of parameter values
) {
char buf[32];
while (*fmt) {
if (*fmt == '%') {
fmt++;
char fmtChar = *fmt++;
switch (fmtChar) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
const char *pad = " ";
if (fmtChar=='0') {
pad = "0";
fmtChar = *fmt++;
}
int digits = fmtChar - '0';
int v = va_arg(argp, int);
if (*fmt=='x') itostr_extra(v, buf, false, 16);
else { assert('d' == *fmt); itostr(v, buf, 10); }
fmt++; // skip over 'd'
int len = (int)strlen(buf);
while (len < digits) {
user_callback(pad,user_data);
len++;
}
user_callback(buf,user_data);
break;
}
case 'd': itostr(va_arg(argp, int), buf, 10); user_callback(buf,user_data); break;
case 'x': itostr_extra(va_arg(argp, int), buf, false, 16); user_callback(buf,user_data); break;
case 'L': {
unsigned int rad = 10;
bool signedVal = true;
if (*fmt=='x') { rad=16; fmt++; signedVal = false; }
itostr_extra(va_arg(argp, JsVarInt), buf, signedVal, rad); user_callback(buf,user_data);
} break;
case 'f': ftoa_bounded(va_arg(argp, JsVarFloat), buf, sizeof(buf)); user_callback(buf,user_data); break;
case 's': user_callback(va_arg(argp, char *), user_data); break;
case 'c': buf[0]=(char)va_arg(argp, int/*char*/);buf[1]=0; user_callback(buf, user_data); break;
case 'q':
case 'v': {
bool quoted = fmtChar=='q';
if (quoted) user_callback("\"",user_data);
JsVar *v = jsvAsString(va_arg(argp, JsVar*), false/*no unlock*/);
buf[1] = 0;
if (jsvIsString(v)) {
JsvStringIterator it;
jsvStringIteratorNew(&it, v, 0);
while (jsvStringIteratorHasChar(&it)) {
buf[0] = jsvStringIteratorGetChar(&it);
if (quoted) {
user_callback(escapeCharacter(buf[0]), user_data);
} else {
user_callback(buf,user_data);
}
jsvStringIteratorNext(&it);
}
jsvStringIteratorFree(&it);
jsvUnLock(v);
}
if (quoted) user_callback("\"",user_data);
} break;
case 'j': {
JsVar *v = va_arg(argp, JsVar*);
jsfGetJSONWithCallback(v, JSON_SOME_NEWLINES | JSON_PRETTY | JSON_SHOW_DEVICES, 0, user_callback, user_data);
break;
}
case 't': {
JsVar *v = va_arg(argp, JsVar*);
const char *n = jsvIsNull(v)?"null":jswGetBasicObjectName(v);
if (!n) n = jsvGetTypeOf(v);
user_callback(n, user_data);
break;
}
case 'p': jshGetPinString(buf, (Pin)va_arg(argp, int/*Pin*/)); user_callback(buf, user_data); break;
default: assert(0); return; // eep
}
} else {
buf[0] = *(fmt++);
buf[1] = 0;
user_callback(&buf[0], user_data);
}
}
}
| 0 |
ovs | 65c61b0c23a0d474696d7b1cea522a5016a8aeb3 | NOT_APPLICABLE | NOT_APPLICABLE | format_SET_IPV4_SRC(const struct ofpact_ipv4 *a,
const struct ofpact_format_params *fp)
{
ds_put_format(fp->s, "%smod_nw_src:%s"IP_FMT,
colors.param, colors.end, IP_ARGS(a->ipv4));
} | 0 |
Chrome | adca986a53b31b6da4cb22f8e755f6856daea89a | NOT_APPLICABLE | NOT_APPLICABLE | void InterstitialPageImpl::CreateNewFullscreenWidget(int32_t render_process_id,
int32_t route_id) {
NOTREACHED()
<< "InterstitialPage does not support showing full screen popups.";
}
| 0 |
gst-plugins-good | d0949baf3dadea6021d54abef6802fed5a06af75 | NOT_APPLICABLE | NOT_APPLICABLE | qtdemux_tag_add_tmpo (GstQTDemux * qtdemux, GstTagList * taglist,
const char *tag1, const char *dummy, GNode * node)
{
GNode *data;
int len;
int type;
int n1;
data = qtdemux_tree_get_child_by_type (node, FOURCC_data);
if (data) {
len = QT_UINT32 (data->data);
type = QT_UINT32 ((guint8 *) data->data + 8);
GST_DEBUG_OBJECT (qtdemux, "have tempo tag, type=%d,len=%d", type, len);
/* some files wrongly have a type 0x0f=15, but it should be 0x15 */
if ((type == 0x00000015 || type == 0x0000000f) && len >= 18) {
n1 = QT_UINT16 ((guint8 *) data->data + 16);
if (n1) {
/* do not add bpm=0 */
GST_DEBUG_OBJECT (qtdemux, "adding tag %d", n1);
gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, tag1, (gdouble) n1,
NULL);
}
}
}
} | 0 |
linux-stable | 0c461cb727d146c9ef2d3e86214f498b78b7d125 | NOT_APPLICABLE | NOT_APPLICABLE | static int selinux_socket_getsockopt(struct socket *sock, int level,
int optname)
{
return sock_has_perm(current, sock->sk, SOCKET__GETOPT);
} | 0 |
tcpdump | 3ed82f4ed0095768529afc22b923c8f7171fff70 | CVE-2015-3138 | CWE-20 | wb_prep(netdissect_options *ndo,
const struct pkt_prep *prep, u_int len)
{
int n;
const struct pgstate *ps;
const u_char *ep = ndo->ndo_snapend;
ND_PRINT((ndo, " wb-prep:"));
if (len < sizeof(*prep)) {
return (-1);
}
n = EXTRACT_32BITS(&prep->pp_n);
ps = (const struct pgstate *)(prep + 1);
while (--n >= 0 && !ND_TTEST(*ps)) {
const struct id_off *io, *ie;
char c = '<';
ND_PRINT((ndo, " %u/%s:%u",
EXTRACT_32BITS(&ps->slot),
ipaddr_string(ndo, &ps->page.p_sid),
EXTRACT_32BITS(&ps->page.p_uid)));
io = (struct id_off *)(ps + 1);
for (ie = io + ps->nid; io < ie && !ND_TTEST(*io); ++io) {
ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id),
EXTRACT_32BITS(&io->off)));
c = ',';
}
ND_PRINT((ndo, ">"));
ps = (struct pgstate *)io;
}
return ((u_char *)ps <= ep? 0 : -1);
}
| 1 |
miniupnp | f321c2066b96d18afa5158dfa2d2873a2957ef38 | NOT_APPLICABLE | NOT_APPLICABLE | upnp_get_portmappings_in_range(unsigned short startport,
unsigned short endport,
const char * protocol,
unsigned int * number)
{
int proto;
proto = proto_atoi(protocol);
if(!number)
return NULL;
return get_portmappings_in_range(startport, endport, proto, number);
}
| 0 |
ghostscript | 83d4dae44c71816c084a635550acc1a51529b881 | NOT_APPLICABLE | NOT_APPLICABLE | fz_keep_colorspace_context(fz_context *ctx)
{
if (!ctx)
return NULL;
return fz_keep_imp(ctx, ctx->colorspace, &ctx->colorspace->ctx_refs);
}
| 0 |
php | 2cc4e69cc6d8dbc4b3568ad3dd583324a7c11d64 | NOT_APPLICABLE | NOT_APPLICABLE | static int _rollback_transactions(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
PGconn *link;
PGresult *res;
int orig;
if (Z_TYPE_P(rsrc) != le_plink)
return 0;
link = (PGconn *) rsrc->ptr;
if (PQ_SETNONBLOCKING(link, 0)) {
php_error_docref("ref.pgsql" TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
return -1;
}
while ((res = PQgetResult(link))) {
PQclear(res);
}
#if HAVE_PGTRANSACTIONSTATUS && HAVE_PQPROTOCOLVERSION
if ((PQprotocolVersion(link) >= 3 && PQtransactionStatus(link) != PQTRANS_IDLE) || PQprotocolVersion(link) < 3)
#endif
{
orig = PGG(ignore_notices);
PGG(ignore_notices) = 1;
#if HAVE_PGTRANSACTIONSTATUS && HAVE_PQPROTOCOLVERSION
res = PQexec(link,"ROLLBACK;");
#else
res = PQexec(link,"BEGIN;");
PQclear(res);
res = PQexec(link,"ROLLBACK;");
#endif
PQclear(res);
PGG(ignore_notices) = orig;
}
return 0;
}
| 0 |
CImg | 10af1e8c1ad2a58a0a3342a856bae63e8f257abb | NOT_APPLICABLE | NOT_APPLICABLE |
static double mp_srand0(_cimg_math_parser& mp) {
cimg::unused(mp);
return cimg::srand(); | 0 |
savannah | 3fcd042d26d70856e826a42b5f93dc4854d80bf0 | NOT_APPLICABLE | NOT_APPLICABLE | re_patch (void)
{
p_first = 0;
p_newfirst = 0;
p_ptrn_lines = 0;
p_repl_lines = 0;
p_end = -1;
p_max = 0;
p_indent = 0;
p_strip_trailing_cr = false;
}
| 0 |
linux | fda4e2e85589191b123d31cdc21fd33ee70f50fd | NOT_APPLICABLE | NOT_APPLICABLE | static void shared_msr_update(unsigned slot, u32 msr)
{
u64 value;
unsigned int cpu = smp_processor_id();
struct kvm_shared_msrs *smsr = per_cpu_ptr(shared_msrs, cpu);
/* only read, and nobody should modify it at this time,
* so don't need lock */
if (slot >= shared_msrs_global.nr) {
printk(KERN_ERR "kvm: invalid MSR slot!");
return;
}
rdmsrl_safe(msr, &value);
smsr->values[slot].host = value;
smsr->values[slot].curr = value;
}
| 0 |
linux | bc3aae2bbac46dd894c89db5d5e98f7f0ef9e205 | NOT_APPLICABLE | NOT_APPLICABLE | static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
__be32 daddr, const bool do_cache)
{
bool ret = false;
spin_lock_bh(&fnhe_lock);
if (daddr == fnhe->fnhe_daddr) {
struct rtable __rcu **porig;
struct rtable *orig;
int genid = fnhe_genid(dev_net(rt->dst.dev));
if (rt_is_input_route(rt))
porig = &fnhe->fnhe_rth_input;
else
porig = &fnhe->fnhe_rth_output;
orig = rcu_dereference(*porig);
if (fnhe->fnhe_genid != genid) {
fnhe->fnhe_genid = genid;
fnhe->fnhe_gw = 0;
fnhe->fnhe_pmtu = 0;
fnhe->fnhe_expires = 0;
fnhe_flush_routes(fnhe);
orig = NULL;
}
fill_route_from_fnhe(rt, fnhe);
if (!rt->rt_gateway)
rt->rt_gateway = daddr;
if (do_cache) {
dst_hold(&rt->dst);
rcu_assign_pointer(*porig, rt);
if (orig) {
dst_dev_put(&orig->dst);
dst_release(&orig->dst);
}
ret = true;
}
fnhe->fnhe_stamp = jiffies;
}
spin_unlock_bh(&fnhe_lock);
return ret;
}
| 0 |
Subsets and Splits