project
stringclasses 788
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 126
values | func
stringlengths 14
482k
| vul
int8 0
1
|
---|---|---|---|---|---|
linux-2.6 | 672e7cca17ed6036a1756ed34cf20dbd72d5e5f6 | NOT_APPLICABLE | NOT_APPLICABLE | struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *ulpq,
struct sctp_association *asoc)
{
memset(ulpq, 0, sizeof(struct sctp_ulpq));
ulpq->asoc = asoc;
skb_queue_head_init(&ulpq->reasm);
skb_queue_head_init(&ulpq->lobby);
ulpq->pd_mode = 0;
ulpq->malloced = 0;
return ulpq;
} | 0 |
qemu | ebf101955ce8f8d72fba103b5151115a4335de2c | NOT_APPLICABLE | NOT_APPLICABLE | static void setup_root(struct lo_data *lo, struct lo_inode *root)
{
int fd, res;
struct stat stat;
fd = open("/", O_PATH);
if (fd == -1) {
fuse_log(FUSE_LOG_ERR, "open(%s, O_PATH): %m\n", lo->source);
exit(1);
}
res = fstatat(fd, "", &stat, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
if (res == -1) {
fuse_log(FUSE_LOG_ERR, "fstatat(%s): %m\n", lo->source);
exit(1);
}
root->filetype = S_IFDIR;
root->fd = fd;
root->key.ino = stat.st_ino;
root->key.dev = stat.st_dev;
root->nlookup = 2;
g_atomic_int_set(&root->refcount, 2);
} | 0 |
Chrome | 28aaa72a03df96fa1934876b0efbbc7e6b4b38af | NOT_APPLICABLE | NOT_APPLICABLE | void LoginPromptBrowserTestObserver::Register(
const content::NotificationSource& source) {
registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source);
registrar_.Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, source);
registrar_.Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, source);
}
| 0 |
nautilus | 1630f53481f445ada0a455e9979236d31a8d3bb0 | CVE-2017-14604 | CWE-20 | copy_move_file (CopyMoveJob *copy_job,
GFile *src,
GFile *dest_dir,
gboolean same_fs,
gboolean unique_names,
char **dest_fs_type,
SourceInfo *source_info,
TransferInfo *transfer_info,
GHashTable *debuting_files,
GdkPoint *position,
gboolean overwrite,
gboolean *skipped_file,
gboolean readonly_source_fs)
{
GFile *dest, *new_dest;
g_autofree gchar *dest_uri = NULL;
GError *error;
GFileCopyFlags flags;
char *primary, *secondary, *details;
int response;
ProgressData pdata;
gboolean would_recurse, is_merge;
CommonJob *job;
gboolean res;
int unique_name_nr;
gboolean handled_invalid_filename;
job = (CommonJob *) copy_job;
if (should_skip_file (job, src))
{
*skipped_file = TRUE;
return;
}
unique_name_nr = 1;
/* another file in the same directory might have handled the invalid
* filename condition for us
*/
handled_invalid_filename = *dest_fs_type != NULL;
if (unique_names)
{
dest = get_unique_target_file (src, dest_dir, same_fs, *dest_fs_type, unique_name_nr++);
}
else if (copy_job->target_name != NULL)
{
dest = get_target_file_with_custom_name (src, dest_dir, *dest_fs_type, same_fs,
copy_job->target_name);
}
else
{
dest = get_target_file (src, dest_dir, *dest_fs_type, same_fs);
}
/* Don't allow recursive move/copy into itself.
* (We would get a file system error if we proceeded but it is nicer to
* detect and report it at this level) */
if (test_dir_is_parent (dest_dir, src))
{
if (job->skip_all_error)
{
goto out;
}
/* the run_warning() frees all strings passed in automatically */
primary = copy_job->is_move ? g_strdup (_("You cannot move a folder into itself."))
: g_strdup (_("You cannot copy a folder into itself."));
secondary = g_strdup (_("The destination folder is inside the source folder."));
response = run_cancel_or_skip_warning (job,
primary,
secondary,
NULL,
source_info->num_files,
source_info->num_files - transfer_info->num_files);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT)
{
abort_job (job);
}
else if (response == 1) /* skip all */
{
job->skip_all_error = TRUE;
}
else if (response == 2) /* skip */
{ /* do nothing */
}
else
{
g_assert_not_reached ();
}
goto out;
}
/* Don't allow copying over the source or one of the parents of the source.
*/
if (test_dir_is_parent (src, dest))
{
if (job->skip_all_error)
{
goto out;
}
/* the run_warning() frees all strings passed in automatically */
primary = copy_job->is_move ? g_strdup (_("You cannot move a file over itself."))
: g_strdup (_("You cannot copy a file over itself."));
secondary = g_strdup (_("The source file would be overwritten by the destination."));
response = run_cancel_or_skip_warning (job,
primary,
secondary,
NULL,
source_info->num_files,
source_info->num_files - transfer_info->num_files);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT)
{
abort_job (job);
}
else if (response == 1) /* skip all */
{
job->skip_all_error = TRUE;
}
else if (response == 2) /* skip */
{ /* do nothing */
}
else
{
g_assert_not_reached ();
}
goto out;
}
retry:
error = NULL;
flags = G_FILE_COPY_NOFOLLOW_SYMLINKS;
if (overwrite)
{
flags |= G_FILE_COPY_OVERWRITE;
}
if (readonly_source_fs)
{
flags |= G_FILE_COPY_TARGET_DEFAULT_PERMS;
}
pdata.job = copy_job;
pdata.last_size = 0;
pdata.source_info = source_info;
pdata.transfer_info = transfer_info;
if (copy_job->is_move)
{
res = g_file_move (src, dest,
flags,
job->cancellable,
copy_file_progress_callback,
&pdata,
&error);
}
else
{
res = g_file_copy (src, dest,
flags,
job->cancellable,
copy_file_progress_callback,
&pdata,
&error);
}
if (res)
{
GFile *real;
real = map_possibly_volatile_file_to_real (dest, job->cancellable, &error);
if (real == NULL)
{
res = FALSE;
}
else
{
g_object_unref (dest);
dest = real;
}
}
if (res)
{
transfer_info->num_files++;
report_copy_progress (copy_job, source_info, transfer_info);
if (debuting_files)
{
dest_uri = g_file_get_uri (dest);
if (position)
{
nautilus_file_changes_queue_schedule_position_set (dest, *position, job->screen_num);
}
else if (eel_uri_is_desktop (dest_uri))
{
nautilus_file_changes_queue_schedule_position_remove (dest);
}
g_hash_table_replace (debuting_files, g_object_ref (dest), GINT_TO_POINTER (TRUE));
}
if (copy_job->is_move)
{
nautilus_file_changes_queue_file_moved (src, dest);
}
else
{
nautilus_file_changes_queue_file_added (dest);
}
/* If copying a trusted desktop file to the desktop,
* mark it as trusted. */
if (copy_job->desktop_location != NULL &&
g_file_equal (copy_job->desktop_location, dest_dir) &&
is_trusted_desktop_file (src, job->cancellable))
{
mark_desktop_file_trusted (job,
job->cancellable,
dest,
FALSE);
}
if (job->undo_info != NULL)
{
nautilus_file_undo_info_ext_add_origin_target_pair (NAUTILUS_FILE_UNDO_INFO_EXT (job->undo_info),
src, dest);
}
g_object_unref (dest);
return;
}
if (!handled_invalid_filename &&
IS_IO_ERROR (error, INVALID_FILENAME))
{
handled_invalid_filename = TRUE;
g_assert (*dest_fs_type == NULL);
*dest_fs_type = query_fs_type (dest_dir, job->cancellable);
if (unique_names)
{
new_dest = get_unique_target_file (src, dest_dir, same_fs, *dest_fs_type, unique_name_nr);
}
else
{
new_dest = get_target_file (src, dest_dir, *dest_fs_type, same_fs);
}
if (!g_file_equal (dest, new_dest))
{
g_object_unref (dest);
dest = new_dest;
g_error_free (error);
goto retry;
}
else
{
g_object_unref (new_dest);
}
}
/* Conflict */
if (!overwrite &&
IS_IO_ERROR (error, EXISTS))
{
gboolean is_merge;
FileConflictResponse *response;
g_error_free (error);
if (unique_names)
{
g_object_unref (dest);
dest = get_unique_target_file (src, dest_dir, same_fs, *dest_fs_type, unique_name_nr++);
goto retry;
}
is_merge = FALSE;
if (is_dir (dest) && is_dir (src))
{
is_merge = TRUE;
}
if ((is_merge && job->merge_all) ||
(!is_merge && job->replace_all))
{
overwrite = TRUE;
goto retry;
}
if (job->skip_all_conflict)
{
goto out;
}
response = handle_copy_move_conflict (job, src, dest, dest_dir);
if (response->id == GTK_RESPONSE_CANCEL ||
response->id == GTK_RESPONSE_DELETE_EVENT)
{
file_conflict_response_free (response);
abort_job (job);
}
else if (response->id == CONFLICT_RESPONSE_SKIP)
{
if (response->apply_to_all)
{
job->skip_all_conflict = TRUE;
}
file_conflict_response_free (response);
}
else if (response->id == CONFLICT_RESPONSE_REPLACE) /* merge/replace */
{
if (response->apply_to_all)
{
if (is_merge)
{
job->merge_all = TRUE;
}
else
{
job->replace_all = TRUE;
}
}
overwrite = TRUE;
file_conflict_response_free (response);
goto retry;
}
else if (response->id == CONFLICT_RESPONSE_RENAME)
{
g_object_unref (dest);
dest = get_target_file_for_display_name (dest_dir,
response->new_name);
file_conflict_response_free (response);
goto retry;
}
else
{
g_assert_not_reached ();
}
}
else if (overwrite &&
IS_IO_ERROR (error, IS_DIRECTORY))
{
gboolean existing_file_deleted;
DeleteExistingFileData data;
g_error_free (error);
data.job = job;
data.source = src;
existing_file_deleted =
delete_file_recursively (dest,
job->cancellable,
existing_file_removed_callback,
&data);
if (existing_file_deleted)
{
goto retry;
}
}
/* Needs to recurse */
else if (IS_IO_ERROR (error, WOULD_RECURSE) ||
IS_IO_ERROR (error, WOULD_MERGE))
{
is_merge = error->code == G_IO_ERROR_WOULD_MERGE;
would_recurse = error->code == G_IO_ERROR_WOULD_RECURSE;
g_error_free (error);
if (overwrite && would_recurse)
{
error = NULL;
/* Copying a dir onto file, first remove the file */
if (!g_file_delete (dest, job->cancellable, &error) &&
!IS_IO_ERROR (error, NOT_FOUND))
{
if (job->skip_all_error)
{
g_error_free (error);
goto out;
}
if (copy_job->is_move)
{
primary = f (_("Error while moving “%B”."), src);
}
else
{
primary = f (_("Error while copying “%B”."), src);
}
secondary = f (_("Could not remove the already existing file with the same name in %F."), dest_dir);
details = error->message;
/* setting TRUE on show_all here, as we could have
* another error on the same file later.
*/
response = run_warning (job,
primary,
secondary,
details,
TRUE,
CANCEL, SKIP_ALL, SKIP,
NULL);
g_error_free (error);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT)
{
abort_job (job);
}
else if (response == 1) /* skip all */
{
job->skip_all_error = TRUE;
}
else if (response == 2) /* skip */
{ /* do nothing */
}
else
{
g_assert_not_reached ();
}
goto out;
}
if (error)
{
g_error_free (error);
error = NULL;
}
nautilus_file_changes_queue_file_removed (dest);
}
if (is_merge)
{
/* On merge we now write in the target directory, which may not
* be in the same directory as the source, even if the parent is
* (if the merged directory is a mountpoint). This could cause
* problems as we then don't transcode filenames.
* We just set same_fs to FALSE which is safe but a bit slower. */
same_fs = FALSE;
}
if (!copy_move_directory (copy_job, src, &dest, same_fs,
would_recurse, dest_fs_type,
source_info, transfer_info,
debuting_files, skipped_file,
readonly_source_fs))
{
/* destination changed, since it was an invalid file name */
g_assert (*dest_fs_type != NULL);
handled_invalid_filename = TRUE;
goto retry;
}
g_object_unref (dest);
return;
}
else if (IS_IO_ERROR (error, CANCELLED))
{
g_error_free (error);
}
/* Other error */
else
{
if (job->skip_all_error)
{
g_error_free (error);
goto out;
}
primary = f (_("Error while copying “%B”."), src);
secondary = f (_("There was an error copying the file into %F."), dest_dir);
details = error->message;
response = run_cancel_or_skip_warning (job,
primary,
secondary,
details,
source_info->num_files,
source_info->num_files - transfer_info->num_files);
g_error_free (error);
if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT)
{
abort_job (job);
}
else if (response == 1) /* skip all */
{
job->skip_all_error = TRUE;
}
else if (response == 2) /* skip */
{ /* do nothing */
}
else
{
g_assert_not_reached ();
}
}
out:
*skipped_file = TRUE; /* Or aborted, but same-same */
g_object_unref (dest);
}
| 1 |
date | 8f2d7a0c7e52cea8333824bd527822e5449ed83d | NOT_APPLICABLE | NOT_APPLICABLE | date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
{
VALUE vy, vw, vd, vsg;
VALUE argv2[4];
rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg);
RETURN_FALSE_UNLESS_NUMERIC(vy);
RETURN_FALSE_UNLESS_NUMERIC(vw);
RETURN_FALSE_UNLESS_NUMERIC(vd);
argv2[0] = vy;
argv2[1] = vw;
argv2[2] = vd;
if (argc < 4)
argv2[3] = INT2FIX(DEFAULT_SG);
else
argv2[3] = vsg;
if (NIL_P(valid_commercial_sub(4, argv2, klass, 0)))
return Qfalse;
return Qtrue;
} | 0 |
linux | 950336ba3e4a1ffd2ca60d29f6ef386dd2c7351d | NOT_APPLICABLE | NOT_APPLICABLE | static int ati_remote2_setup(struct ati_remote2 *ar2, unsigned int ch_mask)
{
int r, i, channel;
/*
* Configure receiver to only accept input from remote "channel"
* channel == 0 -> Accept input from any remote channel
* channel == 1 -> Only accept input from remote channel 1
* channel == 2 -> Only accept input from remote channel 2
* ...
* channel == 16 -> Only accept input from remote channel 16
*/
channel = 0;
for (i = 0; i < 16; i++) {
if ((1 << i) & ch_mask) {
if (!(~(1 << i) & ch_mask))
channel = i + 1;
break;
}
}
r = usb_control_msg(ar2->udev, usb_sndctrlpipe(ar2->udev, 0),
0x20,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
channel, 0x0, NULL, 0, USB_CTRL_SET_TIMEOUT);
if (r) {
dev_err(&ar2->udev->dev, "%s - failed to set channel due to error: %d\n",
__func__, r);
return r;
}
return 0;
}
| 0 |
openafs | 396240cf070a806b91fea81131d034e1399af1e0 | NOT_APPLICABLE | NOT_APPLICABLE | SPR_NewEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
afs_int32 *aid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = newEntry(call, aname, flag, oid, aid, &cid);
osi_auditU(call, PTS_NewEntEvent, code, AUD_ID, *aid, AUD_STR, aname,
AUD_ID, oid, AUD_END);
ViceLog(5, ("PTS_NewEntry: code %d cid %d aid %d aname %s oid %d\n", code, cid, *aid, aname, oid));
return code;
}
| 0 |
Android | 45737cb776625f17384540523674761e6313e6d4 | CVE-2016-2495 | CWE-20 | status_t SampleTable::setTimeToSampleParams(
off64_t data_offset, size_t data_size) {
if (mTimeToSample != NULL || data_size < 8) {
return ERROR_MALFORMED;
}
uint8_t header[8];
if (mDataSource->readAt(
data_offset, header, sizeof(header)) < (ssize_t)sizeof(header)) {
return ERROR_IO;
}
if (U32_AT(header) != 0) {
return ERROR_MALFORMED;
}
mTimeToSampleCount = U32_AT(&header[4]);
uint64_t allocSize = (uint64_t)mTimeToSampleCount * 2 * sizeof(uint32_t);
if (allocSize > UINT32_MAX) {
return ERROR_OUT_OF_RANGE;
}
mTimeToSample = new (std::nothrow) uint32_t[mTimeToSampleCount * 2];
if (!mTimeToSample)
return ERROR_OUT_OF_RANGE;
size_t size = sizeof(uint32_t) * mTimeToSampleCount * 2;
if (mDataSource->readAt(
data_offset + 8, mTimeToSample, size) < (ssize_t)size) {
return ERROR_IO;
}
for (uint32_t i = 0; i < mTimeToSampleCount * 2; ++i) {
mTimeToSample[i] = ntohl(mTimeToSample[i]);
}
return OK;
}
| 1 |
savannah | 863d31ae775d56b785dc5b0105b6d251515d81d5 | NOT_APPLICABLE | NOT_APPLICABLE | reset_locale_vars ()
{
char *t;
#if defined (HAVE_SETLOCALE)
if (lang == 0 || *lang == '\0')
maybe_make_export_env (); /* trust that this will change environment for setlocale */
if (setlocale (LC_ALL, lang ? lang : "") == 0)
return 0;
# if defined (LC_CTYPE)
t = setlocale (LC_CTYPE, get_locale_var ("LC_CTYPE"));
# endif
# if defined (LC_COLLATE)
t = setlocale (LC_COLLATE, get_locale_var ("LC_COLLATE"));
# endif
# if defined (LC_MESSAGES)
t = setlocale (LC_MESSAGES, get_locale_var ("LC_MESSAGES"));
# endif
# if defined (LC_NUMERIC)
t = setlocale (LC_NUMERIC, get_locale_var ("LC_NUMERIC"));
# endif
# if defined (LC_TIME)
t = setlocale (LC_TIME, get_locale_var ("LC_TIME"));
# endif
locale_setblanks ();
locale_mb_cur_max = MB_CUR_MAX;
u32reset ();
#endif
return 1;
}
| 0 |
Chrome | d913f72b4875cf0814fc3f03ad7c00642097c4a4 | NOT_APPLICABLE | NOT_APPLICABLE | StyleSheetContents* CSSStyleSheetResource::CreateParsedStyleSheetFromCache(
const CSSParserContext* context) {
if (!parsed_style_sheet_cache_)
return nullptr;
if (parsed_style_sheet_cache_->HasFailedOrCanceledSubresources()) {
SetParsedStyleSheetCache(nullptr);
return nullptr;
}
DCHECK(parsed_style_sheet_cache_->IsCacheableForResource());
DCHECK(parsed_style_sheet_cache_->IsReferencedFromResource());
if (*parsed_style_sheet_cache_->ParserContext() != *context)
return nullptr;
DCHECK(!parsed_style_sheet_cache_->IsLoading());
if (RuntimeEnabledFeatures::CacheStyleSheetWithMediaQueriesEnabled() &&
parsed_style_sheet_cache_->HasMediaQueries()) {
return parsed_style_sheet_cache_->Copy();
}
return parsed_style_sheet_cache_;
}
| 0 |
gnuplot | 052cbd17c3cbbc602ee080b2617d32a8417d7563 | NOT_APPLICABLE | NOT_APPLICABLE | help_command()
{
static char *helpbuf = NULL;
static char *prompt = NULL;
static int toplevel = 1;
int base; /* index of first char AFTER help string */
int len; /* length of current help string */
TBOOLEAN more_help;
TBOOLEAN only; /* TRUE if only printing subtopics */
TBOOLEAN subtopics; /* 0 if no subtopics for this topic */
int start; /* starting token of help string */
char *help_ptr; /* name of help file */
# if defined(SHELFIND)
static char help_fname[256] = ""; /* keep helpfilename across calls */
# endif
if ((help_ptr = getenv("GNUHELP")) == (char *) NULL)
# ifndef SHELFIND
/* if can't find environment variable then just use HELPFILE */
# if defined(MSDOS) || defined(OS2)
help_ptr = HelpFile;
# else
help_ptr = HELPFILE;
# endif
# else /* !SHELFIND */
/* try whether we can find the helpfile via shell_find. If not, just
use the default. (tnx Andreas) */
if (!strchr(HELPFILE, ':') && !strchr(HELPFILE, '/') &&
!strchr(HELPFILE, '\\')) {
if (strlen(help_fname) == 0) {
strcpy(help_fname, HELPFILE);
if (shel_find(help_fname) == 0) {
strcpy(help_fname, HELPFILE);
}
}
help_ptr = help_fname;
} else {
help_ptr = HELPFILE;
}
# endif /* !SHELFIND */
/* Since MSDOS DGROUP segment is being overflowed we can not allow such */
/* huge static variables (1k each). Instead we dynamically allocate them */
/* on the first call to this function... */
if (helpbuf == NULL) {
helpbuf = gp_alloc(MAX_LINE_LEN, "help buffer");
prompt = gp_alloc(MAX_LINE_LEN, "help prompt");
helpbuf[0] = prompt[0] = 0;
}
if (toplevel)
helpbuf[0] = prompt[0] = 0; /* in case user hit ^c last time */
/* if called recursively, toplevel == 0; toplevel must == 1 if called
* from command() to get the same behaviour as before when toplevel
* supplied as function argument
*/
toplevel = 1;
len = base = strlen(helpbuf);
start = ++c_token;
/* find the end of the help command */
while (!(END_OF_COMMAND))
c_token++;
/* copy new help input into helpbuf */
if (len > 0)
helpbuf[len++] = ' '; /* add a space */
capture(helpbuf + len, start, c_token - 1, MAX_LINE_LEN - len);
squash_spaces(helpbuf + base, 1); /* only bother with new stuff */
len = strlen(helpbuf);
/* now, a lone ? will print subtopics only */
if (strcmp(helpbuf + (base ? base + 1 : 0), "?") == 0) {
/* subtopics only */
subtopics = 1;
only = TRUE;
helpbuf[base] = NUL; /* cut off question mark */
} else {
/* normal help request */
subtopics = 0;
only = FALSE;
}
switch (help(helpbuf, help_ptr, &subtopics)) {
case H_FOUND:{
/* already printed the help info */
/* subtopics now is true if there were any subtopics */
screen_ok = FALSE;
do {
if (subtopics && !only) {
/* prompt for subtopic with current help string */
if (len > 0) {
strcpy (prompt, "Subtopic of ");
strncat (prompt, helpbuf, MAX_LINE_LEN - 16);
strcat (prompt, ": ");
} else
strcpy(prompt, "Help topic: ");
read_line(prompt, 0);
num_tokens = scanner(&gp_input_line, &gp_input_line_len);
c_token = 0;
more_help = !(END_OF_COMMAND);
if (more_help) {
c_token--;
toplevel = 0;
/* base for next level is all of current helpbuf */
help_command();
}
} else
more_help = FALSE;
} while (more_help);
break;
}
case H_NOTFOUND:
printf("Sorry, no help for '%s'\n", helpbuf);
break;
case H_ERROR:
perror(help_ptr);
break;
default:
int_error(NO_CARET, "Impossible case in switch");
break;
}
helpbuf[base] = NUL; /* cut it off where we started */
} | 0 |
php | 6297a117d77fa3a0df2e21ca926a92c231819cd5 | NOT_APPLICABLE | NOT_APPLICABLE | PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC)
{
php_stream *stream;
php_stream_temp_data *ts;
off_t newoffs;
if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) {
if (length) {
assert(buf != NULL);
php_stream_temp_write(stream, buf, length TSRMLS_CC);
php_stream_temp_seek(stream, 0, SEEK_SET, &newoffs TSRMLS_CC);
}
ts = (php_stream_temp_data*)stream->abstract;
assert(ts != NULL);
ts->mode = mode;
}
return stream;
}
| 0 |
ImageMagick6 | 4745eb1047617330141e9abfd5ae01236a71ae12 | NOT_APPLICABLE | NOT_APPLICABLE | static MagickBooleanType ReadPSDLayersInternal(Image *image,
const ImageInfo *image_info,const PSDInfo *psd_info,
const MagickBooleanType skip_layers,ExceptionInfo *exception)
{
char
type[4];
LayerInfo
*layer_info;
MagickSizeType
size;
MagickBooleanType
status;
register ssize_t
i;
ssize_t
count,
j,
number_layers;
size=GetPSDSize(psd_info,image);
if (size == 0)
{
/*
Skip layers & masks.
*/
(void) ReadBlobLong(image);
count=ReadBlob(image,4,(unsigned char *) type);
if (count == 4)
ReversePSDString(image,type,count);
if ((count != 4) || (LocaleNCompare(type,"8BIM",4) != 0))
return(MagickTrue);
else
{
count=ReadBlob(image,4,(unsigned char *) type);
if (count == 4)
ReversePSDString(image,type,4);
if ((count == 4) && ((LocaleNCompare(type,"Lr16",4) == 0) ||
(LocaleNCompare(type,"Lr32",4) == 0)))
size=GetPSDSize(psd_info,image);
else
return(MagickTrue);
}
}
status=MagickTrue;
if (size != 0)
{
layer_info=(LayerInfo *) NULL;
number_layers=(short) ReadBlobShort(image);
if (number_layers < 0)
{
/*
The first alpha channel in the merged result contains the
transparency data for the merged result.
*/
number_layers=MagickAbsoluteValue(number_layers);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" negative layer count corrected for");
image->matte=MagickTrue;
}
/*
We only need to know if the image has an alpha channel
*/
if (skip_layers != MagickFalse)
return(MagickTrue);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" image contains %.20g layers",(double) number_layers);
if (number_layers == 0)
ThrowBinaryException(CorruptImageError,"InvalidNumberOfLayers",
image->filename);
layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers,
sizeof(*layer_info));
if (layer_info == (LayerInfo *) NULL)
{
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" allocation of LayerInfo failed");
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
(void) memset(layer_info,0,(size_t) number_layers*sizeof(*layer_info));
for (i=0; i < number_layers; i++)
{
ssize_t
x,
y;
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" reading layer #%.20g",(double) i+1);
layer_info[i].page.y=ReadBlobSignedLong(image);
layer_info[i].page.x=ReadBlobSignedLong(image);
y=ReadBlobSignedLong(image);
x=ReadBlobSignedLong(image);
layer_info[i].page.width=(size_t) (x-layer_info[i].page.x);
layer_info[i].page.height=(size_t) (y-layer_info[i].page.y);
layer_info[i].channels=ReadBlobShort(image);
if (layer_info[i].channels > MaxPSDChannels)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,"MaximumChannelsExceeded",
image->filename);
}
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g",
(double) layer_info[i].page.x,(double) layer_info[i].page.y,
(double) layer_info[i].page.height,(double)
layer_info[i].page.width,(double) layer_info[i].channels);
for (j=0; j < (ssize_t) layer_info[i].channels; j++)
{
layer_info[i].channel_info[j].type=(short) ReadBlobShort(image);
if ((layer_info[i].channel_info[j].type < -4) ||
(layer_info[i].channel_info[j].type > 4))
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,"NoSuchImageChannel",
image->filename);
}
layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info,
image);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" channel[%.20g]: type=%.20g, size=%.20g",(double) j,
(double) layer_info[i].channel_info[j].type,
(double) layer_info[i].channel_info[j].size);
}
if (CheckPSDChannels(psd_info,&layer_info[i]) == MagickFalse)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,"ImproperImageHeader",
image->filename);
}
count=ReadBlob(image,4,(unsigned char *) type);
if (count == 4)
ReversePSDString(image,type,4);
if ((count != 4) || (LocaleNCompare(type,"8BIM",4) != 0))
{
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer type was %.4s instead of 8BIM", type);
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,"ImproperImageHeader",
image->filename);
}
count=ReadBlob(image,4,(unsigned char *) layer_info[i].blendkey);
if (count != 4)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,"ImproperImageHeader",
image->filename);
}
ReversePSDString(image,layer_info[i].blendkey,4);
layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
layer_info[i].clipping=(unsigned char) ReadBlobByte(image);
layer_info[i].flags=(unsigned char) ReadBlobByte(image);
layer_info[i].visible=!(layer_info[i].flags & 0x02);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s",
layer_info[i].blendkey,(double) layer_info[i].opacity,
layer_info[i].clipping ? "true" : "false",layer_info[i].flags,
layer_info[i].visible ? "true" : "false");
(void) ReadBlobByte(image); /* filler */
size=ReadBlobLong(image);
if (size != 0)
{
MagickSizeType
combined_length,
length;
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer contains additional info");
length=ReadBlobLong(image);
combined_length=length+4;
if (length != 0)
{
/*
Layer mask info.
*/
layer_info[i].mask.page.y=ReadBlobSignedLong(image);
layer_info[i].mask.page.x=ReadBlobSignedLong(image);
layer_info[i].mask.page.height=(size_t) (ReadBlobSignedLong(image)-
layer_info[i].mask.page.y);
layer_info[i].mask.page.width=(size_t) (ReadBlobSignedLong(image)-
layer_info[i].mask.page.x);
layer_info[i].mask.background=(unsigned char) ReadBlobByte(
image);
layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image);
if (!(layer_info[i].mask.flags & 0x01))
{
layer_info[i].mask.page.y=layer_info[i].mask.page.y-
layer_info[i].page.y;
layer_info[i].mask.page.x=layer_info[i].mask.page.x-
layer_info[i].page.x;
}
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g",
(double) layer_info[i].mask.page.x,(double)
layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width,
(double) layer_info[i].mask.page.height,(double)
((MagickOffsetType) length)-18);
/*
Skip over the rest of the layer mask information.
*/
if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile",
image->filename);
}
}
length=ReadBlobLong(image);
combined_length+=length+4;
if (length != 0)
{
/*
Layer blending ranges info.
*/
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer blending ranges: length=%.20g",(double)
((MagickOffsetType) length));
if (DiscardBlobBytes(image,length) == MagickFalse)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,
"UnexpectedEndOfFile",image->filename);
}
}
/*
Layer name.
*/
length=(MagickSizeType) (unsigned char) ReadBlobByte(image);
combined_length+=length+1;
if (length > 0)
(void) ReadBlob(image,(size_t) length++,layer_info[i].name);
layer_info[i].name[length]='\0';
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer name: %s",layer_info[i].name);
if ((length % 4) != 0)
{
length=4-(length % 4);
combined_length+=length;
/* Skip over the padding of the layer name */
if (DiscardBlobBytes(image,length) == MagickFalse)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,
"UnexpectedEndOfFile",image->filename);
}
}
length=(MagickSizeType) size-combined_length;
if (length > 0)
{
unsigned char
*info;
if (length > GetBlobSize(image))
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,
"InsufficientImageDataInFile",image->filename);
}
layer_info[i].info=AcquireStringInfo((const size_t) length);
info=GetStringInfoDatum(layer_info[i].info);
(void) ReadBlob(image,(const size_t) length,info);
}
}
}
for (i=0; i < number_layers; i++)
{
if ((layer_info[i].page.width == 0) ||
(layer_info[i].page.height == 0))
{
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer data is empty");
if (layer_info[i].info != (StringInfo *) NULL)
layer_info[i].info=DestroyStringInfo(layer_info[i].info);
continue;
}
/*
Allocate layered image.
*/
layer_info[i].image=CloneImage(image,layer_info[i].page.width,
layer_info[i].page.height,MagickFalse,exception);
if (layer_info[i].image == (Image *) NULL)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" allocation of image for layer %.20g failed",(double) i);
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
if (layer_info[i].info != (StringInfo *) NULL)
{
(void) SetImageProfile(layer_info[i].image,"psd:additional-info",
layer_info[i].info);
layer_info[i].info=DestroyStringInfo(layer_info[i].info);
}
}
if (image_info->ping == MagickFalse)
{
for (i=0; i < number_layers; i++)
{
if (layer_info[i].image == (Image *) NULL)
{
for (j=0; j < layer_info[i].channels; j++)
{
if (DiscardBlobBytes(image,(MagickSizeType)
layer_info[i].channel_info[j].size) == MagickFalse)
{
layer_info=DestroyLayerInfo(layer_info,number_layers);
ThrowBinaryException(CorruptImageError,
"UnexpectedEndOfFile",image->filename);
}
}
continue;
}
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" reading data for layer %.20g",(double) i);
status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i],
exception);
if (status == MagickFalse)
break;
status=SetImageProgress(image,LoadImagesTag,i,(MagickSizeType)
number_layers);
if (status == MagickFalse)
break;
}
}
if (status != MagickFalse)
{
for (i=0; i < number_layers; i++)
{
if (layer_info[i].image == (Image *) NULL)
{
for (j=i; j < number_layers - 1; j++)
layer_info[j] = layer_info[j+1];
number_layers--;
i--;
}
}
if (number_layers > 0)
{
for (i=0; i < number_layers; i++)
{
if (i > 0)
layer_info[i].image->previous=layer_info[i-1].image;
if (i < (number_layers-1))
layer_info[i].image->next=layer_info[i+1].image;
layer_info[i].image->page=layer_info[i].page;
}
image->next=layer_info[0].image;
layer_info[0].image->previous=image;
}
layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info);
}
else
layer_info=DestroyLayerInfo(layer_info,number_layers);
}
return(status);
} | 0 |
linux | 5a07975ad0a36708c6b0a5b9fea1ff811d0b0c1f | NOT_APPLICABLE | NOT_APPLICABLE | static void digi_rx_unthrottle(struct tty_struct *tty)
{
int ret = 0;
unsigned long flags;
struct usb_serial_port *port = tty->driver_data;
struct digi_port *priv = usb_get_serial_port_data(port);
spin_lock_irqsave(&priv->dp_port_lock, flags);
/* restart read chain */
if (priv->dp_throttle_restart)
ret = usb_submit_urb(port->read_urb, GFP_ATOMIC);
/* turn throttle off */
priv->dp_throttled = 0;
priv->dp_throttle_restart = 0;
spin_unlock_irqrestore(&priv->dp_port_lock, flags);
if (ret)
dev_err(&port->dev,
"%s: usb_submit_urb failed, ret=%d, port=%d\n",
__func__, ret, priv->dp_port_num);
}
| 0 |
oniguruma | 474e5dd6a245faf5f75922bc83f077e55881fa5b | NOT_APPLICABLE | NOT_APPLICABLE | add_code_range_to_buf(BBuf** pbuf, OnigCodePoint from, OnigCodePoint to)
{
int r, inc_n, pos;
int low, high, bound, x;
OnigCodePoint n, *data;
BBuf* bbuf;
if (from > to) {
n = from; from = to; to = n;
}
if (IS_NULL(*pbuf)) {
r = new_code_range(pbuf);
if (r != 0) return r;
bbuf = *pbuf;
n = 0;
}
else {
bbuf = *pbuf;
GET_CODE_POINT(n, bbuf->p);
}
data = (OnigCodePoint* )(bbuf->p);
data++;
for (low = 0, bound = n; low < bound; ) {
x = (low + bound) >> 1;
if (from > data[x*2 + 1])
low = x + 1;
else
bound = x;
}
high = (to == ~((OnigCodePoint )0)) ? n : low;
for (bound = n; high < bound; ) {
x = (high + bound) >> 1;
if (to + 1 >= data[x*2])
high = x + 1;
else
bound = x;
}
inc_n = low + 1 - high;
if (n + inc_n > ONIG_MAX_MULTI_BYTE_RANGES_NUM)
return ONIGERR_TOO_MANY_MULTI_BYTE_RANGES;
if (inc_n != 1) {
if (from > data[low*2])
from = data[low*2];
if (to < data[(high - 1)*2 + 1])
to = data[(high - 1)*2 + 1];
}
if (inc_n != 0 && (OnigCodePoint )high < n) {
int from_pos = SIZE_CODE_POINT * (1 + high * 2);
int to_pos = SIZE_CODE_POINT * (1 + (low + 1) * 2);
int size = (n - high) * 2 * SIZE_CODE_POINT;
if (inc_n > 0) {
BB_MOVE_RIGHT(bbuf, from_pos, to_pos, size);
}
else {
BB_MOVE_LEFT_REDUCE(bbuf, from_pos, to_pos);
}
}
pos = SIZE_CODE_POINT * (1 + low * 2);
BB_ENSURE_SIZE(bbuf, pos + SIZE_CODE_POINT * 2);
BB_WRITE_CODE_POINT(bbuf, pos, from);
BB_WRITE_CODE_POINT(bbuf, pos + SIZE_CODE_POINT, to);
n += inc_n;
BB_WRITE_CODE_POINT(bbuf, 0, n);
return 0;
} | 0 |
linux | ca4ef4574f1ee5252e2cd365f8f5d5bafd048f32 | NOT_APPLICABLE | NOT_APPLICABLE | static void ip_cmsg_recv_retopts(struct msghdr *msg, struct sk_buff *skb)
{
unsigned char optbuf[sizeof(struct ip_options) + 40];
struct ip_options *opt = (struct ip_options *)optbuf;
if (IPCB(skb)->opt.optlen == 0)
return;
if (ip_options_echo(opt, skb)) {
msg->msg_flags |= MSG_CTRUNC;
return;
}
ip_options_undo(opt);
put_cmsg(msg, SOL_IP, IP_RETOPTS, opt->optlen, opt->__data);
}
| 0 |
acrn-hypervisor | 25c0e3817eb332660dd63d1d4522e63dcc94e79a | NOT_APPLICABLE | NOT_APPLICABLE | static inline uint8_t iommu_ecap_sc(uint64_t ecap)
{
return ((uint8_t)(ecap >> 7U) & 1U);
} | 0 |
libxslt | 7ca19df892ca22d9314e95d59ce2abdeff46b617 | NOT_APPLICABLE | NOT_APPLICABLE | xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr node) {
/*
* The xsltXSLTElemMarker marker was set beforehand by
* the parsing mechanism for all elements in the XSLT namespace.
*/
if (style == NULL) {
if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
node->psvi = NULL;
return;
}
if (node == NULL)
return;
if (! IS_XSLT_ELEM_FAST(node))
return;
node->psvi = NULL;
if (XSLT_CCTXT(style)->inode->type != 0) {
switch (XSLT_CCTXT(style)->inode->type) {
case XSLT_FUNC_APPLYTEMPLATES:
xsltApplyTemplatesComp(style, node);
break;
case XSLT_FUNC_WITHPARAM:
xsltWithParamComp(style, node);
break;
case XSLT_FUNC_VALUEOF:
xsltValueOfComp(style, node);
break;
case XSLT_FUNC_COPY:
xsltCopyComp(style, node);
break;
case XSLT_FUNC_COPYOF:
xsltCopyOfComp(style, node);
break;
case XSLT_FUNC_IF:
xsltIfComp(style, node);
break;
case XSLT_FUNC_CHOOSE:
xsltChooseComp(style, node);
break;
case XSLT_FUNC_WHEN:
xsltWhenComp(style, node);
break;
case XSLT_FUNC_OTHERWISE:
/* NOP yet */
return;
case XSLT_FUNC_FOREACH:
xsltForEachComp(style, node);
break;
case XSLT_FUNC_APPLYIMPORTS:
xsltApplyImportsComp(style, node);
break;
case XSLT_FUNC_ATTRIBUTE:
xsltAttributeComp(style, node);
break;
case XSLT_FUNC_ELEMENT:
xsltElementComp(style, node);
break;
case XSLT_FUNC_SORT:
xsltSortComp(style, node);
break;
case XSLT_FUNC_COMMENT:
xsltCommentComp(style, node);
break;
case XSLT_FUNC_NUMBER:
xsltNumberComp(style, node);
break;
case XSLT_FUNC_PI:
xsltProcessingInstructionComp(style, node);
break;
case XSLT_FUNC_CALLTEMPLATE:
xsltCallTemplateComp(style, node);
break;
case XSLT_FUNC_PARAM:
xsltParamComp(style, node);
break;
case XSLT_FUNC_VARIABLE:
xsltVariableComp(style, node);
break;
case XSLT_FUNC_FALLBACK:
/* NOP yet */
return;
case XSLT_FUNC_DOCUMENT:
/* The extra one */
node->psvi = (void *) xsltDocumentComp(style, node,
(xsltTransformFunction) xsltDocumentElem);
break;
case XSLT_FUNC_MESSAGE:
/* NOP yet */
return;
default:
/*
* NOTE that xsl:text, xsl:template, xsl:stylesheet,
* xsl:transform, xsl:import, xsl:include are not expected
* to be handed over to this function.
*/
xsltTransformError(NULL, style, node,
"Internal error: (xsltStylePreCompute) cannot handle "
"the XSLT element '%s'.\n", node->name);
style->errors++;
return;
}
} else {
/*
* Fallback to string comparison.
*/
if (IS_XSLT_NAME(node, "apply-templates")) {
xsltApplyTemplatesComp(style, node);
} else if (IS_XSLT_NAME(node, "with-param")) {
xsltWithParamComp(style, node);
} else if (IS_XSLT_NAME(node, "value-of")) {
xsltValueOfComp(style, node);
} else if (IS_XSLT_NAME(node, "copy")) {
xsltCopyComp(style, node);
} else if (IS_XSLT_NAME(node, "copy-of")) {
xsltCopyOfComp(style, node);
} else if (IS_XSLT_NAME(node, "if")) {
xsltIfComp(style, node);
} else if (IS_XSLT_NAME(node, "choose")) {
xsltChooseComp(style, node);
} else if (IS_XSLT_NAME(node, "when")) {
xsltWhenComp(style, node);
} else if (IS_XSLT_NAME(node, "otherwise")) {
/* NOP yet */
return;
} else if (IS_XSLT_NAME(node, "for-each")) {
xsltForEachComp(style, node);
} else if (IS_XSLT_NAME(node, "apply-imports")) {
xsltApplyImportsComp(style, node);
} else if (IS_XSLT_NAME(node, "attribute")) {
xsltAttributeComp(style, node);
} else if (IS_XSLT_NAME(node, "element")) {
xsltElementComp(style, node);
} else if (IS_XSLT_NAME(node, "sort")) {
xsltSortComp(style, node);
} else if (IS_XSLT_NAME(node, "comment")) {
xsltCommentComp(style, node);
} else if (IS_XSLT_NAME(node, "number")) {
xsltNumberComp(style, node);
} else if (IS_XSLT_NAME(node, "processing-instruction")) {
xsltProcessingInstructionComp(style, node);
} else if (IS_XSLT_NAME(node, "call-template")) {
xsltCallTemplateComp(style, node);
} else if (IS_XSLT_NAME(node, "param")) {
xsltParamComp(style, node);
} else if (IS_XSLT_NAME(node, "variable")) {
xsltVariableComp(style, node);
} else if (IS_XSLT_NAME(node, "fallback")) {
/* NOP yet */
return;
} else if (IS_XSLT_NAME(node, "document")) {
/* The extra one */
node->psvi = (void *) xsltDocumentComp(style, node,
(xsltTransformFunction) xsltDocumentElem);
} else if (IS_XSLT_NAME(node, "output")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "preserve-space")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "strip-space")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "key")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "message")) {
return;
} else if (IS_XSLT_NAME(node, "attribute-set")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "namespace-alias")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "decimal-format")) {
/* Top-level */
return;
} else if (IS_XSLT_NAME(node, "include")) {
/* Top-level */
} else {
/*
* NOTE that xsl:text, xsl:template, xsl:stylesheet,
* xsl:transform, xsl:import, xsl:include are not expected
* to be handed over to this function.
*/
xsltTransformError(NULL, style, node,
"Internal error: (xsltStylePreCompute) cannot handle "
"the XSLT element '%s'.\n", node->name);
style->errors++;
return;
}
}
/*
* Assign the current list of in-scope namespaces to the
* item. This is needed for XPath expressions.
*/
if (node->psvi != NULL) {
((xsltStylePreCompPtr) node->psvi)->inScopeNs =
XSLT_CCTXT(style)->inode->inScopeNs;
}
} | 0 |
znc | a4a5aeeb17d32937d8c7d743dae9a4cc755ce773 | NOT_APPLICABLE | NOT_APPLICABLE | CString CWebSock::FindTmpl(CModule* pModule, const CString& sName) {
VCString vsDirs = GetDirs(pModule, true);
CString sFile = pModule->GetModName() + "_" + sName;
for (const CString& sDir : vsDirs) {
if (CFile::Exists(CDir::ChangeDir(sDir, sFile))) {
m_Template.AppendPath(sDir);
return sFile;
}
}
return sName;
} | 0 |
php-src | 28a6ed9f9a36b9c517e4a8a429baf4dd382fc5d5?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | static inline spl_dllist_object *spl_dllist_from_obj(zend_object *obj) /* {{{ */ {
return (spl_dllist_object*)((char*)(obj) - XtOffsetOf(spl_dllist_object, std));
}
/* }}} */
| 0 |
krb5 | a7886f0ed1277c69142b14a2c6629175a6331edc | NOT_APPLICABLE | NOT_APPLICABLE | make_spnego_tokenInit_msg(spnego_gss_ctx_id_t spnego_ctx,
int negHintsCompat,
gss_buffer_t mechListMIC, OM_uint32 req_flags,
gss_buffer_t data, send_token_flag sendtoken,
gss_buffer_t outbuf)
{
int ret = 0;
unsigned int tlen, dataLen = 0;
unsigned int negTokenInitSize = 0;
unsigned int negTokenInitSeqSize = 0;
unsigned int negTokenInitContSize = 0;
unsigned int rspTokenSize = 0;
unsigned int mechListTokenSize = 0;
unsigned int micTokenSize = 0;
unsigned char *t;
unsigned char *ptr;
if (outbuf == GSS_C_NO_BUFFER)
return (-1);
outbuf->length = 0;
outbuf->value = NULL;
/* calculate the data length */
/*
* 0xa0 [DER LEN] [mechTypes]
*/
mechListTokenSize = 1 +
gssint_der_length_size(spnego_ctx->DER_mechTypes.length) +
spnego_ctx->DER_mechTypes.length;
dataLen += mechListTokenSize;
/*
* If a token from gss_init_sec_context exists,
* add the length of the token + the ASN.1 overhead
*/
if (data != NULL) {
/*
* Encoded in final output as:
* 0xa2 [DER LEN] 0x04 [DER LEN] [DATA]
* -----s--------|--------s2----------
*/
rspTokenSize = 1 +
gssint_der_length_size(data->length) +
data->length;
dataLen += 1 + gssint_der_length_size(rspTokenSize) +
rspTokenSize;
}
if (mechListMIC) {
/*
* Encoded in final output as:
* 0xa3 [DER LEN] 0x04 [DER LEN] [DATA]
* --s-- -----tlen------------
*/
micTokenSize = 1 +
gssint_der_length_size(mechListMIC->length) +
mechListMIC->length;
dataLen += 1 +
gssint_der_length_size(micTokenSize) +
micTokenSize;
}
/*
* Add size of DER encoding
* [ SEQUENCE { MechTypeList | ReqFLags | Token | mechListMIC } ]
* 0x30 [DER_LEN] [data]
*
*/
negTokenInitContSize = dataLen;
negTokenInitSeqSize = 1 + gssint_der_length_size(dataLen) + dataLen;
dataLen = negTokenInitSeqSize;
/*
* negTokenInitSize indicates the bytes needed to
* hold the ASN.1 encoding of the entire NegTokenInit
* SEQUENCE.
* 0xa0 [DER_LEN] + data
*
*/
negTokenInitSize = 1 +
gssint_der_length_size(negTokenInitSeqSize) +
negTokenInitSeqSize;
tlen = g_token_size(gss_mech_spnego, negTokenInitSize);
t = (unsigned char *) gssalloc_malloc(tlen);
if (t == NULL) {
return (-1);
}
ptr = t;
/* create the message */
if ((ret = g_make_token_header(gss_mech_spnego, negTokenInitSize,
&ptr, tlen)))
goto errout;
*ptr++ = CONTEXT; /* NegotiationToken identifier */
if ((ret = gssint_put_der_length(negTokenInitSeqSize, &ptr, tlen)))
goto errout;
*ptr++ = SEQUENCE;
if ((ret = gssint_put_der_length(negTokenInitContSize, &ptr,
tlen - (int)(ptr-t))))
goto errout;
*ptr++ = CONTEXT | 0x00; /* MechTypeList identifier */
if ((ret = gssint_put_der_length(spnego_ctx->DER_mechTypes.length,
&ptr, tlen - (int)(ptr-t))))
goto errout;
/* We already encoded the MechSetList */
(void) memcpy(ptr, spnego_ctx->DER_mechTypes.value,
spnego_ctx->DER_mechTypes.length);
ptr += spnego_ctx->DER_mechTypes.length;
if (data != NULL) {
*ptr++ = CONTEXT | 0x02;
if ((ret = gssint_put_der_length(rspTokenSize,
&ptr, tlen - (int)(ptr - t))))
goto errout;
if ((ret = put_input_token(&ptr, data,
tlen - (int)(ptr - t))))
goto errout;
}
if (mechListMIC != GSS_C_NO_BUFFER) {
*ptr++ = CONTEXT | 0x03;
if ((ret = gssint_put_der_length(micTokenSize,
&ptr, tlen - (int)(ptr - t))))
goto errout;
if (negHintsCompat) {
ret = put_neg_hints(&ptr, mechListMIC,
tlen - (int)(ptr - t));
if (ret)
goto errout;
} else if ((ret = put_input_token(&ptr, mechListMIC,
tlen - (int)(ptr - t))))
goto errout;
}
errout:
if (ret != 0) {
if (t)
free(t);
t = NULL;
tlen = 0;
}
outbuf->length = tlen;
outbuf->value = (void *) t;
return (ret);
}
| 0 |
linux | 4d6636498c41891d0482a914dd570343a838ad79 | NOT_APPLICABLE | NOT_APPLICABLE | static inline void mcba_usb_free_ctx(struct mcba_usb_ctx *ctx)
{
/* Increase number of free ctxs before freeing ctx */
atomic_inc(&ctx->priv->free_ctx_cnt);
ctx->ndx = MCBA_CTX_FREE;
/* Wake up the queue once ctx is marked free */
netif_wake_queue(ctx->priv->netdev);
} | 0 |
Chrome | 7cde8513c12a6e8ec5d1d1eb1cfd078d9adad3ef | NOT_APPLICABLE | NOT_APPLICABLE | std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
std::vector<ContentSettingsType> permission_list;
for (size_t i = 0; i < base::size(kPermissionType); ++i) {
#if !defined(OS_ANDROID)
if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY)
continue;
#endif
permission_list.push_back(kPermissionType[i]);
}
return permission_list;
}
| 0 |
ghostscript | 1e03c06456d997435019fb3526fa2d4be7dbc6ec | NOT_APPLICABLE | NOT_APPLICABLE | pdf_dict_getp(fz_context *ctx, pdf_obj *obj, const char *keys)
{
char buf[256];
char *k, *e;
RESOLVE(obj);
if (!OBJ_IS_DICT(obj))
return NULL;
if (strlen(keys)+1 > 256)
fz_throw(ctx, FZ_ERROR_GENERIC, "path too long");
strcpy(buf, keys);
e = buf;
while (*e && obj)
{
k = e;
while (*e != '/' && *e != '\0')
e++;
if (*e == '/')
{
*e = '\0';
e++;
}
obj = pdf_dict_gets(ctx, obj, k);
}
return obj;
}
| 0 |
linux | ee53664bda169f519ce3c6a22d378f0b946c8178 | NOT_APPLICABLE | NOT_APPLICABLE | static inline pte_t pte_mknuma(pte_t pte)
{
pte = pte_set_flags(pte, _PAGE_NUMA);
return pte_clear_flags(pte, _PAGE_PRESENT);
} | 0 |
FreeRDP | 6b485b146a1b9d6ce72dfd7b5f36456c166e7a16 | NOT_APPLICABLE | NOT_APPLICABLE | BOOL nego_set_requested_protocols(rdpNego* nego, UINT32 RequestedProtocols)
{
if (!nego)
return FALSE;
nego->RequestedProtocols = RequestedProtocols;
return TRUE;
} | 0 |
linux | 2d8a041b7bfe1097af21441cb77d6af95f4f4680 | NOT_APPLICABLE | NOT_APPLICABLE | static void ip_vs_unlink_service(struct ip_vs_service *svc)
{
/*
* Unhash it from the service table
*/
write_lock_bh(&__ip_vs_svc_lock);
ip_vs_svc_unhash(svc);
/*
* Wait until all the svc users go away.
*/
IP_VS_WAIT_WHILE(atomic_read(&svc->usecnt) > 0);
__ip_vs_del_service(svc);
write_unlock_bh(&__ip_vs_svc_lock);
}
| 0 |
linux | 350b8bdd689cd2ab2c67c8a86a0be86cfa0751a7 | NOT_APPLICABLE | NOT_APPLICABLE | int kvm_iommu_map_guest(struct kvm *kvm)
{
int r;
if (!iommu_present(&pci_bus_type)) {
printk(KERN_ERR "%s: iommu not found\n", __func__);
return -ENODEV;
}
mutex_lock(&kvm->slots_lock);
kvm->arch.iommu_domain = iommu_domain_alloc(&pci_bus_type);
if (!kvm->arch.iommu_domain) {
r = -ENOMEM;
goto out_unlock;
}
if (!allow_unsafe_assigned_interrupts &&
!iommu_domain_has_cap(kvm->arch.iommu_domain,
IOMMU_CAP_INTR_REMAP)) {
printk(KERN_WARNING "%s: No interrupt remapping support,"
" disallowing device assignment."
" Re-enble with \"allow_unsafe_assigned_interrupts=1\""
" module option.\n", __func__);
iommu_domain_free(kvm->arch.iommu_domain);
kvm->arch.iommu_domain = NULL;
r = -EPERM;
goto out_unlock;
}
r = kvm_iommu_map_memslots(kvm);
if (r)
kvm_iommu_unmap_memslots(kvm);
out_unlock:
mutex_unlock(&kvm->slots_lock);
return r;
}
| 0 |
tor | 80c404c4b79f3bcba3fc4585d4c62a62a04f3ed9 | NOT_APPLICABLE | NOT_APPLICABLE | parse_extended_hostname(char *address, hostname_type_t *type_out)
{
char *s;
char *q;
char query[HS_SERVICE_ADDR_LEN_BASE32+1];
s = strrchr(address,'.');
if (!s) {
*type_out = NORMAL_HOSTNAME; /* no dot, thus normal */
goto success;
}
if (!strcmp(s+1,"exit")) {
*s = 0; /* NUL-terminate it */
*type_out = EXIT_HOSTNAME; /* .exit */
goto success;
}
if (strcmp(s+1,"onion")) {
*type_out = NORMAL_HOSTNAME; /* neither .exit nor .onion, thus normal */
goto success;
}
/* so it is .onion */
*s = 0; /* NUL-terminate it */
/* locate a 'sub-domain' component, in order to remove it */
q = strrchr(address, '.');
if (q == address) {
*type_out = BAD_HOSTNAME;
goto failed; /* reject sub-domain, as DNS does */
}
q = (NULL == q) ? address : q + 1;
if (strlcpy(query, q, HS_SERVICE_ADDR_LEN_BASE32+1) >=
HS_SERVICE_ADDR_LEN_BASE32+1) {
*type_out = BAD_HOSTNAME;
goto failed;
}
if (q != address) {
memmove(address, q, strlen(q) + 1 /* also get \0 */);
}
/* v2 onion address check. */
if (strlen(query) == REND_SERVICE_ID_LEN_BASE32) {
*type_out = ONION_V2_HOSTNAME;
if (rend_valid_v2_service_id(query)) {
goto success;
}
goto failed;
}
/* v3 onion address check. */
if (strlen(query) == HS_SERVICE_ADDR_LEN_BASE32) {
*type_out = ONION_V3_HOSTNAME;
if (hs_address_is_valid(query)) {
goto success;
}
goto failed;
}
/* Reaching this point, nothing was recognized. */
*type_out = BAD_HOSTNAME;
goto failed;
success:
return true;
failed:
/* otherwise, return to previous state and return 0 */
*s = '.';
const bool is_onion = (*type_out == ONION_V2_HOSTNAME) ||
(*type_out == ONION_V3_HOSTNAME);
log_warn(LD_APP, "Invalid %shostname %s; rejecting",
is_onion ? "onion " : "",
safe_str_client(address));
if (*type_out == ONION_V3_HOSTNAME) {
*type_out = BAD_HOSTNAME;
}
return false;
} | 0 |
Chrome | afbc71b7a78ac99810a6b22b2b0a2e85dde18794 | NOT_APPLICABLE | NOT_APPLICABLE | void OneClickSigninHelper::ShowInfoBarUIThread(
const std::string& session_index,
const std::string& email,
AutoAccept auto_accept,
SyncPromoUI::Source source,
const GURL& continue_url,
int child_id,
int route_id) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id,
route_id);
if (!web_contents)
return;
OneClickSigninHelper* helper =
OneClickSigninHelper::FromWebContents(web_contents);
if (!helper)
return;
if (auto_accept != AUTO_ACCEPT_NONE)
helper->auto_accept_ = auto_accept;
if (source != SyncPromoUI::SOURCE_UNKNOWN &&
helper->source_ == SyncPromoUI::SOURCE_UNKNOWN) {
helper->source_ = source;
}
CanOfferFor can_offer_for =
(auto_accept != AUTO_ACCEPT_EXPLICIT &&
helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ?
CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL;
std::string error_message;
if (!web_contents || !CanOffer(web_contents, can_offer_for, email,
&error_message)) {
VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering";
if (helper && helper->error_message_.empty() && !error_message.empty())
helper->error_message_ = error_message;
return;
}
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
SigninManager* manager = profile ?
SigninManagerFactory::GetForProfile(profile) : NULL;
helper->untrusted_confirmation_required_ |=
(manager && !manager->IsSigninProcess(child_id));
if (!session_index.empty())
helper->session_index_ = session_index;
if (!email.empty())
helper->email_ = email;
if (continue_url.is_valid())
helper->continue_url_ = continue_url;
}
| 0 |
PackageKit | 7e8a7905ea9abbd1f384f05f36a4458682cd4697 | NOT_APPLICABLE | NOT_APPLICABLE | pk_transaction_status_changed_emit (PkTransaction *transaction, PkStatusEnum status)
{
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
/* already set */
if (transaction->priv->status == status)
return;
transaction->priv->status = status;
/* emit */
pk_transaction_emit_property_changed (transaction,
"Status",
g_variant_new_uint32 (status));
} | 0 |
Chrome | 248a92c21c20c14b5983680c50e1d8b73fc79a2f | NOT_APPLICABLE | NOT_APPLICABLE | void setCheckForFloatsFromLastLine(bool check) { m_checkForFloatsFromLastLine = check; }
| 0 |
linux | 040757f738e13caaa9c5078bca79aa97e11dde88 | NOT_APPLICABLE | NOT_APPLICABLE | static int set_is_seen(struct ctl_table_set *set)
{
return ¤t_user_ns()->set == set;
}
| 0 |
Android | 1f4b49e64adf4623eefda503bca61e253597b9bf | NOT_APPLICABLE | NOT_APPLICABLE | status_t Parcel::readFloatVector(std::unique_ptr<std::vector<float>>* val) const {
return readNullableTypedVector(val, &Parcel::readFloat);
}
| 0 |
FFmpeg | 3819db745da2ac7fb3faacb116788c32f4753f34 | NOT_APPLICABLE | NOT_APPLICABLE | static av_cold int rpza_decode_end(AVCodecContext *avctx)
{
RpzaContext *s = avctx->priv_data;
av_frame_unref(&s->frame);
return 0;
}
| 0 |
php | 25e8fcc88fa20dc9d4c47184471003f436927cde | CVE-2011-4718 | CWE-264 | static ps_sd *ps_sd_new(ps_mm *data, const char *key)
{
php_uint32 hv, slot;
ps_sd *sd;
int keylen;
keylen = strlen(key);
sd = mm_malloc(data->mm, sizeof(ps_sd) + keylen);
if (!sd) {
TSRMLS_FETCH();
php_error_docref(NULL TSRMLS_CC, E_WARNING, "mm_malloc failed, avail %d, err %s", mm_available(data->mm), mm_error());
return NULL;
}
hv = ps_sd_hash(key, keylen);
slot = hv & data->hash_max;
sd->ctime = 0;
sd->hv = hv;
sd->data = NULL;
sd->alloclen = sd->datalen = 0;
memcpy(sd->key, key, keylen + 1);
sd->next = data->hash[slot];
data->hash[slot] = sd;
data->hash_cnt++;
if (!sd->next) {
if (data->hash_cnt >= data->hash_max) {
hash_split(data);
}
}
ps_mm_debug(("inserting %s(%p) into slot %d\n", key, sd, slot));
return sd;
}
| 1 |
Espruino | ce1924193862d58cb43d3d4d9dada710a8361b89 | NOT_APPLICABLE | NOT_APPLICABLE | JsVarInt jsvArrayPush(JsVar *arr, JsVar *value) {
assert(jsvIsArray(arr));
JsVarInt index = jsvGetArrayLength(arr);
JsVar *idx = jsvMakeIntoVariableName(jsvNewFromInteger(index), value);
if (!idx) return 0; // out of memory - error flag will have been set already
jsvAddName(arr, idx);
jsvUnLock(idx);
return jsvGetArrayLength(arr);
}
| 0 |
linux | c70422f760c120480fee4de6c38804c72aa26bc1 | NOT_APPLICABLE | NOT_APPLICABLE | nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
const char *name, unsigned int len,
struct svc_export **exp_ret, struct dentry **dentry_ret)
{
struct svc_export *exp;
struct dentry *dparent;
struct dentry *dentry;
int host_err;
dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name);
dparent = fhp->fh_dentry;
exp = exp_get(fhp->fh_export);
/* Lookup the name, but don't follow links */
if (isdotent(name, len)) {
if (len==1)
dentry = dget(dparent);
else if (dparent != exp->ex_path.dentry)
dentry = dget_parent(dparent);
else if (!EX_NOHIDE(exp) && !nfsd_v4client(rqstp))
dentry = dget(dparent); /* .. == . just like at / */
else {
/* checking mountpoint crossing is very different when stepping up */
host_err = nfsd_lookup_parent(rqstp, dparent, &exp, &dentry);
if (host_err)
goto out_nfserr;
}
} else {
/*
* In the nfsd4_open() case, this may be held across
* subsequent open and delegation acquisition which may
* need to take the child's i_mutex:
*/
fh_lock_nested(fhp, I_MUTEX_PARENT);
dentry = lookup_one_len(name, dparent, len);
host_err = PTR_ERR(dentry);
if (IS_ERR(dentry))
goto out_nfserr;
if (nfsd_mountpoint(dentry, exp)) {
/*
* We don't need the i_mutex after all. It's
* still possible we could open this (regular
* files can be mountpoints too), but the
* i_mutex is just there to prevent renames of
* something that we might be about to delegate,
* and a mountpoint won't be renamed:
*/
fh_unlock(fhp);
if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) {
dput(dentry);
goto out_nfserr;
}
}
}
*dentry_ret = dentry;
*exp_ret = exp;
return 0;
out_nfserr:
exp_put(exp);
return nfserrno(host_err);
}
| 0 |
ghostscript | 4dcc6affe04368461310a21238f7e1871a752a05 | NOT_APPLICABLE | NOT_APPLICABLE | static void pdf_run_gs_OPM(fz_context *ctx, pdf_processor *proc, int i)
{
pdf_run_processor *pr = (pdf_run_processor *)proc;
pdf_gstate *gstate = pdf_flush_text(ctx, pr);
gstate->stroke.color_params.opm = i;
gstate->fill.color_params.opm = i;
}
| 0 |
httpd | cd2b7a26c776b0754fb98426a67804fd48118708 | NOT_APPLICABLE | NOT_APPLICABLE | AP_DECLARE(int) ap_is_initial_req(request_rec *r)
{
return (r->main == NULL) /* otherwise, this is a sub-request */
&& (r->prev == NULL); /* otherwise, this is an internal redirect */
}
| 0 |
libsoup | cbeeb7a0f7f0e8b16f2d382157496f9100218dea | NOT_APPLICABLE | NOT_APPLICABLE | soup_server_get_port (SoupServer *server)
{
g_return_val_if_fail (SOUP_IS_SERVER (server), 0);
return SOUP_SERVER_GET_PRIVATE (server)->port;
} | 0 |
linux | 68cb695ccecf949d48949e72f8ce591fdaaa325c | NOT_APPLICABLE | NOT_APPLICABLE | static int efx_ethtool_set_settings(struct net_device *net_dev,
struct ethtool_cmd *ecmd)
{
struct efx_nic *efx = netdev_priv(net_dev);
int rc;
/* GMAC does not support 1000Mbps HD */
if ((ethtool_cmd_speed(ecmd) == SPEED_1000) &&
(ecmd->duplex != DUPLEX_FULL)) {
netif_dbg(efx, drv, efx->net_dev,
"rejecting unsupported 1000Mbps HD setting\n");
return -EINVAL;
}
mutex_lock(&efx->mac_lock);
rc = efx->phy_op->set_settings(efx, ecmd);
mutex_unlock(&efx->mac_lock);
return rc;
}
| 0 |
linux | ac902c112d90a89e59916f751c2745f4dbdbb4bd | NOT_APPLICABLE | NOT_APPLICABLE | static int snd_ctl_elem_init_enum_names(struct user_element *ue)
{
char *names, *p;
size_t buf_len, name_len;
unsigned int i;
const uintptr_t user_ptrval = ue->info.value.enumerated.names_ptr;
if (ue->info.value.enumerated.names_length > 64 * 1024)
return -EINVAL;
names = memdup_user((const void __user *)user_ptrval,
ue->info.value.enumerated.names_length);
if (IS_ERR(names))
return PTR_ERR(names);
/* check that there are enough valid names */
buf_len = ue->info.value.enumerated.names_length;
p = names;
for (i = 0; i < ue->info.value.enumerated.items; ++i) {
name_len = strnlen(p, buf_len);
if (name_len == 0 || name_len >= 64 || name_len == buf_len) {
kfree(names);
return -EINVAL;
}
p += name_len + 1;
buf_len -= name_len + 1;
}
ue->priv_data = names;
ue->info.value.enumerated.names_ptr = 0;
return 0;
}
| 0 |
Chrome | 7d085fbb43b21e959900b94f191588fd10546a94 | NOT_APPLICABLE | NOT_APPLICABLE | RenderImageResource* ImageLoader::renderImageResource()
{
RenderObject* renderer = m_element->renderer();
if (!renderer)
return 0;
if (renderer->isImage() && !static_cast<RenderImage*>(renderer)->isGeneratedContent())
return toRenderImage(renderer)->imageResource();
#if ENABLE(SVG)
if (renderer->isSVGImage())
return toRenderSVGImage(renderer)->imageResource();
#endif
if (renderer->isVideo())
return toRenderVideo(renderer)->imageResource();
return 0;
}
| 0 |
Chrome | 201d2ae4d50a755f3b4ba799c00590cfa2fe3b93 | NOT_APPLICABLE | NOT_APPLICABLE | int AwMainDelegate::RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) {
if (process_type.empty()) {
AwBrowserDependencyFactoryImpl::InstallInstance();
browser_runner_.reset(content::BrowserMainRunner::Create());
int exit_code = browser_runner_->Initialize(main_function_params);
DCHECK_LT(exit_code, 0);
g_allow_wait_in_ui_thread.Get().reset(
new ScopedAllowWaitForLegacyWebViewApi);
return 0;
}
return -1;
}
| 0 |
Chrome | d18c519758c2e6043f0e1f00e2b69a55b3d7997f | NOT_APPLICABLE | NOT_APPLICABLE | void NavigateToDataURLAndCheckForTerminationDisabler(
Shell* shell,
const std::string& html,
bool expect_onunload,
bool expect_onbeforeunload) {
NavigateToURL(shell, GURL("data:text/html," + html));
RenderFrameHostImpl* rfh =
static_cast<RenderFrameHostImpl*>(shell->web_contents()->GetMainFrame());
EXPECT_EQ(expect_onunload,
rfh->GetSuddenTerminationDisablerState(blink::kUnloadHandler));
EXPECT_EQ(expect_onbeforeunload, rfh->GetSuddenTerminationDisablerState(
blink::kBeforeUnloadHandler));
}
| 0 |
redis | 874804da0c014a7d704b3d285aa500098a931f50 | NOT_APPLICABLE | NOT_APPLICABLE | void version(void) {
printf("Redis server v=%s sha=%s:%d malloc=%s bits=%d build=%llx\n",
REDIS_VERSION,
redisGitSHA1(),
atoi(redisGitDirty()) > 0,
ZMALLOC_LIB,
sizeof(long) == 4 ? 32 : 64,
(unsigned long long) redisBuildId());
exit(0);
}
| 0 |
linux | a2b9e6c1a35afcc0973acb72e591c714e78885ff | NOT_APPLICABLE | NOT_APPLICABLE | static int set_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 data)
{
switch (msr) {
case HV_X64_MSR_APIC_ASSIST_PAGE: {
u64 gfn;
unsigned long addr;
if (!(data & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE)) {
vcpu->arch.hv_vapic = data;
if (kvm_lapic_enable_pv_eoi(vcpu, 0))
return 1;
break;
}
gfn = data >> HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT;
addr = gfn_to_hva(vcpu->kvm, gfn);
if (kvm_is_error_hva(addr))
return 1;
if (__clear_user((void __user *)addr, PAGE_SIZE))
return 1;
vcpu->arch.hv_vapic = data;
mark_page_dirty(vcpu->kvm, gfn);
if (kvm_lapic_enable_pv_eoi(vcpu, gfn_to_gpa(gfn) | KVM_MSR_ENABLED))
return 1;
break;
}
case HV_X64_MSR_EOI:
return kvm_hv_vapic_msr_write(vcpu, APIC_EOI, data);
case HV_X64_MSR_ICR:
return kvm_hv_vapic_msr_write(vcpu, APIC_ICR, data);
case HV_X64_MSR_TPR:
return kvm_hv_vapic_msr_write(vcpu, APIC_TASKPRI, data);
default:
vcpu_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
"data 0x%llx\n", msr, data);
return 1;
}
return 0;
}
| 0 |
xserver | 8a59e3b7dbb30532a7c3769c555e00d7c4301170 | NOT_APPLICABLE | NOT_APPLICABLE | xf86PrintDefaultModulePath(void)
{
ErrorF("%s\n", DEFAULT_MODULE_PATH);
} | 0 |
Chrome | 802ecdb9cee0d66fe546bdf24e98150f8f716ad8 | CVE-2012-5152 | CWE-119 | int AudioRendererAlgorithm::FillBuffer(
uint8* dest, int requested_frames) {
DCHECK_NE(bytes_per_frame_, 0);
if (playback_rate_ == 0.0f)
return 0;
int total_frames_rendered = 0;
uint8* output_ptr = dest;
while (total_frames_rendered < requested_frames) {
if (index_into_window_ == window_size_)
ResetWindow();
bool rendered_frame = true;
if (playback_rate_ > 1.0)
rendered_frame = OutputFasterPlayback(output_ptr);
else if (playback_rate_ < 1.0)
rendered_frame = OutputSlowerPlayback(output_ptr);
else
rendered_frame = OutputNormalPlayback(output_ptr);
if (!rendered_frame) {
needs_more_data_ = true;
break;
}
output_ptr += bytes_per_frame_;
total_frames_rendered++;
}
return total_frames_rendered;
}
| 1 |
ImageMagick | f0232a2a45dfd003c1faf6079497895df3ab0ee1 | NOT_APPLICABLE | NOT_APPLICABLE | int exif_inf(png_structp png_ptr, unsigned char *source,
unsigned char **dest, size_t n, png_uint_32 inflated_size)
{
/* *source: compressed data stream (input)
*dest: inflated data (output)
n: length of input
Returns one of the following:
return(-1); chunk had an error
return(n); success, n is length of inflated data
*/
int ret;
z_stream strm;
size_t inflated_length = inflated_size;
if (inflated_length >= PNG_USER_CHUNK_MALLOC_MAX - 1U ||
inflated_length == 0)
return (-1);
/* allocate dest */
#if PNG_LIBPNG_VER >= 14000
*dest=(unsigned char *) png_malloc(png_ptr,
(png_alloc_size_t) inflated_length);
#else
*dest=(unsigned char *) png_malloc(png_ptr,
(png_size_t) inflated_length);
#endif
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return (-1);
/* decompress until deflate stream ends or end of file */
do {
strm.avail_in = (int)n;
strm.next_in = source;
/* run inflate() on input until output buffer not full */
do {
strm.avail_out = (int)inflated_length;
strm.next_out = *dest;
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return (-1);
}
} while (strm.avail_out == 0);
/* done when inflate() says it's done */
} while (ret != Z_STREAM_END);
/* clean up and return */
/* To do: take care of too little or too much data */
(void)inflateEnd(&strm);
return (inflated_length);
} | 0 |
php | 1cbd25ca15383394ffa9ee8601c5de4c0f2f90e1 | NOT_APPLICABLE | NOT_APPLICABLE | static int spl_heap_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (intern->fptr_count) {
zval *rv;
zend_call_method_with_0_params(&object, intern->std.ce, &intern->fptr_count, "count", &rv);
if (rv) {
zval_ptr_dtor(&intern->retval);
MAKE_STD_ZVAL(intern->retval);
ZVAL_ZVAL(intern->retval, rv, 1, 1);
convert_to_long(intern->retval);
*count = (long) Z_LVAL_P(intern->retval);
return SUCCESS;
}
*count = 0;
return FAILURE;
}
*count = spl_ptr_heap_count(intern->heap);
return SUCCESS;
}
/* }}} */
| 0 |
quagga | 8794e8d229dc9fe29ea31424883433d4880ef408 | NOT_APPLICABLE | NOT_APPLICABLE | bgp_attr_aggregate_intern (struct bgp *bgp, u_char origin,
struct aspath *aspath,
struct community *community, int as_set)
{
struct attr attr;
struct attr *new;
struct attr_extra *attre;
memset (&attr, 0, sizeof (struct attr));
attre = bgp_attr_extra_get (&attr);
/* Origin attribute. */
attr.origin = origin;
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
/* AS path attribute. */
if (aspath)
attr.aspath = aspath_intern (aspath);
else
attr.aspath = aspath_empty ();
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
/* Next hop attribute. */
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
if (community)
{
attr.community = community;
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
}
attre->weight = BGP_ATTR_DEFAULT_WEIGHT;
#ifdef HAVE_IPV6
attre->mp_nexthop_len = IPV6_MAX_BYTELEN;
#endif
if (! as_set)
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);
if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION))
attre->aggregator_as = bgp->confed_id;
else
attre->aggregator_as = bgp->as;
attre->aggregator_addr = bgp->router_id;
new = bgp_attr_intern (&attr);
bgp_attr_extra_free (&attr);
aspath_unintern (&new->aspath);
return new;
} | 0 |
linux | 04f5866e41fb70690e28397487d8bd8eea7d712a | NOT_APPLICABLE | NOT_APPLICABLE | void exit_mmap(struct mm_struct *mm)
{
struct mmu_gather tlb;
struct vm_area_struct *vma;
unsigned long nr_accounted = 0;
/* mm's last user has gone, and its about to be pulled down */
mmu_notifier_release(mm);
if (unlikely(mm_is_oom_victim(mm))) {
/*
* Manually reap the mm to free as much memory as possible.
* Then, as the oom reaper does, set MMF_OOM_SKIP to disregard
* this mm from further consideration. Taking mm->mmap_sem for
* write after setting MMF_OOM_SKIP will guarantee that the oom
* reaper will not run on this mm again after mmap_sem is
* dropped.
*
* Nothing can be holding mm->mmap_sem here and the above call
* to mmu_notifier_release(mm) ensures mmu notifier callbacks in
* __oom_reap_task_mm() will not block.
*
* This needs to be done before calling munlock_vma_pages_all(),
* which clears VM_LOCKED, otherwise the oom reaper cannot
* reliably test it.
*/
(void)__oom_reap_task_mm(mm);
set_bit(MMF_OOM_SKIP, &mm->flags);
down_write(&mm->mmap_sem);
up_write(&mm->mmap_sem);
}
if (mm->locked_vm) {
vma = mm->mmap;
while (vma) {
if (vma->vm_flags & VM_LOCKED)
munlock_vma_pages_all(vma);
vma = vma->vm_next;
}
}
arch_exit_mmap(mm);
vma = mm->mmap;
if (!vma) /* Can happen if dup_mmap() received an OOM */
return;
lru_add_drain();
flush_cache_mm(mm);
tlb_gather_mmu(&tlb, mm, 0, -1);
/* update_hiwater_rss(mm) here? but nobody should be looking */
/* Use -1 here to ensure all VMAs in the mm are unmapped */
unmap_vmas(&tlb, vma, 0, -1);
free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING);
tlb_finish_mmu(&tlb, 0, -1);
/*
* Walk the list again, actually closing and freeing it,
* with preemption enabled, without holding any MM locks.
*/
while (vma) {
if (vma->vm_flags & VM_ACCOUNT)
nr_accounted += vma_pages(vma);
vma = remove_vma(vma);
}
vm_unacct_memory(nr_accounted);
}
| 0 |
audiofile | 822b732fd31ffcb78f6920001e9b1fbd815fa712 | CVE-2018-17095 | CWE-787 | void SimpleModule::runPull()
{
pull(m_outChunk->frameCount);
run(*m_inChunk, *m_outChunk);
} | 1 |
libjpeg | 4746b577931e926a49e50de9720a4946de3069a7 | NOT_APPLICABLE | NOT_APPLICABLE | void SampleInterleavedLSScan::FindComponentDimensions(void)
{
#if ACCUSOFT_CODE
UBYTE cx;
JPEGLSScan::FindComponentDimensions();
//
// Check that all MCU dimensions are 1.
for(cx = 0;cx < m_ucCount;cx++) {
class Component *comp = ComponentOf(cx);
if (comp->MCUHeightOf() != 1 || comp->MCUWidthOf() != 1)
JPG_THROW(INVALID_PARAMETER,"SampleInterleavedLSScan::FindComponentDimensions",
"sample interleaved JPEG LS does not support subsampling");
}
#endif
} | 0 |
exim | d4bc023436e4cce7c23c5f8bb5199e178b4cc743 | CVE-2022-37452 | CWE-787 | host_name_lookup(void)
{
int old_pool, rc;
int sep = 0;
uschar *save_hostname;
uschar **aliases;
uschar *ordername;
const uschar *list = host_lookup_order;
dns_answer * dnsa = store_get_dns_answer();
dns_scan dnss;
sender_host_dnssec = host_lookup_deferred = host_lookup_failed = FALSE;
HDEBUG(D_host_lookup)
debug_printf("looking up host name for %s\n", sender_host_address);
/* For testing the case when a lookup does not complete, we have a special
reserved IP address. */
if (f.running_in_test_harness &&
Ustrcmp(sender_host_address, "99.99.99.99") == 0)
{
HDEBUG(D_host_lookup)
debug_printf("Test harness: host name lookup returns DEFER\n");
host_lookup_deferred = TRUE;
return DEFER;
}
/* Do lookups directly in the DNS or via gethostbyaddr() (or equivalent), in
the order specified by the host_lookup_order option. */
while ((ordername = string_nextinlist(&list, &sep, NULL, 0)))
{
if (strcmpic(ordername, US"bydns") == 0)
{
uschar * name = dns_build_reverse(sender_host_address);
dns_init(FALSE, FALSE, FALSE); /* dnssec ctrl by dns_dnssec_ok glbl */
rc = dns_lookup_timerwrap(dnsa, name, T_PTR, NULL);
/* The first record we come across is used for the name; others are
considered to be aliases. We have to scan twice, in order to find out the
number of aliases. However, if all the names are empty, we will behave as
if failure. (PTR records that yield empty names have been encountered in
the DNS.) */
if (rc == DNS_SUCCEED)
{
uschar **aptr = NULL;
int ssize = 264;
int count = 0;
int old_pool = store_pool;
sender_host_dnssec = dns_is_secure(dnsa);
DEBUG(D_dns)
debug_printf("Reverse DNS security status: %s\n",
sender_host_dnssec ? "DNSSEC verified (AD)" : "unverified");
store_pool = POOL_PERM; /* Save names in permanent storage */
for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS);
rr;
rr = dns_next_rr(dnsa, &dnss, RESET_NEXT)) if (rr->type == T_PTR)
count++;
/* Get store for the list of aliases. For compatibility with
gethostbyaddr, we make an empty list if there are none. */
aptr = sender_host_aliases = store_get(count * sizeof(uschar *), FALSE);
/* Re-scan and extract the names */
for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS);
rr;
rr = dns_next_rr(dnsa, &dnss, RESET_NEXT)) if (rr->type == T_PTR)
{
uschar * s = store_get(ssize, TRUE); /* names are tainted */
/* If an overlong response was received, the data will have been
truncated and dn_expand may fail. */
if (dn_expand(dnsa->answer, dnsa->answer + dnsa->answerlen,
US (rr->data), (DN_EXPAND_ARG4_TYPE)(s), ssize) < 0)
{
log_write(0, LOG_MAIN, "host name alias list truncated for %s",
sender_host_address);
break;
}
store_release_above(s + Ustrlen(s) + 1);
if (!s[0])
{
HDEBUG(D_host_lookup) debug_printf("IP address lookup yielded an "
"empty name: treated as non-existent host name\n");
continue;
}
if (!sender_host_name) sender_host_name = s;
else *aptr++ = s;
while (*s) { *s = tolower(*s); s++; }
}
*aptr = NULL; /* End of alias list */
store_pool = old_pool; /* Reset store pool */
/* If we've found a name, break out of the "order" loop */
if (sender_host_name) break;
}
/* If the DNS lookup deferred, we must also defer. */
if (rc == DNS_AGAIN)
{
HDEBUG(D_host_lookup)
debug_printf("IP address PTR lookup gave temporary error\n");
host_lookup_deferred = TRUE;
return DEFER;
}
}
/* Do a lookup using gethostbyaddr() - or equivalent */
else if (strcmpic(ordername, US"byaddr") == 0)
{
HDEBUG(D_host_lookup)
debug_printf("IP address lookup using gethostbyaddr()\n");
rc = host_name_lookup_byaddr();
if (rc == DEFER)
{
host_lookup_deferred = TRUE;
return rc; /* Can't carry on */
}
if (rc == OK) break; /* Found a name */
}
} /* Loop for bydns/byaddr scanning */
/* If we have failed to find a name, return FAIL and log when required.
NB host_lookup_msg must be in permanent store. */
if (!sender_host_name)
{
if (host_checking || !f.log_testing_mode)
log_write(L_host_lookup_failed, LOG_MAIN, "no host name found for IP "
"address %s", sender_host_address);
host_lookup_msg = US" (failed to find host name from IP address)";
host_lookup_failed = TRUE;
return FAIL;
}
HDEBUG(D_host_lookup)
{
uschar **aliases = sender_host_aliases;
debug_printf("IP address lookup yielded \"%s\"\n", sender_host_name);
while (*aliases != NULL) debug_printf(" alias \"%s\"\n", *aliases++);
}
/* We need to verify that a forward lookup on the name we found does indeed
correspond to the address. This is for security: in principle a malefactor who
happened to own a reverse zone could set it to point to any names at all.
This code was present in versions of Exim before 3.20. At that point I took it
out because I thought that gethostbyaddr() did the check anyway. It turns out
that this isn't always the case, so it's coming back in at 4.01. This version
is actually better, because it also checks aliases.
The code was made more robust at release 4.21. Prior to that, it accepted all
the names if any of them had the correct IP address. Now the code checks all
the names, and accepts only those that have the correct IP address. */
save_hostname = sender_host_name; /* Save for error messages */
aliases = sender_host_aliases;
for (uschar * hname = sender_host_name; hname; hname = *aliases++)
{
int rc;
BOOL ok = FALSE;
host_item h = { .next = NULL, .name = hname, .mx = MX_NONE, .address = NULL };
dnssec_domains d =
{ .request = sender_host_dnssec ? US"*" : NULL, .require = NULL };
if ( (rc = host_find_bydns(&h, NULL, HOST_FIND_BY_A | HOST_FIND_BY_AAAA,
NULL, NULL, NULL, &d, NULL, NULL)) == HOST_FOUND
|| rc == HOST_FOUND_LOCAL
)
{
HDEBUG(D_host_lookup) debug_printf("checking addresses for %s\n", hname);
/* If the forward lookup was not secure we cancel the is-secure variable */
DEBUG(D_dns) debug_printf("Forward DNS security status: %s\n",
h.dnssec == DS_YES ? "DNSSEC verified (AD)" : "unverified");
if (h.dnssec != DS_YES) sender_host_dnssec = FALSE;
for (host_item * hh = &h; hh; hh = hh->next)
if (host_is_in_net(hh->address, sender_host_address, 0))
{
HDEBUG(D_host_lookup) debug_printf(" %s OK\n", hh->address);
ok = TRUE;
break;
}
else
HDEBUG(D_host_lookup) debug_printf(" %s\n", hh->address);
if (!ok) HDEBUG(D_host_lookup)
debug_printf("no IP address for %s matched %s\n", hname,
sender_host_address);
}
else if (rc == HOST_FIND_AGAIN)
{
HDEBUG(D_host_lookup) debug_printf("temporary error for host name lookup\n");
host_lookup_deferred = TRUE;
sender_host_name = NULL;
return DEFER;
}
else
HDEBUG(D_host_lookup) debug_printf("no IP addresses found for %s\n", hname);
/* If this name is no good, and it's the sender name, set it null pro tem;
if it's an alias, just remove it from the list. */
if (!ok)
{
if (hname == sender_host_name) sender_host_name = NULL; else
{
uschar **a; /* Don't amalgamate - some */
a = --aliases; /* compilers grumble */
while (*a != NULL) { *a = a[1]; a++; }
}
}
}
/* If sender_host_name == NULL, it means we didn't like the name. Replace
it with the first alias, if there is one. */
if (sender_host_name == NULL && *sender_host_aliases != NULL)
sender_host_name = *sender_host_aliases++;
/* If we now have a main name, all is well. */
if (sender_host_name != NULL) return OK;
/* We have failed to find an address that matches. */
HDEBUG(D_host_lookup)
debug_printf("%s does not match any IP address for %s\n",
sender_host_address, save_hostname);
/* This message must be in permanent store */
old_pool = store_pool;
store_pool = POOL_PERM;
host_lookup_msg = string_sprintf(" (%s does not match any IP address for %s)",
sender_host_address, save_hostname);
store_pool = old_pool;
host_lookup_failed = TRUE;
return FAIL;
} | 1 |
linux | dc0b027dfadfcb8a5504f7d8052754bf8d501ab9 | NOT_APPLICABLE | NOT_APPLICABLE | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
{
struct xdr_stream xdr;
struct compound_hdr hdr;
int status;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
status = decode_compound_hdr(&xdr, &hdr);
if (status)
goto out;
status = decode_putfh(&xdr);
if (status)
goto out;
status = decode_write(&xdr, res);
if (status)
goto out;
decode_getfattr(&xdr, res->fattr, res->server);
if (!status)
status = res->count;
out:
return status;
}
| 0 |
Chrome | 9fe90fe465e046a219411b192d8b08086faae39c | NOT_APPLICABLE | NOT_APPLICABLE | void OmniboxPopupViewGtk::Hide() {
gtk_widget_hide(window_);
opened_ = false;
}
| 0 |
linux | 51aa68e7d57e3217192d88ce90fd5b8ef29ec94f | NOT_APPLICABLE | NOT_APPLICABLE | static int handle_vmfunc(struct kvm_vcpu *vcpu)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
struct vmcs12 *vmcs12;
u32 function = vcpu->arch.regs[VCPU_REGS_RAX];
/*
* VMFUNC is only supported for nested guests, but we always enable the
* secondary control for simplicity; for non-nested mode, fake that we
* didn't by injecting #UD.
*/
if (!is_guest_mode(vcpu)) {
kvm_queue_exception(vcpu, UD_VECTOR);
return 1;
}
vmcs12 = get_vmcs12(vcpu);
if ((vmcs12->vm_function_control & (1 << function)) == 0)
goto fail;
switch (function) {
case 0:
if (nested_vmx_eptp_switching(vcpu, vmcs12))
goto fail;
break;
default:
goto fail;
}
return kvm_skip_emulated_instruction(vcpu);
fail:
nested_vmx_vmexit(vcpu, vmx->exit_reason,
vmcs_read32(VM_EXIT_INTR_INFO),
vmcs_readl(EXIT_QUALIFICATION));
return 1;
}
| 0 |
linux | 2da424b0773cea3db47e1e81db71eeebde8269d4 | NOT_APPLICABLE | NOT_APPLICABLE | static u8 iwlagn_key_sta_id(struct iwl_priv *priv,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
u8 sta_id = IWL_INVALID_STATION;
if (sta)
sta_id = iwl_sta_id(sta);
/*
* The device expects GTKs for station interfaces to be
* installed as GTKs for the AP station. If we have no
* station ID, then use the ap_sta_id in that case.
*/
if (!sta && vif && vif_priv->ctx) {
switch (vif->type) {
case NL80211_IFTYPE_STATION:
sta_id = vif_priv->ctx->ap_sta_id;
break;
default:
/*
* In all other cases, the key will be
* used either for TX only or is bound
* to a station already.
*/
break;
}
}
return sta_id;
}
| 0 |
linux | e09463f220ca9a1a1ecfda84fcda658f99a1f12a | NOT_APPLICABLE | NOT_APPLICABLE | static int start_this_handle(journal_t *journal, handle_t *handle,
gfp_t gfp_mask)
{
transaction_t *transaction, *new_transaction = NULL;
int blocks = handle->h_buffer_credits;
int rsv_blocks = 0;
unsigned long ts = jiffies;
if (handle->h_rsv_handle)
rsv_blocks = handle->h_rsv_handle->h_buffer_credits;
/*
* Limit the number of reserved credits to 1/2 of maximum transaction
* size and limit the number of total credits to not exceed maximum
* transaction size per operation.
*/
if ((rsv_blocks > journal->j_max_transaction_buffers / 2) ||
(rsv_blocks + blocks > journal->j_max_transaction_buffers)) {
printk(KERN_ERR "JBD2: %s wants too many credits "
"credits:%d rsv_credits:%d max:%d\n",
current->comm, blocks, rsv_blocks,
journal->j_max_transaction_buffers);
WARN_ON(1);
return -ENOSPC;
}
alloc_transaction:
if (!journal->j_running_transaction) {
/*
* If __GFP_FS is not present, then we may be being called from
* inside the fs writeback layer, so we MUST NOT fail.
*/
if ((gfp_mask & __GFP_FS) == 0)
gfp_mask |= __GFP_NOFAIL;
new_transaction = kmem_cache_zalloc(transaction_cache,
gfp_mask);
if (!new_transaction)
return -ENOMEM;
}
jbd_debug(3, "New handle %p going live.\n", handle);
/*
* We need to hold j_state_lock until t_updates has been incremented,
* for proper journal barrier handling
*/
repeat:
read_lock(&journal->j_state_lock);
BUG_ON(journal->j_flags & JBD2_UNMOUNT);
if (is_journal_aborted(journal) ||
(journal->j_errno != 0 && !(journal->j_flags & JBD2_ACK_ERR))) {
read_unlock(&journal->j_state_lock);
jbd2_journal_free_transaction(new_transaction);
return -EROFS;
}
/*
* Wait on the journal's transaction barrier if necessary. Specifically
* we allow reserved handles to proceed because otherwise commit could
* deadlock on page writeback not being able to complete.
*/
if (!handle->h_reserved && journal->j_barrier_count) {
read_unlock(&journal->j_state_lock);
wait_event(journal->j_wait_transaction_locked,
journal->j_barrier_count == 0);
goto repeat;
}
if (!journal->j_running_transaction) {
read_unlock(&journal->j_state_lock);
if (!new_transaction)
goto alloc_transaction;
write_lock(&journal->j_state_lock);
if (!journal->j_running_transaction &&
(handle->h_reserved || !journal->j_barrier_count)) {
jbd2_get_transaction(journal, new_transaction);
new_transaction = NULL;
}
write_unlock(&journal->j_state_lock);
goto repeat;
}
transaction = journal->j_running_transaction;
if (!handle->h_reserved) {
/* We may have dropped j_state_lock - restart in that case */
if (add_transaction_credits(journal, blocks, rsv_blocks))
goto repeat;
} else {
/*
* We have handle reserved so we are allowed to join T_LOCKED
* transaction and we don't have to check for transaction size
* and journal space.
*/
sub_reserved_credits(journal, blocks);
handle->h_reserved = 0;
}
/* OK, account for the buffers that this operation expects to
* use and add the handle to the running transaction.
*/
update_t_max_wait(transaction, ts);
handle->h_transaction = transaction;
handle->h_requested_credits = blocks;
handle->h_start_jiffies = jiffies;
atomic_inc(&transaction->t_updates);
atomic_inc(&transaction->t_handle_count);
jbd_debug(4, "Handle %p given %d credits (total %d, free %lu)\n",
handle, blocks,
atomic_read(&transaction->t_outstanding_credits),
jbd2_log_space_left(journal));
read_unlock(&journal->j_state_lock);
current->journal_info = handle;
rwsem_acquire_read(&journal->j_trans_commit_map, 0, 0, _THIS_IP_);
jbd2_journal_free_transaction(new_transaction);
/*
* Ensure that no allocations done while the transaction is open are
* going to recurse back to the fs layer.
*/
handle->saved_alloc_context = memalloc_nofs_save();
return 0;
} | 0 |
linux | 2287a51ba822384834dafc1c798453375d1107c7 | NOT_APPLICABLE | NOT_APPLICABLE | int vt_move_to_console(unsigned int vt, int alloc)
{
int prev;
console_lock();
/* Graphics mode - up to X */
if (disable_vt_switch) {
console_unlock();
return 0;
}
prev = fg_console;
if (alloc && vc_allocate(vt)) {
/* we can't have a free VC for now. Too bad,
* we don't want to mess the screen for now. */
console_unlock();
return -ENOSPC;
}
if (set_console(vt)) {
/*
* We're unable to switch to the SUSPEND_CONSOLE.
* Let the calling function know so it can decide
* what to do.
*/
console_unlock();
return -EIO;
}
console_unlock();
if (vt_waitactive(vt + 1)) {
pr_debug("Suspend: Can't switch VCs.");
return -EINTR;
}
return prev;
} | 0 |
wolfMQTT | 84d4b53122e0fa0280c7872350b89d5777dabbb2 | NOT_APPLICABLE | NOT_APPLICABLE | int SN_Client_WaitMessage_ex(MqttClient *client, SN_Object* packet_obj,
int timeout_ms)
{
return SN_Client_WaitType(client, packet_obj,
SN_MSG_TYPE_ANY, 0, timeout_ms);
} | 0 |
linux | 054aa8d439b9185d4f5eb9a90282d1ce74772969 | NOT_APPLICABLE | NOT_APPLICABLE | int f_dupfd(unsigned int from, struct file *file, unsigned flags)
{
unsigned long nofile = rlimit(RLIMIT_NOFILE);
int err;
if (from >= nofile)
return -EINVAL;
err = alloc_fd(from, nofile, flags);
if (err >= 0) {
get_file(file);
fd_install(err, file);
}
return err;
} | 0 |
Chrome | a6e146b4a369b31afa4c4323cc813dcbe0ef0c2b | NOT_APPLICABLE | NOT_APPLICABLE | HttpBridge::URLFetchState::URLFetchState() : url_poster(NULL),
aborted(false),
request_completed(false),
request_succeeded(false),
http_response_code(-1),
os_error_code(-1) {}
| 0 |
linux | 9bbfceea12a8f145097a27d7c7267af25893c060 | NOT_APPLICABLE | NOT_APPLICABLE | static int dwc3_pci_resume(struct device *dev)
{
struct dwc3_pci *dwc = dev_get_drvdata(dev);
return dwc3_pci_dsm(dwc, PCI_INTEL_BXT_STATE_D0);
} | 0 |
glewlwyd | 125281f1c0d4b6a8b49f7e55a757205a2ef01fbe | NOT_APPLICABLE | NOT_APPLICABLE | int callback_glewlwyd_delete_user_auth_scheme_module (const struct _u_request * request, struct _u_response * response, void * user_auth_scheme_data) {
struct config_elements * config = (struct config_elements *)user_auth_scheme_data;
json_t * j_search_module;
j_search_module = get_user_auth_scheme_module(config, u_map_get(request->map_url, "name"));
if (check_result_value(j_search_module, G_OK)) {
if (delete_user_auth_scheme_module(config, u_map_get(request->map_url, "name")) != G_OK) {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_user_auth_scheme_module - Error delete_user_auth_scheme_module");
response->status = 500;
} else {
y_log_message(Y_LOG_LEVEL_INFO, "Event - User auth scheme module '%s' removed", u_map_get(request->map_url, "name"));
}
} else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) {
response->status = 404;
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_user_auth_scheme_module - Error get_user_auth_scheme_module");
response->status = 500;
}
json_decref(j_search_module);
return U_CALLBACK_CONTINUE;
} | 0 |
weechat | f105c6f0b56fb5687b2d2aedf37cb1d1b434d556 | NOT_APPLICABLE | NOT_APPLICABLE | logger_day_changed_signal_cb (const void *pointer, void *data,
const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
logger_adjust_log_filenames ();
return WEECHAT_RC_OK;
}
| 0 |
passenger | 4043718264095cde6623c2cbe8c644541036d7bf | NOT_APPLICABLE | NOT_APPLICABLE | bool shouldLoadShellEnvvars(const Options &options, const SpawnPreparationInfo &preparation) const {
if (options.loadShellEnvvars) {
string shellName = extractBaseName(preparation.userSwitching.shell);
bool retVal = shellName == "bash" || shellName == "zsh" || shellName == "ksh";
P_DEBUG("shellName = '" << shellName << "' in [bash,zsh,ksh]: " << (retVal ? "true" : "false"));
return retVal;
} else {
P_DEBUG("options.loadShellEnvvars = false");
return false;
}
} | 0 |
linux | f63a8daa5812afef4f06c962351687e1ff9ccb2b | NOT_APPLICABLE | NOT_APPLICABLE | static inline void perf_detach_cgroup(struct perf_event *event)
{
css_put(&event->cgrp->css);
event->cgrp = NULL;
}
| 0 |
linux | 1f1ea6c2d9d8c0be9ec56454b05315273b5de8ce | NOT_APPLICABLE | NOT_APPLICABLE | static int decode_attr_mdsthreshold(struct xdr_stream *xdr,
uint32_t *bitmap,
struct nfs4_threshold *res)
{
__be32 *p;
int status = 0;
uint32_t num;
if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U)))
return -EIO;
if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) {
/* Did the server return an unrequested attribute? */
if (unlikely(res == NULL))
return -EREMOTEIO;
p = xdr_inline_decode(xdr, 4);
if (unlikely(!p))
goto out_overflow;
num = be32_to_cpup(p);
if (num == 0)
return 0;
if (num > 1)
printk(KERN_INFO "%s: Warning: Multiple pNFS layout "
"drivers per filesystem not supported\n",
__func__);
status = decode_first_threshold_item4(xdr, res);
bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD;
}
return status;
out_overflow:
print_overflow_msg(__func__, xdr);
return -EIO;
} | 0 |
libgit2 | 58a6fe94cb851f71214dbefac3f9bffee437d6fe | NOT_APPLICABLE | NOT_APPLICABLE | int git_index_remove_directory(git_index *index, const char *dir, int stage)
{
git_buf pfx = GIT_BUF_INIT;
int error = 0;
size_t pos;
git_index_entry *entry;
if (!(error = git_buf_sets(&pfx, dir)) &&
!(error = git_path_to_dir(&pfx)))
index_find(&pos, index, pfx.ptr, pfx.size, GIT_INDEX_STAGE_ANY);
while (!error) {
entry = git_vector_get(&index->entries, pos);
if (!entry || git__prefixcmp(entry->path, pfx.ptr) != 0)
break;
if (GIT_IDXENTRY_STAGE(entry) != stage) {
++pos;
continue;
}
error = index_remove_entry(index, pos);
/* removed entry at 'pos' so we don't need to increment */
}
git_buf_free(&pfx);
return error;
}
| 0 |
linux | d4fdf8ba0e5808ba9ad6b44337783bd9935e0982 | NOT_APPLICABLE | NOT_APPLICABLE | static void __next_free_blkoff(struct f2fs_sb_info *sbi,
struct curseg_info *seg, block_t start)
{
struct seg_entry *se = get_seg_entry(sbi, seg->segno);
int entries = SIT_VBLOCK_MAP_SIZE / sizeof(unsigned long);
unsigned long *target_map = SIT_I(sbi)->tmp_map;
unsigned long *ckpt_map = (unsigned long *)se->ckpt_valid_map;
unsigned long *cur_map = (unsigned long *)se->cur_valid_map;
int i, pos;
for (i = 0; i < entries; i++)
target_map[i] = ckpt_map[i] | cur_map[i];
pos = __find_rev_next_zero_bit(target_map, sbi->blocks_per_seg, start);
seg->next_blkoff = pos;
}
| 0 |
Chrome | aa1a102f73565feeb1d121d0d6c9524bebcdd75f | NOT_APPLICABLE | NOT_APPLICABLE | Stream* XMLHttpRequest::responseStream()
{
ASSERT(m_responseTypeCode == ResponseTypeStream);
if (m_error || (m_state != LOADING && m_state != DONE))
return 0;
return m_responseStream.get();
}
| 0 |
gst-plugins-base | 2fdccfd64fc609e44e9c4b8eed5bfdc0ab9c9095 | NOT_APPLICABLE | NOT_APPLICABLE | ac3_type_find (GstTypeFind * tf, gpointer unused)
{
DataScanCtx c = { 0, NULL, 0 };
/* Search for an ac3 frame; not necessarily right at the start, but give it
* a lower probability if not found right at the start. Check that the
* frame is followed by a second frame at the expected offset.
* We could also check the two ac3 CRCs, but we don't do that right now */
while (c.offset < 1024) {
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 5)))
break;
if (c.data[0] == 0x0b && c.data[1] == 0x77) {
guint bsid = c.data[5] >> 3;
if (bsid <= 8) {
/* ac3 */
guint fscod = c.data[4] >> 6;
guint frmsizecod = c.data[4] & 0x3f;
if (fscod < 3 && frmsizecod < 38) {
DataScanCtx c_next = c;
guint frame_size;
frame_size = ac3_frmsizecod_tbl[frmsizecod].frm_size[fscod];
GST_LOG ("possible AC3 frame sync at offset %"
G_GUINT64_FORMAT ", size=%u", c.offset, frame_size);
if (data_scan_ctx_ensure_data (tf, &c_next, (frame_size * 2) + 5)) {
data_scan_ctx_advance (tf, &c_next, frame_size * 2);
if (c_next.data[0] == 0x0b && c_next.data[1] == 0x77) {
fscod = c_next.data[4] >> 6;
frmsizecod = c_next.data[4] & 0x3f;
if (fscod < 3 && frmsizecod < 38) {
GstTypeFindProbability prob;
GST_LOG ("found second AC3 frame (size=%u), looks good",
ac3_frmsizecod_tbl[frmsizecod].frm_size[fscod]);
if (c.offset == 0)
prob = GST_TYPE_FIND_MAXIMUM;
else
prob = GST_TYPE_FIND_NEARLY_CERTAIN;
gst_type_find_suggest (tf, prob, AC3_CAPS);
return;
}
} else {
GST_LOG ("no second AC3 frame found, false sync");
}
}
}
} else if (bsid <= 16 && bsid > 10) {
/* eac3 */
DataScanCtx c_next = c;
guint frame_size;
frame_size = (((c.data[2] & 0x07) << 8) + c.data[3]) + 1;
GST_LOG ("possible E-AC3 frame sync at offset %"
G_GUINT64_FORMAT ", size=%u", c.offset, frame_size);
if (data_scan_ctx_ensure_data (tf, &c_next, (frame_size * 2) + 5)) {
data_scan_ctx_advance (tf, &c_next, frame_size * 2);
if (c_next.data[0] == 0x0b && c_next.data[1] == 0x77) {
GstTypeFindProbability prob;
GST_LOG ("found second E-AC3 frame, looks good");
if (c.offset == 0)
prob = GST_TYPE_FIND_MAXIMUM;
else
prob = GST_TYPE_FIND_NEARLY_CERTAIN;
gst_type_find_suggest (tf, prob, EAC3_CAPS);
return;
} else {
GST_LOG ("no second E-AC3 frame found, false sync");
}
}
} else {
GST_LOG ("invalid AC3 BSID: %u", bsid);
}
}
data_scan_ctx_advance (tf, &c, 1);
}
} | 0 |
memcached | d67cfbf9922f7f4be6ee7315b0877c796b182e7d | NOT_APPLICABLE | NOT_APPLICABLE | static uint64_t lru_total_bumps_dropped(void) {
uint64_t total = 0;
lru_bump_buf *b;
pthread_mutex_lock(&bump_buf_lock);
for (b = bump_buf_head; b != NULL; b=b->next) {
pthread_mutex_lock(&b->mutex);
total += b->dropped;
pthread_mutex_unlock(&b->mutex);
}
pthread_mutex_unlock(&bump_buf_lock);
return total;
} | 0 |
gpac | a51f951b878c2b73c1d8e2f1518c7cdc5fb82c3f | NOT_APPLICABLE | NOT_APPLICABLE | u32 parse_gendoc(char *name, u32 opt)
{
u32 i=0;
//gen MD
if (!opt) {
help_flags = GF_PRINTARG_MD | GF_PRINTARG_IS_APP;
helpout = gf_fopen("mp4box-gen-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » General");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
fprintf(helpout, "# Syntax\n");
gf_sys_format_help(helpout, help_flags, "MP4Box [option] input [option] [other_dash_inputs]\n"
" \n"
);
PrintGeneralUsage();
PrintEncryptUsage();
fprintf(helpout, "# Help Options\n");
while (m4b_usage_args[i].name) {
GF_GPACArg *g_arg = (GF_GPACArg *) &m4b_usage_args[i];
i++;
gf_sys_print_arg(helpout, help_flags, g_arg, "mp4box-general");
}
gf_fclose(helpout);
helpout = gf_fopen("mp4box-import-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » Media Import");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
PrintImportUsage();
gf_fclose(helpout);
helpout = gf_fopen("mp4box-dash-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » Media DASH");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
PrintDASHUsage();
gf_fclose(helpout);
helpout = gf_fopen("mp4box-dump-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » Media Dump and Export");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
PrintExtractUsage();
PrintDumpUsage();
PrintSplitUsage();
gf_fclose(helpout);
helpout = gf_fopen("mp4box-meta-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » Meta and HEIF/IFF");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
PrintMetaUsage();
gf_fclose(helpout);
helpout = gf_fopen("mp4box-scene-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » Scene Description");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
PrintEncodeUsage();
#if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
PrintLiveUsage();
#endif
PrintSWFUsage();
gf_fclose(helpout);
helpout = gf_fopen("mp4box-other-opts.md", "w");
fprintf(helpout, "[**HOME**](Home) » [**MP4Box**](MP4Box) » Other Features");
fprintf(helpout, "<!-- automatically generated - do not edit, patch gpac/applications/mp4box/main.c -->\n");
PrintHintUsage();
PrintTags();
gf_fclose(helpout);
}
//gen man
else {
help_flags = GF_PRINTARG_MAN;
helpout = gf_fopen("mp4box.1", "w");
fprintf(helpout, ".TH MP4Box 1 2019 MP4Box GPAC\n");
fprintf(helpout, ".\n.SH NAME\n.LP\nMP4Box \\- GPAC command-line media packager\n.SH SYNOPSIS\n.LP\n.B MP4Box\n.RI [options] \\ [file] \\ [options]\n.br\n.\n");
PrintGeneralUsage();
PrintExtractUsage();
PrintDASHUsage();
PrintSplitUsage();
PrintDumpUsage();
PrintImportUsage();
PrintHintUsage();
PrintEncodeUsage();
PrintEncryptUsage();
PrintMetaUsage();
PrintSWFUsage();
PrintTags();
#if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
PrintLiveUsage();
#endif
fprintf(helpout, ".SH EXAMPLES\n.TP\nBasic and advanced examples are available at https://wiki.gpac.io/MP4Box\n");
fprintf(helpout, ".SH MORE\n.LP\nAuthors: GPAC developers, see git repo history (-log)\n"
".br\nFor bug reports, feature requests, more information and source code, visit https://github.com/gpac/gpac\n"
".br\nbuild: %s\n"
".br\nCopyright: %s\n.br\n"
".SH SEE ALSO\n"
".LP\ngpac(1), MP4Client(1)\n", gf_gpac_version(), gf_gpac_copyright());
gf_fclose(helpout);
}
return 1;
} | 0 |
FFmpeg | 2a05c8f813de6f2278827734bf8102291e7484aa | NOT_APPLICABLE | NOT_APPLICABLE | static int http_buf_read_compressed(URLContext *h, uint8_t *buf, int size)
{
HTTPContext *s = h->priv_data;
int ret;
if (!s->inflate_buffer) {
s->inflate_buffer = av_malloc(DECOMPRESS_BUF_SIZE);
if (!s->inflate_buffer)
return AVERROR(ENOMEM);
}
if (s->inflate_stream.avail_in == 0) {
int read = http_buf_read(h, s->inflate_buffer, DECOMPRESS_BUF_SIZE);
if (read <= 0)
return read;
s->inflate_stream.next_in = s->inflate_buffer;
s->inflate_stream.avail_in = read;
}
s->inflate_stream.avail_out = size;
s->inflate_stream.next_out = buf;
ret = inflate(&s->inflate_stream, Z_SYNC_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END)
av_log(h, AV_LOG_WARNING, "inflate return value: %d, %s\n",
ret, s->inflate_stream.msg);
return size - s->inflate_stream.avail_out;
}
| 0 |
linux | cadfad870154e14f745ec845708bc17d166065f2 | NOT_APPLICABLE | NOT_APPLICABLE | static void xen_machine_halt(void)
{
xen_reboot(SHUTDOWN_poweroff);
} | 0 |
Subsets and Splits