project
stringclasses 791
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 127
values | func
stringlengths 5
484k
| vul
int8 0
1
|
---|---|---|---|---|---|
Chrome | bc1f34b9be509f1404f0bb1ba1947614d5f0bcd1 | NOT_APPLICABLE | NOT_APPLICABLE | void ServiceManagerConnectionImpl::AddEmbeddedService(
const std::string& name,
const service_manager::EmbeddedServiceInfo& info) {
context_->AddEmbeddedService(name, info);
}
| 0 |
Chrome | fea16c8b60ff3d0756d5eb392394963b647bc41a | NOT_APPLICABLE | NOT_APPLICABLE | bool ContentSecurityPolicy::allowScriptFromSource(
const KURL& url,
const String& nonce,
ParserDisposition parserDisposition,
RedirectStatus redirectStatus,
SecurityViolationReportingPolicy reportingPolicy) const {
if (shouldBypassContentSecurityPolicy(url)) {
UseCounter::count(
document(),
parserDisposition == ParserInserted
? UseCounter::ScriptWithCSPBypassingSchemeParserInserted
: UseCounter::ScriptWithCSPBypassingSchemeNotParserInserted);
}
return isAllowedByAll<&CSPDirectiveList::allowScriptFromSource>(
m_policies, url, nonce, parserDisposition, redirectStatus,
reportingPolicy);
}
| 0 |
server | f0d774d48416bb06063184380b684380ca005a41 | NOT_APPLICABLE | NOT_APPLICABLE | mysql_set_character_set_with_default_collation(MYSQL *mysql)
{
const char *save= charsets_dir;
if (mysql->options.charset_dir)
charsets_dir=mysql->options.charset_dir;
if ((mysql->charset= get_charset_by_csname(mysql->options.charset_name,
MY_CS_PRIMARY, MYF(MY_WME))))
{
/* Try to set compiled default collation when it's possible. */
CHARSET_INFO *collation;
if ((collation=
get_charset_by_name(MYSQL_DEFAULT_COLLATION_NAME, MYF(MY_WME))) &&
my_charset_same(mysql->charset, collation))
{
mysql->charset= collation;
}
else
{
/*
Default compiled collation not found, or is not applicable
to the requested character set.
Continue with the default collation of the character set.
*/
}
}
charsets_dir= save;
} | 0 |
Chrome | 5925dff83699508b5e2735afb0297dfb310e159d | NOT_APPLICABLE | NOT_APPLICABLE | void Browser::GoBack(WindowOpenDisposition disposition) {
UserMetrics::RecordAction(UserMetricsAction("Back"));
TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
if (CanGoBack()) {
TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
if (current_tab->tab_contents()->showing_interstitial_page() &&
(new_tab != current_tab->tab_contents()))
return;
new_tab->controller().GoBack();
}
}
| 0 |
FFmpeg | bab0716c7f4793ec42e05a5aa7e80d82a0dd4e75 | NOT_APPLICABLE | NOT_APPLICABLE | static int find_body_sid_by_offset(MXFContext *mxf, int64_t offset)
{
int a, b, m;
int64_t this_partition;
a = -1;
b = mxf->partitions_count;
while (b - a > 1) {
m = (a + b) >> 1;
this_partition = mxf->partitions[m].this_partition;
if (this_partition <= offset)
a = m;
else
b = m;
}
if (a == -1)
return 0;
return mxf->partitions[a].body_sid;
}
| 0 |
linux | 59c816c1f24df0204e01851431d3bab3eb76719c | NOT_APPLICABLE | NOT_APPLICABLE | static int vhost_scsi_write_pending_status(struct se_cmd *se_cmd)
{
return 0;
}
| 0 |
libvncserver | a6788d1da719ae006605b78d22f5a9f170b423af | NOT_APPLICABLE | NOT_APPLICABLE | void rfbScaledScreenUpdateRect(rfbScreenInfoPtr screen, rfbScreenInfoPtr ptr, int x0, int y0, int w0, int h0)
{
int x,y,w,v,z;
int x1, y1, w1, h1;
int bitsPerPixel, bytesPerPixel, bytesPerLine, areaX, areaY, area2;
unsigned char *srcptr, *dstptr;
/* Nothing to do!!! */
if (screen==ptr) return;
x1 = x0;
y1 = y0;
w1 = w0;
h1 = h0;
rfbScaledCorrection(screen, ptr, &x1, &y1, &w1, &h1, "rfbScaledScreenUpdateRect");
x0 = ScaleX(ptr, screen, x1);
y0 = ScaleY(ptr, screen, y1);
w0 = ScaleX(ptr, screen, w1);
h0 = ScaleY(ptr, screen, h1);
bitsPerPixel = screen->bitsPerPixel;
bytesPerPixel = bitsPerPixel / 8;
bytesPerLine = w1 * bytesPerPixel;
srcptr = (unsigned char *)(screen->frameBuffer +
(y0 * screen->paddedWidthInBytes + x0 * bytesPerPixel));
dstptr = (unsigned char *)(ptr->frameBuffer +
( y1 * ptr->paddedWidthInBytes + x1 * bytesPerPixel));
/* The area of the source framebuffer for each destination pixel */
areaX = ScaleX(ptr,screen,1);
areaY = ScaleY(ptr,screen,1);
area2 = areaX*areaY;
/* Ensure that we do not go out of bounds */
if ((x1+w1) > (ptr->width))
{
if (x1==0) w1=ptr->width; else x1 = ptr->width - w1;
}
if ((y1+h1) > (ptr->height))
{
if (y1==0) h1=ptr->height; else y1 = ptr->height - h1;
}
/*
* rfbLog("rfbScaledScreenUpdateRect(%dXx%dY-%dWx%dH -> %dXx%dY-%dWx%dH <%dx%d>) {%dWx%dH -> %dWx%dH} 0x%p\n",
* x0, y0, w0, h0, x1, y1, w1, h1, areaX, areaY,
* screen->width, screen->height, ptr->width, ptr->height, ptr->frameBuffer);
*/
if (screen->serverFormat.trueColour) { /* Blend neighbouring pixels together */
unsigned char *srcptr2;
unsigned long pixel_value, red, green, blue;
unsigned int redShift = screen->serverFormat.redShift;
unsigned int greenShift = screen->serverFormat.greenShift;
unsigned int blueShift = screen->serverFormat.blueShift;
unsigned long redMax = screen->serverFormat.redMax;
unsigned long greenMax = screen->serverFormat.greenMax;
unsigned long blueMax = screen->serverFormat.blueMax;
/* for each *destination* pixel... */
for (y = 0; y < h1; y++) {
for (x = 0; x < w1; x++) {
red = green = blue = 0;
/* Get the totals for rgb from the source grid... */
for (w = 0; w < areaX; w++) {
for (v = 0; v < areaY; v++) {
srcptr2 = &srcptr[(((x * areaX) + w) * bytesPerPixel) +
(v * screen->paddedWidthInBytes)];
pixel_value = 0;
switch (bytesPerPixel) {
case 4: pixel_value = *((unsigned int *)srcptr2); break;
case 2: pixel_value = *((unsigned short *)srcptr2); break;
case 1: pixel_value = *((unsigned char *)srcptr2); break;
default:
/* fixme: endianness problem? */
for (z = 0; z < bytesPerPixel; z++)
pixel_value += ((unsigned long)srcptr2[z] << (8 * z));
break;
}
/*
srcptr2 += bytesPerPixel;
*/
red += ((pixel_value >> redShift) & redMax);
green += ((pixel_value >> greenShift) & greenMax);
blue += ((pixel_value >> blueShift) & blueMax);
}
}
/* We now have a total for all of the colors, find the average! */
red /= area2;
green /= area2;
blue /= area2;
/* Stuff the new value back into memory */
pixel_value = ((red & redMax) << redShift) | ((green & greenMax) << greenShift) | ((blue & blueMax) << blueShift);
switch (bytesPerPixel) {
case 4: *((unsigned int *)dstptr) = (unsigned int) pixel_value; break;
case 2: *((unsigned short *)dstptr) = (unsigned short) pixel_value; break;
case 1: *((unsigned char *)dstptr) = (unsigned char) pixel_value; break;
default:
/* fixme: endianness problem? */
for (z = 0; z < bytesPerPixel; z++)
dstptr[z]=(pixel_value >> (8 * z)) & 0xff;
break;
}
dstptr += bytesPerPixel;
}
srcptr += (screen->paddedWidthInBytes * areaY);
dstptr += (ptr->paddedWidthInBytes - bytesPerLine);
}
} else
{ /* Not truecolour, so we can't blend. Just use the top-left pixel instead */
for (y = y1; y < (y1+h1); y++) {
for (x = x1; x < (x1+w1); x++)
memcpy (&ptr->frameBuffer[(y *ptr->paddedWidthInBytes) + (x * bytesPerPixel)],
&screen->frameBuffer[(y * areaY * screen->paddedWidthInBytes) + (x *areaX * bytesPerPixel)], bytesPerPixel);
}
}
} | 0 |
lxc | 592fd47a6245508b79fe6ac819fe6d3b2c1289be | NOT_APPLICABLE | NOT_APPLICABLE | static inline bool cgm_enter(void *hdata, pid_t pid)
{
struct cgm_data *d = hdata;
char **slist = subsystems;
bool ret = false;
int i;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (cgm_all_controllers_same)
slist = subsystems_inone;
for (i = 0; slist[i]; i++) {
if (!lxc_cgmanager_enter(pid, slist[i], d->cgroup_path, false))
goto out;
}
ret = true;
out:
cgm_dbus_disconnect();
return ret;
}
| 0 |
linux | f2fcfcd670257236ebf2088bbdf26f6a8ef459fe | NOT_APPLICABLE | NOT_APPLICABLE | static int l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
{
struct l2cap_conn *conn;
BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
if (hcon->type != ACL_LINK)
return 0;
if (!status) {
conn = l2cap_conn_add(hcon, status);
if (conn)
l2cap_conn_ready(conn);
} else
l2cap_conn_del(hcon, bt_err(status));
return 0;
}
| 0 |
Android | 2b4667baa5a2badbdfec1794156ee17d4afef37c | NOT_APPLICABLE | NOT_APPLICABLE | static media_status_t translate_error(status_t err) {
if (err == OK) {
return AMEDIA_OK;
} else if (err == -EAGAIN) {
return (media_status_t) AMEDIACODEC_INFO_TRY_AGAIN_LATER;
}
ALOGE("sf error code: %d", err);
return AMEDIA_ERROR_UNKNOWN;
}
| 0 |
krb5 | 524688ce87a15fc75f87efc8c039ba4c7d5c197b | NOT_APPLICABLE | NOT_APPLICABLE | spnego_gss_context_time(
OM_uint32 *minor_status,
const gss_ctx_id_t context_handle,
OM_uint32 *time_rec)
{
OM_uint32 ret;
ret = gss_context_time(minor_status,
context_handle,
time_rec);
return (ret);
} | 0 |
libetpan | 1fe8fbc032ccda1db9af66d93016b49c16c1f22d | NOT_APPLICABLE | NOT_APPLICABLE | int mailimf_fws_atom_parse(const char * message, size_t length,
size_t * indx, char ** result)
{
size_t cur_token;
int r;
int res;
char * atom;
size_t end;
cur_token = * indx;
r = mailimf_fws_parse(message, length, &cur_token);
if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
res = r;
goto err;
}
end = cur_token;
if (end >= length) {
res = MAILIMF_ERROR_PARSE;
goto err;
}
while (is_atext(message[end])) {
end ++;
if (end >= length)
break;
}
if (end == cur_token) {
res = MAILIMF_ERROR_PARSE;
goto err;
}
atom = malloc(end - cur_token + 1);
if (atom == NULL) {
res = MAILIMF_ERROR_MEMORY;
goto err;
}
strncpy(atom, message + cur_token, end - cur_token);
atom[end - cur_token] = '\0';
cur_token = end;
* indx = cur_token;
* result = atom;
return MAILIMF_NO_ERROR;
err:
return res;
}
| 0 |
virglrenderer | 0a5dff15912207b83018485f83e067474e818bab | NOT_APPLICABLE | NOT_APPLICABLE | static int vrend_decode_create_sub_ctx(struct vrend_decode_ctx *ctx, int length)
{
if (length != 1)
return EINVAL;
uint32_t ctx_sub_id = get_buf_entry(ctx, 1);
vrend_renderer_create_sub_ctx(ctx->grctx, ctx_sub_id);
return 0;
}
| 0 |
linux | 3f190e3aec212fc8c61e202c51400afa7384d4bc | NOT_APPLICABLE | NOT_APPLICABLE | static int cxusb_rc_query(struct dvb_usb_device *d)
{
u8 ircode[4];
cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
if (ircode[2] || ircode[3])
rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN,
RC_SCANCODE_RC5(ircode[2], ircode[3]), 0);
return 0;
}
| 0 |
linux | 4291086b1f081b869c6d79e5b7441633dc3ace00 | NOT_APPLICABLE | NOT_APPLICABLE | static void eraser(unsigned char c, struct tty_struct *tty)
{
struct n_tty_data *ldata = tty->disc_data;
enum { ERASE, WERASE, KILL } kill_type;
size_t head;
size_t cnt;
int seen_alnums;
if (ldata->read_head == ldata->canon_head) {
/* process_output('\a', tty); */ /* what do you think? */
return;
}
if (c == ERASE_CHAR(tty))
kill_type = ERASE;
else if (c == WERASE_CHAR(tty))
kill_type = WERASE;
else {
if (!L_ECHO(tty)) {
ldata->read_head = ldata->canon_head;
return;
}
if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) {
ldata->read_head = ldata->canon_head;
finish_erasing(ldata);
echo_char(KILL_CHAR(tty), tty);
/* Add a newline if ECHOK is on and ECHOKE is off. */
if (L_ECHOK(tty))
echo_char_raw('\n', ldata);
return;
}
kill_type = KILL;
}
seen_alnums = 0;
while (ldata->read_head != ldata->canon_head) {
head = ldata->read_head;
/* erase a single possibly multibyte character */
do {
head--;
c = read_buf(ldata, head);
} while (is_continuation(c, tty) && head != ldata->canon_head);
/* do not partially erase */
if (is_continuation(c, tty))
break;
if (kill_type == WERASE) {
/* Equivalent to BSD's ALTWERASE. */
if (isalnum(c) || c == '_')
seen_alnums++;
else if (seen_alnums)
break;
}
cnt = ldata->read_head - head;
ldata->read_head = head;
if (L_ECHO(tty)) {
if (L_ECHOPRT(tty)) {
if (!ldata->erasing) {
echo_char_raw('\\', ldata);
ldata->erasing = 1;
}
/* if cnt > 1, output a multi-byte character */
echo_char(c, tty);
while (--cnt > 0) {
head++;
echo_char_raw(read_buf(ldata, head), ldata);
echo_move_back_col(ldata);
}
} else if (kill_type == ERASE && !L_ECHOE(tty)) {
echo_char(ERASE_CHAR(tty), tty);
} else if (c == '\t') {
unsigned int num_chars = 0;
int after_tab = 0;
size_t tail = ldata->read_head;
/*
* Count the columns used for characters
* since the start of input or after a
* previous tab.
* This info is used to go back the correct
* number of columns.
*/
while (tail != ldata->canon_head) {
tail--;
c = read_buf(ldata, tail);
if (c == '\t') {
after_tab = 1;
break;
} else if (iscntrl(c)) {
if (L_ECHOCTL(tty))
num_chars += 2;
} else if (!is_continuation(c, tty)) {
num_chars++;
}
}
echo_erase_tab(num_chars, after_tab, ldata);
} else {
if (iscntrl(c) && L_ECHOCTL(tty)) {
echo_char_raw('\b', ldata);
echo_char_raw(' ', ldata);
echo_char_raw('\b', ldata);
}
if (!iscntrl(c) || L_ECHOCTL(tty)) {
echo_char_raw('\b', ldata);
echo_char_raw(' ', ldata);
echo_char_raw('\b', ldata);
}
}
}
if (kill_type == ERASE)
break;
}
if (ldata->read_head == ldata->canon_head && L_ECHO(tty))
finish_erasing(ldata);
}
| 0 |
Chrome | c4a4dfb26615b5ef5e9dcc730ef43f70ce9202e2 | NOT_APPLICABLE | NOT_APPLICABLE | std::string HostToCustomHistogramSuffix(const std::string& host) {
if (host == "mail.google.com")
return ".gmail";
if (host == "docs.google.com" || host == "drive.google.com")
return ".docs";
if (host == "plus.google.com")
return ".plus";
return std::string();
}
| 0 |
linux | 054aa8d439b9185d4f5eb9a90282d1ce74772969 | NOT_APPLICABLE | NOT_APPLICABLE | void do_close_on_exec(struct files_struct *files)
{
unsigned i;
struct fdtable *fdt;
/* exec unshares first */
spin_lock(&files->file_lock);
for (i = 0; ; i++) {
unsigned long set;
unsigned fd = i * BITS_PER_LONG;
fdt = files_fdtable(files);
if (fd >= fdt->max_fds)
break;
set = fdt->close_on_exec[i];
if (!set)
continue;
fdt->close_on_exec[i] = 0;
for ( ; set ; fd++, set >>= 1) {
struct file *file;
if (!(set & 1))
continue;
file = fdt->fd[fd];
if (!file)
continue;
rcu_assign_pointer(fdt->fd[fd], NULL);
__put_unused_fd(files, fd);
spin_unlock(&files->file_lock);
filp_close(file, files);
cond_resched();
spin_lock(&files->file_lock);
}
}
spin_unlock(&files->file_lock);
} | 0 |
exiv2 | c72d16f4c402a8acc2dfe06fe3d58bf6cf99069e | NOT_APPLICABLE | NOT_APPLICABLE | void TiffFinder::visitBinaryElement(TiffBinaryElement* object)
{
findObject(object);
} | 0 |
uzbl | 1958b52d41cba96956dc1995660de49525ed1047 | NOT_APPLICABLE | NOT_APPLICABLE | update_title (void) {
Behaviour *b = &uzbl.behave;
gchar *parsed;
if (b->show_status) {
if (b->title_format_short) {
parsed = expand(b->title_format_short, 0);
if (uzbl.gui.main_window)
gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
g_free(parsed);
}
if (b->status_format) {
parsed = expand(b->status_format, 0);
gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label), parsed);
g_free(parsed);
}
if (b->status_background) {
GdkColor color;
gdk_color_parse (b->status_background, &color);
if (uzbl.gui.main_window)
gtk_widget_modify_bg (uzbl.gui.main_window, GTK_STATE_NORMAL, &color);
else if (uzbl.gui.plug)
gtk_widget_modify_bg (GTK_WIDGET(uzbl.gui.plug), GTK_STATE_NORMAL, &color);
}
} else {
if (b->title_format_long) {
parsed = expand(b->title_format_long, 0);
if (uzbl.gui.main_window)
gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed);
g_free(parsed);
}
}
}
| 0 |
nautilus | 1630f53481f445ada0a455e9979236d31a8d3bb0 | NOT_APPLICABLE | NOT_APPLICABLE | mark_all_files_unconfirmed (NautilusDirectory *directory)
{
GList *node;
NautilusFile *file;
for (node = directory->details->file_list; node != NULL; node = node->next)
{
file = node->data;
set_file_unconfirmed (file, TRUE);
}
}
| 0 |
libtiff | 5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3 | NOT_APPLICABLE | NOT_APPLICABLE | static biasFn *lineSubtractFn (unsigned bits)
{
switch (bits) {
case 8: return subtract8;
case 16: return subtract16;
case 32: return subtract32;
}
return NULL;
}
| 0 |
postgres | b048f558dd7c26a0c630a2cff29d3d8981eaf6b9 | NOT_APPLICABLE | NOT_APPLICABLE | report_name_conflict(Oid classId, const char *name)
{
char *msgfmt;
switch (classId)
{
case EventTriggerRelationId:
msgfmt = gettext_noop("event trigger \"%s\" already exists");
break;
case ForeignDataWrapperRelationId:
msgfmt = gettext_noop("foreign-data wrapper \"%s\" already exists");
break;
case ForeignServerRelationId:
msgfmt = gettext_noop("server \"%s\" already exists");
break;
case LanguageRelationId:
msgfmt = gettext_noop("language \"%s\" already exists");
break;
case PublicationRelationId:
msgfmt = gettext_noop("publication \"%s\" already exists");
break;
case SubscriptionRelationId:
msgfmt = gettext_noop("subscription \"%s\" already exists");
break;
default:
elog(ERROR, "unsupported object class %u", classId);
break;
}
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg(msgfmt, name)));
} | 0 |
php | 777c39f4042327eac4b63c7ee87dc1c7a09a3115 | NOT_APPLICABLE | NOT_APPLICABLE | static size_t zend_shared_alloc_get_largest_free_block(void)
{
int i;
size_t largest_block_size = 0;
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
size_t block_size = ZSMMG(shared_segments)[i]->size - ZSMMG(shared_segments)[i]->pos;
if (block_size>largest_block_size) {
largest_block_size = block_size;
}
}
return largest_block_size;
}
| 0 |
libxml2 | cbb271655cadeb8dbb258a64701d9a3a0c4835b4 | NOT_APPLICABLE | NOT_APPLICABLE | xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
xmlRegStatePtr previous;
int ret;
previous = ctxt->state;
ret = xmlFAParsePiece(ctxt);
if (ret != 0) {
if (xmlFAGenerateTransitions(ctxt, previous,
(CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
return(-1);
previous = ctxt->state;
ctxt->atom = NULL;
}
while ((ret != 0) && (ctxt->error == 0)) {
ret = xmlFAParsePiece(ctxt);
if (ret != 0) {
if (xmlFAGenerateTransitions(ctxt, previous,
(CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
return(-1);
previous = ctxt->state;
ctxt->atom = NULL;
}
}
return(0);
} | 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | template<typename tp, typename tf, typename tc, typename to>
const CImg<T>& _display_object3d(CImgDisplay& disp, const char *const title,
const CImg<tp>& vertices,
const CImgList<tf>& primitives,
const CImgList<tc>& colors,
const to& opacities,
const bool centering,
const int render_static, const int render_motion,
const bool is_double_sided, const float focale,
const float light_x, const float light_y, const float light_z,
const float specular_lightness, const float specular_shininess,
const bool display_axes, float *const pose_matrix,
const bool exit_on_anykey) const {
typedef typename cimg::superset<tp,float>::type tpfloat;
// Check input arguments
if (is_empty()) {
if (disp) return CImg<T>(disp.width(),disp.height(),1,(colors && colors[0].size()==1)?1:3,0).
_display_object3d(disp,title,vertices,primitives,colors,opacities,centering,
render_static,render_motion,is_double_sided,focale,
light_x,light_y,light_z,specular_lightness,specular_shininess,
display_axes,pose_matrix,exit_on_anykey);
else return CImg<T>(1,2,1,1,64,128).resize(cimg_fitscreen(CImgDisplay::screen_width()/2,
CImgDisplay::screen_height()/2,1),
1,(colors && colors[0].size()==1)?1:3,3).
_display_object3d(disp,title,vertices,primitives,colors,opacities,centering,
render_static,render_motion,is_double_sided,focale,
light_x,light_y,light_z,specular_lightness,specular_shininess,
display_axes,pose_matrix,exit_on_anykey);
} else { if (disp) disp.resize(*this,false); }
CImg<charT> error_message(1024);
if (!vertices.is_object3d(primitives,colors,opacities,true,error_message))
throw CImgArgumentException(_cimg_instance
"display_object3d(): Invalid specified 3D object (%u,%u) (%s).",
cimg_instance,vertices._width,primitives._width,error_message.data());
if (vertices._width && !primitives) {
CImgList<tf> nprimitives(vertices._width,1,1,1,1);
cimglist_for(nprimitives,l) nprimitives(l,0) = (tf)l;
return _display_object3d(disp,title,vertices,nprimitives,colors,opacities,centering,
render_static,render_motion,is_double_sided,focale,
light_x,light_y,light_z,specular_lightness,specular_shininess,
display_axes,pose_matrix,exit_on_anykey);
}
if (!disp) {
disp.assign(cimg_fitscreen(_width,_height,_depth),title?title:0,3);
if (!title) disp.set_title("CImg<%s> (%u vertices, %u primitives)",
pixel_type(),vertices._width,primitives._width);
} else if (title) disp.set_title("%s",title);
// Init 3D objects and compute object statistics
CImg<floatT>
pose,
rotated_vertices(vertices._width,3),
bbox_vertices, rotated_bbox_vertices,
axes_vertices, rotated_axes_vertices,
bbox_opacities, axes_opacities;
CImgList<uintT> bbox_primitives, axes_primitives;
CImgList<tf> reverse_primitives;
CImgList<T> bbox_colors, bbox_colors2, axes_colors;
unsigned int ns_width = 0, ns_height = 0;
int _is_double_sided = (int)is_double_sided;
bool ndisplay_axes = display_axes;
const CImg<T>
background_color(1,1,1,_spectrum,0),
foreground_color(1,1,1,_spectrum,(T)std::min((int)cimg::type<T>::max(),255));
float
Xoff = 0, Yoff = 0, Zoff = 0, sprite_scale = 1,
xm = 0, xM = vertices?vertices.get_shared_row(0).max_min(xm):0,
ym = 0, yM = vertices?vertices.get_shared_row(1).max_min(ym):0,
zm = 0, zM = vertices?vertices.get_shared_row(2).max_min(zm):0;
const float delta = cimg::max(xM - xm,yM - ym,zM - zm);
rotated_bbox_vertices = bbox_vertices.assign(8,3,1,1,
xm,xM,xM,xm,xm,xM,xM,xm,
ym,ym,yM,yM,ym,ym,yM,yM,
zm,zm,zm,zm,zM,zM,zM,zM);
bbox_primitives.assign(6,1,4,1,1, 0,3,2,1, 4,5,6,7, 1,2,6,5, 0,4,7,3, 0,1,5,4, 2,3,7,6);
bbox_colors.assign(6,_spectrum,1,1,1,background_color[0]);
bbox_colors2.assign(6,_spectrum,1,1,1,foreground_color[0]);
bbox_opacities.assign(bbox_colors._width,1,1,1,0.3f);
rotated_axes_vertices = axes_vertices.assign(7,3,1,1,
0,20,0,0,22,-6,-6,
0,0,20,0,-6,22,-6,
0,0,0,20,0,0,22);
axes_opacities.assign(3,1,1,1,1);
axes_colors.assign(3,_spectrum,1,1,1,foreground_color[0]);
axes_primitives.assign(3,1,2,1,1, 0,1, 0,2, 0,3);
// Begin user interaction loop
CImg<T> visu0(*this,false), visu;
CImg<tpfloat> zbuffer(visu0.width(),visu0.height(),1,1,0);
bool init_pose = true, clicked = false, redraw = true;
unsigned int key = 0;
int
x0 = 0, y0 = 0, x1 = 0, y1 = 0,
nrender_static = render_static,
nrender_motion = render_motion;
disp.show().flush();
while (!disp.is_closed() && !key) {
// Init object pose
if (init_pose) {
const float
ratio = delta>0?(2.f*std::min(disp.width(),disp.height())/(3.f*delta)):1,
dx = (xM + xm)/2, dy = (yM + ym)/2, dz = (zM + zm)/2;
if (centering)
CImg<floatT>(4,3,1,1, ratio,0.,0.,-ratio*dx, 0.,ratio,0.,-ratio*dy, 0.,0.,ratio,-ratio*dz).move_to(pose);
else CImg<floatT>(4,3,1,1, 1,0,0,0, 0,1,0,0, 0,0,1,0).move_to(pose);
if (pose_matrix) {
CImg<floatT> pose0(pose_matrix,4,3,1,1,false);
pose0.resize(4,4,1,1,0); pose.resize(4,4,1,1,0);
pose0(3,3) = pose(3,3) = 1;
(pose0*pose).get_crop(0,0,3,2).move_to(pose);
Xoff = pose_matrix[12]; Yoff = pose_matrix[13]; Zoff = pose_matrix[14]; sprite_scale = pose_matrix[15];
} else { Xoff = Yoff = Zoff = 0; sprite_scale = 1; }
init_pose = false;
redraw = true;
}
// Rotate and draw 3D object
if (redraw) {
const float
r00 = pose(0,0), r10 = pose(1,0), r20 = pose(2,0), r30 = pose(3,0),
r01 = pose(0,1), r11 = pose(1,1), r21 = pose(2,1), r31 = pose(3,1),
r02 = pose(0,2), r12 = pose(1,2), r22 = pose(2,2), r32 = pose(3,2);
if ((clicked && nrender_motion>=0) || (!clicked && nrender_static>=0))
cimg_forX(vertices,l) {
const float x = (float)vertices(l,0), y = (float)vertices(l,1), z = (float)vertices(l,2);
rotated_vertices(l,0) = r00*x + r10*y + r20*z + r30;
rotated_vertices(l,1) = r01*x + r11*y + r21*z + r31;
rotated_vertices(l,2) = r02*x + r12*y + r22*z + r32;
}
else cimg_forX(bbox_vertices,l) {
const float x = bbox_vertices(l,0), y = bbox_vertices(l,1), z = bbox_vertices(l,2);
rotated_bbox_vertices(l,0) = r00*x + r10*y + r20*z + r30;
rotated_bbox_vertices(l,1) = r01*x + r11*y + r21*z + r31;
rotated_bbox_vertices(l,2) = r02*x + r12*y + r22*z + r32;
}
// Draw objects
const bool render_with_zbuffer = !clicked && nrender_static>0;
visu = visu0;
if ((clicked && nrender_motion<0) || (!clicked && nrender_static<0))
visu.draw_object3d(Xoff + visu._width/2.f,Yoff + visu._height/2.f,Zoff,
rotated_bbox_vertices,bbox_primitives,bbox_colors,bbox_opacities,2,false,focale).
draw_object3d(Xoff + visu._width/2.f,Yoff + visu._height/2.f,Zoff,
rotated_bbox_vertices,bbox_primitives,bbox_colors2,1,false,focale);
else visu._draw_object3d((void*)0,render_with_zbuffer?zbuffer.fill(0):CImg<tpfloat>::empty(),
Xoff + visu._width/2.f,Yoff + visu._height/2.f,Zoff,
rotated_vertices,reverse_primitives?reverse_primitives:primitives,
colors,opacities,clicked?nrender_motion:nrender_static,_is_double_sided==1,focale,
width()/2.f + light_x,height()/2.f + light_y,light_z + Zoff,
specular_lightness,specular_shininess,1,sprite_scale);
// Draw axes
if (ndisplay_axes) {
const float
n = 1e-8f + cimg::hypot(r00,r01,r02),
_r00 = r00/n, _r10 = r10/n, _r20 = r20/n,
_r01 = r01/n, _r11 = r11/n, _r21 = r21/n,
_r02 = r01/n, _r12 = r12/n, _r22 = r22/n,
Xaxes = 25, Yaxes = visu._height - 38.f;
cimg_forX(axes_vertices,l) {
const float
x = axes_vertices(l,0),
y = axes_vertices(l,1),
z = axes_vertices(l,2);
rotated_axes_vertices(l,0) = _r00*x + _r10*y + _r20*z;
rotated_axes_vertices(l,1) = _r01*x + _r11*y + _r21*z;
rotated_axes_vertices(l,2) = _r02*x + _r12*y + _r22*z;
}
axes_opacities(0,0) = (rotated_axes_vertices(1,2)>0)?0.5f:1.f;
axes_opacities(1,0) = (rotated_axes_vertices(2,2)>0)?0.5f:1.f;
axes_opacities(2,0) = (rotated_axes_vertices(3,2)>0)?0.5f:1.f;
visu.draw_object3d(Xaxes,Yaxes,0,rotated_axes_vertices,axes_primitives,
axes_colors,axes_opacities,1,false,focale).
draw_text((int)(Xaxes + rotated_axes_vertices(4,0)),
(int)(Yaxes + rotated_axes_vertices(4,1)),
"X",axes_colors[0]._data,0,axes_opacities(0,0),13).
draw_text((int)(Xaxes + rotated_axes_vertices(5,0)),
(int)(Yaxes + rotated_axes_vertices(5,1)),
"Y",axes_colors[1]._data,0,axes_opacities(1,0),13).
draw_text((int)(Xaxes + rotated_axes_vertices(6,0)),
(int)(Yaxes + rotated_axes_vertices(6,1)),
"Z",axes_colors[2]._data,0,axes_opacities(2,0),13);
}
visu.display(disp);
if (!clicked || nrender_motion==nrender_static) redraw = false;
}
// Handle user interaction
disp.wait();
if ((disp.button() || disp.wheel()) && disp.mouse_x()>=0 && disp.mouse_y()>=0) {
redraw = true;
if (!clicked) { x0 = x1 = disp.mouse_x(); y0 = y1 = disp.mouse_y(); if (!disp.wheel()) clicked = true; }
else { x1 = disp.mouse_x(); y1 = disp.mouse_y(); }
if (disp.button()&1) {
const float
R = 0.45f*std::min(disp.width(),disp.height()),
R2 = R*R,
u0 = (float)(x0 - disp.width()/2),
v0 = (float)(y0 - disp.height()/2),
u1 = (float)(x1 - disp.width()/2),
v1 = (float)(y1 - disp.height()/2),
n0 = cimg::hypot(u0,v0),
n1 = cimg::hypot(u1,v1),
nu0 = n0>R?(u0*R/n0):u0,
nv0 = n0>R?(v0*R/n0):v0,
nw0 = (float)std::sqrt(std::max(0.f,R2 - nu0*nu0 - nv0*nv0)),
nu1 = n1>R?(u1*R/n1):u1,
nv1 = n1>R?(v1*R/n1):v1,
nw1 = (float)std::sqrt(std::max(0.f,R2 - nu1*nu1 - nv1*nv1)),
u = nv0*nw1 - nw0*nv1,
v = nw0*nu1 - nu0*nw1,
w = nv0*nu1 - nu0*nv1,
n = cimg::hypot(u,v,w),
alpha = (float)std::asin(n/R2)*180/cimg::PI;
(CImg<floatT>::rotation_matrix(u,v,w,-alpha)*pose).move_to(pose);
x0 = x1; y0 = y1;
}
if (disp.button()&2) {
if (focale>0) Zoff-=(y0 - y1)*focale/400;
else { const float s = std::exp((y0 - y1)/400.f); pose*=s; sprite_scale*=s; }
x0 = x1; y0 = y1;
}
if (disp.wheel()) {
if (focale>0) Zoff-=disp.wheel()*focale/20;
else { const float s = std::exp(disp.wheel()/20.f); pose*=s; sprite_scale*=s; }
disp.set_wheel();
}
if (disp.button()&4) { Xoff+=(x1 - x0); Yoff+=(y1 - y0); x0 = x1; y0 = y1; }
if ((disp.button()&1) && (disp.button()&2)) {
init_pose = true; disp.set_button(); x0 = x1; y0 = y1;
pose = CImg<floatT>(4,3,1,1, 1,0,0,0, 0,1,0,0, 0,0,1,0);
}
} else if (clicked) { x0 = x1; y0 = y1; clicked = false; redraw = true; }
CImg<charT> filename(32);
switch (key = disp.key()) {
#if cimg_OS!=2
case cimg::keyCTRLRIGHT :
#endif
case 0 : case cimg::keyCTRLLEFT : key = 0; break;
case cimg::keyD: if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) {
disp.set_fullscreen(false).
resize(CImgDisplay::_fitscreen(3*disp.width()/2,3*disp.height()/2,1,128,-100,false),
CImgDisplay::_fitscreen(3*disp.width()/2,3*disp.height()/2,1,128,-100,true),false).
_is_resized = true;
disp.set_key(key,false); key = 0;
} break;
case cimg::keyC : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) {
disp.set_fullscreen(false).
resize(cimg_fitscreen(2*disp.width()/3,2*disp.height()/3,1),false)._is_resized = true;
disp.set_key(key,false); key = 0;
} break;
case cimg::keyR : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) {
disp.set_fullscreen(false).resize(cimg_fitscreen(_width,_height,_depth),false)._is_resized = true;
disp.set_key(key,false); key = 0;
} break;
case cimg::keyF : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) {
if (!ns_width || !ns_height ||
ns_width>(unsigned int)disp.screen_width() || ns_height>(unsigned int)disp.screen_height()) {
ns_width = disp.screen_width()*3U/4;
ns_height = disp.screen_height()*3U/4;
}
if (disp.is_fullscreen()) disp.resize(ns_width,ns_height,false);
else {
ns_width = disp._width; ns_height = disp._height;
disp.resize(disp.screen_width(),disp.screen_height(),false);
}
disp.toggle_fullscreen()._is_resized = true;
disp.set_key(key,false); key = 0;
} break;
case cimg::keyT : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) {
// Switch single/double-sided primitives.
if (--_is_double_sided==-2) _is_double_sided = 1;
if (_is_double_sided>=0) reverse_primitives.assign();
else primitives.get_reverse_object3d().move_to(reverse_primitives);
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyZ : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Enable/disable Z-buffer
if (zbuffer) zbuffer.assign();
else zbuffer.assign(visu0.width(),visu0.height(),1,1,0);
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyX : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Show/hide 3D axes
ndisplay_axes = !ndisplay_axes;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyF1 : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Set rendering mode to points
nrender_motion = (nrender_static==0 && nrender_motion!=0)?0:-1; nrender_static = 0;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyF2 : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Set rendering mode to lines
nrender_motion = (nrender_static==1 && nrender_motion!=1)?1:-1; nrender_static = 1;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyF3 : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Set rendering mode to flat
nrender_motion = (nrender_static==2 && nrender_motion!=2)?2:-1; nrender_static = 2;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyF4 : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Set rendering mode to flat-shaded
nrender_motion = (nrender_static==3 && nrender_motion!=3)?3:-1; nrender_static = 3;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyF5 : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) {
// Set rendering mode to gouraud-shaded.
nrender_motion = (nrender_static==4 && nrender_motion!=4)?4:-1; nrender_static = 4;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyF6 : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Set rendering mode to phong-shaded
nrender_motion = (nrender_static==5 && nrender_motion!=5)?5:-1; nrender_static = 5;
disp.set_key(key,false); key = 0; redraw = true;
} break;
case cimg::keyS : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Save snapshot
static unsigned int snap_number = 0;
std::FILE *file;
do {
cimg_snprintf(filename,filename._width,cimg_appname "_%.4u.bmp",snap_number++);
if ((file=cimg::std_fopen(filename,"r"))!=0) cimg::fclose(file);
} while (file);
(+visu).__draw_text(" Saving snapshot... ",0).display(disp);
visu.save(filename);
(+visu).__draw_text(" Snapshot '%s' saved. ",0,filename._data).display(disp);
disp.set_key(key,false); key = 0;
} break;
case cimg::keyG : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Save object as a .off file
static unsigned int snap_number = 0;
std::FILE *file;
do {
cimg_snprintf(filename,filename._width,cimg_appname "_%.4u.off",snap_number++);
if ((file=cimg::std_fopen(filename,"r"))!=0) cimg::fclose(file);
} while (file);
(+visu).__draw_text(" Saving object... ",0).display(disp);
vertices.save_off(reverse_primitives?reverse_primitives:primitives,colors,filename);
(+visu).__draw_text(" Object '%s' saved. ",0,filename._data).display(disp);
disp.set_key(key,false); key = 0;
} break;
case cimg::keyO : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Save object as a .cimg file
static unsigned int snap_number = 0;
std::FILE *file;
do {
#ifdef cimg_use_zlib
cimg_snprintf(filename,filename._width,cimg_appname "_%.4u.cimgz",snap_number++);
#else
cimg_snprintf(filename,filename._width,cimg_appname "_%.4u.cimg",snap_number++);
#endif
if ((file=cimg::std_fopen(filename,"r"))!=0) cimg::fclose(file);
} while (file);
(+visu).__draw_text(" Saving object... ",0).display(disp);
vertices.get_object3dtoCImg3d(reverse_primitives?reverse_primitives:primitives,colors,opacities).
save(filename);
(+visu).__draw_text(" Object '%s' saved. ",0,filename._data).display(disp);
disp.set_key(key,false); key = 0;
} break;
#ifdef cimg_use_board
case cimg::keyP : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Save object as a .EPS file
static unsigned int snap_number = 0;
std::FILE *file;
do {
cimg_snprintf(filename,filename._width,cimg_appname "_%.4u.eps",snap_number++);
if ((file=cimg::std_fopen(filename,"r"))!=0) cimg::fclose(file);
} while (file);
(+visu).__draw_text(" Saving EPS snapshot... ",0).display(disp);
LibBoard::Board board;
(+visu)._draw_object3d(&board,zbuffer.fill(0),
Xoff + visu._width/2.f,Yoff + visu._height/2.f,Zoff,
rotated_vertices,reverse_primitives?reverse_primitives:primitives,
colors,opacities,clicked?nrender_motion:nrender_static,
_is_double_sided==1,focale,
visu.width()/2.f + light_x,visu.height()/2.f + light_y,light_z + Zoff,
specular_lightness,specular_shininess,1,
sprite_scale);
board.saveEPS(filename);
(+visu).__draw_text(" Object '%s' saved. ",0,filename._data).display(disp);
disp.set_key(key,false); key = 0;
} break;
case cimg::keyV : if (disp.is_keyCTRLLEFT() || disp.is_keyCTRLRIGHT()) { // Save object as a .SVG file
static unsigned int snap_number = 0;
std::FILE *file;
do {
cimg_snprintf(filename,filename._width,cimg_appname "_%.4u.svg",snap_number++);
if ((file=cimg::std_fopen(filename,"r"))!=0) cimg::fclose(file);
} while (file);
(+visu).__draw_text(" Saving SVG snapshot... ",0,13).display(disp);
LibBoard::Board board;
(+visu)._draw_object3d(&board,zbuffer.fill(0),
Xoff + visu._width/2.f,Yoff + visu._height/2.f,Zoff,
rotated_vertices,reverse_primitives?reverse_primitives:primitives,
colors,opacities,clicked?nrender_motion:nrender_static,
_is_double_sided==1,focale,
visu.width()/2.f + light_x,visu.height()/2.f + light_y,light_z + Zoff,
specular_lightness,specular_shininess,1,
sprite_scale);
board.saveSVG(filename);
(+visu).__draw_text(" Object '%s' saved. ",0,filename._data).display(disp);
disp.set_key(key,false); key = 0;
} break;
#endif
}
if (disp.is_resized()) {
disp.resize(false); visu0 = get_resize(disp,1);
if (zbuffer) zbuffer.assign(disp.width(),disp.height());
redraw = true;
}
if (!exit_on_anykey && key && key!=cimg::keyESC &&
(key!=cimg::keyW || (!disp.is_keyCTRLLEFT() && !disp.is_keyCTRLRIGHT()))) {
key = 0;
}
}
if (pose_matrix) {
std::memcpy(pose_matrix,pose._data,12*sizeof(float));
pose_matrix[12] = Xoff; pose_matrix[13] = Yoff; pose_matrix[14] = Zoff; pose_matrix[15] = sprite_scale;
}
disp.set_button().set_key(key);
return *this; | 0 |
tensorflow | 8ee24e7949a203d234489f9da2c5bf45a7d5157d | NOT_APPLICABLE | NOT_APPLICABLE | inline int Offset(const Dims<4>& dims, int* index) {
return Offset(dims, index[0], index[1], index[2], index[3]);
} | 0 |
linux | b4487b93545214a9db8cbf32e86411677b0cca21 | NOT_APPLICABLE | NOT_APPLICABLE | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req,
struct xdr_stream *xdr,
const void *data)
{
const struct nfs4_fs_locations_arg *args = data;
struct compound_hdr hdr = {
.minorversion = nfs4_xdr_minorversion(&args->seq_args),
};
uint32_t replen;
encode_compound_hdr(xdr, req, &hdr);
encode_sequence(xdr, &args->seq_args, &hdr);
if (args->migration) {
encode_putfh(xdr, args->fh, &hdr);
replen = hdr.replen;
encode_fs_locations(xdr, args->bitmask, &hdr);
if (args->renew)
encode_renew(xdr, args->clientid, &hdr);
} else {
encode_putfh(xdr, args->dir_fh, &hdr);
encode_lookup(xdr, args->name, &hdr);
replen = hdr.replen;
encode_fs_locations(xdr, args->bitmask, &hdr);
}
rpc_prepare_reply_pages(req, (struct page **)&args->page, 0,
PAGE_SIZE, replen + 1);
encode_nops(&hdr);
} | 0 |
ImageMagick | f8e8535bc821f24a30beee0030ff21ee3a2deedc | NOT_APPLICABLE | NOT_APPLICABLE | static const char *poly_basis_str(ssize_t n)
{
/* return the result for this polynomial term */
switch(n) {
case 0: return(""); /* constant */
case 1: return("*ii");
case 2: return("*jj"); /* affine order = 1 terms = 3 */
case 3: return("*ii*jj"); /* bilinear order = 1.5 terms = 4 */
case 4: return("*ii*ii");
case 5: return("*jj*jj"); /* quadratic order = 2 terms = 6 */
case 6: return("*ii*ii*ii");
case 7: return("*ii*ii*jj");
case 8: return("*ii*jj*jj");
case 9: return("*jj*jj*jj"); /* cubic order = 3 terms = 10 */
case 10: return("*ii*ii*ii*ii");
case 11: return("*ii*ii*ii*jj");
case 12: return("*ii*ii*jj*jj");
case 13: return("*ii*jj*jj*jj");
case 14: return("*jj*jj*jj*jj"); /* quartic order = 4 terms = 15 */
case 15: return("*ii*ii*ii*ii*ii");
case 16: return("*ii*ii*ii*ii*jj");
case 17: return("*ii*ii*ii*jj*jj");
case 18: return("*ii*ii*jj*jj*jj");
case 19: return("*ii*jj*jj*jj*jj");
case 20: return("*jj*jj*jj*jj*jj"); /* quintic order = 5 terms = 21 */
}
return( "UNKNOWN" ); /* should never happen */
} | 0 |
FreeRDP | 445a5a42c500ceb80f8fa7f2c11f3682538033f3 | NOT_APPLICABLE | NOT_APPLICABLE | rdpUpdate* update_new(rdpRdp* rdp)
{
const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL };
rdpUpdate* update;
OFFSCREEN_DELETE_LIST* deleteList;
update = (rdpUpdate*) calloc(1, sizeof(rdpUpdate));
if (!update)
return NULL;
update->log = WLog_Get("com.freerdp.core.update");
update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate));
if (!update->pointer)
goto fail;
update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate));
if (!update->primary)
goto fail;
update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate));
if (!update->secondary)
goto fail;
update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate));
if (!update->altsec)
goto fail;
update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate));
if (!update->window)
goto fail;
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
deleteList->sIndices = 64;
deleteList->indices = calloc(deleteList->sIndices, 2);
if (!deleteList->indices)
goto fail;
deleteList->cIndices = 0;
update->SuppressOutput = update_send_suppress_output;
update->initialState = TRUE;
update->queue = MessageQueue_New(&cb);
if (!update->queue)
goto fail;
return update;
fail:
update_free(update);
return NULL;
}
| 0 |
vim | 44db8213d38c39877d2148eff6a72f4beccfb94e | NOT_APPLICABLE | NOT_APPLICABLE | get_unname_register()
{
return y_previous == NULL ? -1 : y_previous - &y_regs[0];
} | 0 |
linux-2.6 | 6a6029b8cefe0ca7e82f27f3904dbedba3de4e06 | NOT_APPLICABLE | NOT_APPLICABLE | static inline struct cfs_rq *cpu_cfs_rq(struct cfs_rq *cfs_rq, int this_cpu)
{
return cfs_rq->tg->cfs_rq[this_cpu];
} | 0 |
linux | ac795161c93699d600db16c1a8cc23a65a1eceaf | NOT_APPLICABLE | NOT_APPLICABLE | static void nfs_set_verifier_locked(struct dentry *dentry, unsigned long verf)
{
struct inode *inode = d_inode(dentry);
struct inode *dir = d_inode(dentry->d_parent);
if (!nfs_verify_change_attribute(dir, verf))
return;
if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
nfs_set_verifier_delegated(&verf);
dentry->d_time = verf;
} | 0 |
linux | 83eaddab4378db256d00d295bda6ca997cd13a52 | NOT_APPLICABLE | NOT_APPLICABLE | static int dccp_v6_rcv(struct sk_buff *skb)
{
const struct dccp_hdr *dh;
bool refcounted;
struct sock *sk;
int min_cov;
/* Step 1: Check header basics */
if (dccp_invalid_packet(skb))
goto discard_it;
/* Step 1: If header checksum is incorrect, drop packet and return. */
if (dccp_v6_csum_finish(skb, &ipv6_hdr(skb)->saddr,
&ipv6_hdr(skb)->daddr)) {
DCCP_WARN("dropped packet with invalid checksum\n");
goto discard_it;
}
dh = dccp_hdr(skb);
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
if (dccp_packet_without_ack(skb))
DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
else
DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
lookup:
sk = __inet6_lookup_skb(&dccp_hashinfo, skb, __dccp_hdr_len(dh),
dh->dccph_sport, dh->dccph_dport,
inet6_iif(skb), &refcounted);
if (!sk) {
dccp_pr_debug("failed to look up flow ID in table and "
"get corresponding socket\n");
goto no_dccp_socket;
}
/*
* Step 2:
* ... or S.state == TIMEWAIT,
* Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return
*/
if (sk->sk_state == DCCP_TIME_WAIT) {
dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
inet_twsk_put(inet_twsk(sk));
goto no_dccp_socket;
}
if (sk->sk_state == DCCP_NEW_SYN_RECV) {
struct request_sock *req = inet_reqsk(sk);
struct sock *nsk;
sk = req->rsk_listener;
if (unlikely(sk->sk_state != DCCP_LISTEN)) {
inet_csk_reqsk_queue_drop_and_put(sk, req);
goto lookup;
}
sock_hold(sk);
refcounted = true;
nsk = dccp_check_req(sk, skb, req);
if (!nsk) {
reqsk_put(req);
goto discard_and_relse;
}
if (nsk == sk) {
reqsk_put(req);
} else if (dccp_child_process(sk, nsk, skb)) {
dccp_v6_ctl_send_reset(sk, skb);
goto discard_and_relse;
} else {
sock_put(sk);
return 0;
}
}
/*
* RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
* o if MinCsCov = 0, only packets with CsCov = 0 are accepted
* o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
*/
min_cov = dccp_sk(sk)->dccps_pcrlen;
if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
dh->dccph_cscov, min_cov);
/* FIXME: send Data Dropped option (see also dccp_v4_rcv) */
goto discard_and_relse;
}
if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
goto discard_and_relse;
return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,
refcounted) ? -1 : 0;
no_dccp_socket:
if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
goto discard_it;
/*
* Step 2:
* If no socket ...
* Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return
*/
if (dh->dccph_type != DCCP_PKT_RESET) {
DCCP_SKB_CB(skb)->dccpd_reset_code =
DCCP_RESET_CODE_NO_CONNECTION;
dccp_v6_ctl_send_reset(sk, skb);
}
discard_it:
kfree_skb(skb);
return 0;
discard_and_relse:
if (refcounted)
sock_put(sk);
goto discard_it;
}
| 0 |
linux | f6b8c6b5543983e9de29dc14716bfa4eb3f157c4 | NOT_APPLICABLE | NOT_APPLICABLE | static void sco_sock_kill(struct sock *sk)
{
if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket ||
sock_flag(sk, SOCK_DEAD))
return;
BT_DBG("sk %p state %d", sk, sk->sk_state);
/* Kill poor orphan */
bt_sock_unlink(&sco_sk_list, sk);
sock_set_flag(sk, SOCK_DEAD);
sock_put(sk);
} | 0 |
ytnef | f98f5d4adc1c4bd4033638f6167c1bb95d642f89 | NOT_APPLICABLE | NOT_APPLICABLE | int MAPISysTimetoDTR(BYTE *data, dtr *thedate) {
DDWORD ddword_tmp;
int startingdate = 0;
int tmp_date;
int days_in_year = 365;
unsigned int months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ddword_tmp = *((DDWORD *)data);
ddword_tmp = ddword_tmp / 10; // micro-s
ddword_tmp /= 1000; // ms
ddword_tmp /= 1000; // s
thedate->wSecond = (ddword_tmp % 60);
ddword_tmp /= 60; // seconds to minutes
thedate->wMinute = (ddword_tmp % 60);
ddword_tmp /= 60; //minutes to hours
thedate->wHour = (ddword_tmp % 24);
ddword_tmp /= 24; // Hours to days
// Now calculate the year based on # of days
thedate->wYear = 1601;
startingdate = 1;
while (ddword_tmp >= days_in_year) {
ddword_tmp -= days_in_year;
thedate->wYear++;
days_in_year = 365;
startingdate++;
if ((thedate->wYear % 4) == 0) {
if ((thedate->wYear % 100) == 0) {
// if the year is 1700,1800,1900, etc, then it is only
// a leap year if exactly divisible by 400, not 4.
if ((thedate->wYear % 400) == 0) {
startingdate++;
days_in_year = 366;
}
} else {
startingdate++;
days_in_year = 366;
}
}
startingdate %= 7;
}
// the remaining number is the day # in this year
// So now calculate the Month, & Day of month
if ((thedate->wYear % 4) == 0) {
// 29 days in february in a leap year
months[1] = 29;
}
tmp_date = (int)ddword_tmp;
thedate->wDayOfWeek = (tmp_date + startingdate) % 7;
thedate->wMonth = 0;
while (tmp_date > months[thedate->wMonth]) {
tmp_date -= months[thedate->wMonth];
thedate->wMonth++;
}
thedate->wMonth++;
thedate->wDay = tmp_date + 1;
return 0;
} | 0 |
ghostscript | b326a71659b7837d3acde954b18bda1a6f5e9498 | NOT_APPLICABLE | NOT_APPLICABLE | static int labrange(i_ctx_t * i_ctx_p, ref *space, float *ptr)
{
int i, code;
ref CIEdict, *tempref, valref;
code = array_get(imemory, space, 1, &CIEdict);
if (code < 0)
return code;
/* If we have a Range entry, get the values from that */
code = dict_find_string(&CIEdict, "Range", &tempref);
if (code > 0 && !r_has_type(tempref, t_null)) {
for (i=0;i<4;i++) {
code = array_get(imemory, tempref, i, &valref);
if (code < 0)
return code;
if (r_has_type(&valref, t_integer))
ptr[i] = (float)valref.value.intval;
else if (r_has_type(&valref, t_real))
ptr[i] = (float)valref.value.realval;
else
return_error(gs_error_typecheck);
}
} else {
/* Default values for Lab */
for (i=0;i<2;i++) {
ptr[2 * i] = -100;
ptr[(2 * i) + 1] = 100;
}
}
return 0;
}
| 0 |
Chrome | 0ab2412a104d2f235d7b9fe19d30ef605a410832 | NOT_APPLICABLE | NOT_APPLICABLE | void DocumentLoader::UpdateForSameDocumentNavigation(
const KURL& new_url,
SameDocumentNavigationSource same_document_navigation_source,
RefPtr<SerializedScriptValue> data,
HistoryScrollRestorationType scroll_restoration_type,
FrameLoadType type,
Document* initiating_document) {
if (initiating_document && !initiating_document->CanCreateHistoryEntry())
type = kFrameLoadTypeReplaceCurrentItem;
KURL old_url = request_.Url();
original_request_.SetURL(new_url);
request_.SetURL(new_url);
SetReplacesCurrentHistoryItem(type != kFrameLoadTypeStandard);
if (same_document_navigation_source == kSameDocumentNavigationHistoryApi) {
request_.SetHTTPMethod(HTTPNames::GET);
request_.SetHTTPBody(nullptr);
}
ClearRedirectChain();
if (is_client_redirect_)
AppendRedirect(old_url);
AppendRedirect(new_url);
SetHistoryItemStateForCommit(
history_item_.Get(), type,
same_document_navigation_source == kSameDocumentNavigationHistoryApi
? HistoryNavigationType::kHistoryApi
: HistoryNavigationType::kFragment);
history_item_->SetDocumentState(frame_->GetDocument()->FormElementsState());
if (same_document_navigation_source == kSameDocumentNavigationHistoryApi) {
history_item_->SetStateObject(std::move(data));
history_item_->SetScrollRestorationType(scroll_restoration_type);
}
HistoryCommitType commit_type = LoadTypeToCommitType(type);
frame_->FrameScheduler()->DidCommitProvisionalLoad(
commit_type == kHistoryInertCommit, type == kFrameLoadTypeReload,
frame_->IsLocalRoot());
GetLocalFrameClient().DispatchDidNavigateWithinPage(
history_item_.Get(), commit_type, initiating_document);
}
| 0 |
qemu | 1d20398694a3b67a388d955b7a945ba4aa90a8a8 | NOT_APPLICABLE | NOT_APPLICABLE | static void coroutine_fn v9fs_getattr(void *opaque)
{
int32_t fid;
size_t offset = 7;
ssize_t retval = 0;
struct stat stbuf;
V9fsFidState *fidp;
uint64_t request_mask;
V9fsStatDotl v9stat_dotl;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
retval = pdu_unmarshal(pdu, offset, "dq", &fid, &request_mask);
if (retval < 0) {
goto out_nofid;
}
trace_v9fs_getattr(pdu->tag, pdu->id, fid, request_mask);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
retval = -ENOENT;
goto out_nofid;
}
/*
* Currently we only support BASIC fields in stat, so there is no
* need to look at request_mask.
*/
retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (retval < 0) {
goto out;
}
stat_to_v9stat_dotl(s, &stbuf, &v9stat_dotl);
/* fill st_gen if requested and supported by underlying fs */
if (request_mask & P9_STATS_GEN) {
retval = v9fs_co_st_gen(pdu, &fidp->path, stbuf.st_mode, &v9stat_dotl);
switch (retval) {
case 0:
/* we have valid st_gen: update result mask */
v9stat_dotl.st_result_mask |= P9_STATS_GEN;
break;
case -EINTR:
/* request cancelled, e.g. by Tflush */
goto out;
default:
/* failed to get st_gen: not fatal, ignore */
break;
}
}
retval = pdu_marshal(pdu, offset, "A", &v9stat_dotl);
if (retval < 0) {
goto out;
}
retval += offset;
trace_v9fs_getattr_return(pdu->tag, pdu->id, v9stat_dotl.st_result_mask,
v9stat_dotl.st_mode, v9stat_dotl.st_uid,
v9stat_dotl.st_gid);
out:
put_fid(pdu, fidp);
out_nofid:
pdu_complete(pdu, retval);
}
| 0 |
mongo | 35c1b1f588f04926a958ad2fe4d9c59d79f81e8b | NOT_APPLICABLE | NOT_APPLICABLE | NamespaceString _getCollectionNssFromUUID(OperationContext* opCtx, const UUID& uuid) {
Collection* source = UUIDCatalog::get(opCtx).lookupCollectionByUUID(uuid);
return source ? source->ns() : NamespaceString();
} | 0 |
linux | a134f083e79fb4c3d0a925691e732c56911b4326 | NOT_APPLICABLE | NOT_APPLICABLE | int ping_init_sock(struct sock *sk)
{
struct net *net = sock_net(sk);
kgid_t group = current_egid();
struct group_info *group_info;
int i, j, count;
kgid_t low, high;
int ret = 0;
if (sk->sk_family == AF_INET6)
sk->sk_ipv6only = 1;
inet_get_ping_group_range_net(net, &low, &high);
if (gid_lte(low, group) && gid_lte(group, high))
return 0;
group_info = get_current_groups();
count = group_info->ngroups;
for (i = 0; i < group_info->nblocks; i++) {
int cp_count = min_t(int, NGROUPS_PER_BLOCK, count);
for (j = 0; j < cp_count; j++) {
kgid_t gid = group_info->blocks[i][j];
if (gid_lte(low, gid) && gid_lte(gid, high))
goto out_release_group;
}
count -= cp_count;
}
ret = -EACCES;
out_release_group:
put_group_info(group_info);
return ret;
}
| 0 |
gpac | 6063b1a011c3f80cee25daade18154e15e4c058c | NOT_APPLICABLE | NOT_APPLICABLE |
void pdin_del(GF_Box *s)
{
GF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox*)s;
if (ptr == NULL) return;
if (ptr->rates) gf_free(ptr->rates);
if (ptr->times) gf_free(ptr->times);
gf_free(ptr); | 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 |
linux | b4e00444cab4c3f3fec876dc0cccc8cbb0d1a948 | NOT_APPLICABLE | NOT_APPLICABLE | void __mmdrop(struct mm_struct *mm)
{
BUG_ON(mm == &init_mm);
WARN_ON_ONCE(mm == current->mm);
WARN_ON_ONCE(mm == current->active_mm);
mm_free_pgd(mm);
destroy_context(mm);
mmu_notifier_subscriptions_destroy(mm);
check_mm(mm);
put_user_ns(mm->user_ns);
free_mm(mm);
} | 0 |
systemd | bf65b7e0c9fc215897b676ab9a7c9d1c688143ba | NOT_APPLICABLE | NOT_APPLICABLE | void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlags flags) {
const char *reason;
Manager *m;
assert(u);
assert(os < _UNIT_ACTIVE_STATE_MAX);
assert(ns < _UNIT_ACTIVE_STATE_MAX);
/* Note that this is called for all low-level state changes, even if they might map to the same high-level
* UnitActiveState! That means that ns == os is an expected behavior here. For example: if a mount point is
* remounted this function will be called too! */
m = u->manager;
/* Let's enqueue the change signal early. In case this unit has a job associated we want that this unit is in
* the bus queue, so that any job change signal queued will force out the unit change signal first. */
unit_add_to_dbus_queue(u);
/* Update timestamps for state changes */
if (!MANAGER_IS_RELOADING(m)) {
dual_timestamp_get(&u->state_change_timestamp);
if (UNIT_IS_INACTIVE_OR_FAILED(os) && !UNIT_IS_INACTIVE_OR_FAILED(ns))
u->inactive_exit_timestamp = u->state_change_timestamp;
else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && UNIT_IS_INACTIVE_OR_FAILED(ns))
u->inactive_enter_timestamp = u->state_change_timestamp;
if (!UNIT_IS_ACTIVE_OR_RELOADING(os) && UNIT_IS_ACTIVE_OR_RELOADING(ns))
u->active_enter_timestamp = u->state_change_timestamp;
else if (UNIT_IS_ACTIVE_OR_RELOADING(os) && !UNIT_IS_ACTIVE_OR_RELOADING(ns))
u->active_exit_timestamp = u->state_change_timestamp;
}
/* Keep track of failed units */
(void) manager_update_failed_units(m, u, ns == UNIT_FAILED);
/* Make sure the cgroup and state files are always removed when we become inactive */
if (UNIT_IS_INACTIVE_OR_FAILED(ns)) {
unit_prune_cgroup(u);
unit_unlink_state_files(u);
}
unit_update_on_console(u);
if (!MANAGER_IS_RELOADING(m)) {
bool unexpected;
/* Let's propagate state changes to the job */
if (u->job)
unexpected = unit_process_job(u->job, ns, flags);
else
unexpected = true;
/* If this state change happened without being requested by a job, then let's retroactively start or
* stop dependencies. We skip that step when deserializing, since we don't want to create any
* additional jobs just because something is already activated. */
if (unexpected) {
if (UNIT_IS_INACTIVE_OR_FAILED(os) && UNIT_IS_ACTIVE_OR_ACTIVATING(ns))
retroactively_start_dependencies(u);
else if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
retroactively_stop_dependencies(u);
}
/* stop unneeded units regardless if going down was expected or not */
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
check_unneeded_dependencies(u);
if (ns != os && ns == UNIT_FAILED) {
log_unit_debug(u, "Unit entered failed state.");
if (!(flags & UNIT_NOTIFY_WILL_AUTO_RESTART))
unit_start_on_failure(u);
}
if (UNIT_IS_ACTIVE_OR_RELOADING(ns) && !UNIT_IS_ACTIVE_OR_RELOADING(os)) {
/* This unit just finished starting up */
unit_emit_audit_start(u);
manager_send_unit_plymouth(m, u);
}
if (UNIT_IS_INACTIVE_OR_FAILED(ns) && !UNIT_IS_INACTIVE_OR_FAILED(os)) {
/* This unit just stopped/failed. */
unit_emit_audit_stop(u, ns);
unit_log_resources(u);
}
}
manager_recheck_journal(m);
manager_recheck_dbus(m);
unit_trigger_notify(u);
if (!MANAGER_IS_RELOADING(m)) {
/* Maybe we finished startup and are now ready for being stopped because unneeded? */
unit_submit_to_stop_when_unneeded_queue(u);
/* Maybe we finished startup, but something we needed has vanished? Let's die then. (This happens when
* something BindsTo= to a Type=oneshot unit, as these units go directly from starting to inactive,
* without ever entering started.) */
unit_check_binds_to(u);
if (os != UNIT_FAILED && ns == UNIT_FAILED) {
reason = strjoina("unit ", u->id, " failed");
emergency_action(m, u->failure_action, 0, u->reboot_arg, unit_failure_action_exit_status(u), reason);
} else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && ns == UNIT_INACTIVE) {
reason = strjoina("unit ", u->id, " succeeded");
emergency_action(m, u->success_action, 0, u->reboot_arg, unit_success_action_exit_status(u), reason);
}
}
unit_add_to_gc_queue(u);
} | 0 |
linux | d6f5e358452479fa8a773b5c6ccc9e4ec5a20880 | NOT_APPLICABLE | NOT_APPLICABLE | __smb2_find_mid(struct TCP_Server_Info *server, char *buf, bool dequeue)
{
struct mid_q_entry *mid;
struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
__u64 wire_mid = le64_to_cpu(shdr->MessageId);
if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) {
cifs_server_dbg(VFS, "Encrypted frame parsing not supported yet\n");
return NULL;
}
spin_lock(&GlobalMid_Lock);
list_for_each_entry(mid, &server->pending_mid_q, qhead) {
if ((mid->mid == wire_mid) &&
(mid->mid_state == MID_REQUEST_SUBMITTED) &&
(mid->command == shdr->Command)) {
kref_get(&mid->refcount);
if (dequeue) {
list_del_init(&mid->qhead);
mid->mid_flags |= MID_DELETED;
}
spin_unlock(&GlobalMid_Lock);
return mid;
}
}
spin_unlock(&GlobalMid_Lock);
return NULL;
} | 0 |
mindrot | ed4ce82dbfa8a3a3c8ea6fa0db113c71e234416c | CVE-2016-1908 | CWE-254 | ssh_session(void)
{
int type;
int interactive = 0;
int have_tty = 0;
struct winsize ws;
char *cp;
const char *display;
/* Enable compression if requested. */
if (options.compression) {
options.compression_level);
if (options.compression_level < 1 ||
options.compression_level > 9)
fatal("Compression level must be from 1 (fast) to "
"9 (slow, best).");
/* Send the request. */
packet_start(SSH_CMSG_REQUEST_COMPRESSION);
packet_put_int(options.compression_level);
packet_send();
packet_write_wait();
type = packet_read();
if (type == SSH_SMSG_SUCCESS)
packet_start_compression(options.compression_level);
else if (type == SSH_SMSG_FAILURE)
logit("Warning: Remote host refused compression.");
else
packet_disconnect("Protocol error waiting for "
"compression response.");
}
/* Allocate a pseudo tty if appropriate. */
if (tty_flag) {
debug("Requesting pty.");
/* Start the packet. */
packet_start(SSH_CMSG_REQUEST_PTY);
/* Store TERM in the packet. There is no limit on the
length of the string. */
cp = getenv("TERM");
if (!cp)
cp = "";
packet_put_cstring(cp);
/* Store window size in the packet. */
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) < 0)
memset(&ws, 0, sizeof(ws));
packet_put_int((u_int)ws.ws_row);
packet_put_int((u_int)ws.ws_col);
packet_put_int((u_int)ws.ws_xpixel);
packet_put_int((u_int)ws.ws_ypixel);
/* Store tty modes in the packet. */
tty_make_modes(fileno(stdin), NULL);
/* Send the packet, and wait for it to leave. */
packet_send();
packet_write_wait();
/* Read response from the server. */
type = packet_read();
if (type == SSH_SMSG_SUCCESS) {
interactive = 1;
have_tty = 1;
} else if (type == SSH_SMSG_FAILURE)
logit("Warning: Remote host failed or refused to "
"allocate a pseudo tty.");
else
packet_disconnect("Protocol error waiting for pty "
"request response.");
}
/* Request X11 forwarding if enabled and DISPLAY is set. */
display = getenv("DISPLAY");
display = getenv("DISPLAY");
if (display == NULL && options.forward_x11)
debug("X11 forwarding requested but DISPLAY not set");
if (options.forward_x11 && display != NULL) {
char *proto, *data;
/* Get reasonable local authentication information. */
client_x11_get_proto(display, options.xauth_location,
options.forward_x11_trusted,
options.forward_x11_timeout,
&proto, &data);
/* Request forwarding with authentication spoofing. */
debug("Requesting X11 forwarding with authentication "
"spoofing.");
/* Request forwarding with authentication spoofing. */
debug("Requesting X11 forwarding with authentication "
"spoofing.");
x11_request_forwarding_with_spoofing(0, display, proto,
data, 0);
/* Read response from the server. */
type = packet_read();
if (type == SSH_SMSG_SUCCESS) {
interactive = 1;
} else if (type == SSH_SMSG_FAILURE) {
logit("Warning: Remote host denied X11 forwarding.");
} else {
packet_disconnect("Protocol error waiting for X11 "
"forwarding");
}
}
/* Tell the packet module whether this is an interactive session. */
packet_set_interactive(interactive,
options.ip_qos_interactive, options.ip_qos_bulk);
/* Request authentication agent forwarding if appropriate. */
check_agent_present();
if (options.forward_agent) {
debug("Requesting authentication agent forwarding.");
auth_request_forwarding();
/* Read response from the server. */
type = packet_read();
packet_check_eom();
if (type != SSH_SMSG_SUCCESS)
logit("Warning: Remote host denied authentication agent forwarding.");
}
/* Initiate port forwardings. */
ssh_init_stdio_forwarding();
ssh_init_forwarding();
/* Execute a local command */
if (options.local_command != NULL &&
options.permit_local_command)
ssh_local_cmd(options.local_command);
/*
* If requested and we are not interested in replies to remote
* forwarding requests, then let ssh continue in the background.
*/
if (fork_after_authentication_flag) {
if (options.exit_on_forward_failure &&
options.num_remote_forwards > 0) {
debug("deferring postauth fork until remote forward "
"confirmation received");
} else
fork_postauth();
}
/*
* If a command was specified on the command line, execute the
* command now. Otherwise request the server to start a shell.
*/
if (buffer_len(&command) > 0) {
int len = buffer_len(&command);
if (len > 900)
len = 900;
debug("Sending command: %.*s", len,
(u_char *)buffer_ptr(&command));
packet_start(SSH_CMSG_EXEC_CMD);
packet_put_string(buffer_ptr(&command), buffer_len(&command));
packet_send();
packet_write_wait();
} else {
debug("Requesting shell.");
packet_start(SSH_CMSG_EXEC_SHELL);
packet_send();
packet_write_wait();
}
/* Enter the interactive session. */
return client_loop(have_tty, tty_flag ?
options.escape_char : SSH_ESCAPECHAR_NONE, 0);
}
| 1 |
collectd | d16c24542b2f96a194d43a73c2e5778822b9cb47 | NOT_APPLICABLE | NOT_APPLICABLE | static int csnmp_dispatch_table(host_definition_t *host,
data_definition_t *data,
csnmp_list_instances_t *instance_list,
csnmp_table_values_t **value_table) {
const data_set_t *ds;
value_list_t vl = VALUE_LIST_INIT;
csnmp_list_instances_t *instance_list_ptr;
csnmp_table_values_t **value_table_ptr;
size_t i;
_Bool have_more;
oid_t current_suffix;
ds = plugin_get_ds(data->type);
if (!ds) {
ERROR("snmp plugin: DataSet `%s' not defined.", data->type);
return (-1);
}
assert(ds->ds_num == data->values_len);
assert(data->values_len > 0);
instance_list_ptr = instance_list;
value_table_ptr = calloc(data->values_len, sizeof(*value_table_ptr));
if (value_table_ptr == NULL)
return (-1);
for (i = 0; i < data->values_len; i++)
value_table_ptr[i] = value_table[i];
vl.values_len = data->values_len;
vl.values = malloc(sizeof(*vl.values) * vl.values_len);
if (vl.values == NULL) {
ERROR("snmp plugin: malloc failed.");
sfree(value_table_ptr);
return (-1);
}
sstrncpy(vl.host, host->name, sizeof(vl.host));
sstrncpy(vl.plugin, "snmp", sizeof(vl.plugin));
vl.interval = host->interval;
have_more = 1;
while (have_more) {
_Bool suffix_skipped = 0;
/* Determine next suffix to handle. */
if (instance_list != NULL) {
if (instance_list_ptr == NULL) {
have_more = 0;
continue;
}
memcpy(¤t_suffix, &instance_list_ptr->suffix,
sizeof(current_suffix));
} else /* no instance configured */
{
csnmp_table_values_t *ptr = value_table_ptr[0];
if (ptr == NULL) {
have_more = 0;
continue;
}
memcpy(¤t_suffix, &ptr->suffix, sizeof(current_suffix));
}
/* Update all the value_table_ptr to point at the entry with the same
* trailing partial OID */
for (i = 0; i < data->values_len; i++) {
while (
(value_table_ptr[i] != NULL) &&
(csnmp_oid_compare(&value_table_ptr[i]->suffix, ¤t_suffix) < 0))
value_table_ptr[i] = value_table_ptr[i]->next;
if (value_table_ptr[i] == NULL) {
have_more = 0;
break;
} else if (csnmp_oid_compare(&value_table_ptr[i]->suffix,
¤t_suffix) > 0) {
/* This suffix is missing in the subtree. Indicate this with the
* "suffix_skipped" flag and try the next instance / suffix. */
suffix_skipped = 1;
break;
}
} /* for (i = 0; i < columns; i++) */
if (!have_more)
break;
/* Matching the values failed. Start from the beginning again. */
if (suffix_skipped) {
if (instance_list != NULL)
instance_list_ptr = instance_list_ptr->next;
else
value_table_ptr[0] = value_table_ptr[0]->next;
continue;
}
/* if we reach this line, all value_table_ptr[i] are non-NULL and are set
* to the same subid. instance_list_ptr is either NULL or points to the
* same subid, too. */
#if COLLECT_DEBUG
for (i = 1; i < data->values_len; i++) {
assert(value_table_ptr[i] != NULL);
assert(csnmp_oid_compare(&value_table_ptr[i - 1]->suffix,
&value_table_ptr[i]->suffix) == 0);
}
assert((instance_list_ptr == NULL) ||
(csnmp_oid_compare(&instance_list_ptr->suffix,
&value_table_ptr[0]->suffix) == 0));
#endif
sstrncpy(vl.type, data->type, sizeof(vl.type));
{
char temp[DATA_MAX_NAME_LEN];
if (instance_list_ptr == NULL)
csnmp_oid_to_string(temp, sizeof(temp), ¤t_suffix);
else
sstrncpy(temp, instance_list_ptr->instance, sizeof(temp));
if (data->instance_prefix == NULL)
sstrncpy(vl.type_instance, temp, sizeof(vl.type_instance));
else
ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s%s",
data->instance_prefix, temp);
}
for (i = 0; i < data->values_len; i++)
vl.values[i] = value_table_ptr[i]->value;
/* If we get here `vl.type_instance' and all `vl.values' have been set
* vl.type_instance can be empty, i.e. a blank port description on a
* switch if you're using IF-MIB::ifDescr as Instance.
*/
if (vl.type_instance[0] != '\0')
plugin_dispatch_values(&vl);
if (instance_list != NULL)
instance_list_ptr = instance_list_ptr->next;
else
value_table_ptr[0] = value_table_ptr[0]->next;
} /* while (have_more) */
sfree(vl.values);
sfree(value_table_ptr);
return (0);
} /* int csnmp_dispatch_table */
| 0 |
Chrome | 08965161257ab9aeef9a3548c1cd1a44525dc562 | NOT_APPLICABLE | NOT_APPLICABLE | bool system_level() const { return system_level_; }
| 0 |
Chrome | f85a87ec670ad0fce9d98d90c9a705b72a288154 | NOT_APPLICABLE | NOT_APPLICABLE | static void uint8ArrayMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestObjectPythonV8Internal::uint8ArrayMethodMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
| 0 |
Chrome | 1c40f9042ae2d6ee7483d72998aabb5e73b2ff60 | NOT_APPLICABLE | NOT_APPLICABLE | void InspectorNetworkAgent::DidFinishEventSourceRequest(
ThreadableLoaderClient* event_source) {
known_request_id_map_.erase(event_source);
ClearPendingRequestData();
}
| 0 |
matio | a47b7cd3aca70e9a0bddf8146eb4ab0cbd19c2c3 | NOT_APPLICABLE | NOT_APPLICABLE | int SafeMulDims(const matvar_t *matvar, size_t* nelems)
{
int i;
if ( matvar->rank == 0 ) {
*nelems = 0;
return 0;
}
for ( i = 0; i < matvar->rank; i++ ) {
if ( !psnip_safe_size_mul(nelems, *nelems, matvar->dims[i]) ) {
*nelems = 0;
return 1;
}
}
return 0;
} | 0 |
FFmpeg | 5aba5b89d0b1d73164d3b81764828bb8b20ff32a | NOT_APPLICABLE | NOT_APPLICABLE | int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
{
Mpeg4DecContext *ctx = avctx->priv_data;
MpegEncContext *s = &ctx->m;
if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) {
if (s->codec_tag == AV_RL32("XVID") ||
s->codec_tag == AV_RL32("XVIX") ||
s->codec_tag == AV_RL32("RMP4") ||
s->codec_tag == AV_RL32("ZMP4") ||
s->codec_tag == AV_RL32("SIPP"))
ctx->xvid_build = 0;
}
if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1)
if (s->codec_tag == AV_RL32("DIVX") && s->vo_type == 0 &&
ctx->vol_control_parameters == 0)
ctx->divx_version = 400; // divx 4
if (ctx->xvid_build >= 0 && ctx->divx_version >= 0) {
ctx->divx_version =
ctx->divx_build = -1;
}
if (s->workaround_bugs & FF_BUG_AUTODETECT) {
if (s->codec_tag == AV_RL32("XVIX"))
s->workaround_bugs |= FF_BUG_XVID_ILACE;
if (s->codec_tag == AV_RL32("UMP4"))
s->workaround_bugs |= FF_BUG_UMP4;
if (ctx->divx_version >= 500 && ctx->divx_build < 1814)
s->workaround_bugs |= FF_BUG_QPEL_CHROMA;
if (ctx->divx_version > 502 && ctx->divx_build < 1814)
s->workaround_bugs |= FF_BUG_QPEL_CHROMA2;
if (ctx->xvid_build <= 3U)
s->padding_bug_score = 256 * 256 * 256 * 64;
if (ctx->xvid_build <= 1U)
s->workaround_bugs |= FF_BUG_QPEL_CHROMA;
if (ctx->xvid_build <= 12U)
s->workaround_bugs |= FF_BUG_EDGE;
if (ctx->xvid_build <= 32U)
s->workaround_bugs |= FF_BUG_DC_CLIP;
#define SET_QPEL_FUNC(postfix1, postfix2) \
s->qdsp.put_ ## postfix1 = ff_put_ ## postfix2; \
s->qdsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2; \
s->qdsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
if (ctx->lavc_build < 4653U)
s->workaround_bugs |= FF_BUG_STD_QPEL;
if (ctx->lavc_build < 4655U)
s->workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE;
if (ctx->lavc_build < 4670U)
s->workaround_bugs |= FF_BUG_EDGE;
if (ctx->lavc_build <= 4712U)
s->workaround_bugs |= FF_BUG_DC_CLIP;
if ((ctx->lavc_build&0xFF) >= 100) {
if (ctx->lavc_build > 3621476 && ctx->lavc_build < 3752552 &&
(ctx->lavc_build < 3752037 || ctx->lavc_build > 3752191) // 3.2.1+
)
s->workaround_bugs |= FF_BUG_IEDGE;
}
if (ctx->divx_version >= 0)
s->workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE;
if (ctx->divx_version == 501 && ctx->divx_build == 20020416)
s->padding_bug_score = 256 * 256 * 256 * 64;
if (ctx->divx_version < 500U)
s->workaround_bugs |= FF_BUG_EDGE;
if (ctx->divx_version >= 0)
s->workaround_bugs |= FF_BUG_HPEL_CHROMA;
}
if (s->workaround_bugs & FF_BUG_STD_QPEL) {
SET_QPEL_FUNC(qpel_pixels_tab[0][5], qpel16_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][7], qpel16_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][9], qpel16_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][5], qpel8_mc11_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][7], qpel8_mc31_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][9], qpel8_mc12_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
}
if (avctx->debug & FF_DEBUG_BUGS)
av_log(s->avctx, AV_LOG_DEBUG,
"bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
s->workaround_bugs, ctx->lavc_build, ctx->xvid_build,
ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : "");
if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
s->codec_id == AV_CODEC_ID_MPEG4 &&
avctx->idct_algo == FF_IDCT_AUTO) {
avctx->idct_algo = FF_IDCT_XVID;
ff_mpv_idct_init(s);
return 1;
}
return 0;
}
| 0 |
xserver | cad5a1050b7184d828aef9c1dd151c3ab649d37e | NOT_APPLICABLE | NOT_APPLICABLE | ProcXvQueryImageAttributes(ClientPtr client)
{
xvQueryImageAttributesReply rep;
int size, num_planes, i;
CARD16 width, height;
XvImagePtr pImage = NULL;
XvPortPtr pPort;
int *offsets;
int *pitches;
int planeLength;
REQUEST(xvQueryImageAttributesReq);
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
for (i = 0; i < pPort->pAdaptor->nImages; i++) {
if (pPort->pAdaptor->pImages[i].id == stuff->id) {
pImage = &(pPort->pAdaptor->pImages[i]);
break;
}
}
#ifdef XvMCExtension
if (!pImage)
pImage = XvMCFindXvImage(pPort, stuff->id);
#endif
if (!pImage)
return BadMatch;
num_planes = pImage->num_planes;
if (!(offsets = malloc(num_planes << 3)))
return BadAlloc;
pitches = offsets + num_planes;
width = stuff->width;
height = stuff->height;
size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage,
&width, &height, offsets,
pitches);
rep = (xvQueryImageAttributesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = planeLength = num_planes << 1,
.num_planes = num_planes,
.width = width,
.height = height,
.data_size = size
};
_WriteQueryImageAttributesReply(client, &rep);
if (client->swapped)
SwapLongs((CARD32 *) offsets, planeLength);
WriteToClient(client, planeLength << 2, offsets);
free(offsets);
return Success;
}
| 0 |
ImageMagick | b007dd3a048097d8f58949297f5b434612e1e1a3 | CVE-2017-11449 | CWE-20 | ModuleExport size_t RegisterMPCImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("CACHE");
entry->description=ConstantString("Magick Persistent Cache image format");
entry->module=ConstantString("MPC");
entry->stealth=MagickTrue;
(void) RegisterMagickInfo(entry);
entry=SetMagickInfo("MPC");
entry->decoder=(DecodeImageHandler *) ReadMPCImage;
entry->encoder=(EncodeImageHandler *) WriteMPCImage;
entry->magick=(IsImageFormatHandler *) IsMPC;
entry->description=ConstantString("Magick Persistent Cache image format");
entry->module=ConstantString("MPC");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
| 1 |
Android | 472271b153c5dc53c28beac55480a8d8434b2d5c | NOT_APPLICABLE | NOT_APPLICABLE | static bool hal_init(const hci_hal_callbacks_t *upper_callbacks, thread_t *upper_thread) {
assert(upper_callbacks != NULL);
assert(upper_thread != NULL);
callbacks = upper_callbacks;
thread = upper_thread;
return true;
}
| 0 |
ntfs-3g | 60717a846deaaea47e50ce58872869f7bd1103b5 | NOT_APPLICABLE | NOT_APPLICABLE | int ntfs_attr_map_whole_runlist(ntfs_attr *na)
{
VCN next_vcn, last_vcn, highest_vcn;
ntfs_attr_search_ctx *ctx;
ntfs_volume *vol = na->ni->vol;
ATTR_RECORD *a;
int ret = -1;
int not_mapped;
ntfs_log_enter("Entering for inode %llu, attr 0x%x.\n",
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type));
/* avoid multiple full runlist mappings */
if (NAttrFullyMapped(na)) {
ret = 0;
goto out;
}
ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
if (!ctx)
goto out;
/* Map all attribute extents one by one. */
next_vcn = last_vcn = highest_vcn = 0;
a = NULL;
while (1) {
runlist_element *rl;
not_mapped = 0;
if (ntfs_rl_vcn_to_lcn(na->rl, next_vcn) == LCN_RL_NOT_MAPPED)
not_mapped = 1;
if (ntfs_attr_lookup(na->type, na->name, na->name_len,
CASE_SENSITIVE, next_vcn, NULL, 0, ctx))
break;
a = ctx->attr;
if (not_mapped) {
/* Decode the runlist. */
rl = ntfs_mapping_pairs_decompress(na->ni->vol,
a, na->rl);
if (!rl)
goto err_out;
na->rl = rl;
}
/* Are we in the first extent? */
if (!next_vcn) {
if (a->lowest_vcn) {
errno = EIO;
ntfs_log_perror("First extent of inode %llu "
"attribute has non-zero lowest_vcn",
(unsigned long long)na->ni->mft_no);
goto err_out;
}
/* Get the last vcn in the attribute. */
last_vcn = sle64_to_cpu(a->allocated_size) >>
vol->cluster_size_bits;
}
/* Get the lowest vcn for the next extent. */
highest_vcn = sle64_to_cpu(a->highest_vcn);
next_vcn = highest_vcn + 1;
/* Only one extent or error, which we catch below. */
if (next_vcn <= 0) {
errno = ENOENT;
break;
}
/* Avoid endless loops due to corruption. */
if (next_vcn < sle64_to_cpu(a->lowest_vcn)) {
errno = EIO;
ntfs_log_perror("Inode %llu has corrupt attribute list",
(unsigned long long)na->ni->mft_no);
goto err_out;
}
}
if (!a) {
ntfs_log_perror("Couldn't find attribute for runlist mapping");
goto err_out;
}
/*
* Cannot check highest_vcn when the last runlist has
* been modified earlier, as runlists and sizes may be
* updated without highest_vcn being in sync, when
* HOLES_DELAY is used
*/
if (not_mapped && highest_vcn && highest_vcn != last_vcn - 1) {
errno = EIO;
ntfs_log_perror("Failed to load full runlist: inode: %llu "
"highest_vcn: 0x%llx last_vcn: 0x%llx",
(unsigned long long)na->ni->mft_no,
(long long)highest_vcn, (long long)last_vcn);
goto err_out;
}
if (errno == ENOENT) {
NAttrSetFullyMapped(na);
ret = 0;
}
err_out:
ntfs_attr_put_search_ctx(ctx);
out:
ntfs_log_leave("\n");
return ret;
} | 0 |
Chrome | 62154472bd2c43e1790dd1bd8a527c1db9118d88 | NOT_APPLICABLE | NOT_APPLICABLE | bool MatchesFilters(
const std::string* device_name,
const UUIDSet& device_uuids,
const base::Optional<
std::vector<blink::mojom::WebBluetoothLeScanFilterPtr>>& filters) {
DCHECK(!HasEmptyOrInvalidFilter(filters));
for (const auto& filter : filters.value()) {
if (MatchesFilter(device_name, device_uuids, filter)) {
return true;
}
}
return false;
}
| 0 |
linux | f5364c150aa645b3d7daa21b5c0b9feaa1c9cd6d | NOT_APPLICABLE | NOT_APPLICABLE | void set_user_nice(struct task_struct *p, long nice)
{
int old_prio, delta, queued;
struct rq_flags rf;
struct rq *rq;
if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE)
return;
/*
* We have to be careful, if called from sys_setpriority(),
* the task might be in the middle of scheduling on another CPU.
*/
rq = task_rq_lock(p, &rf);
/*
* The RT priorities are set via sched_setscheduler(), but we still
* allow the 'normal' nice value to be set - but as expected
* it wont have any effect on scheduling until the task is
* SCHED_DEADLINE, SCHED_FIFO or SCHED_RR:
*/
if (task_has_dl_policy(p) || task_has_rt_policy(p)) {
p->static_prio = NICE_TO_PRIO(nice);
goto out_unlock;
}
queued = task_on_rq_queued(p);
if (queued)
dequeue_task(rq, p, DEQUEUE_SAVE);
p->static_prio = NICE_TO_PRIO(nice);
set_load_weight(p);
old_prio = p->prio;
p->prio = effective_prio(p);
delta = p->prio - old_prio;
if (queued) {
enqueue_task(rq, p, ENQUEUE_RESTORE);
/*
* If the task increased its priority or is running and
* lowered its priority, then reschedule its CPU:
*/
if (delta < 0 || (delta > 0 && task_running(rq, p)))
resched_curr(rq);
}
out_unlock:
task_rq_unlock(rq, p, &rf);
}
| 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | //! Discard neighboring duplicates in the image buffer, along the specified axis \newinstance.
CImg<T> get_discard(const char axis=0) const {
CImg<T> res;
if (is_empty()) return res;
const char _axis = cimg::lowercase(axis);
T current = *_data?(T)0:(T)1;
int j = 0;
res.assign(width(),height(),depth(),spectrum());
switch (_axis) {
case 'x' : {
cimg_forX(*this,i)
if ((*this)(i)!=current) { res.draw_image(j++,get_column(i)); current = (*this)(i); }
res.resize(j,-100,-100,-100,0);
} break;
case 'y' : {
cimg_forY(*this,i)
if ((*this)(0,i)!=current) { res.draw_image(0,j++,get_row(i)); current = (*this)(0,i); }
res.resize(-100,j,-100,-100,0);
} break;
case 'z' : {
cimg_forZ(*this,i)
if ((*this)(0,0,i)!=current) { res.draw_image(0,0,j++,get_slice(i)); current = (*this)(0,0,i); }
res.resize(-100,-100,j,-100,0);
} break;
case 'c' : {
cimg_forC(*this,i)
if ((*this)(0,0,0,i)!=current) { res.draw_image(0,0,0,j++,get_channel(i)); current = (*this)(0,0,0,i); }
res.resize(-100,-100,-100,j,0);
} break;
default : {
res.unroll('y');
cimg_foroff(*this,i)
if ((*this)[i]!=current) res[j++] = current = (*this)[i];
res.resize(-100,j,-100,-100,0);
}
}
return res; | 0 |
pycurl | 2a743674dcf152beaaf6adaddb1ef51b18d1fffe | NOT_APPLICABLE | NOT_APPLICABLE | do_curl_clear(CurlObject *self)
{
#ifdef WITH_THREAD
assert(pycurl_get_thread_state(self) == NULL);
#endif
util_curl_xdecref(self, PYCURL_MEMGROUP_ALL, self->handle);
return 0;
} | 0 |
linux | 550fd08c2cebad61c548def135f67aba284c6162 | NOT_APPLICABLE | NOT_APPLICABLE | static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
{
struct bonding *bond = netdev_priv(bond_dev);
info->bond_mode = bond->params.mode;
info->miimon = bond->params.miimon;
read_lock(&bond->lock);
info->num_slaves = bond->slave_cnt;
read_unlock(&bond->lock);
return 0;
}
| 0 |
libxml2 | bdd66182ef53fe1f7209ab6535fda56366bd7ac9 | NOT_APPLICABLE | NOT_APPLICABLE | xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlNodePtr elem,
int options)
{
int depth = -1, adoptns = 0, parnsdone = 0;
xmlNsPtr ns, prevns;
xmlDocPtr doc;
xmlNodePtr cur, curElem = NULL;
xmlNsMapPtr nsMap = NULL;
xmlNsMapItemPtr /* topmi = NULL, */ mi;
/* @ancestorsOnly should be set by an option flag. */
int ancestorsOnly = 0;
int optRemoveRedundantNS =
((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0;
xmlNsPtr *listRedund = NULL;
int sizeRedund = 0, nbRedund = 0, ret, i, j;
if ((elem == NULL) || (elem->doc == NULL) ||
(elem->type != XML_ELEMENT_NODE))
return (-1);
doc = elem->doc;
cur = elem;
do {
switch (cur->type) {
case XML_ELEMENT_NODE:
adoptns = 1;
curElem = cur;
depth++;
/*
* Namespace declarations.
*/
if (cur->nsDef != NULL) {
prevns = NULL;
ns = cur->nsDef;
while (ns != NULL) {
if (! parnsdone) {
if ((elem->parent) &&
((xmlNodePtr) elem->parent->doc != elem->parent)) {
/*
* Gather ancestor in-scope ns-decls.
*/
if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,
elem->parent) == -1)
goto internal_error;
}
parnsdone = 1;
}
/*
* Lookup the ns ancestor-axis for equal ns-decls in scope.
*/
if (optRemoveRedundantNS && XML_NSMAP_NOTEMPTY(nsMap)) {
XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
(mi->shadowDepth == -1) &&
((ns->prefix == mi->newNs->prefix) ||
xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&
((ns->href == mi->newNs->href) ||
xmlStrEqual(ns->href, mi->newNs->href)))
{
/*
* A redundant ns-decl was found.
* Add it to the list of redundant ns-decls.
*/
if (xmlDOMWrapNSNormAddNsMapItem2(&listRedund,
&sizeRedund, &nbRedund, ns, mi->newNs) == -1)
goto internal_error;
/*
* Remove the ns-decl from the element-node.
*/
if (prevns)
prevns->next = ns->next;
else
cur->nsDef = ns->next;
goto next_ns_decl;
}
}
}
/*
* Skip ns-references handling if the referenced
* ns-decl is declared on the same element.
*/
if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
adoptns = 0;
/*
* Does it shadow any ns-decl?
*/
if (XML_NSMAP_NOTEMPTY(nsMap)) {
XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
(mi->shadowDepth == -1) &&
((ns->prefix == mi->newNs->prefix) ||
xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
mi->shadowDepth = depth;
}
}
}
/*
* Push mapping.
*/
if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,
depth) == NULL)
goto internal_error;
prevns = ns;
next_ns_decl:
ns = ns->next;
}
}
if (! adoptns)
goto ns_end;
/* No break on purpose. */
case XML_ATTRIBUTE_NODE:
/* No ns, no fun. */
if (cur->ns == NULL)
goto ns_end;
if (! parnsdone) {
if ((elem->parent) &&
((xmlNodePtr) elem->parent->doc != elem->parent)) {
if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,
elem->parent) == -1)
goto internal_error;
}
parnsdone = 1;
}
/*
* Adjust the reference if this was a redundant ns-decl.
*/
if (listRedund) {
for (i = 0, j = 0; i < nbRedund; i++, j += 2) {
if (cur->ns == listRedund[j]) {
cur->ns = listRedund[++j];
break;
}
}
}
/*
* Adopt ns-references.
*/
if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Search for a mapping.
*/
XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->shadowDepth == -1) &&
(cur->ns == mi->oldNs)) {
cur->ns = mi->newNs;
goto ns_end;
}
}
}
/*
* Aquire a normalized ns-decl and add it to the map.
*/
if (xmlDOMWrapNSNormAquireNormalizedNs(doc, curElem,
cur->ns, &ns,
&nsMap, depth,
ancestorsOnly,
(cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1)
goto internal_error;
cur->ns = ns;
ns_end:
if ((cur->type == XML_ELEMENT_NODE) &&
(cur->properties != NULL)) {
/*
* Process attributes.
*/
cur = (xmlNodePtr) cur->properties;
continue;
}
break;
default:
goto next_sibling;
}
into_content:
if ((cur->type == XML_ELEMENT_NODE) &&
(cur->children != NULL)) {
/*
* Process content of element-nodes only.
*/
cur = cur->children;
continue;
}
next_sibling:
if (cur == elem)
break;
if (cur->type == XML_ELEMENT_NODE) {
if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
XML_NSMAP_POP(nsMap, mi)
}
/*
* Unshadow.
*/
XML_NSMAP_FOREACH(nsMap, mi) {
if (mi->shadowDepth >= depth)
mi->shadowDepth = -1;
}
}
depth--;
}
if (cur->next != NULL)
cur = cur->next;
else {
if (cur->type == XML_ATTRIBUTE_NODE) {
cur = cur->parent;
goto into_content;
}
cur = cur->parent;
goto next_sibling;
}
} while (cur != NULL);
ret = 0;
goto exit;
internal_error:
ret = -1;
exit:
if (listRedund) {
for (i = 0, j = 0; i < nbRedund; i++, j += 2) {
xmlFreeNs(listRedund[j]);
}
xmlFree(listRedund);
}
if (nsMap != NULL)
xmlDOMWrapNsMapFree(nsMap);
return (ret);
} | 0 |
Chrome | a4150b688a754d3d10d2ca385155b1c95d77d6ae | NOT_APPLICABLE | NOT_APPLICABLE | bool GLES2Implementation::GetSyncivHelper(GLsync sync,
GLenum pname,
GLsizei bufsize,
GLsizei* length,
GLint* values) {
GLint value = 0;
switch (pname) {
case GL_OBJECT_TYPE:
value = GL_SYNC_FENCE;
break;
case GL_SYNC_CONDITION:
value = GL_SYNC_GPU_COMMANDS_COMPLETE;
break;
case GL_SYNC_FLAGS:
value = 0;
break;
default:
return false;
}
if (bufsize > 0) {
DCHECK(values);
*values = value;
}
if (length) {
*length = 1;
}
return true;
}
| 0 |
ImageMagick | b61d35eaccc0a7ddeff8a1c3abfcd0a43ccf210b | NOT_APPLICABLE | NOT_APPLICABLE | static Image *ReadTEXTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
filename[MagickPathExtent],
geometry[MagickPathExtent],
*p,
text[MagickPathExtent];
DrawInfo
*draw_info;
Image
*image,
*texture;
MagickBooleanType
status;
PointInfo
delta;
RectangleInfo
page;
ssize_t
offset;
TypeMetric
metrics;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
(void) ResetMagickMemory(text,0,sizeof(text));
(void) ReadBlobString(image,text);
/*
Set the page geometry.
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
if ((image->resolution.x == 0.0) || (image->resolution.y == 0.0))
{
GeometryInfo
geometry_info;
MagickStatusType
flags;
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
image->resolution.x=geometry_info.rho;
image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
image->resolution.y=image->resolution.x;
}
page.width=612;
page.height=792;
page.x=43;
page.y=43;
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
/*
Initialize Image structure.
*/
image->columns=(size_t) floor((((double) page.width*image->resolution.x)/
delta.x)+0.5);
image->rows=(size_t) floor((((double) page.height*image->resolution.y)/
delta.y)+0.5);
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
image->page.x=0;
image->page.y=0;
texture=(Image *) NULL;
if (image_info->texture != (char *) NULL)
{
ImageInfo
*read_info;
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) CopyMagickString(read_info->filename,image_info->texture,
MagickPathExtent);
texture=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
}
/*
Annotate the text image.
*/
(void) SetImageBackgroundColor(image,exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
(void) CloneString(&draw_info->text,image_info->filename);
(void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
status=GetTypeMetrics(image,draw_info,&metrics,exception);
if (status == MagickFalse)
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);
(void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
(void) CopyMagickString(filename,image_info->filename,MagickPathExtent);
if (*draw_info->text != '\0')
*draw_info->text='\0';
p=text;
for (offset=2*page.y; p != (char *) NULL; )
{
/*
Annotate image with text.
*/
(void) ConcatenateString(&draw_info->text,text);
(void) ConcatenateString(&draw_info->text,"\n");
offset+=(ssize_t) (metrics.ascent-metrics.descent);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset,
image->rows);
if (status == MagickFalse)
break;
}
p=ReadBlobString(image,text);
if ((offset < (ssize_t) image->rows) && (p != (char *) NULL))
continue;
if (texture != (Image *) NULL)
{
MagickProgressMonitor
progress_monitor;
progress_monitor=SetImageProgressMonitor(image,
(MagickProgressMonitor) NULL,image->client_data);
(void) TextureImage(image,texture,exception);
(void) SetImageProgressMonitor(image,progress_monitor,
image->client_data);
}
(void) AnnotateImage(image,draw_info,exception);
if (p == (char *) NULL)
break;
/*
Page is full-- allocate next image structure.
*/
*draw_info->text='\0';
offset=2*page.y;
AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image->next->columns=image->columns;
image->next->rows=image->rows;
image=SyncNextImageInList(image);
(void) CopyMagickString(image->filename,filename,MagickPathExtent);
(void) SetImageBackgroundColor(image,exception);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
if (texture != (Image *) NULL)
{
MagickProgressMonitor
progress_monitor;
progress_monitor=SetImageProgressMonitor(image,
(MagickProgressMonitor) NULL,image->client_data);
(void) TextureImage(image,texture,exception);
(void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
}
(void) AnnotateImage(image,draw_info,exception);
if (texture != (Image *) NULL)
texture=DestroyImage(texture);
draw_info=DestroyDrawInfo(draw_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
| 0 |
Android | 37c88107679d36c419572732b4af6e18bb2f7dce | NOT_APPLICABLE | NOT_APPLICABLE | static int config_clear(void) {
LOG_INFO("%s", __func__);
return btif_config_clear();
}
| 0 |
poppler | b1026b5978c385328f2a15a2185c599a563edf91 | NOT_APPLICABLE | NOT_APPLICABLE | void CCITTFaxStream::reset() {
int code1;
ccittReset(gFalse);
if (codingLine != NULL && refLine != NULL) {
eof = gFalse;
codingLine[0] = columns;
} else {
eof = gTrue;
}
while ((code1 = lookBits(12)) == 0) {
eatBits(1);
}
if (code1 == 0x001) {
eatBits(12);
endOfLine = gTrue;
}
if (encoding > 0) {
nextLine2D = !lookBits(1);
eatBits(1);
}
}
| 0 |
linux | cfa39381173d5f969daf43582c95ad679189cbc9 | NOT_APPLICABLE | NOT_APPLICABLE | static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm,
struct kvm_enable_cap *cap)
{
switch (cap->cap) {
#ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
case KVM_CAP_MANUAL_DIRTY_LOG_PROTECT:
if (cap->flags || (cap->args[0] & ~1))
return -EINVAL;
kvm->manual_dirty_log_protect = cap->args[0];
return 0;
#endif
default:
return kvm_vm_ioctl_enable_cap(kvm, cap);
}
}
| 0 |
Chrome | 244c78b3f737f2cacab2d212801b0524cbcc3a7b | NOT_APPLICABLE | NOT_APPLICABLE | CloudPolicySubsystem::CloudPolicySubsystem()
: refresh_pref_name_(NULL) {}
| 0 |
linux-2.6 | 06a279d636734da32bb62dd2f7b0ade666f65d7c | NOT_APPLICABLE | NOT_APPLICABLE | struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
ext4_lblk_t block, int create, int *err)
{
struct buffer_head *bh;
bh = ext4_getblk(handle, inode, block, create, err);
if (!bh)
return bh;
if (buffer_uptodate(bh))
return bh;
ll_rw_block(READ_META, 1, &bh);
wait_on_buffer(bh);
if (buffer_uptodate(bh))
return bh;
put_bh(bh);
*err = -EIO;
return NULL;
} | 0 |
ImageMagick | 90406972f108c4da71f998601b06abdc2ac6f06e | NOT_APPLICABLE | NOT_APPLICABLE | MagickExport ImageType IdentifyImageType(const Image *image,
ExceptionInfo *exception)
{
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (image->colorspace == CMYKColorspace)
{
if (image->alpha_trait == UndefinedPixelTrait)
return(ColorSeparationType);
return(ColorSeparationAlphaType);
}
if (IdentifyImageMonochrome(image,exception) != MagickFalse)
return(BilevelType);
if (IdentifyImageGray(image,exception) != UndefinedType)
{
if (image->alpha_trait != UndefinedPixelTrait)
return(GrayscaleAlphaType);
return(GrayscaleType);
}
if (IdentifyPaletteImage(image,exception) != MagickFalse)
{
if (image->alpha_trait != UndefinedPixelTrait)
return(PaletteAlphaType);
return(PaletteType);
}
if (image->alpha_trait != UndefinedPixelTrait)
return(TrueColorAlphaType);
return(TrueColorType);
} | 0 |
postgres | 31400a673325147e1205326008e32135a78b4d8a | NOT_APPLICABLE | NOT_APPLICABLE | parse_hstore(HSParser *state)
{
int st = WKEY;
bool escaped = false;
state->plen = 16;
state->pairs = (Pairs *) palloc(sizeof(Pairs) * state->plen);
state->pcur = 0;
state->ptr = state->begin;
state->word = NULL;
while (1)
{
if (st == WKEY)
{
if (!get_val(state, false, &escaped))
return;
if (state->pcur >= state->plen)
{
state->plen *= 2;
state->pairs = (Pairs *) repalloc(state->pairs, sizeof(Pairs) * state->plen);
}
state->pairs[state->pcur].key = state->word;
state->pairs[state->pcur].keylen = hstoreCheckKeyLen(state->cur - state->word);
state->pairs[state->pcur].val = NULL;
state->word = NULL;
st = WEQ;
}
else if (st == WEQ)
{
if (*(state->ptr) == '=')
{
st = WGT;
}
else if (*(state->ptr) == '\0')
{
elog(ERROR, "Unexpected end of string");
}
else if (!isspace((unsigned char) *(state->ptr)))
{
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
}
}
else if (st == WGT)
{
if (*(state->ptr) == '>')
{
st = WVAL;
}
else if (*(state->ptr) == '\0')
{
elog(ERROR, "Unexpected end of string");
}
else
{
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
}
}
else if (st == WVAL)
{
if (!get_val(state, true, &escaped))
elog(ERROR, "Unexpected end of string");
state->pairs[state->pcur].val = state->word;
state->pairs[state->pcur].vallen = hstoreCheckValLen(state->cur - state->word);
state->pairs[state->pcur].isnull = false;
state->pairs[state->pcur].needfree = true;
if (state->cur - state->word == 4 && !escaped)
{
state->word[4] = '\0';
if (0 == pg_strcasecmp(state->word, "null"))
state->pairs[state->pcur].isnull = true;
}
state->word = NULL;
state->pcur++;
st = WDEL;
}
else if (st == WDEL)
{
if (*(state->ptr) == ',')
{
st = WKEY;
}
else if (*(state->ptr) == '\0')
{
return;
}
else if (!isspace((unsigned char) *(state->ptr)))
{
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
}
}
else
elog(ERROR, "Unknown state %d at line %d in file '%s'", st, __LINE__, __FILE__);
state->ptr++;
}
}
| 0 |
samba | c252546ceeb0925eb8a4061315e3ff0a8c55b48b | NOT_APPLICABLE | NOT_APPLICABLE | void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
{
struct map_struct *buf;
OFF_T i, len = st_p->st_size;
md_context m;
int32 remainder;
int fd;
memset(sum, 0, MAX_DIGEST_LEN);
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1)
return;
buf = map_file(fd, len, MAX_MAP_SIZE, CSUM_CHUNK);
switch (checksum_type) {
case CSUM_MD5:
md5_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
md5_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
remainder = (int32)(len - i);
if (remainder > 0)
md5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
md5_result(&m, (uchar *)sum);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC:
mdfour_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
/* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes. */
remainder = (int32)(len - i);
if (remainder > 0 || checksum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);
break;
default:
rprintf(FERROR, "invalid checksum-choice for the --checksum option (%d)\n", checksum_type);
exit_cleanup(RERR_UNSUPPORTED);
}
close(fd);
unmap_file(buf);
}
| 0 |
Chrome | 6bdf46c517fd12674ffc61d827dc8987e67f0334 | CVE-2013-2917 | CWE-119 | ReverbConvolverStage::ReverbConvolverStage(const float* impulseResponse, size_t, size_t reverbTotalLatency, size_t stageOffset, size_t stageLength,
size_t fftSize, size_t renderPhase, size_t renderSliceSize, ReverbAccumulationBuffer* accumulationBuffer, bool directMode)
: m_accumulationBuffer(accumulationBuffer)
, m_accumulationReadIndex(0)
, m_inputReadIndex(0)
, m_directMode(directMode)
{
ASSERT(impulseResponse);
ASSERT(accumulationBuffer);
if (!m_directMode) {
m_fftKernel = adoptPtr(new FFTFrame(fftSize));
m_fftKernel->doPaddedFFT(impulseResponse + stageOffset, stageLength);
m_fftConvolver = adoptPtr(new FFTConvolver(fftSize));
} else {
m_directKernel = adoptPtr(new AudioFloatArray(fftSize / 2));
m_directKernel->copyToRange(impulseResponse + stageOffset, 0, fftSize / 2);
m_directConvolver = adoptPtr(new DirectConvolver(renderSliceSize));
}
m_temporaryBuffer.allocate(renderSliceSize);
size_t totalDelay = stageOffset + reverbTotalLatency;
size_t halfSize = fftSize / 2;
if (!m_directMode) {
ASSERT(totalDelay >= halfSize);
if (totalDelay >= halfSize)
totalDelay -= halfSize;
}
int maxPreDelayLength = std::min(halfSize, totalDelay);
m_preDelayLength = totalDelay > 0 ? renderPhase % maxPreDelayLength : 0;
if (m_preDelayLength > totalDelay)
m_preDelayLength = 0;
m_postDelayLength = totalDelay - m_preDelayLength;
m_preReadWriteIndex = 0;
m_framesProcessed = 0; // total frames processed so far
size_t delayBufferSize = m_preDelayLength < fftSize ? fftSize : m_preDelayLength;
delayBufferSize = delayBufferSize < renderSliceSize ? renderSliceSize : delayBufferSize;
m_preDelayBuffer.allocate(delayBufferSize);
}
| 1 |
linux | a4a5ed2835e8ea042868b7401dced3f517cafa76 | NOT_APPLICABLE | NOT_APPLICABLE | static u64 __init get_ramdisk_image(void)
{
u64 ramdisk_image = boot_params.hdr.ramdisk_image;
ramdisk_image |= (u64)boot_params.ext_ramdisk_image << 32;
return ramdisk_image;
}
| 0 |
libtool | e91f7b960032074a55fc91273c1917e3082b5338 | NOT_APPLICABLE | NOT_APPLICABLE | lt_dladvise_local (lt_dladvise *padvise)
{
assert (padvise && *padvise);
(*padvise)->is_symlocal = 1;
return 0;
} | 0 |
passenger | 4043718264095cde6623c2cbe8c644541036d7bf | NOT_APPLICABLE | NOT_APPLICABLE | string createErrorPageFromStderrOutput(const string &msg,
SpawnException::ErrorKind errorKind,
const string &stderrOutput)
{
// These kinds of SpawnExceptions are not supposed to be handled through this function.
assert(errorKind != SpawnException::PRELOADER_STARTUP_EXPLAINABLE_ERROR);
assert(errorKind != SpawnException::APP_STARTUP_EXPLAINABLE_ERROR);
string result = escapeHTML(msg);
if (errorKind == SpawnException::PRELOADER_STARTUP_TIMEOUT
|| errorKind == SpawnException::APP_STARTUP_TIMEOUT
|| errorKind == SpawnException::PRELOADER_STARTUP_ERROR
|| errorKind == SpawnException::APP_STARTUP_ERROR)
{
result.append(" Please read <a href=\"https://github.com/phusion/passenger/wiki/Debugging-application-startup-problems\">this article</a> "
"for more information about this problem.");
}
result.append("<br>\n<h2>Raw process output:</h2>\n");
if (strip(stderrOutput).empty()) {
result.append("(empty)");
} else {
result.append("<pre>");
result.append(escapeHTML(stderrOutput));
result.append("</pre>");
}
return result;
} | 0 |
quagga | cfb1fae25f8c092e0d17073eaf7bd428ce1cd546 | CVE-2016-1245 | CWE-119 | rtadv_read (struct thread *thread)
{
int sock;
int len;
u_char buf[RTADV_MSG_SIZE];
struct sockaddr_in6 from;
ifindex_t ifindex = 0;
int hoplimit = -1;
struct zebra_vrf *zvrf = THREAD_ARG (thread);
sock = THREAD_FD (thread);
zvrf->rtadv.ra_read = NULL;
/* Register myself. */
rtadv_event (zvrf, RTADV_READ, sock);
len = rtadv_recv_packet (sock, buf, BUFSIZ, &from, &ifindex, &hoplimit);
if (len < 0)
{
zlog_warn ("router solicitation recv failed: %s.", safe_strerror (errno));
return len;
}
rtadv_process_packet (buf, (unsigned)len, ifindex, hoplimit, zvrf->vrf_id);
return 0;
}
| 1 |
linux-2.6 | 5e739d1752aca4e8f3e794d431503bfca3162df4 | NOT_APPLICABLE | NOT_APPLICABLE | int sctp_inet_listen(struct socket *sock, int backlog)
{
struct sock *sk = sock->sk;
struct crypto_hash *tfm = NULL;
int err = -EINVAL;
if (unlikely(backlog < 0))
goto out;
sctp_lock_sock(sk);
if (sock->state != SS_UNCONNECTED)
goto out;
/* Allocate HMAC for generating cookie. */
if (!sctp_sk(sk)->hmac && sctp_hmac_alg) {
tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
if (net_ratelimit()) {
printk(KERN_INFO
"SCTP: failed to load transform for %s: %ld\n",
sctp_hmac_alg, PTR_ERR(tfm));
}
err = -ENOSYS;
goto out;
}
}
switch (sock->type) {
case SOCK_SEQPACKET:
err = sctp_seqpacket_listen(sk, backlog);
break;
case SOCK_STREAM:
err = sctp_stream_listen(sk, backlog);
break;
default:
break;
}
if (err)
goto cleanup;
/* Store away the transform reference. */
if (!sctp_sk(sk)->hmac)
sctp_sk(sk)->hmac = tfm;
out:
sctp_release_sock(sk);
return err;
cleanup:
crypto_free_hash(tfm);
goto out;
} | 0 |
samba | 530d50a1abdcdf4d1775652d4c456c1274d83d8d | NOT_APPLICABLE | NOT_APPLICABLE | bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
struct asn1_data *data,
const char **result)
{
DATA_BLOB string;
if (!asn1_read_OctetString(data, mem_ctx, &string))
return false;
*result = blob2string_talloc(mem_ctx, string);
data_blob_free(&string);
return true;
}
| 0 |
mruby | b1d0296a937fe278239bdfac840a3fd0e93b3ee9 | NOT_APPLICABLE | NOT_APPLICABLE | mrb_class_inherited(mrb_state *mrb, struct RClass *super, struct RClass *klass)
{
mrb_value s;
mrb_sym mid;
if (!super)
super = mrb->object_class;
super->flags |= MRB_FL_CLASS_IS_INHERITED;
s = mrb_obj_value(super);
mrb_mc_clear_by_class(mrb, klass);
mid = MRB_SYM(inherited);
if (!mrb_func_basic_p(mrb, s, mid, mrb_do_nothing)) {
mrb_value c = mrb_obj_value(klass);
mrb_funcall_argv(mrb, s, mid, 1, &c);
}
} | 0 |
tensorflow | c57c0b9f3a4f8684f3489dd9a9ec627ad8b599f5 | CVE-2021-29521 | CWE-125 | void Compute(OpKernelContext* context) override {
const Tensor& indices = context->input(0);
const Tensor& values = context->input(1);
const Tensor& shape = context->input(2);
const Tensor& weights = context->input(3);
bool use_weights = weights.NumElements() > 0;
OP_REQUIRES(context, TensorShapeUtils::IsMatrix(indices.shape()),
errors::InvalidArgument(
"Input indices must be a 2-dimensional tensor. Got: ",
indices.shape().DebugString()));
if (use_weights) {
OP_REQUIRES(
context, weights.shape() == values.shape(),
errors::InvalidArgument(
"Weights and values must have the same shape. Weight shape: ",
weights.shape().DebugString(),
"; values shape: ", values.shape().DebugString()));
}
OP_REQUIRES(context, shape.NumElements() != 0,
errors::InvalidArgument(
"The shape argument requires at least one element."));
bool is_1d = shape.NumElements() == 1;
int num_batches = is_1d ? 1 : shape.flat<int64>()(0);
int num_values = values.NumElements();
OP_REQUIRES(context, num_values == indices.shape().dim_size(0),
errors::InvalidArgument(
"Number of values must match first dimension of indices.",
"Got ", num_values,
" values, indices shape: ", indices.shape().DebugString()));
const auto indices_values = indices.matrix<int64>();
const auto values_values = values.flat<T>();
const auto weight_values = weights.flat<W>();
auto per_batch_counts = BatchedMap<W>(num_batches);
T max_value = 0;
for (int idx = 0; idx < num_values; ++idx) {
int batch = is_1d ? 0 : indices_values(idx, 0);
if (batch >= num_batches) {
OP_REQUIRES(context, batch < num_batches,
errors::InvalidArgument(
"Indices value along the first dimension must be ",
"lower than the first index of the shape.", "Got ",
batch, " as batch and ", num_batches,
" as the first dimension of the shape."));
}
const auto& value = values_values(idx);
if (value >= 0 && (maxlength_ <= 0 || value < maxlength_)) {
if (binary_output_) {
per_batch_counts[batch][value] = 1;
} else if (use_weights) {
per_batch_counts[batch][value] += weight_values(idx);
} else {
per_batch_counts[batch][value]++;
}
if (value > max_value) {
max_value = value;
}
}
}
int num_output_values = GetOutputSize(max_value, maxlength_, minlength_);
OP_REQUIRES_OK(context, OutputSparse<W>(per_batch_counts, num_output_values,
is_1d, context));
} | 1 |
keepalived | 04f2d32871bb3b11d7dc024039952f2fe2750306 | CVE-2018-19044 | CWE-59 | vrrp_print_stats(void)
{
FILE *file;
file = fopen (stats_file, "w");
if (!file) {
log_message(LOG_INFO, "Can't open %s (%d: %s)",
stats_file, errno, strerror(errno));
return;
}
list l = vrrp_data->vrrp;
element e;
vrrp_t *vrrp;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
fprintf(file, "VRRP Instance: %s\n", vrrp->iname);
fprintf(file, " Advertisements:\n");
fprintf(file, " Received: %" PRIu64 "\n", vrrp->stats->advert_rcvd);
fprintf(file, " Sent: %d\n", vrrp->stats->advert_sent);
fprintf(file, " Became master: %d\n", vrrp->stats->become_master);
fprintf(file, " Released master: %d\n",
vrrp->stats->release_master);
fprintf(file, " Packet Errors:\n");
fprintf(file, " Length: %" PRIu64 "\n", vrrp->stats->packet_len_err);
fprintf(file, " TTL: %" PRIu64 "\n", vrrp->stats->ip_ttl_err);
fprintf(file, " Invalid Type: %" PRIu64 "\n",
vrrp->stats->invalid_type_rcvd);
fprintf(file, " Advertisement Interval: %" PRIu64 "\n",
vrrp->stats->advert_interval_err);
fprintf(file, " Address List: %" PRIu64 "\n",
vrrp->stats->addr_list_err);
fprintf(file, " Authentication Errors:\n");
fprintf(file, " Invalid Type: %d\n",
vrrp->stats->invalid_authtype);
#ifdef _WITH_VRRP_AUTH_
fprintf(file, " Type Mismatch: %d\n",
vrrp->stats->authtype_mismatch);
fprintf(file, " Failure: %d\n",
vrrp->stats->auth_failure);
#endif
fprintf(file, " Priority Zero:\n");
fprintf(file, " Received: %" PRIu64 "\n", vrrp->stats->pri_zero_rcvd);
fprintf(file, " Sent: %" PRIu64 "\n", vrrp->stats->pri_zero_sent);
}
fclose(file);
}
| 1 |
linux | 8b8addf891de8a00e4d39fc32f93f7c5eb8feceb | CVE-2016-3672 | CWE-254 | static unsigned long mmap_legacy_base(unsigned long rnd)
{
if (mmap_is_ia32())
return TASK_UNMAPPED_BASE;
else
return TASK_UNMAPPED_BASE + rnd;
}
| 1 |
dbus | 954d75b2b64e4799f360d2a6bf9cff6d9fee37e7 | NOT_APPLICABLE | NOT_APPLICABLE | _dbus_poll (DBusPollFD *fds,
int n_fds,
int timeout_milliseconds)
{
#define USE_CHRIS_IMPL 0
#if USE_CHRIS_IMPL
#define DBUS_POLL_CHAR_BUFFER_SIZE 2000
char msg[DBUS_POLL_CHAR_BUFFER_SIZE];
char *msgp;
int ret = 0;
int i;
struct timeval tv;
int ready;
#define DBUS_STACK_WSAEVENTS 256
WSAEVENT eventsOnStack[DBUS_STACK_WSAEVENTS];
WSAEVENT *pEvents = NULL;
if (n_fds > DBUS_STACK_WSAEVENTS)
pEvents = calloc(sizeof(WSAEVENT), n_fds);
else
pEvents = eventsOnStack;
#ifdef DBUS_ENABLE_VERBOSE_MODE
msgp = msg;
msgp += sprintf (msgp, "WSAEventSelect: to=%d\n\t", timeout_milliseconds);
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (fdp->events & _DBUS_POLLIN)
msgp += sprintf (msgp, "R:%d ", fdp->fd);
if (fdp->events & _DBUS_POLLOUT)
msgp += sprintf (msgp, "W:%d ", fdp->fd);
msgp += sprintf (msgp, "E:%d\n\t", fdp->fd);
if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE)
{
_dbus_assert_not_reached ("buffer overflow in _dbus_poll");
}
}
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
#endif
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
WSAEVENT ev;
long lNetworkEvents = FD_OOB;
ev = WSACreateEvent();
if (fdp->events & _DBUS_POLLIN)
lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE;
if (fdp->events & _DBUS_POLLOUT)
lNetworkEvents |= FD_WRITE | FD_CONNECT;
WSAEventSelect(fdp->fd, ev, lNetworkEvents);
pEvents[i] = ev;
}
ready = WSAWaitForMultipleEvents (n_fds, pEvents, FALSE, timeout_milliseconds, FALSE);
if (DBUS_SOCKET_API_RETURNS_ERROR (ready))
{
DBUS_SOCKET_SET_ERRNO ();
if (errno != WSAEWOULDBLOCK)
_dbus_verbose ("WSAWaitForMultipleEvents: failed: %s\n", _dbus_strerror_from_errno ());
ret = -1;
}
else if (ready == WSA_WAIT_TIMEOUT)
{
_dbus_verbose ("WSAWaitForMultipleEvents: WSA_WAIT_TIMEOUT\n");
ret = 0;
}
else if (ready >= WSA_WAIT_EVENT_0 && ready < (int)(WSA_WAIT_EVENT_0 + n_fds))
{
msgp = msg;
msgp += sprintf (msgp, "WSAWaitForMultipleEvents: =%d\n\t", ready);
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
WSANETWORKEVENTS ne;
fdp->revents = 0;
WSAEnumNetworkEvents(fdp->fd, pEvents[i], &ne);
if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
fdp->revents |= _DBUS_POLLIN;
if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT))
fdp->revents |= _DBUS_POLLOUT;
if (ne.lNetworkEvents & (FD_OOB))
fdp->revents |= _DBUS_POLLERR;
if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
msgp += sprintf (msgp, "R:%d ", fdp->fd);
if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT))
msgp += sprintf (msgp, "W:%d ", fdp->fd);
if (ne.lNetworkEvents & (FD_OOB))
msgp += sprintf (msgp, "E:%d ", fdp->fd);
msgp += sprintf (msgp, "lNetworkEvents:%d ", ne.lNetworkEvents);
if(ne.lNetworkEvents)
ret++;
WSAEventSelect(fdp->fd, pEvents[i], 0);
}
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
}
else
{
_dbus_verbose ("WSAWaitForMultipleEvents: failed for unknown reason!");
ret = -1;
}
for(i = 0; i < n_fds; i++)
{
WSACloseEvent(pEvents[i]);
}
if (n_fds > DBUS_STACK_WSAEVENTS)
free(pEvents);
return ret;
#else /* USE_CHRIS_IMPL */
#define DBUS_POLL_CHAR_BUFFER_SIZE 2000
char msg[DBUS_POLL_CHAR_BUFFER_SIZE];
char *msgp;
fd_set read_set, write_set, err_set;
int max_fd = 0;
int i;
struct timeval tv;
int ready;
FD_ZERO (&read_set);
FD_ZERO (&write_set);
FD_ZERO (&err_set);
#ifdef DBUS_ENABLE_VERBOSE_MODE
msgp = msg;
msgp += sprintf (msgp, "select: to=%d\n\t", timeout_milliseconds);
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (fdp->events & _DBUS_POLLIN)
msgp += sprintf (msgp, "R:%d ", fdp->fd);
if (fdp->events & _DBUS_POLLOUT)
msgp += sprintf (msgp, "W:%d ", fdp->fd);
msgp += sprintf (msgp, "E:%d\n\t", fdp->fd);
if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE)
{
_dbus_assert_not_reached ("buffer overflow in _dbus_poll");
}
}
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
#endif
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (fdp->events & _DBUS_POLLIN)
FD_SET (fdp->fd, &read_set);
if (fdp->events & _DBUS_POLLOUT)
FD_SET (fdp->fd, &write_set);
FD_SET (fdp->fd, &err_set);
max_fd = MAX (max_fd, fdp->fd);
}
tv.tv_sec = timeout_milliseconds < 0 ? 1 : timeout_milliseconds / 1000;
tv.tv_usec = timeout_milliseconds < 0 ? 0 : (timeout_milliseconds % 1000) * 1000;
ready = select (max_fd + 1, &read_set, &write_set, &err_set, &tv);
if (DBUS_SOCKET_API_RETURNS_ERROR (ready))
{
DBUS_SOCKET_SET_ERRNO ();
if (errno != WSAEWOULDBLOCK)
_dbus_verbose ("select: failed: %s\n", _dbus_strerror_from_errno ());
}
else if (ready == 0)
_dbus_verbose ("select: = 0\n");
else
if (ready > 0)
{
#ifdef DBUS_ENABLE_VERBOSE_MODE
msgp = msg;
msgp += sprintf (msgp, "select: = %d:\n\t", ready);
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (FD_ISSET (fdp->fd, &read_set))
msgp += sprintf (msgp, "R:%d ", fdp->fd);
if (FD_ISSET (fdp->fd, &write_set))
msgp += sprintf (msgp, "W:%d ", fdp->fd);
if (FD_ISSET (fdp->fd, &err_set))
msgp += sprintf (msgp, "E:%d\n\t", fdp->fd);
}
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
#endif
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
fdp->revents = 0;
if (FD_ISSET (fdp->fd, &read_set))
fdp->revents |= _DBUS_POLLIN;
if (FD_ISSET (fdp->fd, &write_set))
fdp->revents |= _DBUS_POLLOUT;
if (FD_ISSET (fdp->fd, &err_set))
fdp->revents |= _DBUS_POLLERR;
}
}
return ready;
#endif /* USE_CHRIS_IMPL */
}
| 0 |
postgres | 31400a673325147e1205326008e32135a78b4d8a | NOT_APPLICABLE | NOT_APPLICABLE | box_height(PG_FUNCTION_ARGS)
{
BOX *box = PG_GETARG_BOX_P(0);
PG_RETURN_FLOAT8(box->high.y - box->low.y);
}
| 0 |
Chrome | 2aec794f26098c7a361c27d7c8f57119631cca8a | NOT_APPLICABLE | NOT_APPLICABLE | DevToolsAgentHost* agent_host() { return agent_host_.get(); }
| 0 |
libvirt | 506e9d6c2d4baaf580d489fff0690c0ff2ff588f | NOT_APPLICABLE | NOT_APPLICABLE | virDomainGetFSInfo(virDomainPtr dom,
virDomainFSInfoPtr **info,
unsigned int flags)
{
VIR_DOMAIN_DEBUG(dom, "info=%p, flags=%x", info, flags);
virResetLastError();
virCheckDomainReturn(dom, -1);
virCheckReadOnlyGoto(dom->conn->flags, error);
virCheckNonNullArgGoto(info, error);
*info = NULL;
if (dom->conn->driver->domainGetFSInfo) {
int ret = dom->conn->driver->domainGetFSInfo(dom, info, flags);
if (ret < 0)
goto error;
return ret;
}
virReportUnsupportedError();
error:
virDispatchError(dom->conn);
return -1;
}
| 0 |
linux | 58bdd544e2933a21a51eecf17c3f5f94038261b5 | NOT_APPLICABLE | NOT_APPLICABLE | int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
struct msghdr *msg, size_t len)
{
struct sk_buff *pdu;
struct nfc_llcp_local *local;
size_t frag_len = 0, remaining_len;
u8 *msg_ptr, *msg_data;
u16 remote_miu;
int err;
pr_debug("Send UI frame len %zd\n", len);
local = sock->local;
if (local == NULL)
return -ENODEV;
msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN);
if (msg_data == NULL)
return -ENOMEM;
if (memcpy_from_msg(msg_data, msg, len)) {
kfree(msg_data);
return -EFAULT;
}
remaining_len = len;
msg_ptr = msg_data;
do {
remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
local->remote_miu : sock->remote_miu;
frag_len = min_t(size_t, remote_miu, remaining_len);
pr_debug("Fragment %zd bytes remaining %zd",
frag_len, remaining_len);
pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, 0,
frag_len + LLCP_HEADER_SIZE, &err);
if (pdu == NULL) {
pr_err("Could not allocate PDU (error=%d)\n", err);
len -= remaining_len;
if (len == 0)
len = err;
break;
}
pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
if (likely(frag_len > 0))
skb_put_data(pdu, msg_ptr, frag_len);
/* No need to check for the peer RW for UI frames */
skb_queue_tail(&local->tx_queue, pdu);
remaining_len -= frag_len;
msg_ptr += frag_len;
} while (remaining_len > 0);
kfree(msg_data);
return len;
}
| 0 |
qemu | ff82911cd3f69f028f2537825c9720ff78bc3f19 | CVE-2017-7539 | CWE-20 | static void nbd_recv_coroutines_enter_all(NBDClientSession *s)
{
int i;
for (i = 0; i < MAX_NBD_REQUESTS; i++) {
qemu_coroutine_enter(s->recv_coroutine[i]);
qemu_coroutine_enter(s->recv_coroutine[i]);
}
}
| 1 |
ruby | 1c2ef610358af33f9ded3086aa2d70aac03dcac5 | NOT_APPLICABLE | NOT_APPLICABLE | rb_str_rjust(int argc, VALUE *argv, VALUE str)
{
return rb_str_justify(argc, argv, str, 'r');
} | 0 |
FFmpeg | 4f05e2e2dc1a89f38cd9f0960a6561083d714f1e | NOT_APPLICABLE | NOT_APPLICABLE | static char *var_read_string(AVIOContext *pb, int size)
{
int n;
char *str;
if (size < 0 || size == INT_MAX)
return NULL;
str = av_malloc(size + 1);
if (!str)
return NULL;
n = avio_get_str(pb, size, str, size + 1);
if (n < size)
avio_skip(pb, size - n);
return str;
}
| 0 |
qemu | 3251bdcf1c67427d964517053c3d185b46e618e8 | NOT_APPLICABLE | NOT_APPLICABLE | static void ide_dummy_transfer_stop(IDEState *s)
{
s->data_ptr = s->io_buffer;
s->data_end = s->io_buffer;
s->io_buffer[0] = 0xff;
s->io_buffer[1] = 0xff;
s->io_buffer[2] = 0xff;
s->io_buffer[3] = 0xff;
}
| 0 |
qemu | fa365d7cd11185237471823a5a33d36765454e16 | NOT_APPLICABLE | NOT_APPLICABLE | static void acpi_pcihp_update(AcpiPciHpState *s)
{
int i;
for (i = 0; i < ACPI_PCIHP_MAX_HOTPLUG_BUS; ++i) {
acpi_pcihp_update_hotplug_bus(s, i);
}
}
| 0 |
stb | 244d83bc3d859293f55812d48b3db168e581f6ab | NOT_APPLICABLE | NOT_APPLICABLE | static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
{
int a_off = base_n >> 3;
float A2 = A[0+a_off];
float *z = e + i_off;
float *base = z - 16 * n;
while (z > base) {
float k00,k11;
k00 = z[-0] - z[-8];
k11 = z[-1] - z[-9];
z[-0] = z[-0] + z[-8];
z[-1] = z[-1] + z[-9];
z[-8] = k00;
z[-9] = k11 ;
k00 = z[ -2] - z[-10];
k11 = z[ -3] - z[-11];
z[ -2] = z[ -2] + z[-10];
z[ -3] = z[ -3] + z[-11];
z[-10] = (k00+k11) * A2;
z[-11] = (k11-k00) * A2;
k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation
k11 = z[ -5] - z[-13];
z[ -4] = z[ -4] + z[-12];
z[ -5] = z[ -5] + z[-13];
z[-12] = k11;
z[-13] = k00;
k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation
k11 = z[ -7] - z[-15];
z[ -6] = z[ -6] + z[-14];
z[ -7] = z[ -7] + z[-15];
z[-14] = (k00+k11) * A2;
z[-15] = (k00-k11) * A2;
iter_54(z);
iter_54(z-8);
z -= 16;
}
}
| 0 |
php-src | 7cf7148a8f8f4f55fb04de2a517d740bb6253eac | NOT_APPLICABLE | NOT_APPLICABLE | PHP_NAMED_FUNCTION(php_if_iconv)
{
char *in_charset, *out_charset;
zend_string *in_buffer;
size_t in_charset_len = 0, out_charset_len = 0;
php_iconv_err_t err;
zend_string *out_buffer;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssS",
&in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer) == FAILURE)
return;
if (in_charset_len >= ICONV_CSNMAXLEN || out_charset_len >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;
}
err = php_iconv_string(ZSTR_VAL(in_buffer), (size_t)ZSTR_LEN(in_buffer), &out_buffer, out_charset, in_charset);
_php_iconv_show_error(err, out_charset, in_charset);
if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
RETVAL_STR(out_buffer);
} else {
if (out_buffer != NULL) {
zend_string_free(out_buffer);
}
RETURN_FALSE;
}
} | 0 |
linux | c7e8e8a8f7a70b343ca1e0f90a31e35ab2d16de1 | NOT_APPLICABLE | NOT_APPLICABLE | static void br_ip4_multicast_leave_group(struct net_bridge *br,
struct net_bridge_port *port,
__be32 group,
__u16 vid)
{
struct br_ip br_group;
if (ipv4_is_local_multicast(group))
return;
br_group.u.ip4 = group;
br_group.proto = htons(ETH_P_IP);
br_group.vid = vid;
br_multicast_leave_group(br, port, &br_group);
}
| 0 |
php-src | 6dbb1ee46b5f4725cc6519abf91e512a2a10dfed?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | ZEND_END_MODULE_GLOBALS(exif)
ZEND_DECLARE_MODULE_GLOBALS(exif)
#ifdef ZTS
#define EXIF_G(v) TSRMG(exif_globals_id, zend_exif_globals *, v)
#else
#define EXIF_G(v) (exif_globals.v)
#endif
/* {{{ PHP_INI
*/
ZEND_INI_MH(OnUpdateEncode)
{
if (new_value && new_value_length) {
const zend_encoding **return_list;
size_t return_size;
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length,
&return_list, &return_size, 0 TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal encoding ignored: '%s'", new_value);
return FAILURE;
}
efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
ZEND_INI_MH(OnUpdateDecode)
{
if (new_value) {
const zend_encoding **return_list;
size_t return_size;
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length,
&return_list, &return_size, 0 TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal encoding ignored: '%s'", new_value);
return FAILURE;
}
efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("exif.encode_unicode", "ISO-8859-15", PHP_INI_ALL, OnUpdateEncode, encode_unicode, zend_exif_globals, exif_globals)
STD_PHP_INI_ENTRY("exif.decode_unicode_motorola", "UCS-2BE", PHP_INI_ALL, OnUpdateDecode, decode_unicode_be, zend_exif_globals, exif_globals)
STD_PHP_INI_ENTRY("exif.decode_unicode_intel", "UCS-2LE", PHP_INI_ALL, OnUpdateDecode, decode_unicode_le, zend_exif_globals, exif_globals)
STD_PHP_INI_ENTRY("exif.encode_jis", "", PHP_INI_ALL, OnUpdateEncode, encode_jis, zend_exif_globals, exif_globals)
STD_PHP_INI_ENTRY("exif.decode_jis_motorola", "JIS", PHP_INI_ALL, OnUpdateDecode, decode_jis_be, zend_exif_globals, exif_globals)
STD_PHP_INI_ENTRY("exif.decode_jis_intel", "JIS", PHP_INI_ALL, OnUpdateDecode, decode_jis_le, zend_exif_globals, exif_globals)
PHP_INI_END()
/* }}} */
| 0 |
wolfssl | fb2288c46dd4c864b78f00a47a364b96a09a5c0f | NOT_APPLICABLE | NOT_APPLICABLE | int wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, RsaKey* key)
{
WC_RNG* rng;
#ifdef WC_RSA_BLINDING
rng = key->rng;
#else
rng = NULL;
#endif
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
RSA_PRIVATE_DECRYPT, RSA_BLOCK_TYPE_2, WC_RSA_PKCSV15_PAD,
WC_HASH_TYPE_NONE, WC_MGF1NONE, NULL, 0, 0, rng);
} | 0 |
linux | 681fef8380eb818c0b845fca5d2ab1dcbab114ee | NOT_APPLICABLE | NOT_APPLICABLE | static int proc_resetep(struct usb_dev_state *ps, void __user *arg)
{
unsigned int ep;
int ret;
if (get_user(ep, (unsigned int __user *)arg))
return -EFAULT;
ret = findintfep(ps->dev, ep);
if (ret < 0)
return ret;
ret = checkintf(ps, ret);
if (ret)
return ret;
check_reset_of_active_ep(ps->dev, ep, "RESETEP");
usb_reset_endpoint(ps->dev, ep);
return 0;
}
| 0 |
asylo | bda9772e7872b0d2b9bee32930cf7a4983837b39 | NOT_APPLICABLE | NOT_APPLICABLE | bool FromkLinuxEpollEvent(const struct klinux_epoll_event *input,
struct epoll_event *output) {
if (!input || !output) return false;
output->events = FromkLinuxEpollEvents(input->events);
if (input->events != 0 && output->events == 0) {
return false;
}
output->data.u64 = input->data.u64;
return true;
} | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.