target
int64 0
1
| func
stringlengths 0
484k
| idx
int64 1
378k
|
---|---|---|
1 | static int xan_huffman_decode(unsigned char *dest, const unsigned char *src, int dest_len) { unsigned char byte = *src++; unsigned char ival = byte + 0x16; const unsigned char * ptr = src + byte*2; unsigned char val = ival; unsigned char *dest_end = dest + dest_len; GetBitContext gb; init_get_bits(&gb, ptr, 0); // FIXME: no src size available while ( val != 0x16 ) { val = src[val - 0x17 + get_bits1(&gb) * byte]; if ( val < 0x16 ) { if (dest + 1 > dest_end) return 0; *dest++ = val; val = ival; } } return 0; } | 496 |
0 | int IniParser::write()
{
int bugs = 0;
if (!inifile.isDirty())
{
y2debug ("File %s did not change. Not saving.", multiple_files ? files[0].c_str () : file.c_str ());
return 0;
}
if (read_only)
{
y2debug ("Attempt to write file %s that was mounted read-only. Not saving.", multiple_files ? files[0].c_str () : file.c_str ());
return 0;
}
UpdateIfModif ();
if (multiple_files)
{
IniIterator
ci = inifile.getContainerBegin (),
ce = inifile.getContainerEnd ();
for (;ci != ce; ++ci)
{
if (ci->t () == SECTION)
{
IniSection&s = ci->s ();
int wb = s.getRewriteBy (); // bug #19066
string filename = getFileName (s.getName (), wb);
// This is the only place where we unmark a
// section for deletion - when it is a file
// that got some data again. We can do it
// because we only erase the files afterwards.
deleted_sections.erase (filename);
if (!s.isDirty ()) {
y2debug ("Skipping file %s that was not changed.", filename.c_str());
continue;
}
s.initReadBy ();
bugs += write_file(filename, s);
}
else
{
y2error ("Value %s encountered at multifile top level",
ci->e ().getName ());
}
}
// FIXME: update time stamps of files...
// erase removed files...
for (set<string>::iterator i = deleted_sections.begin (); i!=deleted_sections.end();i++)
if (multi_files.find (*i) != multi_files.end ()) {
y2debug ("Removing file %s\n", (*i).c_str());
unlink ((*i).c_str());
}
}
else
{
bugs += write_file(file, inifile);
timestamp = getTimeStamp ();
}
return bugs ? -1 : 0;
} | 497 |
1 | static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const char *base, int baselen, struct diff_options *opt)
{
unsigned mode1, mode2;
const char *path1, *path2;
const unsigned char *sha1, *sha2;
int cmp, pathlen1, pathlen2;
sha1 = tree_entry_extract(t1, &path1, &mode1);
sha2 = tree_entry_extract(t2, &path2, &mode2);
pathlen1 = tree_entry_len(path1, sha1);
pathlen2 = tree_entry_len(path2, sha2);
cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
if (cmp < 0) {
show_entry(opt, "-", t1, base, baselen);
return -1;
}
if (cmp > 0) {
show_entry(opt, "+", t2, base, baselen);
return 1;
}
if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
return 0;
/*
* If the filemode has changed to/from a directory from/to a regular
* file, we need to consider it a remove and an add.
*/
if (S_ISDIR(mode1) != S_ISDIR(mode2)) {
show_entry(opt, "-", t1, base, baselen);
show_entry(opt, "+", t2, base, baselen);
return 0;
}
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
int retval;
char *newbase = malloc_base(base, baselen, path1, pathlen1);
if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))
opt->change(opt, mode1, mode2,
sha1, sha2, base, path1);
retval = diff_tree_sha1(sha1, sha2, newbase, opt);
free(newbase);
return retval;
}
opt->change(opt, mode1, mode2, sha1, sha2, base, path1);
return 0;
} | 498 |
1 | static int kvm_log_stop(CPUPhysMemoryClient *client, target_phys_addr_t phys_addr, ram_addr_t size) { return kvm_dirty_pages_log_change(phys_addr, size, false); } | 499 |
0 | inline GRANT_COLUMN * column_hash_search ( GRANT_TABLE * t , const char * cname , uint length ) {
return ( GRANT_COLUMN * ) hash_search ( & t -> hash_columns , ( uchar * ) cname , length ) ;
} | 500 |
1 | static void diff_index_show_file(struct rev_info *revs,
const char *prefix,
struct cache_entry *ce,
const unsigned char *sha1, unsigned int mode)
{
diff_addremove(&revs->diffopt, prefix[0], mode,
sha1, ce->name, NULL);
} | 501 |
0 | void mainwindow_destroy ( MAIN_WINDOW_REC * window ) {
g_return_if_fail ( window != NULL ) ;
mainwindows = g_slist_remove ( mainwindows , window ) ;
signal_emit ( "mainwindow destroyed" , 1 , window ) ;
term_window_destroy ( window -> screen_win ) ;
if ( mainwindows != NULL ) {
gui_windows_remove_parent ( window ) ;
if ( ! quitting ) {
mainwindows_add_space ( window ) ;
mainwindows_redraw ( ) ;
}
}
g_free ( window ) ;
if ( active_mainwin == window ) active_mainwin = NULL ;
} | 502 |
1 | spnego_gss_wrap_aead(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
gss_buffer_t input_assoc_buffer,
gss_buffer_t input_payload_buffer,
int *conf_state,
gss_buffer_t output_message_buffer)
{
OM_uint32 ret;
ret = gss_wrap_aead(minor_status,
context_handle,
conf_req_flag,
qop_req,
input_assoc_buffer,
input_payload_buffer,
conf_state,
output_message_buffer);
return (ret);
} | 504 |
0 | int IniParser::write_file(const string & filename, IniSection & section)
{
// ensure that the directories exist
Pathname pn(filename);
PathInfo::assert_dir (pn.dirname ());
mode_t file_umask = section.isPrivate()? 0077: 0022;
mode_t orig_umask = umask(file_umask);
// rewriting an existing file wouldnt change its mode
unlink(filename.c_str());
ofstream of(filename.c_str());
if (!of.good()) {
y2error ("Can not open file %s for write", filename.c_str());
return -1;
}
write_helper (section, of, 0);
of.close();
umask(orig_umask);
return 0;
} | 505 |
1 | void diff_addremove(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
const char *base, const char *path)
{
char concatpath[PATH_MAX];
struct diff_filespec *one, *two;
if (DIFF_OPT_TST(options, IGNORE_SUBMODULES) && S_ISGITLINK(mode))
return;
/* This may look odd, but it is a preparation for
* feeding "there are unchanged files which should
* not produce diffs, but when you are doing copy
* detection you would need them, so here they are"
* entries to the diff-core. They will be prefixed
* with something like '=' or '*' (I haven't decided
* which but should not make any difference).
* Feeding the same new and old to diff_change()
* also has the same effect.
* Before the final output happens, they are pruned after
* merged into rename/copy pairs as appropriate.
*/
if (DIFF_OPT_TST(options, REVERSE_DIFF))
addremove = (addremove == '+' ? '-' :
addremove == '-' ? '+' : addremove);
if (!path) path = "";
sprintf(concatpath, "%s%s", base, path);
if (options->prefix &&
strncmp(concatpath, options->prefix, options->prefix_length))
return;
one = alloc_filespec(concatpath);
two = alloc_filespec(concatpath);
if (addremove != '+')
fill_filespec(one, sha1, mode);
if (addremove != '-')
fill_filespec(two, sha1, mode);
diff_queue(&diff_queued_diff, one, two);
DIFF_OPT_SET(options, HAS_CHANGES);
} | 506 |
1 | static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) { BDRVBlkdebugState *s = bs->opaque; QDict *opts; const QDictEntry *e; bool force_json = false; for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "config") && strcmp(qdict_entry_key(e), "x-image")) { force_json = true; break; } } if (force_json && !bs->file->bs->full_open_options) { /* The config file cannot be recreated, so creating a plain filename * is impossible */ return; } if (!force_json && bs->file->bs->exact_filename[0]) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkdebug:%s:%s", s->config_file ?: "", bs->file->bs->exact_filename); } opts = qdict_new(); qdict_put_str(opts, "driver", "blkdebug"); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "image", bs->file->bs->full_open_options); for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "x-image")) { qobject_incref(qdict_entry_value(e)); qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e)); } } bs->full_open_options = opts; } | 507 |
0 | rfbBool rfbFilenameTranslate2UNIX ( rfbClientPtr cl , char * path , char * unixPath , size_t unixPathMaxLen ) {
int x ;
char * home = NULL ;
FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN ( "" , cl , FALSE ) ;
if ( strlen ( path ) >= unixPathMaxLen ) return FALSE ;
if ( path [ 0 ] == 'C' && path [ 1 ] == ':' ) strcpy ( unixPath , & path [ 2 ] ) ;
else {
home = getenv ( "HOME" ) ;
if ( home != NULL ) {
if ( ( strlen ( path ) + strlen ( home ) + 1 ) >= unixPathMaxLen ) return FALSE ;
strcpy ( unixPath , home ) ;
strcat ( unixPath , "/" ) ;
strcat ( unixPath , path ) ;
}
else strcpy ( unixPath , path ) ;
}
for ( x = 0 ;
x < strlen ( unixPath ) ;
x ++ ) if ( unixPath [ x ] == '\\' ) unixPath [ x ] = '/' ;
return TRUE ;
} | 508 |
1 | SystemAgent::Execute (const YCPPath& path, const YCPValue& value,
const YCPValue& arg)
{
y2debug ("Execute (%s)", path->toString().c_str());
if (path->isRoot ())
{
return YCPError ("Execute () called without sub-path");
}
if (value.isNull ())
{
return YCPError (string("Execute (")+path->toString()+") without argument.");
}
const string cmd = path->component_str (0); // just a shortcut
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// .bash*
if (cmd == "bash"
|| cmd == "bash_output"
|| cmd == "bash_background")
{
YCPValue environment = YCPVoid();
if (!arg.isNull())
environment = arg;
/**
* @builtin Execute (.target.bash, string command, map environment) -> integer
* @builtin Execute (.target.bash_background, string command, map environment) -> integer
* @builtin Execute (.target.bash_output, string command, map environment) -> map
*
* Runs a bash command. The command is stated as string.
* The map variables can be used to give initial environment
* definitions to the target. The keys have to be strings,
* the values can be of any type. If you use string values,
* the strings may _not_ contain single quotes. Escape them
* with double backqoute, if you need them. This is subject
* to change.
*
* The return value will be either an integer with the exitcode of
* the shell script or a map:<pre>
* $[
* <dd> "exit" : <integer>, //exitcode from shell script
* <dd> "stdout" : <string>, //stdout of the command
* <dd> "stderr" : <string> //stderr of the command
* ]</pre>
*
* @example Execute (.target.bash, "/bin/touch $FILE ; exit 5", $["FILE":"/somedir/somefile"]) -> 5
* @example Execute (.target.bash_output, "/bin/touch $FILE ; exit 5", $["FILE":"/somedir/somefile"]) -> $[ "exit" : 5, "stdout" : "", "stderr" : ""]
*
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad command argument to Execute (.bash, string command [, map env])");
}
/* shell command must have rooted path */
string bashcommand = value->asString()->value();
#if 0
if (bashcommand[0] != '/')
{
ycp2warning ("", 0, "Execute (.bash, ...) without full path !");
}
#endif
/* check for and construct shell enviroment */
YCPMap variables;
if (environment->isMap())
{
variables = environment->asMap();
}
string exports = "";
for (YCPMap::const_iterator pos = variables->begin(); pos != variables->end(); ++pos)
{
const YCPValue& key = pos->first;
const YCPValue& value = pos->second;
if (!key->isString())
{
return YCPError (string("Invalid value '")
+ key->toString()
+ "' for target variable name, which must be a string");
}
exports += "export " + key->asString()->value() + "='";
string valstr;
if (value->isString())
{
valstr = value->asString()->value();
}
else
{
valstr = value->toString();
}
exports += valstr + "'\n";
}
/* execute script and return YCP{Integer|Map} */
if (cmd == "bash")
{
return YCPInteger (shellcommand (exports + bashcommand));
}
else if (cmd == "bash_output")
{
return shellcommand_output (exports + bashcommand, tempdir);
}
else if (cmd == "bash_background")
{
return YCPInteger (shellcommand_background (exports + bashcommand));
}
} // .bash*
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "bash_input")
{
/**
* @builtin Execute (.target.bash_input, string command, string input) -> integer
*
* Note: Function has only one used within YaST2 and is subject to
* sudden change or removal.
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad command argument to Execute (.bash_input, string "
"command, string stdin");
}
if (arg.isNull() || !arg->isString())
{
return YCPError ("Bad command argument to Execute (.bash_input, string "
"command, string stdin");
}
string command = value->asString ()->value ();
command += ">/dev/null 2>&1";
string input = arg->asString ()->value ();
input += "\n";
FILE* p = popen (command.c_str (), "w");
if (!p)
{
return YCPError ("popen failed");
}
fwrite (input.c_str (), input.length (), 1, p);
int ret = pclose (p);
if (WIFEXITED (ret))
return YCPInteger (WEXITSTATUS (ret));
return YCPInteger (WTERMSIG (ret) + 128);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "symlink")
{
/**
* @builtin Execute (.target.symlink, string oldpath, string newpath) -> boolean
*
* Creates a symbolic link named newpath which contains the
* string oldpath.
*
* Symbolic links are interpreted at run-time as if the con
* tents of the link had been substituted into the path being
* followed to find a file or directory.
*
* The return value is true or false, depending of the success.
*
* @example Execute (.target.symlink, "/lib/YaST2", "Y2")
*/
if (value.isNull () || arg.isNull () || !value->isString () ||
!arg->isString ())
{
return YCPError ("Bad arguments to Execute (.symlink, string old, string new)");
}
const char *oldpath = value->asString()->value_cstr();
const string newpath = arg->asString()->value();
y2milestone ("symlink %s -> %s", oldpath, newpath.c_str());
remove (newpath.c_str());
return YCPBoolean (symlink (oldpath, newpath.c_str()) == 0);
} // .symlink
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "mkdir")
{
/**
* @builtin Execute (.target.mkdir, string path <, integer mode>)) -> boolean
*
* Creates a directory and all its parents, if necessary.
* All created elements will have mode 0755 if mode is omitted.
*
* The return value is true or false, depending of the success, ie if
* the directory exists afterwards.
*
* @example Execute (.target.mkdir, "/var/adm/mount")
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad path argument to Execute (.mkdir, string path)");
}
string path = value->asString()->value();
int mode = 0755;
if (!arg.isNull())
{
if (arg->isInteger())
{
mode = arg->asInteger()->value();
}
else
{
return YCPError ("Bad mode argument to Execute (.mkdir, string path, integer mode)");
}
}
size_t pos = 0;
y2milestone ("mkdir %s", path.c_str());
// Create leading components
while (pos = path.find('/', pos + 1), pos != string::npos)
{
mkdir (path.substr(0, pos).c_str(), mode);
}
// Create the last part
mkdir (path.substr(0, pos).c_str(), mode);
struct stat sb;
return YCPBoolean(stat(path.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "mount")
{
/**
* @builtin Execute (.target.mount, [ string device, string mountpoint <, string logfile>], [, string options])) -> boolean
*
* Mounts a (block) device at a mountpoint.
* If logfile is given, the stderr of the mount cmd will be appended to
* this file
*
* The return value is true or false, depending of the success
*
* @example Execute (.target.mount, ["/dev/fd0", "/floppy"], "-t msdos")
* @example Execute (.target.mount, ["/dev/fd0", "/floppy", "/var/log/y2mountlog"], "-t msdos")
*/
if (value.isNull() || !value->isList())
{
return YCPError ("Bad path argument to Execute (.mount, [ string device, string mountpoint <, string y2mountlog> ])");
}
YCPList mountlist = value->asList();
if (mountlist->size() < 2
|| !mountlist->value(0)->isString()
|| !mountlist->value(1)->isString())
{
return YCPError ("Bad list values in argument to Execute (.mount, [ string device, string mountpoint ])");
}
string mountcmd = "/bin/mount ";
// arg is mount options, this is optional
if (!arg.isNull())
{
if (arg->isString())
{
mountcmd += arg->asString()->value() + " ";
}
else
{
return YCPError ("Bad type of mode argument to Execute (.mount, string|list path, string mode)", YCPBoolean (false));
}
}
// device
mountcmd += mountlist->value(0)->asString()->value() + " ";
// mountpoint
mountcmd += mountlist->value(1)->asString()->value();
if (mountlist->size() == 3)
{
if (mountlist->value(2)->isString())
{
mountcmd += " 2> " + mountlist->value(2)->asString()->value();
}
else
{
return YCPError ("Bad logfile argument to Execute (.mount, [ string device, string mountpoint, string logfile ])", YCPBoolean (false));
}
}
return YCPBoolean (shellcommand (mountcmd) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "smbmount")
{
/**
* @builtin Execute (.target.smbmount, [ string server_and_dir, string mountpoint <, string logfile>], [, string options])) -> boolean
*
* Mounts a SMB share at a mountpoint.
* if logfile is given, the stderr of the mount cmd will be appended to
* this file
*
* The return value is true or false, depending of the success
*
* @example Execute (.target.smbmount, ["//windows/crap", "/crap"], "-o guest")
* @example Execute (.target.smbmount, ["//smb/share", "/smbshare", "/var/log/y2mountlog"])
*/
if (value.isNull() || !value->isList())
{
return YCPError ("Bad share argument to Execute (.smbmount, [ string share, string mountpoint <, string y2mountlog> ])");
}
YCPList mountlist = value->asList();
if (mountlist->size() < 2
|| !mountlist->value(0)->isString()
|| !mountlist->value(1)->isString())
{
return YCPError ("Bad list values in argument to Execute (.smbmount, [ string share, string mountpoint ])");
}
string mountcmd = "/usr/bin/smbmount ";
if (!arg.isNull() && arg->isString())
{
mountcmd += arg->asString()->value() + " ";
}
else
{
return YCPError ("Bad mode argument to Execute (.smbmount, string path, integer mode)");
}
// share
mountcmd += mountlist->value(0)->asString()->value() + " ";
// mountpoint
mountcmd += mountlist->value(1)->asString()->value();
// logfile
if (mountlist->size() == 3)
{
if (mountlist->value(2)->isString())
{
mountcmd += " 2> " + mountlist->value(2)->asString()->value();
}
else
{
return YCPError ("Bad logfile argument to Execute (.smbmount, [ string device, string mountpoint, string logfile ])");
}
}
return YCPBoolean (shellcommand (mountcmd) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "umount")
{
/**
* @builtin Execute (.target.umount, string mountpoint) -> boolean
* Unmounts a (block) device at a mountpoint.
*
* The return value is true or false, depending of the success.
*
* @example Execute (.target.umount, "/floppy")
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad mountpoint in Execute (.umount, string mountpoint)");
}
string umountcmd = "/bin/umount " + value->asString()->value();
return YCPBoolean (shellcommand (umountcmd) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "remove")
{
/**
* @builtin Execute (.target.remove, string file) -> boolean
* Remove a file.
*
* The return value is true or false depending on the success.
*
* @example Execute (.target.remove, "/tmp/xyz")
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad file in Execute (.remove, string file)");
}
int ret = unlink (value->asString ()->value_cstr ());
return YCPBoolean (ret == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "insmod")
{
/**
* @builtin Execute (.target.insmod, string module, string options) -> boolean
* Load module in target system.
*
* The return value is true or false, depending of the success.
*
* @example Execute (.target.insmod, "a_module", "an option")
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad source in Execute (.insmod, string module, string options)");
}
string insmodcmd = "/sbin/insmod " + value->asString()->value();
if (!arg.isNull() && arg->isString())
{
insmodcmd += string (" ") + arg->asString()->value();
}
return YCPBoolean (shellcommand (insmodcmd) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "modprobe")
{
/**
* @builtin Execute (.target.modprobe, string module, string options) -> boolean
* Load module in target system.
*
* The return value is true or false, depending of the success.
*
* @example Execute (.target.modprobe, "a_module", "an option")
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad source in Execute (.modprobe, string module, string options)", YCPBoolean (false));
}
string modprobecmd = "/sbin/modprobe " + value->asString()->value();
if (!arg.isNull() && arg->isString())
{
modprobecmd += string (" ") + arg->asString()->value();
}
return YCPBoolean (shellcommand (modprobecmd) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "kill") {
/**
* @builtin Execute(.target.kill, integer pid [, integer signal]) -> boolean
* Kill process with signal (SIGTERM if not specified).
*
* The return value is true or false, depending of the success.
*
* @example Execute (.target.kill, 1, 9)
*/
if (value.isNull() || !value->isInteger())
return YCPError("Bad PID in Execute (.kill, integer pid, integer signal)", YCPBoolean(false));
int signal = 15;
int pid = value->asInteger()->value();
if (!arg.isNull() && arg->isInteger())
signal = arg->asInteger()->value();
return YCPBoolean (kill(pid,signal) != -1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
else if (cmd == "control")
{
if (path->length()<2)
return YCPError(string("Undefined subpath for Execute (.control."));
if (path->component_str(1) == "printer_reset")
{
/**
* @builtin Execute (.target.control.printer_reset, string device) -> boolean
* Reset the given printer (trigger ioctl)
*
* The return value is true or false, depending of the success
*
*/
if (value.isNull() || !value->isString())
{
return YCPError ("Bad filename in Execute (.control.printer_reset, string device");
}
string device = value->asString()->value();
int fd = open(device.c_str(), O_RDWR);
if (fd < 0)
{
return YCPError (string("Open failed: \"" + device + "\" " + string(strerror(errno)?:"")));
}
int ret = ioctl(fd, LPRESET, NULL);
close(fd);
return YCPBoolean (ret == 0);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
return YCPError (string("Undefined subpath for Execute (") + path->toString() + ")");
} | 509 |
1 | static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo, USBPacket *p) { int len; if (likely(!fifo->len)) return USB_RET_STALL; len = MIN(p->len, fifo->fifo[fifo->start].len); memcpy(p->data, fifo->fifo[fifo->start].data, len); if (len == p->len) { fifo->fifo[fifo->start].len -= len; fifo->fifo[fifo->start].data += len; } else { fifo->start ++; fifo->start &= CFIFO_LEN_MASK; fifo->len --; } fifo->dstart += len; fifo->dlen -= len; if (fifo->dstart >= fifo->dsize) { fifo->dstart = 0; fifo->dsize = DFIFO_LEN_MASK + 1; } return len; } | 510 |
1 | static void show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc,
const char *base, int baselen)
{
unsigned mode;
const char *path;
const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {
enum object_type type;
int pathlen = tree_entry_len(path, sha1);
char *newbase = malloc_base(base, baselen, path, pathlen);
struct tree_desc inner;
void *tree;
unsigned long size;
tree = read_sha1_file(sha1, &type, &size);
if (!tree || type != OBJ_TREE)
die("corrupt tree sha %s", sha1_to_hex(sha1));
init_tree_desc(&inner, tree, size);
show_tree(opt, prefix, &inner, newbase, baselen + 1 + pathlen);
free(tree);
free(newbase);
} else {
opt->add_remove(opt, prefix[0], mode, sha1, base, path);
}
} | 511 |
1 | spnego_gss_wrap_iov(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
int *conf_state,
gss_iov_buffer_desc *iov,
int iov_count)
{
OM_uint32 ret;
ret = gss_wrap_iov(minor_status,
context_handle,
conf_req_flag,
qop_req,
conf_state,
iov,
iov_count);
return (ret);
} | 514 |
1 | sf_count_t psf_fwrite ( const void * ptr , sf_count_t bytes , sf_count_t items , SF_PRIVATE * psf ) {
sf_count_t total = 0 ;
ssize_t count ;
if ( psf -> virtual_io ) return psf -> vio . write ( ptr , bytes * items , psf -> vio_user_data ) / bytes ;
items *= bytes ;
if ( items <= 0 ) return 0 ;
while ( items > 0 ) {
count = ( items > SENSIBLE_SIZE ) ? SENSIBLE_SIZE : items ;
count = write ( psf -> file . filedes , ( ( const char * ) ptr ) + total , count ) ;
if ( count == - 1 ) {
if ( errno == EINTR ) continue ;
psf_log_syserr ( psf , errno ) ;
break ;
}
;
if ( count == 0 ) break ;
total += count ;
items -= count ;
}
;
if ( psf -> is_pipe ) psf -> pipeoffset += total ;
return total / bytes ;
} | 515 |
0 | SystemAgent::Write (const YCPPath& path, const YCPValue& value,
const YCPValue& arg)
{
y2debug ("Write (%s)", path->toString().c_str());
if (path->isRoot())
{
ycp2error ("Write () called without sub-path");
return YCPBoolean (false);
}
const string cmd = path->component_str (0); // just a shortcut
if (cmd == "passwd")
{
/**
* @builtin Write (.target.passwd.<name>, string cryptval) -> bool
* .passwd can be used to set or modify the encrypted password
* of an already existing user in /etc/passwd and /etc/shadow.
*
* This call returns true on success and false, if it fails.
*
* @example Write (.target.passwd.root, crypt (a_passwd))
*/
if (path->length() != 2)
{
ycp2error ("Bad path argument in call to Write (.passwd.name)");
return YCPBoolean (false);
}
if (value.isNull() || !value->isString())
{
ycp2error ("Bad password argument in call to Write (.passwd)");
return YCPBoolean (false);
}
string passwd = value->asString()->value();
string bashcommand =
string ("/bin/echo '") +
path->component_str (1).c_str () + ":" + passwd +
"' |/usr/sbin/chpasswd -e >/dev/null 2>&1";
// Don't write the password into the log - even though it's crypted
// y2debug("Executing: '%s'", bashcommand.c_str());
int exitcode = system(bashcommand.c_str());
return YCPBoolean (WIFEXITED (exitcode) && WEXITSTATUS (exitcode) == 0);
}
else if (cmd == "string")
{
/**
* @builtin Write (.target.string, string filename, string value) -> boolean
* @builtin Write (.target.string, [string filename, integer filemode] , string value) -> boolean
* Writes the string <tt>value</tt> into a file. If the file already
* exists, the existing file is overwritten. The return value is
* true, if the file has been written successfully.
*
* @example Write(.target.string, "/etc/papersize", "a4") -> true
* @example Write(.target.string, ["/etc/rsyncd.secrets", 0600], "user:passwd") -> true
*/
if (value.isNull() || !(value->isString() || value->isList()))
{
ycp2error ("Bad filename arg for Write (.string ...)");
return YCPBoolean (false);
}
string filename;
mode_t filemode = 0644;
if (value->isString())
{
filename = value->asString()->value();
}
else
{ // value is list
YCPList flist = value->asList();
if ((flist->size() != 2)
|| (!flist->value(0)->isString())
|| (!flist->value(1)->isInteger()))
{
ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)",
cmd.c_str ());
return YCPBoolean (false);
}
filename = flist->value(0)->asString()->value();
filemode = (int)(flist->value(1)->asInteger()->value());
}
if (arg.isNull() || !arg->isString())
{
ycp2error ("Bad string value for Write (.string ...)");
return YCPBoolean (false);
}
int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, filemode);
if (fd >= 0)
{
string cont = arg->asString()->value();
const char *buffer = cont.c_str();
size_t length = cont.length();
size_t written = write(fd, buffer, length);
close(fd);
return YCPBoolean (written == length);
}
ycp2error ("Write (.string, \"%s\") failed: %s", filename.c_str (), strerror (errno));
return YCPBoolean(false);
}
else if (cmd == "byte")
{
/**
* @builtin Write (.target.byte, string filename, byteblock) -> boolean
* Write a byteblock into a file.
*/
if (value.isNull () || !value->isString ())
{
ycp2error ("Bad filename arg for Write (.byte, ...)");
return YCPBoolean (false);
}
if (arg.isNull () || !arg->isByteblock ())
{
ycp2error ("Bad value for Write (.byte, filename, byteblock)");
return YCPBoolean (false);
}
string filename = value->asString ()->value ();
YCPByteblock byteblock = arg->asByteblock ();
int fd = open (filename.c_str (), O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd >= 0)
{
size_t size = byteblock->size ();
size_t write_size = write (fd, byteblock->value (), size);
close (fd);
return YCPBoolean (write_size == size);
}
ycp2error ("Write (.byte, \"%s\") failed: %s", filename.c_str (), strerror (errno));
return YCPBoolean (false);
}
else if (cmd == "ycp" || cmd == "yast2")
{
/**
* @builtin Write (.target.ycp, string filename, any value) -> boolean
* Opens a file for writing and prints the value <tt>value</tt> in
* YCP syntax to that file. Returns true, if the file has
* been written, false otherwise. The newly created file gets
* the mode 0644 minus umask. Furthermore any missing directory in the
* pathname <tt>filename</tt> is created automatically.
*/
/**
* @builtin Write (.target.ycp, [ string filename, integer mode], any value) -> boolean
* Opens a file for writing and prints the value <tt>value</tt> in
* YCP syntax to that file. Returns true, if the file has
* been written, false otherwise. The newly created file gets
* the mode mode minus umask. Furthermore any missing directory in the
* pathname <tt>filename</tt> is created automatically.
*/
// either string or list
if (value.isNull() || !(value->isString() || value->isList()))
{
ycp2error ("Bad arguments to Write (%s, string filename ...)", cmd.c_str ());
return YCPBoolean (false);
}
string filename;
mode_t filemode = 0644;
if (value->isString())
{
filename = value->asString()->value();
}
else
{ // value is list
YCPList flist = value->asList();
if ((flist->size() != 2)
|| (!flist->value(0)->isString())
|| (!flist->value(1)->isInteger()))
{
ycp2error ("Bad [filename, mode] list in call to Write (%s, [ string filename, integer mode ], ...)",
cmd.c_str ());
return YCPBoolean (false);
}
filename = flist->value(0)->asString()->value();
filemode = (int)(flist->value(1)->asInteger()->value());
}
if (filename.length() == 0)
{
ycp2error ("Invalid empty filename in Write (%s, ...)", cmd.c_str ());
return YCPBoolean (false);
}
// Create directory, if missing
size_t pos = 0;
while (pos = filename.find('/', pos + 1), pos != string::npos)
mkdir (filename.substr(0, pos).c_str(), 0775);
// Remove file, if existing
remove (filename.c_str());
int fd = open (filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC , filemode);
bool success = false;
if (fd < 0)
{
ycp2error ("Error opening '%s': %s", filename.c_str (), strerror (errno));
return YCPBoolean (false);
}
// string contents = (arg.isNull() ? "" : arg->toString());
string contents = (arg.isNull() ? "" : dump_value(0, arg));
ssize_t size = contents.length();
if (size == write(fd, contents.c_str(), size)
&& write(fd, "\n", 1) == 1)
success = true;
close(fd);
return YCPBoolean(success);
}
ycp2error ("Undefined subpath for Write (%s)", path->toString ().c_str ());
return YCPBoolean (false);
} | 516 |
1 | static void file_change(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
const unsigned char *old_sha1,
const unsigned char *new_sha1,
const char *base, const char *path)
{
tree_difference = REV_TREE_DIFFERENT;
DIFF_OPT_SET(options, HAS_CHANGES);
} | 520 |
1 | spnego_gss_wrap_iov_length(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
int *conf_state,
gss_iov_buffer_desc *iov,
int iov_count)
{
OM_uint32 ret;
ret = gss_wrap_iov_length(minor_status,
context_handle,
conf_req_flag,
qop_req,
conf_state,
iov,
iov_count);
return (ret);
} | 521 |
0 | static void mark_desktop_file_executable_task_thread_func ( GTask * task , gpointer source_object , gpointer task_data , GCancellable * cancellable ) {
MarkTrustedJob * job = task_data ;
CommonJob * common ;
common = ( CommonJob * ) job ;
nautilus_progress_info_start ( job -> common . progress ) ;
mark_desktop_file_executable ( common , cancellable , job -> file , job -> interactive ) ;
} | 522 |
1 | static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as) { ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw; struct alsa_params_req req; struct alsa_params_obt obt; snd_pcm_t *handle; struct audsettings obt_as; req.fmt = aud_to_alsafmt (as->fmt, as->endianness); req.freq = as->freq; req.nchannels = as->nchannels; req.period_size = conf.period_size_in; req.buffer_size = conf.buffer_size_in; req.size_in_usec = conf.size_in_usec_in; req.override_mask = (conf.period_size_in_overridden ? 1 : 0) | (conf.buffer_size_in_overridden ? 2 : 0); if (alsa_open (1, &req, &obt, &handle)) { return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; obt_as.fmt = obt.fmt; obt_as.endianness = obt.endianness; audio_pcm_init_info (&hw->info, &obt_as); hw->samples = obt.samples; alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); if (!alsa->pcm_buf) { dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n", hw->samples, 1 << hw->info.shift); alsa_anal_close1 (&handle); return -1; } alsa->handle = handle; return 0; } | 523 |
1 | int run_diff_files(struct rev_info *revs, unsigned int option)
{
int entries, i;
int diff_unmerged_stage = revs->max_count;
int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
? CE_MATCH_RACY_IS_DIRTY : 0);
char symcache[PATH_MAX];
if (diff_unmerged_stage < 0)
diff_unmerged_stage = 2;
entries = active_nr;
symcache[0] = '\0';
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode, newmode;
struct cache_entry *ce = active_cache[i];
int changed;
if (DIFF_OPT_TST(&revs->diffopt, QUIET) &&
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
break;
if (!ce_path_match(ce, revs->prune_data))
continue;
if (ce_stage(ce)) {
struct combine_diff_path *dpath;
int num_compare_stages = 0;
size_t path_len;
path_len = ce_namelen(ce);
dpath = xmalloc(combine_diff_path_size(5, path_len));
dpath->path = (char *) &(dpath->parent[5]);
dpath->next = NULL;
dpath->len = path_len;
memcpy(dpath->path, ce->name, path_len);
dpath->path[path_len] = '\0';
hashclr(dpath->sha1);
memset(&(dpath->parent[0]), 0,
sizeof(struct combine_diff_parent)*5);
changed = check_removed(ce, &st);
if (!changed)
dpath->mode = ce_mode_from_stat(ce, st.st_mode);
else {
if (changed < 0) {
perror(ce->name);
continue;
}
if (silent_on_removed)
continue;
}
while (i < entries) {
struct cache_entry *nce = active_cache[i];
int stage;
if (strcmp(ce->name, nce->name))
break;
/* Stage #2 (ours) is the first parent,
* stage #3 (theirs) is the second.
*/
stage = ce_stage(nce);
if (2 <= stage) {
int mode = nce->ce_mode;
num_compare_stages++;
hashcpy(dpath->parent[stage-2].sha1, nce->sha1);
dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode);
dpath->parent[stage-2].status =
DIFF_STATUS_MODIFIED;
}
/* diff against the proper unmerged stage */
if (stage == diff_unmerged_stage)
ce = nce;
i++;
}
/*
* Compensate for loop update
*/
i--;
if (revs->combine_merges && num_compare_stages == 2) {
show_combined_diff(dpath, 2,
revs->dense_combined_merges,
revs);
free(dpath);
continue;
}
free(dpath);
dpath = NULL;
/*
* Show the diff for the 'ce' if we found the one
* from the desired stage.
*/
diff_unmerge(&revs->diffopt, ce->name, 0, null_sha1);
if (ce_stage(ce) != diff_unmerged_stage)
continue;
}
if (ce_uptodate(ce))
continue;
changed = check_removed(ce, &st);
if (changed) {
if (changed < 0) {
perror(ce->name);
continue;
}
if (silent_on_removed)
continue;
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
ce->sha1, ce->name, NULL);
continue;
}
changed = ce_match_stat(ce, &st, ce_option);
if (!changed) {
ce_mark_uptodate(ce);
if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
continue;
}
oldmode = ce->ce_mode;
newmode = ce_mode_from_stat(ce, st.st_mode);
diff_change(&revs->diffopt, oldmode, newmode,
ce->sha1, (changed ? null_sha1 : ce->sha1),
ce->name, NULL);
}
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
return 0;
} | 524 |
0 | IN_PROC_BROWSER_TEST_F ( FramebustBlockBrowserTest , ModelAllowsRedirection ) {
const GURL blocked_urls [ ] = {
GURL ( chrome : : kChromeUIHistoryURL ) , GURL ( chrome : : kChromeUISettingsURL ) , GURL ( chrome : : kChromeUIVersionURL ) , }
;
auto * helper = GetFramebustTabHelper ( ) ;
for ( const GURL & url : blocked_urls ) {
helper -> AddBlockedUrl ( url , base : : BindOnce ( & FramebustBlockBrowserTest : : OnClick , base : : Unretained ( this ) ) ) ;
}
EXPECT_TRUE ( helper -> HasBlockedUrls ( ) ) ;
ContentSettingFramebustBlockBubbleModel framebust_block_bubble_model ( browser ( ) -> content_setting_bubble_model_delegate ( ) , GetWebContents ( ) , browser ( ) -> profile ( ) ) ;
EXPECT_FALSE ( clicked_index_ . has_value ( ) ) ;
EXPECT_FALSE ( clicked_url_ . has_value ( ) ) ;
content : : TestNavigationObserver observer ( GetWebContents ( ) ) ;
framebust_block_bubble_model . OnListItemClicked ( 1 , ui : : EF_LEFT_MOUSE_BUTTON ) ;
observer . Wait ( ) ;
EXPECT_TRUE ( clicked_index_ . has_value ( ) ) ;
EXPECT_TRUE ( clicked_url_ . has_value ( ) ) ;
EXPECT_EQ ( 1u , clicked_index_ . value ( ) ) ;
EXPECT_EQ ( GURL ( chrome : : kChromeUISettingsURL ) , clicked_url_ . value ( ) ) ;
EXPECT_FALSE ( helper -> HasBlockedUrls ( ) ) ;
EXPECT_EQ ( blocked_urls [ 1 ] , GetWebContents ( ) -> GetLastCommittedURL ( ) ) ;
} | 525 |
1 | virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
CSmartPtr<CWebSession> spSession = WebSock.GetSession();
if (sPageName == "settings") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return SettingsPage(WebSock, Tmpl);
} else if (sPageName == "adduser") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return UserPage(WebSock, Tmpl);
} else if (sPageName == "addnetwork") {
CUser* pUser = SafeGetUserFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
if (pUser) {
return NetworkPage(WebSock, Tmpl, pUser);
}
WebSock.PrintErrorPage("No such username");
return true;
} else if (sPageName == "editnetwork") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (!pNetwork) {
WebSock.PrintErrorPage("No such username or network");
return true;
}
return NetworkPage(WebSock, Tmpl, pNetwork->GetUser(), pNetwork);
} else if (sPageName == "delnetwork") {
CString sUser = WebSock.GetParam("user");
if (sUser.empty() && !WebSock.IsPost()) {
sUser = WebSock.GetParam("user", false);
}
CUser* pUser = CZNC::Get().FindUser(sUser);
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
return DelNetwork(WebSock, pUser, Tmpl);
} else if (sPageName == "editchan") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (!pNetwork) {
WebSock.PrintErrorPage("No such username or network");
return true;
}
CString sChan = WebSock.GetParam("name");
if(sChan.empty() && !WebSock.IsPost()) {
sChan = WebSock.GetParam("name", false);
}
CChan* pChan = pNetwork->FindChan(sChan);
if (!pChan) {
WebSock.PrintErrorPage("No such channel");
return true;
}
return ChanPage(WebSock, Tmpl, pNetwork, pChan);
} else if (sPageName == "addchan") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (pNetwork) {
return ChanPage(WebSock, Tmpl, pNetwork);
}
WebSock.PrintErrorPage("No such username or network");
return true;
} else if (sPageName == "delchan") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (pNetwork) {
return DelChan(WebSock, pNetwork);
}
WebSock.PrintErrorPage("No such username or network");
return true;
} else if (sPageName == "deluser") {
if (!spSession->IsAdmin()) {
return false;
}
if (!WebSock.IsPost()) {
// Show the "Are you sure?" page:
CString sUser = WebSock.GetParam("user", false);
CUser* pUser = CZNC::Get().FindUser(sUser);
if (!pUser) {
WebSock.PrintErrorPage("No such username");
return true;
}
Tmpl.SetFile("del_user.tmpl");
Tmpl["Username"] = sUser;
return true;
}
// The "Are you sure?" page has been submitted with "Yes",
// so we actually delete the user now:
CString sUser = WebSock.GetParam("user");
CUser* pUser = CZNC::Get().FindUser(sUser);
if (pUser && pUser == spSession->GetUser()) {
WebSock.PrintErrorPage("Please don't delete yourself, suicide is not the answer!");
return true;
} else if (CZNC::Get().DeleteUser(sUser)) {
WebSock.Redirect("listusers");
return true;
}
WebSock.PrintErrorPage("No such username");
return true;
} else if (sPageName == "edituser") {
CString sUserName = SafeGetUserNameParam(WebSock);
CUser* pUser = CZNC::Get().FindUser(sUserName);
if(!pUser) {
if(sUserName.empty()) {
pUser = spSession->GetUser();
} // else: the "no such user" message will be printed.
}
// Admin||Self Check
if (!spSession->IsAdmin() && (!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
if (pUser) {
return UserPage(WebSock, Tmpl, pUser);
}
WebSock.PrintErrorPage("No such username");
return true;
} else if (sPageName == "listusers" && spSession->IsAdmin()) {
return ListUsersPage(WebSock, Tmpl);
} else if (sPageName == "traffic" && spSession->IsAdmin()) {
return TrafficPage(WebSock, Tmpl);
} else if (sPageName == "index") {
return true;
} else if (sPageName == "add_listener") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return AddListener(WebSock, Tmpl);
} else if (sPageName == "del_listener") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return DelListener(WebSock, Tmpl);
}
return false;
} | 528 |
1 | spnego_gss_wrap_size_limit(
OM_uint32 *minor_status,
const gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
OM_uint32 req_output_size,
OM_uint32 *max_input_size)
{
OM_uint32 ret;
ret = gss_wrap_size_limit(minor_status,
context_handle,
conf_req_flag,
qop_req,
req_output_size,
max_input_size);
return (ret);
} | 529 |
1 | static int vnc_zlib_stop(VncState *vs, int stream_id) { z_streamp zstream = &vs->zlib_stream[stream_id]; int previous_out; // switch back to normal output/zlib buffers vs->zlib = vs->output; vs->output = vs->zlib_tmp; // compress the zlib buffer // initialize the stream // XXX need one stream per session if (zstream->opaque != vs) { int err; VNC_DEBUG("VNC: initializing zlib stream %d\n", stream_id); VNC_DEBUG("VNC: opaque = %p | vs = %p\n", zstream->opaque, vs); zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; err = deflateInit2(zstream, vs->tight_compression, Z_DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (err != Z_OK) { fprintf(stderr, "VNC: error initializing zlib\n"); return -1; } zstream->opaque = vs; } // XXX what to do if tight_compression changed in between? // reserve memory in output buffer buffer_reserve(&vs->output, vs->zlib.offset + 64); // set pointers zstream->next_in = vs->zlib.buffer; zstream->avail_in = vs->zlib.offset; zstream->next_out = vs->output.buffer + vs->output.offset; zstream->avail_out = vs->output.capacity - vs->output.offset; zstream->data_type = Z_BINARY; previous_out = zstream->total_out; // start encoding if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) { fprintf(stderr, "VNC: error during zlib compression\n"); return -1; } vs->output.offset = vs->output.capacity - zstream->avail_out; return zstream->total_out - previous_out; } | 530 |
1 | static void prepare_attr_stack(const char *path, int dirlen)
{
struct attr_stack *elem, *info;
int len;
char pathbuf[PATH_MAX];
/*
* At the bottom of the attribute stack is the built-in
* set of attribute definitions. Then, contents from
* .gitattribute files from directories closer to the
* root to the ones in deeper directories are pushed
* to the stack. Finally, at the very top of the stack
* we always keep the contents of $GIT_DIR/info/attributes.
*
* When checking, we use entries from near the top of the
* stack, preferring $GIT_DIR/info/attributes, then
* .gitattributes in deeper directories to shallower ones,
* and finally use the built-in set as the default.
*/
if (!attr_stack)
bootstrap_attr_stack();
/*
* Pop the "info" one that is always at the top of the stack.
*/
info = attr_stack;
attr_stack = info->prev;
/*
* Pop the ones from directories that are not the prefix of
* the path we are checking.
*/
while (attr_stack && attr_stack->origin) {
int namelen = strlen(attr_stack->origin);
elem = attr_stack;
if (namelen <= dirlen &&
!strncmp(elem->origin, path, namelen))
break;
debug_pop(elem);
attr_stack = elem->prev;
free_attr_elem(elem);
}
/*
* Read from parent directories and push them down
*/
if (!is_bare_repository()) {
while (1) {
char *cp;
len = strlen(attr_stack->origin);
if (dirlen <= len)
break;
memcpy(pathbuf, path, dirlen);
memcpy(pathbuf + dirlen, "/", 2);
cp = strchr(pathbuf + len + 1, '/');
strcpy(cp + 1, GITATTRIBUTES_FILE);
elem = read_attr(pathbuf, 0);
*cp = '\0';
elem->origin = strdup(pathbuf);
elem->prev = attr_stack;
attr_stack = elem;
debug_push(elem);
}
}
/*
* Finally push the "info" one at the top of the stack.
*/
info->prev = attr_stack;
attr_stack = info;
} | 531 |
0 | gint proto_registrar_get_length ( const int n ) {
header_field_info * hfinfo ;
PROTO_REGISTRAR_GET_NTH ( n , hfinfo ) ;
return ftype_length ( hfinfo -> type ) ;
} | 532 |
1 | static int dccp_setsockopt_change(struct sock *sk, int type,
struct dccp_so_feat __user *optval)
{
struct dccp_so_feat opt;
u8 *val;
int rc;
if (copy_from_user(&opt, optval, sizeof(opt)))
return -EFAULT;
val = kmalloc(opt.dccpsf_len, GFP_KERNEL);
if (!val)
return -ENOMEM;
if (copy_from_user(val, opt.dccpsf_val, opt.dccpsf_len)) {
rc = -EFAULT;
goto out_free_val;
}
rc = dccp_feat_change(dccp_msk(sk), type, opt.dccpsf_feat,
val, opt.dccpsf_len, GFP_KERNEL);
if (rc)
goto out_free_val;
out:
return rc;
out_free_val:
kfree(val);
goto out;
} | 536 |
1 | int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags) { VLCcode *buf; int i, j, ret; vlc->bits = nb_bits; if(flags & INIT_VLC_USE_NEW_STATIC){ VLC dyn_vlc = *vlc; if (vlc->table_size) return 0; ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags & ~INIT_VLC_USE_NEW_STATIC); av_assert0(ret >= 0); av_assert0(dyn_vlc.table_size <= vlc->table_allocated); if(dyn_vlc.table_size < vlc->table_allocated) av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated); memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table)); vlc->table_size = dyn_vlc.table_size; ff_free_vlc(&dyn_vlc); return 0; }else { vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; } av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); av_assert0(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) {\ GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ if (!(condition))\ continue;\ if (buf[j].bits > 3*nb_bits || buf[j].bits>32) {\ av_log(NULL, AV_LOG_ERROR, "Too long VLC in init_vlc\n");\ return -1;\ }\ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ if (buf[j].code >= (1LL<<buf[j].bits)) {\ av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n");\ return -1;\ }\ if (flags & INIT_VLC_LE)\ buf[j].code = bitswap_32(buf[j].code);\ else\ buf[j].code <<= 32 - buf[j].bits;\ if (symbols)\ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ else\ buf[j].symbol = i;\ j++;\ } COPY(buf[j].bits > nb_bits); // qsort is the slowest part of init_vlc, and could probably be improved or avoided qsort(buf, j, sizeof(VLCcode), compare_vlcspec); COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; ret = build_table(vlc, nb_bits, nb_codes, buf, flags); av_free(buf); if (ret < 0) { av_freep(&vlc->table); return -1; } return 0; } | 537 |
0 | static int seqvideo_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) {
const uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
int ret ;
SeqVideoContext * seq = avctx -> priv_data ;
if ( ( ret = ff_reget_buffer ( avctx , & seq -> frame ) ) < 0 ) {
av_log ( seq -> avctx , AV_LOG_ERROR , "tiertexseqvideo: reget_buffer() failed\n" ) ;
return ret ;
}
if ( seqvideo_decode ( seq , buf , buf_size ) ) return AVERROR_INVALIDDATA ;
if ( ( ret = av_frame_ref ( data , & seq -> frame ) ) < 0 ) return ret ;
* got_frame = 1 ;
return buf_size ;
} | 538 |
1 | static int gss_iakerbmechglue_init(void)
{
struct gss_mech_config mech_iakerb;
struct gss_config iakerb_mechanism = krb5_mechanism;
/* IAKERB mechanism mirrors krb5, but with different context SPIs */
iakerb_mechanism.gss_accept_sec_context = iakerb_gss_accept_sec_context;
iakerb_mechanism.gss_init_sec_context = iakerb_gss_init_sec_context;
iakerb_mechanism.gss_delete_sec_context = iakerb_gss_delete_sec_context;
iakerb_mechanism.gss_acquire_cred = iakerb_gss_acquire_cred;
iakerb_mechanism.gssspi_acquire_cred_with_password
= iakerb_gss_acquire_cred_with_password;
memset(&mech_iakerb, 0, sizeof(mech_iakerb));
mech_iakerb.mech = &iakerb_mechanism;
mech_iakerb.mechNameStr = "iakerb";
mech_iakerb.mech_type = (gss_OID)gss_mech_iakerb;
gssint_register_mechinfo(&mech_iakerb);
return 0;
} | 539 |
1 | static int sctp_setsockopt_auth_chunk(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_authchunk val;
if (optlen != sizeof(struct sctp_authchunk))
return -EINVAL;
if (copy_from_user(&val, optval, optlen))
return -EFAULT;
switch (val.sauth_chunk) {
case SCTP_CID_INIT:
case SCTP_CID_INIT_ACK:
case SCTP_CID_SHUTDOWN_COMPLETE:
case SCTP_CID_AUTH:
return -EINVAL;
}
/* add this chunk id to the endpoint */
return sctp_auth_ep_add_chunkid(sctp_sk(sk)->ep, val.sauth_chunk);
} | 542 |
0 | static void config_phone ( config_tree * ptree ) {
int i ;
string_node * sn ;
i = 0 ;
sn = HEAD_PFIFO ( ptree -> phone ) ;
for ( ;
sn != NULL ;
sn = sn -> link ) {
if ( i < COUNTOF ( sys_phone ) - 1 ) {
sys_phone [ i ++ ] = estrdup ( sn -> s ) ;
sys_phone [ i ] = NULL ;
}
else {
msyslog ( LOG_INFO , "phone: Number of phone entries exceeds %lu. Ignoring phone %s..." , ( u_long ) ( COUNTOF ( sys_phone ) - 1 ) , sn -> s ) ;
}
}
} | 543 |
1 | static void cg3_initfn(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); CG3State *s = CG3(obj); memory_region_init_ram(&s->rom, NULL, "cg3.prom", FCODE_MAX_ROM_SIZE, &error_abort); memory_region_set_readonly(&s->rom, true); sysbus_init_mmio(sbd, &s->rom); memory_region_init_io(&s->reg, NULL, &cg3_reg_ops, s, "cg3.reg", CG3_REG_SIZE); sysbus_init_mmio(sbd, &s->reg); } | 544 |
0 | static void U_CALLCONV UConverter_fromUnicode_HZ_OFFSETS_LOGIC ( UConverterFromUnicodeArgs * args , UErrorCode * err ) {
const UChar * mySource = args -> source ;
char * myTarget = args -> target ;
int32_t * offsets = args -> offsets ;
int32_t mySourceIndex = 0 ;
int32_t myTargetIndex = 0 ;
int32_t targetLength = ( int32_t ) ( args -> targetLimit - myTarget ) ;
int32_t mySourceLength = ( int32_t ) ( args -> sourceLimit - args -> source ) ;
uint32_t targetUniChar = 0x0000 ;
UChar32 mySourceChar = 0x0000 ;
UConverterDataHZ * myConverterData = ( UConverterDataHZ * ) args -> converter -> extraInfo ;
UBool isTargetUCharDBCS = ( UBool ) myConverterData -> isTargetUCharDBCS ;
UBool oldIsTargetUCharDBCS ;
int len = 0 ;
const char * escSeq = NULL ;
if ( args -> converter -> fromUChar32 != 0 && myTargetIndex < targetLength ) {
goto getTrail ;
}
while ( mySourceIndex < mySourceLength ) {
targetUniChar = missingCharMarker ;
if ( myTargetIndex < targetLength ) {
mySourceChar = ( UChar ) mySource [ mySourceIndex ++ ] ;
oldIsTargetUCharDBCS = isTargetUCharDBCS ;
if ( mySourceChar == UCNV_TILDE ) {
len = ESC_LEN ;
escSeq = TILDE_ESCAPE ;
CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ;
continue ;
}
else if ( mySourceChar <= 0x7f ) {
targetUniChar = mySourceChar ;
}
else {
int32_t length = ucnv_MBCSFromUChar32 ( myConverterData -> gbConverter -> sharedData , mySourceChar , & targetUniChar , args -> converter -> useFallback ) ;
if ( length == 2 && ( uint16_t ) ( targetUniChar - 0xa1a1 ) <= ( 0xfdfe - 0xa1a1 ) && ( uint8_t ) ( targetUniChar - 0xa1 ) <= ( 0xfe - 0xa1 ) ) {
targetUniChar -= 0x8080 ;
}
else {
targetUniChar = missingCharMarker ;
}
}
if ( targetUniChar != missingCharMarker ) {
myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS = ( UBool ) ( targetUniChar > 0x00FF ) ;
if ( oldIsTargetUCharDBCS != isTargetUCharDBCS || ! myConverterData -> isEscapeAppended ) {
if ( ! isTargetUCharDBCS ) {
len = ESC_LEN ;
escSeq = SB_ESCAPE ;
CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ;
myConverterData -> isEscapeAppended = TRUE ;
}
else {
len = ESC_LEN ;
escSeq = DB_ESCAPE ;
CONCAT_ESCAPE_MACRO ( args , myTargetIndex , targetLength , escSeq , err , len , mySourceIndex ) ;
myConverterData -> isEscapeAppended = TRUE ;
}
}
if ( isTargetUCharDBCS ) {
if ( myTargetIndex < targetLength ) {
myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar >> 8 ) ;
if ( offsets ) {
* ( offsets ++ ) = mySourceIndex - 1 ;
}
if ( myTargetIndex < targetLength ) {
myTarget [ myTargetIndex ++ ] = ( char ) targetUniChar ;
if ( offsets ) {
* ( offsets ++ ) = mySourceIndex - 1 ;
}
}
else {
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ;
* err = U_BUFFER_OVERFLOW_ERROR ;
}
}
else {
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) ( targetUniChar >> 8 ) ;
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ;
* err = U_BUFFER_OVERFLOW_ERROR ;
}
}
else {
if ( myTargetIndex < targetLength ) {
myTarget [ myTargetIndex ++ ] = ( char ) ( targetUniChar ) ;
if ( offsets ) {
* ( offsets ++ ) = mySourceIndex - 1 ;
}
}
else {
args -> converter -> charErrorBuffer [ args -> converter -> charErrorBufferLength ++ ] = ( char ) targetUniChar ;
* err = U_BUFFER_OVERFLOW_ERROR ;
}
}
}
else {
if ( U16_IS_SURROGATE ( mySourceChar ) ) {
if ( U16_IS_SURROGATE_LEAD ( mySourceChar ) ) {
args -> converter -> fromUChar32 = mySourceChar ;
getTrail : if ( mySourceIndex < mySourceLength ) {
UChar trail = ( UChar ) args -> source [ mySourceIndex ] ;
if ( U16_IS_TRAIL ( trail ) ) {
++ mySourceIndex ;
mySourceChar = U16_GET_SUPPLEMENTARY ( args -> converter -> fromUChar32 , trail ) ;
args -> converter -> fromUChar32 = 0x00 ;
* err = U_INVALID_CHAR_FOUND ;
}
else {
* err = U_ILLEGAL_CHAR_FOUND ;
}
}
else {
* err = U_ZERO_ERROR ;
}
}
else {
* err = U_ILLEGAL_CHAR_FOUND ;
}
}
else {
* err = U_INVALID_CHAR_FOUND ;
}
args -> converter -> fromUChar32 = mySourceChar ;
break ;
}
}
else {
* err = U_BUFFER_OVERFLOW_ERROR ;
break ;
}
targetUniChar = missingCharMarker ;
}
args -> target += myTargetIndex ;
args -> source += mySourceIndex ;
myConverterData -> isTargetUCharDBCS = isTargetUCharDBCS ;
} | 545 |
1 | static int sctp_setsockopt_auth_key(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_authkey *authkey;
struct sctp_association *asoc;
int ret;
if (optlen <= sizeof(struct sctp_authkey))
return -EINVAL;
authkey = kmalloc(optlen, GFP_KERNEL);
if (!authkey)
return -ENOMEM;
if (copy_from_user(authkey, optval, optlen)) {
ret = -EFAULT;
goto out;
}
asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) {
ret = -EINVAL;
goto out;
}
ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey);
out:
kfree(authkey);
return ret;
} | 547 |
1 | iakerb_alloc_context(iakerb_ctx_id_t *pctx)
{
iakerb_ctx_id_t ctx;
krb5_error_code code;
*pctx = NULL;
ctx = k5alloc(sizeof(*ctx), &code);
if (ctx == NULL)
goto cleanup;
ctx->defcred = GSS_C_NO_CREDENTIAL;
ctx->magic = KG_IAKERB_CONTEXT;
ctx->state = IAKERB_AS_REQ;
ctx->count = 0;
code = krb5_gss_init_context(&ctx->k5c);
if (code != 0)
goto cleanup;
*pctx = ctx;
cleanup:
if (code != 0)
iakerb_release_context(ctx);
return code;
} | 548 |
0 | static int reassociate ( struct evport_data * epdp , struct fd_info * fdip , int fd ) {
int sysevents = FDI_TO_SYSEVENTS ( fdip ) ;
if ( sysevents != 0 ) {
if ( port_associate ( epdp -> ed_port , PORT_SOURCE_FD , fd , sysevents , NULL ) == - 1 ) {
event_warn ( "port_associate" ) ;
return ( - 1 ) ;
}
}
check_evportop ( epdp ) ;
return ( 0 ) ;
} | 549 |
1 | static int sctp_setsockopt_del_key(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_authkeyid val;
struct sctp_association *asoc;
if (optlen != sizeof(struct sctp_authkeyid))
return -EINVAL;
if (copy_from_user(&val, optval, optlen))
return -EFAULT;
asoc = sctp_id2assoc(sk, val.scact_assoc_id);
if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP))
return -EINVAL;
return sctp_auth_del_key_id(sctp_sk(sk)->ep, asoc,
val.scact_keynumber);
} | 550 |
1 | int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) { int id, sr, ch, ba, tag, bps; id = avctx->codec_id; sr = avctx->sample_rate; ch = avctx->channels; ba = avctx->block_align; tag = avctx->codec_tag; bps = av_get_exact_bits_per_sample(avctx->codec_id); /* codecs with an exact constant bits per sample */ if (bps > 0 && ch > 0 && frame_bytes > 0) return (frame_bytes * 8) / (bps * ch); bps = avctx->bits_per_coded_sample; /* codecs with a fixed packet duration */ switch (id) { case CODEC_ID_ADPCM_ADX: return 32; case CODEC_ID_ADPCM_IMA_QT: return 64; case CODEC_ID_ADPCM_EA_XAS: return 128; case CODEC_ID_AMR_NB: case CODEC_ID_GSM: case CODEC_ID_QCELP: case CODEC_ID_RA_144: case CODEC_ID_RA_288: return 160; case CODEC_ID_IMC: return 256; case CODEC_ID_AMR_WB: case CODEC_ID_GSM_MS: return 320; case CODEC_ID_MP1: return 384; case CODEC_ID_ATRAC1: return 512; case CODEC_ID_ATRAC3: return 1024; case CODEC_ID_MP2: case CODEC_ID_MUSEPACK7: return 1152; case CODEC_ID_AC3: return 1536; } if (sr > 0) { /* calc from sample rate */ if (id == CODEC_ID_TTA) return 256 * sr / 245; if (ch > 0) { /* calc from sample rate and channels */ if (id == CODEC_ID_BINKAUDIO_DCT) return (480 << (sr / 22050)) / ch; } } if (ba > 0) { /* calc from block_align */ if (id == CODEC_ID_SIPR) { switch (ba) { case 20: return 160; case 19: return 144; case 29: return 288; case 37: return 480; } } } if (frame_bytes > 0) { /* calc from frame_bytes only */ if (id == CODEC_ID_TRUESPEECH) return 240 * (frame_bytes / 32); if (id == CODEC_ID_NELLYMOSER) return 256 * (frame_bytes / 64); if (bps > 0) { /* calc from frame_bytes and bits_per_coded_sample */ if (id == CODEC_ID_ADPCM_G726) return frame_bytes * 8 / bps; } if (ch > 0) { /* calc from frame_bytes and channels */ switch (id) { case CODEC_ID_ADPCM_4XM: case CODEC_ID_ADPCM_IMA_ISS: return (frame_bytes - 4 * ch) * 2 / ch; case CODEC_ID_ADPCM_IMA_SMJPEG: return (frame_bytes - 4) * 2 / ch; case CODEC_ID_ADPCM_IMA_AMV: return (frame_bytes - 8) * 2 / ch; case CODEC_ID_ADPCM_XA: return (frame_bytes / 128) * 224 / ch; case CODEC_ID_INTERPLAY_DPCM: return (frame_bytes - 6 - ch) / ch; case CODEC_ID_ROQ_DPCM: return (frame_bytes - 8) / ch; case CODEC_ID_XAN_DPCM: return (frame_bytes - 2 * ch) / ch; case CODEC_ID_MACE3: return 3 * frame_bytes / ch; case CODEC_ID_MACE6: return 6 * frame_bytes / ch; case CODEC_ID_PCM_LXF: return 2 * (frame_bytes / (5 * ch)); } if (tag) { /* calc from frame_bytes, channels, and codec_tag */ if (id == CODEC_ID_SOL_DPCM) { if (tag == 3) return frame_bytes / ch; else return frame_bytes * 2 / ch; } } if (ba > 0) { /* calc from frame_bytes, channels, and block_align */ int blocks = frame_bytes / ba; switch (avctx->codec_id) { case CODEC_ID_ADPCM_IMA_WAV: return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8); case CODEC_ID_ADPCM_IMA_DK3: return blocks * (((ba - 16) * 2 / 3 * 4) / ch); case CODEC_ID_ADPCM_IMA_DK4: return blocks * (1 + (ba - 4 * ch) * 2 / ch); case CODEC_ID_ADPCM_MS: return blocks * (2 + (ba - 7 * ch) * 2 / ch); } } if (bps > 0) { /* calc from frame_bytes, channels, and bits_per_coded_sample */ switch (avctx->codec_id) { case CODEC_ID_PCM_DVD: return 2 * (frame_bytes / ((bps * 2 / 8) * ch)); case CODEC_ID_PCM_BLURAY: return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8); case CODEC_ID_S302M: return 2 * (frame_bytes / ((bps + 4) / 4)) / ch; } } } } return 0; } | 551 |
1 | iakerb_gss_accept_sec_context(OM_uint32 *minor_status,
gss_ctx_id_t *context_handle,
gss_cred_id_t verifier_cred_handle,
gss_buffer_t input_token,
gss_channel_bindings_t input_chan_bindings,
gss_name_t *src_name,
gss_OID *mech_type,
gss_buffer_t output_token,
OM_uint32 *ret_flags,
OM_uint32 *time_rec,
gss_cred_id_t *delegated_cred_handle)
{
OM_uint32 major_status = GSS_S_FAILURE;
OM_uint32 code;
iakerb_ctx_id_t ctx;
int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT);
if (initialContextToken) {
code = iakerb_alloc_context(&ctx);
if (code != 0)
goto cleanup;
} else
ctx = (iakerb_ctx_id_t)*context_handle;
if (iakerb_is_iakerb_token(input_token)) {
if (ctx->gssc != GSS_C_NO_CONTEXT) {
/* We shouldn't get an IAKERB token now. */
code = G_WRONG_TOKID;
major_status = GSS_S_DEFECTIVE_TOKEN;
goto cleanup;
}
code = iakerb_acceptor_step(ctx, initialContextToken,
input_token, output_token);
if (code == (OM_uint32)KRB5_BAD_MSIZE)
major_status = GSS_S_DEFECTIVE_TOKEN;
if (code != 0)
goto cleanup;
if (initialContextToken) {
*context_handle = (gss_ctx_id_t)ctx;
ctx = NULL;
}
if (src_name != NULL)
*src_name = GSS_C_NO_NAME;
if (mech_type != NULL)
*mech_type = (gss_OID)gss_mech_iakerb;
if (ret_flags != NULL)
*ret_flags = 0;
if (time_rec != NULL)
*time_rec = 0;
if (delegated_cred_handle != NULL)
*delegated_cred_handle = GSS_C_NO_CREDENTIAL;
major_status = GSS_S_CONTINUE_NEEDED;
} else {
krb5_gss_ctx_ext_rec exts;
iakerb_make_exts(ctx, &exts);
major_status = krb5_gss_accept_sec_context_ext(&code,
&ctx->gssc,
verifier_cred_handle,
input_token,
input_chan_bindings,
src_name,
NULL,
output_token,
ret_flags,
time_rec,
delegated_cred_handle,
&exts);
if (major_status == GSS_S_COMPLETE) {
*context_handle = ctx->gssc;
ctx->gssc = NULL;
iakerb_release_context(ctx);
}
if (mech_type != NULL)
*mech_type = (gss_OID)gss_mech_krb5;
}
cleanup:
if (initialContextToken && GSS_ERROR(major_status)) {
iakerb_release_context(ctx);
*context_handle = GSS_C_NO_CONTEXT;
}
*minor_status = code;
return major_status;
} | 552 |
1 | static void parse_context_init(SchroParseUnitContext *parse_ctx, const uint8_t *buf, int buf_size) { parse_ctx->buf = buf; parse_ctx->buf_size = buf_size; } | 553 |
1 | void CIRCSock::ReadLine(const CString& sData) {
CString sLine = sData;
sLine.TrimRight("\n\r");
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/"
<< m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]");
bool bReturn = false;
IRCSOCKMODULECALL(OnRaw(sLine), &bReturn);
if (bReturn) return;
CMessage Message(sLine);
Message.SetNetwork(m_pNetwork);
IRCSOCKMODULECALL(OnRawMessage(Message), &bReturn);
if (bReturn) return;
switch (Message.GetType()) {
case CMessage::Type::Account:
bReturn = OnAccountMessage(Message);
break;
case CMessage::Type::Action:
bReturn = OnActionMessage(Message);
break;
case CMessage::Type::Away:
bReturn = OnAwayMessage(Message);
break;
case CMessage::Type::Capability:
bReturn = OnCapabilityMessage(Message);
break;
case CMessage::Type::CTCP:
bReturn = OnCTCPMessage(Message);
break;
case CMessage::Type::Error:
bReturn = OnErrorMessage(Message);
break;
case CMessage::Type::Invite:
bReturn = OnInviteMessage(Message);
break;
case CMessage::Type::Join:
bReturn = OnJoinMessage(Message);
break;
case CMessage::Type::Kick:
bReturn = OnKickMessage(Message);
break;
case CMessage::Type::Mode:
bReturn = OnModeMessage(Message);
break;
case CMessage::Type::Nick:
bReturn = OnNickMessage(Message);
break;
case CMessage::Type::Notice:
bReturn = OnNoticeMessage(Message);
break;
case CMessage::Type::Numeric:
bReturn = OnNumericMessage(Message);
break;
case CMessage::Type::Part:
bReturn = OnPartMessage(Message);
break;
case CMessage::Type::Ping:
bReturn = OnPingMessage(Message);
break;
case CMessage::Type::Pong:
bReturn = OnPongMessage(Message);
break;
case CMessage::Type::Quit:
bReturn = OnQuitMessage(Message);
break;
case CMessage::Type::Text:
bReturn = OnTextMessage(Message);
break;
case CMessage::Type::Topic:
bReturn = OnTopicMessage(Message);
break;
case CMessage::Type::Wallops:
bReturn = OnWallopsMessage(Message);
break;
default:
break;
}
if (bReturn) return;
m_pNetwork->PutUser(Message);
} | 554 |
0 | static const char * default_iconv_charset ( const char * charset ) {
if ( charset != NULL && charset [ 0 ] != '\0' ) return charset ;
# if HAVE_LOCALE_CHARSET && ! defined ( __APPLE__ ) return locale_charset ( ) ;
# elif HAVE_NL_LANGINFO return nl_langinfo ( CODESET ) ;
# else return "" ;
# endif } | 555 |
1 | static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
char __user *optval, int __user *optlen)
{
struct sctp_authchunks __user *p = (void __user *)optval;
struct sctp_authchunks val;
struct sctp_association *asoc;
struct sctp_chunks_param *ch;
u32 num_chunks;
char __user *to;
if (len <= sizeof(struct sctp_authchunks))
return -EINVAL;
if (copy_from_user(&val, p, sizeof(struct sctp_authchunks)))
return -EFAULT;
to = p->gauth_chunks;
asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
if (!asoc && val.gauth_assoc_id && sctp_style(sk, UDP))
return -EINVAL;
if (asoc)
ch = (struct sctp_chunks_param*)asoc->c.auth_chunks;
else
ch = sctp_sk(sk)->ep->auth_chunk_list;
num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t);
if (len < num_chunks)
return -EINVAL;
len = num_chunks;
if (put_user(len, optlen))
return -EFAULT;
if (put_user(num_chunks, &p->gauth_number_of_chunks))
return -EFAULT;
if (copy_to_user(to, ch->chunks, len))
return -EFAULT;
return 0;
} | 556 |
1 | CString CWebSock::GetSkinPath(const CString& sSkinName) {
CString sRet = CZNC::Get().GetZNCPath() + "/webskins/" + sSkinName;
if (!CFile::IsDir(sRet)) {
sRet = CZNC::Get().GetCurPath() + "/webskins/" + sSkinName;
if (!CFile::IsDir(sRet)) {
sRet = CString(_SKINDIR_) + "/" + sSkinName;
}
}
return sRet + "/";
} | 557 |
0 | static YYSIZE_T yysyntax_error ( char * yyresult , int yystate , int yychar ) {
int yyn = yypact [ yystate ] ;
if ( ! ( YYPACT_NINF < yyn && yyn <= YYLAST ) ) return 0 ;
else {
int yytype = YYTRANSLATE ( yychar ) ;
YYSIZE_T yysize0 = yytnamerr ( 0 , yytname [ yytype ] ) ;
YYSIZE_T yysize = yysize0 ;
YYSIZE_T yysize1 ;
int yysize_overflow = 0 ;
enum {
YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }
;
char const * yyarg [ YYERROR_VERBOSE_ARGS_MAXIMUM ] ;
int yyx ;
# if 0 YY_ ( "syntax error, unexpected %s" ) ;
YY_ ( "syntax error, unexpected %s, expecting %s" ) ;
YY_ ( "syntax error, unexpected %s, expecting %s or %s" ) ;
YY_ ( "syntax error, unexpected %s, expecting %s or %s or %s" ) ;
YY_ ( "syntax error, unexpected %s, expecting %s or %s or %s or %s" ) ;
# endif char * yyfmt ;
char const * yyf ;
static char const yyunexpected [ ] = "syntax error, unexpected %s" ;
static char const yyexpecting [ ] = ", expecting %s" ;
static char const yyor [ ] = " or %s" ;
char yyformat [ sizeof yyunexpected + sizeof yyexpecting - 1 + ( ( YYERROR_VERBOSE_ARGS_MAXIMUM - 2 ) * ( sizeof yyor - 1 ) ) ] ;
char const * yyprefix = yyexpecting ;
int yyxbegin = yyn < 0 ? - yyn : 0 ;
int yychecklim = YYLAST - yyn + 1 ;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS ;
int yycount = 1 ;
yyarg [ 0 ] = yytname [ yytype ] ;
yyfmt = yystpcpy ( yyformat , yyunexpected ) ;
for ( yyx = yyxbegin ;
yyx < yyxend ;
++ yyx ) if ( yycheck [ yyx + yyn ] == yyx && yyx != YYTERROR ) {
if ( yycount == YYERROR_VERBOSE_ARGS_MAXIMUM ) {
yycount = 1 ;
yysize = yysize0 ;
yyformat [ sizeof yyunexpected - 1 ] = '\0' ;
break ;
}
yyarg [ yycount ++ ] = yytname [ yyx ] ;
yysize1 = yysize + yytnamerr ( 0 , yytname [ yyx ] ) ;
yysize_overflow |= ( yysize1 < yysize ) ;
yysize = yysize1 ;
yyfmt = yystpcpy ( yyfmt , yyprefix ) ;
yyprefix = yyor ;
}
yyf = YY_ ( yyformat ) ;
yysize1 = yysize + yystrlen ( yyf ) ;
yysize_overflow |= ( yysize1 < yysize ) ;
yysize = yysize1 ;
if ( yysize_overflow ) return YYSIZE_MAXIMUM ;
if ( yyresult ) {
char * yyp = yyresult ;
int yyi = 0 ;
while ( ( * yyp = * yyf ) != '\0' ) {
if ( * yyp == '%' && yyf [ 1 ] == 's' && yyi < yycount ) {
yyp += yytnamerr ( yyp , yyarg [ yyi ++ ] ) ;
yyf += 2 ;
}
else {
yyp ++ ;
yyf ++ ;
}
}
}
return yysize ;
}
} | 558 |
1 | static int update_size(AVCodecContext *ctx, int w, int h) { VP9Context *s = ctx->priv_data; uint8_t *p; if (s->above_partition_ctx && w == ctx->width && h == ctx->height) return 0; ctx->width = w; ctx->height = h; s->sb_cols = (w + 63) >> 6; s->sb_rows = (h + 63) >> 6; s->cols = (w + 7) >> 3; s->rows = (h + 7) >> 3; #define assign(var, type, n) var = (type) p; p += s->sb_cols * n * sizeof(*var) av_free(s->above_partition_ctx); p = av_malloc(s->sb_cols * (240 + sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx) + 64 * s->sb_rows * (1 + sizeof(*s->mv[0]) * 2))); if (!p) return AVERROR(ENOMEM); assign(s->above_partition_ctx, uint8_t *, 8); assign(s->above_skip_ctx, uint8_t *, 8); assign(s->above_txfm_ctx, uint8_t *, 8); assign(s->above_mode_ctx, uint8_t *, 16); assign(s->above_y_nnz_ctx, uint8_t *, 16); assign(s->above_uv_nnz_ctx[0], uint8_t *, 8); assign(s->above_uv_nnz_ctx[1], uint8_t *, 8); assign(s->intra_pred_data[0], uint8_t *, 64); assign(s->intra_pred_data[1], uint8_t *, 32); assign(s->intra_pred_data[2], uint8_t *, 32); assign(s->above_segpred_ctx, uint8_t *, 8); assign(s->above_intra_ctx, uint8_t *, 8); assign(s->above_comp_ctx, uint8_t *, 8); assign(s->above_ref_ctx, uint8_t *, 8); assign(s->above_filter_ctx, uint8_t *, 8); assign(s->lflvl, struct VP9Filter *, 1); assign(s->above_mv_ctx, VP56mv(*)[2], 16); assign(s->segmentation_map, uint8_t *, 64 * s->sb_rows); assign(s->mv[0], struct VP9mvrefPair *, 64 * s->sb_rows); assign(s->mv[1], struct VP9mvrefPair *, 64 * s->sb_rows); #undef assign return 0; } | 559 |
1 | static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
struct sock *sk,
gfp_t gfp)
{
struct sctp_hmac_algo_param *auth_hmacs = NULL;
struct sctp_chunks_param *auth_chunks = NULL;
struct sctp_shared_key *null_key;
int err;
memset(ep, 0, sizeof(struct sctp_endpoint));
ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp);
if (!ep->digest)
return NULL;
if (sctp_auth_enable) {
/* Allocate space for HMACS and CHUNKS authentication
* variables. There are arrays that we encode directly
* into parameters to make the rest of the operations easier.
*/
auth_hmacs = kzalloc(sizeof(sctp_hmac_algo_param_t) +
sizeof(__u16) * SCTP_AUTH_NUM_HMACS, gfp);
if (!auth_hmacs)
goto nomem;
auth_chunks = kzalloc(sizeof(sctp_chunks_param_t) +
SCTP_NUM_CHUNK_TYPES, gfp);
if (!auth_chunks)
goto nomem;
/* Initialize the HMACS parameter.
* SCTP-AUTH: Section 3.3
* Every endpoint supporting SCTP chunk authentication MUST
* support the HMAC based on the SHA-1 algorithm.
*/
auth_hmacs->param_hdr.type = SCTP_PARAM_HMAC_ALGO;
auth_hmacs->param_hdr.length =
htons(sizeof(sctp_paramhdr_t) + 2);
auth_hmacs->hmac_ids[0] = htons(SCTP_AUTH_HMAC_ID_SHA1);
/* Initialize the CHUNKS parameter */
auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS;
/* If the Add-IP functionality is enabled, we must
* authenticate, ASCONF and ASCONF-ACK chunks
*/
if (sctp_addip_enable) {
auth_chunks->chunks[0] = SCTP_CID_ASCONF;
auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK;
auth_chunks->param_hdr.length =
htons(sizeof(sctp_paramhdr_t) + 2);
}
}
/* Initialize the base structure. */
/* What type of endpoint are we? */
ep->base.type = SCTP_EP_TYPE_SOCKET;
/* Initialize the basic object fields. */
atomic_set(&ep->base.refcnt, 1);
ep->base.dead = 0;
ep->base.malloced = 1;
/* Create an input queue. */
sctp_inq_init(&ep->base.inqueue);
/* Set its top-half handler */
sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv);
/* Initialize the bind addr area */
sctp_bind_addr_init(&ep->base.bind_addr, 0);
/* Remember who we are attached to. */
ep->base.sk = sk;
sock_hold(ep->base.sk);
/* Create the lists of associations. */
INIT_LIST_HEAD(&ep->asocs);
/* Use SCTP specific send buffer space queues. */
ep->sndbuf_policy = sctp_sndbuf_policy;
sk->sk_write_space = sctp_write_space;
sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
/* Get the receive buffer policy for this endpoint */
ep->rcvbuf_policy = sctp_rcvbuf_policy;
/* Initialize the secret key used with cookie. */
get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE);
ep->last_key = ep->current_key = 0;
ep->key_changed_at = jiffies;
/* SCTP-AUTH extensions*/
INIT_LIST_HEAD(&ep->endpoint_shared_keys);
null_key = sctp_auth_shkey_create(0, GFP_KERNEL);
if (!null_key)
goto nomem;
list_add(&null_key->key_list, &ep->endpoint_shared_keys);
/* Allocate and initialize transorms arrays for suported HMACs. */
err = sctp_auth_init_hmacs(ep, gfp);
if (err)
goto nomem_hmacs;
/* Add the null key to the endpoint shared keys list and
* set the hmcas and chunks pointers.
*/
ep->auth_hmacs_list = auth_hmacs;
ep->auth_chunk_list = auth_chunks;
return ep;
nomem_hmacs:
sctp_auth_destroy_keys(&ep->endpoint_shared_keys);
nomem:
/* Free all allocations */
kfree(auth_hmacs);
kfree(auth_chunks);
kfree(ep->digest);
return NULL;
} | 560 |
1 | static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) { SmackerContext *smk = s->priv_data; int flags; int ret; int i; int frame_size = 0; int palchange = 0; if (s->pb->eof_reached || smk->cur_frame >= smk->frames) return AVERROR_EOF; /* if we demuxed all streams, pass another frame */ if(smk->curstream < 0) { avio_seek(s->pb, smk->nextpos, 0); frame_size = smk->frm_size[smk->cur_frame] & (~3); flags = smk->frm_flags[smk->cur_frame]; /* handle palette change event */ if(flags & SMACKER_PAL){ int size, sz, t, off, j, pos; uint8_t *pal = smk->pal; uint8_t oldpal[768]; memcpy(oldpal, pal, 768); size = avio_r8(s->pb); size = size * 4 - 1; frame_size -= size; frame_size--; sz = 0; pos = avio_tell(s->pb) + size; while(sz < 256){ t = avio_r8(s->pb); if(t & 0x80){ /* skip palette entries */ sz += (t & 0x7F) + 1; pal += ((t & 0x7F) + 1) * 3; } else if(t & 0x40){ /* copy with offset */ off = avio_r8(s->pb); j = (t & 0x3F) + 1; if (off + j > 0x100) { av_log(s, AV_LOG_ERROR, "Invalid palette update, offset=%d length=%d extends beyond palette size\n", off, j); return AVERROR_INVALIDDATA; } off *= 3; while(j-- && sz < 256) { *pal++ = oldpal[off + 0]; *pal++ = oldpal[off + 1]; *pal++ = oldpal[off + 2]; sz++; off += 3; } } else { /* new entries */ *pal++ = smk_pal[t]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; *pal++ = smk_pal[avio_r8(s->pb) & 0x3F]; sz++; } } avio_seek(s->pb, pos, 0); palchange |= 1; } flags >>= 1; smk->curstream = -1; /* if audio chunks are present, put them to stack and retrieve later */ for(i = 0; i < 7; i++) { if(flags & 1) { uint32_t size; uint8_t *tmpbuf; size = avio_rl32(s->pb) - 4; if (!size || size > frame_size) { av_log(s, AV_LOG_ERROR, "Invalid audio part size\n"); return AVERROR_INVALIDDATA; } frame_size -= size; frame_size -= 4; smk->curstream++; tmpbuf = av_realloc(smk->bufs[smk->curstream], size); if (!tmpbuf) return AVERROR(ENOMEM); smk->bufs[smk->curstream] = tmpbuf; smk->buf_sizes[smk->curstream] = size; ret = avio_read(s->pb, smk->bufs[smk->curstream], size); if(ret != size) return AVERROR(EIO); smk->stream_id[smk->curstream] = smk->indexes[i]; } flags >>= 1; } if (frame_size < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, frame_size + 769)) return AVERROR(ENOMEM); if(smk->frm_size[smk->cur_frame] & 1) palchange |= 2; pkt->data[0] = palchange; memcpy(pkt->data + 1, smk->pal, 768); ret = avio_read(s->pb, pkt->data + 769, frame_size); if(ret != frame_size) return AVERROR(EIO); pkt->stream_index = smk->videoindex; pkt->pts = smk->cur_frame; pkt->size = ret + 769; smk->cur_frame++; smk->nextpos = avio_tell(s->pb); } else { if (smk->stream_id[smk->curstream] < 0) return AVERROR_INVALIDDATA; if (av_new_packet(pkt, smk->buf_sizes[smk->curstream])) return AVERROR(ENOMEM); memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]); pkt->size = smk->buf_sizes[smk->curstream]; pkt->stream_index = smk->stream_id[smk->curstream]; pkt->pts = smk->aud_pts[smk->curstream]; smk->aud_pts[smk->curstream] += AV_RL32(pkt->data); smk->curstream--; } return 0; } | 562 |
1 | static int sctp_setsockopt_hmac_ident(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_hmacalgo *hmacs;
int err;
if (optlen < sizeof(struct sctp_hmacalgo))
return -EINVAL;
hmacs = kmalloc(optlen, GFP_KERNEL);
if (!hmacs)
return -ENOMEM;
if (copy_from_user(hmacs, optval, optlen)) {
err = -EFAULT;
goto out;
}
if (hmacs->shmac_num_idents == 0 ||
hmacs->shmac_num_idents > SCTP_AUTH_NUM_HMACS) {
err = -EINVAL;
goto out;
}
err = sctp_auth_ep_set_hmacs(sctp_sk(sk)->ep, hmacs);
out:
kfree(hmacs);
return err;
} | 563 |
1 | static int sctp_getsockopt_active_key(struct sock *sk, int len,
char __user *optval, int __user *optlen)
{
struct sctp_authkeyid val;
struct sctp_association *asoc;
if (len < sizeof(struct sctp_authkeyid))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid)))
return -EFAULT;
asoc = sctp_id2assoc(sk, val.scact_assoc_id);
if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP))
return -EINVAL;
if (asoc)
val.scact_keynumber = asoc->active_key_id;
else
val.scact_keynumber = sctp_sk(sk)->ep->active_key_id;
return 0;
} | 564 |
1 | static void wm8750_audio_out_cb(void *opaque, int free_b) { struct wm8750_s *s = (struct wm8750_s *) opaque; wm8750_out_flush(s); s->req_out = free_b; s->data_req(s->opaque, free_b >> 2, s->req_in >> 2); } | 565 |
0 | void Set(const CString& sLine) {
const CString sVar = sLine.Token(1).AsLower();
CString sUserName = sLine.Token(2);
CString sValue = sLine.Token(3, true);
if (sValue.empty()) {
PutModule(t_s("Usage: Set <variable> <username> <value>"));
return;
}
CUser* pUser = FindUser(sUserName);
if (!pUser) return;
if (sVar == "nick") {
pUser->SetNick(sValue);
PutModule("Nick = " + sValue);
} else if (sVar == "altnick") {
pUser->SetAltNick(sValue);
PutModule("AltNick = " + sValue);
} else if (sVar == "ident") {
pUser->SetIdent(sValue);
PutModule("Ident = " + sValue);
} else if (sVar == "realname") {
pUser->SetRealName(sValue);
PutModule("RealName = " + sValue);
} else if (sVar == "bindhost") {
if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) {
if (sValue.Equals(pUser->GetBindHost())) {
PutModule(t_s("This bind host is already set!"));
return;
}
pUser->SetBindHost(sValue);
PutModule("BindHost = " + sValue);
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "multiclients") {
bool b = sValue.ToBool();
pUser->SetMultiClients(b);
PutModule("MultiClients = " + CString(b));
} else if (sVar == "denyloadmod") {
if (GetUser()->IsAdmin()) {
bool b = sValue.ToBool();
pUser->SetDenyLoadMod(b);
PutModule("DenyLoadMod = " + CString(b));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "denysetbindhost") {
if (GetUser()->IsAdmin()) {
bool b = sValue.ToBool();
pUser->SetDenySetBindHost(b);
PutModule("DenySetBindHost = " + CString(b));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "defaultchanmodes") {
pUser->SetDefaultChanModes(sValue);
PutModule("DefaultChanModes = " + sValue);
} else if (sVar == "quitmsg") {
pUser->SetQuitMsg(sValue);
PutModule("QuitMsg = " + sValue);
} else if (sVar == "chanbuffersize" || sVar == "buffercount") {
unsigned int i = sValue.ToUInt();
// Admins don't have to honour the buffer limit
if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) {
PutModule("ChanBufferSize = " + sValue);
} else {
PutModule(t_f("Setting failed, limit for buffer size is {1}")(
CString(CZNC::Get().GetMaxBufferSize())));
}
} else if (sVar == "querybuffersize") {
unsigned int i = sValue.ToUInt();
// Admins don't have to honour the buffer limit
if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) {
PutModule("QueryBufferSize = " + sValue);
} else {
PutModule(t_f("Setting failed, limit for buffer size is {1}")(
CString(CZNC::Get().GetMaxBufferSize())));
}
} else if (sVar == "keepbuffer") {
// XXX compatibility crap, added in 0.207
bool b = !sValue.ToBool();
pUser->SetAutoClearChanBuffer(b);
PutModule("AutoClearChanBuffer = " + CString(b));
} else if (sVar == "autoclearchanbuffer") {
bool b = sValue.ToBool();
pUser->SetAutoClearChanBuffer(b);
PutModule("AutoClearChanBuffer = " + CString(b));
} else if (sVar == "autoclearquerybuffer") {
bool b = sValue.ToBool();
pUser->SetAutoClearQueryBuffer(b);
PutModule("AutoClearQueryBuffer = " + CString(b));
} else if (sVar == "password") {
const CString sSalt = CUtils::GetSalt();
const CString sHash = CUser::SaltedHash(sValue, sSalt);
pUser->SetPass(sHash, CUser::HASH_DEFAULT, sSalt);
PutModule(t_s("Password has been changed!"));
} else if (sVar == "maxjoins") {
unsigned int i = sValue.ToUInt();
pUser->SetMaxJoins(i);
PutModule("MaxJoins = " + CString(pUser->MaxJoins()));
} else if (sVar == "notraffictimeout") {
unsigned int i = sValue.ToUInt();
if (i < 30) {
PutModule(t_s("Timeout can't be less than 30 seconds!"));
} else {
pUser->SetNoTrafficTimeout(i);
PutModule("NoTrafficTimeout = " +
CString(pUser->GetNoTrafficTimeout()));
}
} else if (sVar == "maxnetworks") {
if (GetUser()->IsAdmin()) {
unsigned int i = sValue.ToUInt();
pUser->SetMaxNetworks(i);
PutModule("MaxNetworks = " + sValue);
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "maxquerybuffers") {
unsigned int i = sValue.ToUInt();
pUser->SetMaxQueryBuffers(i);
PutModule("MaxQueryBuffers = " + sValue);
} else if (sVar == "jointries") {
unsigned int i = sValue.ToUInt();
pUser->SetJoinTries(i);
PutModule("JoinTries = " + CString(pUser->JoinTries()));
} else if (sVar == "timezone") {
pUser->SetTimezone(sValue);
PutModule("Timezone = " + pUser->GetTimezone());
} else if (sVar == "admin") {
if (GetUser()->IsAdmin() && pUser != GetUser()) {
bool b = sValue.ToBool();
pUser->SetAdmin(b);
PutModule("Admin = " + CString(pUser->IsAdmin()));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "prependtimestamp") {
bool b = sValue.ToBool();
pUser->SetTimestampPrepend(b);
PutModule("PrependTimestamp = " + CString(b));
} else if (sVar == "appendtimestamp") {
bool b = sValue.ToBool();
pUser->SetTimestampAppend(b);
PutModule("AppendTimestamp = " + CString(b));
} else if (sVar == "authonlyviamodule") {
if (GetUser()->IsAdmin()) {
bool b = sValue.ToBool();
pUser->SetAuthOnlyViaModule(b);
PutModule("AuthOnlyViaModule = " + CString(b));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "timestampformat") {
pUser->SetTimestampFormat(sValue);
PutModule("TimestampFormat = " + sValue);
} else if (sVar == "dccbindhost") {
if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) {
pUser->SetDCCBindHost(sValue);
PutModule("DCCBindHost = " + sValue);
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "statusprefix") {
if (sVar.find_first_of(" \t\n") == CString::npos) {
pUser->SetStatusPrefix(sValue);
PutModule("StatusPrefix = " + sValue);
} else {
PutModule(t_s("That would be a bad idea!"));
}
}
#ifdef HAVE_I18N
else if (sVar == "language") {
auto mTranslations = CTranslationInfo::GetTranslations();
// TODO: maybe stop special-casing English
if (sValue == "en") {
pUser->SetLanguage("");
PutModule("Language is set to English");
} else if (mTranslations.count(sValue)) {
pUser->SetLanguage(sValue);
PutModule("Language = " + sValue);
} else {
VCString vsCodes = {"en"};
for (const auto it : mTranslations) {
vsCodes.push_back(it.first);
}
PutModule(t_f("Supported languages: {1}")(
CString(", ").Join(vsCodes.begin(), vsCodes.end())));
}
}
#endif
#ifdef HAVE_ICU
else if (sVar == "clientencoding") {
pUser->SetClientEncoding(sValue);
PutModule("ClientEncoding = " + pUser->GetClientEncoding());
}
#endif
else
PutModule(t_s("Error: Unknown variable"));
} | 566 |
0 | static void test_rfc2231_parser ( void ) {
const char * input = ";
key4*=us-ascii''foo" ";
key*2=ba%" ";
key2*0=a" ";
key3*0*=us-ascii'en'xyz" ";
key*0=\"foo\"" ";
key2*1*=b%25" ";
key3*1=plop%" ";
key*1=baz" ;
const char * output [ ] = {
"key" , "foobazba%" , "key2*" , "''ab%25" , "key3*" , "us-ascii'en'xyzplop%25" , "key4*" , "us-ascii''foo" , NULL }
;
struct rfc822_parser_context parser ;
const char * const * result ;
unsigned int i ;
test_begin ( "rfc2231 parser" ) ;
rfc822_parser_init ( & parser , ( const void * ) input , strlen ( input ) , NULL ) ;
test_assert ( rfc2231_parse ( & parser , & result ) == 0 ) ;
for ( i = 0 ;
output [ i ] != NULL && result [ i ] != NULL ;
i ++ ) test_assert ( strcmp ( output [ i ] , result [ i ] ) == 0 ) ;
rfc822_parser_deinit ( & parser ) ;
test_assert ( output [ i ] == NULL && result [ i ] == NULL ) ;
test_end ( ) ;
} | 567 |
1 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
char __user *optval, int __user *optlen)
{
struct sctp_hmac_algo_param *hmacs;
__u16 param_len;
hmacs = sctp_sk(sk)->ep->auth_hmacs_list;
param_len = ntohs(hmacs->param_hdr.length);
if (len < param_len)
return -EINVAL;
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, hmacs->hmac_ids, len))
return -EFAULT;
return 0;
} | 568 |
1 | static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg) { TCPCharDriver *s = chr->opaque; struct cmsghdr *cmsg; for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { int fd; if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) continue; fd = *((int *)CMSG_DATA(cmsg)); if (fd < 0) continue; #ifndef MSG_CMSG_CLOEXEC qemu_set_cloexec(fd); #endif if (s->msgfd != -1) close(s->msgfd); s->msgfd = fd; } } | 569 |
1 | void Set(const CString& sLine) {
const CString sVar = sLine.Token(1).AsLower();
CString sUserName = sLine.Token(2);
CString sValue = sLine.Token(3, true);
if (sValue.empty()) {
PutModule(t_s("Usage: Set <variable> <username> <value>"));
return;
}
CUser* pUser = FindUser(sUserName);
if (!pUser) return;
if (sVar == "nick") {
pUser->SetNick(sValue);
PutModule("Nick = " + sValue);
} else if (sVar == "altnick") {
pUser->SetAltNick(sValue);
PutModule("AltNick = " + sValue);
} else if (sVar == "ident") {
pUser->SetIdent(sValue);
PutModule("Ident = " + sValue);
} else if (sVar == "realname") {
pUser->SetRealName(sValue);
PutModule("RealName = " + sValue);
} else if (sVar == "bindhost") {
if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) {
if (sValue.Equals(pUser->GetBindHost())) {
PutModule(t_s("This bind host is already set!"));
return;
}
pUser->SetBindHost(sValue);
PutModule("BindHost = " + sValue);
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "multiclients") {
bool b = sValue.ToBool();
pUser->SetMultiClients(b);
PutModule("MultiClients = " + CString(b));
} else if (sVar == "denyloadmod") {
if (GetUser()->IsAdmin()) {
bool b = sValue.ToBool();
pUser->SetDenyLoadMod(b);
PutModule("DenyLoadMod = " + CString(b));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "denysetbindhost") {
if (GetUser()->IsAdmin()) {
bool b = sValue.ToBool();
pUser->SetDenySetBindHost(b);
PutModule("DenySetBindHost = " + CString(b));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "defaultchanmodes") {
pUser->SetDefaultChanModes(sValue);
PutModule("DefaultChanModes = " + sValue);
} else if (sVar == "quitmsg") {
pUser->SetQuitMsg(sValue);
PutModule("QuitMsg = " + sValue);
} else if (sVar == "chanbuffersize" || sVar == "buffercount") {
unsigned int i = sValue.ToUInt();
// Admins don't have to honour the buffer limit
if (pUser->SetChanBufferSize(i, GetUser()->IsAdmin())) {
PutModule("ChanBufferSize = " + sValue);
} else {
PutModule(t_f("Setting failed, limit for buffer size is {1}")(
CString(CZNC::Get().GetMaxBufferSize())));
}
} else if (sVar == "querybuffersize") {
unsigned int i = sValue.ToUInt();
// Admins don't have to honour the buffer limit
if (pUser->SetQueryBufferSize(i, GetUser()->IsAdmin())) {
PutModule("QueryBufferSize = " + sValue);
} else {
PutModule(t_f("Setting failed, limit for buffer size is {1}")(
CString(CZNC::Get().GetMaxBufferSize())));
}
} else if (sVar == "keepbuffer") {
// XXX compatibility crap, added in 0.207
bool b = !sValue.ToBool();
pUser->SetAutoClearChanBuffer(b);
PutModule("AutoClearChanBuffer = " + CString(b));
} else if (sVar == "autoclearchanbuffer") {
bool b = sValue.ToBool();
pUser->SetAutoClearChanBuffer(b);
PutModule("AutoClearChanBuffer = " + CString(b));
} else if (sVar == "autoclearquerybuffer") {
bool b = sValue.ToBool();
pUser->SetAutoClearQueryBuffer(b);
PutModule("AutoClearQueryBuffer = " + CString(b));
} else if (sVar == "password") {
const CString sSalt = CUtils::GetSalt();
const CString sHash = CUser::SaltedHash(sValue, sSalt);
pUser->SetPass(sHash, CUser::HASH_DEFAULT, sSalt);
PutModule(t_s("Password has been changed!"));
} else if (sVar == "maxjoins") {
unsigned int i = sValue.ToUInt();
pUser->SetMaxJoins(i);
PutModule("MaxJoins = " + CString(pUser->MaxJoins()));
} else if (sVar == "notraffictimeout") {
unsigned int i = sValue.ToUInt();
if (i < 30) {
PutModule(t_s("Timeout can't be less than 30 seconds!"));
} else {
pUser->SetNoTrafficTimeout(i);
PutModule("NoTrafficTimeout = " +
CString(pUser->GetNoTrafficTimeout()));
}
} else if (sVar == "maxnetworks") {
if (GetUser()->IsAdmin()) {
unsigned int i = sValue.ToUInt();
pUser->SetMaxNetworks(i);
PutModule("MaxNetworks = " + sValue);
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "maxquerybuffers") {
unsigned int i = sValue.ToUInt();
pUser->SetMaxQueryBuffers(i);
PutModule("MaxQueryBuffers = " + sValue);
} else if (sVar == "jointries") {
unsigned int i = sValue.ToUInt();
pUser->SetJoinTries(i);
PutModule("JoinTries = " + CString(pUser->JoinTries()));
} else if (sVar == "timezone") {
pUser->SetTimezone(sValue);
PutModule("Timezone = " + pUser->GetTimezone());
} else if (sVar == "admin") {
if (GetUser()->IsAdmin() && pUser != GetUser()) {
bool b = sValue.ToBool();
pUser->SetAdmin(b);
PutModule("Admin = " + CString(pUser->IsAdmin()));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "prependtimestamp") {
bool b = sValue.ToBool();
pUser->SetTimestampPrepend(b);
PutModule("PrependTimestamp = " + CString(b));
} else if (sVar == "appendtimestamp") {
bool b = sValue.ToBool();
pUser->SetTimestampAppend(b);
PutModule("AppendTimestamp = " + CString(b));
} else if (sVar == "authonlyviamodule") {
if (GetUser()->IsAdmin()) {
bool b = sValue.ToBool();
pUser->SetAuthOnlyViaModule(b);
PutModule("AuthOnlyViaModule = " + CString(b));
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "timestampformat") {
pUser->SetTimestampFormat(sValue);
PutModule("TimestampFormat = " + sValue);
} else if (sVar == "dccbindhost") {
if (!pUser->DenySetBindHost() || GetUser()->IsAdmin()) {
pUser->SetDCCBindHost(sValue);
PutModule("DCCBindHost = " + sValue);
} else {
PutModule(t_s("Access denied!"));
}
} else if (sVar == "statusprefix") {
if (sVar.find_first_of(" \t\n") == CString::npos) {
pUser->SetStatusPrefix(sValue);
PutModule("StatusPrefix = " + sValue);
} else {
PutModule(t_s("That would be a bad idea!"));
}
}
#ifdef HAVE_I18N
else if (sVar == "language") {
auto mTranslations = CTranslationInfo::GetTranslations();
// TODO: maybe stop special-casing English
if (sValue == "en") {
pUser->SetLanguage("");
PutModule("Language is set to English");
} else if (mTranslations.count(sValue)) {
pUser->SetLanguage(sValue);
PutModule("Language = " + sValue);
} else {
VCString vsCodes = {"en"};
for (const auto it : mTranslations) {
vsCodes.push_back(it.first);
}
PutModule(t_f("Supported languages: {1}")(
CString(", ").Join(vsCodes.begin(), vsCodes.end())));
}
}
#endif
#ifdef HAVE_ICU
else if (sVar == "clientencoding") {
pUser->SetClientEncoding(sValue);
PutModule("ClientEncoding = " + sValue);
}
#endif
else
PutModule(t_s("Error: Unknown variable"));
} | 570 |
0 | iakerb_gss_export_sec_context(OM_uint32 *minor_status,
gss_ctx_id_t *context_handle,
gss_buffer_t interprocess_token)
{
OM_uint32 maj;
iakerb_ctx_id_t ctx = (iakerb_ctx_id_t)context_handle;
/* We don't currently support exporting partially established contexts. */
if (!ctx->established)
return GSS_S_UNAVAILABLE;
maj = krb5_gss_export_sec_context(minor_status, &ctx->gssc,
interprocess_token);
if (ctx->gssc == GSS_C_NO_CONTEXT) {
iakerb_release_context(ctx);
*context_handle = GSS_C_NO_CONTEXT;
}
return maj;
} | 571 |
1 | static hb_feature_t * feature_reference ( hb_feature_t * g ) {
hb_feature_t * c = ( hb_feature_t * ) calloc ( 1 , sizeof ( hb_feature_t ) ) ;
if ( unlikely ( ! c ) ) return NULL ;
* c = * g ;
return c ;
} | 572 |
0 | static Datum ExecEvalConvertRowtype ( ConvertRowtypeExprState * cstate , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) {
ConvertRowtypeExpr * convert = ( ConvertRowtypeExpr * ) cstate -> xprstate . expr ;
HeapTuple result ;
Datum tupDatum ;
HeapTupleHeader tuple ;
HeapTupleData tmptup ;
tupDatum = ExecEvalExpr ( cstate -> arg , econtext , isNull , isDone ) ;
if ( * isNull ) return tupDatum ;
tuple = DatumGetHeapTupleHeader ( tupDatum ) ;
if ( cstate -> indesc == NULL ) {
get_cached_rowtype ( exprType ( ( Node * ) convert -> arg ) , - 1 , & cstate -> indesc , econtext ) ;
cstate -> initialized = false ;
}
if ( cstate -> outdesc == NULL ) {
get_cached_rowtype ( convert -> resulttype , - 1 , & cstate -> outdesc , econtext ) ;
cstate -> initialized = false ;
}
Assert ( HeapTupleHeaderGetTypeId ( tuple ) == cstate -> indesc -> tdtypeid || HeapTupleHeaderGetTypeId ( tuple ) == RECORDOID ) ;
if ( ! cstate -> initialized ) {
MemoryContext old_cxt ;
old_cxt = MemoryContextSwitchTo ( econtext -> ecxt_per_query_memory ) ;
cstate -> map = convert_tuples_by_name ( cstate -> indesc , cstate -> outdesc , gettext_noop ( "could not convert row type" ) ) ;
cstate -> initialized = true ;
MemoryContextSwitchTo ( old_cxt ) ;
}
if ( cstate -> map == NULL ) return tupDatum ;
tmptup . t_len = HeapTupleHeaderGetDatumLength ( tuple ) ;
tmptup . t_data = tuple ;
result = do_convert_tuple ( & tmptup , cstate -> map ) ;
return HeapTupleGetDatum ( result ) ;
} | 573 |
0 | void CIRCNetwork::SetEncoding(const CString& s) {
m_sEncoding = CZNC::Get().FixupEncoding(s);
if (GetIRCSock()) {
GetIRCSock()->SetEncoding(m_sEncoding);
}
} | 574 |
0 | void ga_channel_free(GAChannel *c) { if (c->method == GA_CHANNEL_UNIX_LISTEN && c->listen_channel) { ga_channel_listen_close(c); } if (c->client_channel) { ga_channel_client_close(c); } g_free(c); } | 575 |
1 | static int sctp_setsockopt_active_key(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_authkeyid val;
struct sctp_association *asoc;
if (optlen != sizeof(struct sctp_authkeyid))
return -EINVAL;
if (copy_from_user(&val, optval, optlen))
return -EFAULT;
asoc = sctp_id2assoc(sk, val.scact_assoc_id);
if (!asoc && val.scact_assoc_id && sctp_style(sk, UDP))
return -EINVAL;
return sctp_auth_set_active_key(sctp_sk(sk)->ep, asoc,
val.scact_keynumber);
} | 576 |
0 | ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr, Error **errp) { RAMBlock *new_block; ram_addr_t addr; Error *local_err = NULL; size = TARGET_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; new_block->used_length = size; new_block->max_length = max_size; new_block->fd = -1; new_block->host = host; if (host) { new_block->flags |= RAM_PREALLOC; } addr = ram_block_add(new_block, &local_err); if (local_err) { g_free(new_block); error_propagate(errp, local_err); return -1; } return addr; } | 577 |
1 | void CIRCNetwork::SetEncoding(const CString& s) {
m_sEncoding = s;
if (GetIRCSock()) {
GetIRCSock()->SetEncoding(s);
}
} | 578 |
1 | static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
char __user *optval, int __user *optlen)
{
struct sctp_authchunks __user *p = (void __user *)optval;
struct sctp_authchunks val;
struct sctp_association *asoc;
struct sctp_chunks_param *ch;
u32 num_chunks;
char __user *to;
if (len <= sizeof(struct sctp_authchunks))
return -EINVAL;
if (copy_from_user(&val, p, sizeof(struct sctp_authchunks)))
return -EFAULT;
to = p->gauth_chunks;
asoc = sctp_id2assoc(sk, val.gauth_assoc_id);
if (!asoc)
return -EINVAL;
ch = asoc->peer.peer_chunks;
/* See if the user provided enough room for all the data */
num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t);
if (len < num_chunks)
return -EINVAL;
len = num_chunks;
if (put_user(len, optlen))
return -EFAULT;
if (put_user(num_chunks, &p->gauth_number_of_chunks))
return -EFAULT;
if (copy_to_user(to, ch->chunks, len))
return -EFAULT;
return 0;
} | 579 |
1 | static void event_process_active ( struct event_base * base ) {
struct event * ev ;
struct event_list * activeq = NULL ;
int i ;
short ncalls ;
for ( i = 0 ;
i < base -> nactivequeues ;
++ i ) {
if ( TAILQ_FIRST ( base -> activequeues [ i ] ) != NULL ) {
activeq = base -> activequeues [ i ] ;
break ;
}
}
assert ( activeq != NULL ) ;
for ( ev = TAILQ_FIRST ( activeq ) ;
ev ;
ev = TAILQ_FIRST ( activeq ) ) {
if ( ev -> ev_events & EV_PERSIST ) event_queue_remove ( base , ev , EVLIST_ACTIVE ) ;
else event_del ( ev ) ;
ncalls = ev -> ev_ncalls ;
ev -> ev_pncalls = & ncalls ;
while ( ncalls ) {
ncalls -- ;
ev -> ev_ncalls = ncalls ;
( * ev -> ev_callback ) ( ( int ) ev -> ev_fd , ev -> ev_res , ev -> ev_arg ) ;
if ( base -> event_break ) return ;
}
}
} | 581 |
0 | void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word) { uint32_t type; if (io_int_word & IO_INT_WORD_AI) { type = KVM_S390_INT_IO(1, 0, 0, 0); } else { type = ((subchannel_id & 0xff00) << 24) | ((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16); } kvm_s390_interrupt_internal(cpu, type, ((uint32_t)subchannel_id << 16) | subchannel_nr, ((uint64_t)io_int_parm << 32) | io_int_word, 1); } | 583 |
1 | static int sctp_setsockopt_auth_key(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_authkey *authkey;
struct sctp_association *asoc;
int ret;
if (!sctp_auth_enable)
return -EACCES;
if (optlen <= sizeof(struct sctp_authkey))
return -EINVAL;
authkey = kmalloc(optlen, GFP_KERNEL);
if (!authkey)
return -ENOMEM;
if (copy_from_user(authkey, optval, optlen)) {
ret = -EFAULT;
goto out;
}
asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) {
ret = -EINVAL;
goto out;
}
ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey);
out:
kfree(authkey);
return ret;
} | 584 |
0 | static void elcr_ioport_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { PICCommonState *s = opaque; s->elcr = val & s->elcr_mask; } | 585 |
1 | iakerb_gss_init_sec_context(OM_uint32 *minor_status,
gss_cred_id_t claimant_cred_handle,
gss_ctx_id_t *context_handle,
gss_name_t target_name,
gss_OID mech_type,
OM_uint32 req_flags,
OM_uint32 time_req,
gss_channel_bindings_t input_chan_bindings,
gss_buffer_t input_token,
gss_OID *actual_mech_type,
gss_buffer_t output_token,
OM_uint32 *ret_flags,
OM_uint32 *time_rec)
{
OM_uint32 major_status = GSS_S_FAILURE;
krb5_error_code code;
iakerb_ctx_id_t ctx;
krb5_gss_cred_id_t kcred;
krb5_gss_name_t kname;
krb5_boolean cred_locked = FALSE;
int initialContextToken = (*context_handle == GSS_C_NO_CONTEXT);
if (initialContextToken) {
code = iakerb_alloc_context(&ctx);
if (code != 0) {
*minor_status = code;
goto cleanup;
}
if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) {
major_status = iakerb_gss_acquire_cred(minor_status, NULL,
GSS_C_INDEFINITE,
GSS_C_NULL_OID_SET,
GSS_C_INITIATE,
&ctx->defcred, NULL, NULL);
if (GSS_ERROR(major_status))
goto cleanup;
claimant_cred_handle = ctx->defcred;
}
} else {
ctx = (iakerb_ctx_id_t)*context_handle;
if (claimant_cred_handle == GSS_C_NO_CREDENTIAL)
claimant_cred_handle = ctx->defcred;
}
kname = (krb5_gss_name_t)target_name;
major_status = kg_cred_resolve(minor_status, ctx->k5c,
claimant_cred_handle, target_name);
if (GSS_ERROR(major_status))
goto cleanup;
cred_locked = TRUE;
kcred = (krb5_gss_cred_id_t)claimant_cred_handle;
major_status = GSS_S_FAILURE;
if (initialContextToken) {
code = iakerb_get_initial_state(ctx, kcred, kname, time_req,
&ctx->state);
if (code != 0) {
*minor_status = code;
goto cleanup;
}
*context_handle = (gss_ctx_id_t)ctx;
}
if (ctx->state != IAKERB_AP_REQ) {
/* We need to do IAKERB. */
code = iakerb_initiator_step(ctx,
kcred,
kname,
time_req,
input_token,
output_token);
if (code == KRB5_BAD_MSIZE)
major_status = GSS_S_DEFECTIVE_TOKEN;
if (code != 0) {
*minor_status = code;
goto cleanup;
}
}
if (ctx->state == IAKERB_AP_REQ) {
krb5_gss_ctx_ext_rec exts;
if (cred_locked) {
k5_mutex_unlock(&kcred->lock);
cred_locked = FALSE;
}
iakerb_make_exts(ctx, &exts);
if (ctx->gssc == GSS_C_NO_CONTEXT)
input_token = GSS_C_NO_BUFFER;
/* IAKERB is finished, or we skipped to Kerberos directly. */
major_status = krb5_gss_init_sec_context_ext(minor_status,
(gss_cred_id_t) kcred,
&ctx->gssc,
target_name,
(gss_OID)gss_mech_iakerb,
req_flags,
time_req,
input_chan_bindings,
input_token,
NULL,
output_token,
ret_flags,
time_rec,
&exts);
if (major_status == GSS_S_COMPLETE) {
*context_handle = ctx->gssc;
ctx->gssc = GSS_C_NO_CONTEXT;
iakerb_release_context(ctx);
}
if (actual_mech_type != NULL)
*actual_mech_type = (gss_OID)gss_mech_krb5;
} else {
if (actual_mech_type != NULL)
*actual_mech_type = (gss_OID)gss_mech_iakerb;
if (ret_flags != NULL)
*ret_flags = 0;
if (time_rec != NULL)
*time_rec = 0;
major_status = GSS_S_CONTINUE_NEEDED;
}
cleanup:
if (cred_locked)
k5_mutex_unlock(&kcred->lock);
if (initialContextToken && GSS_ERROR(major_status)) {
iakerb_release_context(ctx);
*context_handle = GSS_C_NO_CONTEXT;
}
return major_status;
} | 586 |
0 | int jbig2_decode_generic_region ( Jbig2Ctx * ctx , Jbig2Segment * segment , const Jbig2GenericRegionParams * params , Jbig2ArithState * as , Jbig2Image * image , Jbig2ArithCx * GB_stats ) {
const int8_t * gbat = params -> gbat ;
if ( image -> stride * image -> height > ( 1 << 24 ) && segment -> data_length < image -> stride * image -> height / 256 ) {
return jbig2_error ( ctx , JBIG2_SEVERITY_FATAL , segment -> number , "region is far larger than data provided (%d << %d), aborting to prevent DOS" , segment -> data_length , image -> stride * image -> height ) ;
}
if ( ! params -> MMR && params -> TPGDON ) return jbig2_decode_generic_region_TPGDON ( ctx , segment , params , as , image , GB_stats ) ;
if ( ! params -> MMR && params -> GBTEMPLATE == 0 ) {
if ( gbat [ 0 ] == + 3 && gbat [ 1 ] == - 1 && gbat [ 2 ] == - 3 && gbat [ 3 ] == - 1 && gbat [ 4 ] == + 2 && gbat [ 5 ] == - 2 && gbat [ 6 ] == - 2 && gbat [ 7 ] == - 2 ) return jbig2_decode_generic_template0 ( ctx , segment , params , as , image , GB_stats ) ;
else return jbig2_decode_generic_template0_unopt ( ctx , segment , params , as , image , GB_stats ) ;
}
else if ( ! params -> MMR && params -> GBTEMPLATE == 1 ) return jbig2_decode_generic_template1 ( ctx , segment , params , as , image , GB_stats ) ;
else if ( ! params -> MMR && params -> GBTEMPLATE == 2 ) {
if ( gbat [ 0 ] == 3 && gbat [ 1 ] == - 1 ) return jbig2_decode_generic_template2a ( ctx , segment , params , as , image , GB_stats ) ;
else return jbig2_decode_generic_template2 ( ctx , segment , params , as , image , GB_stats ) ;
}
else if ( ! params -> MMR && params -> GBTEMPLATE == 3 ) {
if ( gbat [ 0 ] == 2 && gbat [ 1 ] == - 1 ) return jbig2_decode_generic_template3_unopt ( ctx , segment , params , as , image , GB_stats ) ;
else return jbig2_decode_generic_template3_unopt ( ctx , segment , params , as , image , GB_stats ) ;
}
{
int i ;
for ( i = 0 ;
i < 8 ;
i ++ ) jbig2_error ( ctx , JBIG2_SEVERITY_DEBUG , segment -> number , "gbat[%d] = %d" , i , params -> gbat [ i ] ) ;
}
jbig2_error ( ctx , JBIG2_SEVERITY_WARNING , segment -> number , "decode_generic_region: MMR=%d, GBTEMPLATE=%d NYI" , params -> MMR , params -> GBTEMPLATE ) ;
return - 1 ;
} | 587 |
1 | void CUser::SetClientEncoding(const CString& s) {
m_sClientEncoding = s;
for (CClient* pClient : GetAllClients()) {
pClient->SetEncoding(s);
}
} | 588 |
1 | static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp)
{
struct sctp_auth_bytes *key;
/* Allocate the shared key */
key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp);
if (!key)
return NULL;
key->len = key_len;
atomic_set(&key->refcnt, 1);
SCTP_DBG_OBJCNT_INC(keys);
return key;
} | 589 |
0 | static gboolean destroy_srcdsc ( gpointer k _U_ , gpointer v , gpointer p _U_ ) {
k12_src_desc_t * rec = ( k12_src_desc_t * ) v ;
g_free ( rec -> input_name ) ;
g_free ( rec -> stack_file ) ;
g_free ( rec ) ;
return TRUE ;
} | 590 |
1 | static int sctp_setsockopt_auth_key(struct sock *sk,
char __user *optval,
int optlen)
{
struct sctp_authkey *authkey;
struct sctp_association *asoc;
int ret;
if (!sctp_auth_enable)
return -EACCES;
if (optlen <= sizeof(struct sctp_authkey))
return -EINVAL;
authkey = kmalloc(optlen, GFP_KERNEL);
if (!authkey)
return -ENOMEM;
if (copy_from_user(authkey, optval, optlen)) {
ret = -EFAULT;
goto out;
}
if (authkey->sca_keylength > optlen) {
ret = -EINVAL;
goto out;
}
asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) {
ret = -EINVAL;
goto out;
}
ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey);
out:
kfree(authkey);
return ret;
} | 591 |
0 | void nonono(const char* file, int line, const char* msg) { fprintf(stderr, "Nonono! %s:%d %s\n", file, line, msg); exit(-5); } | 592 |
0 | CString CZNC::FixupEncoding(const CString& sEncoding) const {
if (!m_uiForceEncoding) {
return sEncoding;
}
if (sEncoding.empty()) {
return "UTF-8";
}
const char* sRealEncoding = sEncoding.c_str();
if (sEncoding[0] == '*' || sEncoding[0] == '^') {
sRealEncoding++;
}
if (!*sRealEncoding) {
return "UTF-8";
}
#ifdef HAVE_ICU
UErrorCode e = U_ZERO_ERROR;
UConverter* cnv = ucnv_open(sRealEncoding, &e);
if (cnv) {
ucnv_close(cnv);
}
if (U_FAILURE(e)) {
return "UTF-8";
}
#endif
return sEncoding;
} | 593 |
0 | int proto_get_first_protocol ( void * * cookie ) {
protocol_t * protocol ;
if ( protocols == NULL ) return - 1 ;
* cookie = protocols ;
protocol = ( protocol_t * ) protocols -> data ;
return protocol -> proto_id ;
} | 594 |
0 | static void spitz_i2c_setup(PXA2xxState *cpu) { /* Attach the CPU on one end of our I2C bus. */ i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]); #ifdef HAS_AUDIO DeviceState *wm; /* Attach a WM8750 to the bus */ wm = i2c_create_slave(bus, "wm8750", 0); spitz_wm8750_addr(wm, 0, 0); pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM, qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]); /* .. and to the sound interface. */ cpu->i2s->opaque = wm; cpu->i2s->codec_out = wm8750_dac_dat; cpu->i2s->codec_in = wm8750_adc_dat; wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s); #endif } | 595 |
1 | CString CZNC::FixupEncoding(const CString& sEncoding) const {
if (sEncoding.empty() && m_uiForceEncoding) {
return "UTF-8";
}
return sEncoding;
} | 596 |
1 | int __init sysenter_setup(void)
{
syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
#ifdef CONFIG_COMPAT_VDSO
__set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_READONLY);
printk("Compat vDSO mapped to %08lx.\n", __fix_to_virt(FIX_VDSO));
#endif
if (!boot_cpu_has(X86_FEATURE_SEP)) {
memcpy(syscall_page,
&vsyscall_int80_start,
&vsyscall_int80_end - &vsyscall_int80_start);
return 0;
}
memcpy(syscall_page,
&vsyscall_sysenter_start,
&vsyscall_sysenter_end - &vsyscall_sysenter_start);
return 0;
} | 597 |
0 | void macio_ide_init_drives ( MACIOIDEState * s , DriveInfo * * hd_table ) {
int i ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
if ( hd_table [ i ] ) {
ide_create_drive ( & s -> bus , i , hd_table [ i ] ) ;
}
}
} | 602 |
0 | void restore_boot_order(void *opaque) { char *normal_boot_order = opaque; static int first = 1; /* Restore boot order and remove ourselves after the first boot */ if (first) { first = 0; return; } qemu_boot_set(normal_boot_order); qemu_unregister_reset(restore_boot_order, normal_boot_order); g_free(normal_boot_order); } | 603 |
0 | void CZNC::ForceEncoding() {
m_uiForceEncoding++;
#ifdef HAVE_ICU
for (Csock* pSock : GetManager()) {
pSock->SetEncoding(FixupEncoding(pSock->GetEncoding()));
}
#endif
} | 604 |
1 | static struct page *syscall_nopage(struct vm_area_struct *vma,
unsigned long adr, int *type)
{
struct page *p = virt_to_page(adr - vma->vm_start + syscall_page);
get_page(p);
return p;
} | 605 |
0 | static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) { VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev); VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev, base); VirtIOSerialBus *bus = DO_UPCAST(VirtIOSerialBus, qbus, qdev->parent_bus); int ret, max_nr_ports; bool plugging_port0; port->vser = bus->vser; port->bh = qemu_bh_new(flush_queued_data_bh, port); /* * Is the first console port we're seeing? If so, put it up at * location 0. This is done for backward compatibility (old * kernel, new qemu). */ plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0); if (find_port_by_id(port->vser, port->id)) { error_report("virtio-serial-bus: A port already exists at id %u\n", port->id); return -1; } if (port->id == VIRTIO_CONSOLE_BAD_ID) { if (plugging_port0) { port->id = 0; } else { port->id = find_free_port_id(port->vser); if (port->id == VIRTIO_CONSOLE_BAD_ID) { error_report("virtio-serial-bus: Maximum port limit for this device reached\n"); return -1; } } } max_nr_ports = tswap32(port->vser->config.max_nr_ports); if (port->id >= max_nr_ports) { error_report("virtio-serial-bus: Out-of-range port id specified, max. allowed: %u\n", max_nr_ports - 1); return -1; } port->info = info; ret = info->init(port); if (ret) { return ret; } if (!use_multiport(port->vser)) { /* * Allow writes to guest in this case; we have no way of * knowing if a guest port is connected. */ port->guest_connected = true; } port->elem.out_num = 0; QTAILQ_INSERT_TAIL(&port->vser->ports, port, next); port->ivq = port->vser->ivqs[port->id]; port->ovq = port->vser->ovqs[port->id]; add_port(port->vser, port->id); /* Send an update to the guest about this new port added */ virtio_notify_config(&port->vser->vdev); return ret; } | 606 |
0 | static inline void set_num_712 ( unsigned char * p , char value ) {
* ( ( char * ) p ) = value ;
} | 607 |
1 | int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
{
struct vm_area_struct *vma;
struct mm_struct *mm = current->mm;
unsigned long addr;
int ret;
down_write(&mm->mmap_sem);
addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
if (IS_ERR_VALUE(addr)) {
ret = addr;
goto up_fail;
}
vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (!vma) {
ret = -ENOMEM;
goto up_fail;
}
vma->vm_start = addr;
vma->vm_end = addr + PAGE_SIZE;
/* MAYWRITE to allow gdb to COW and set breakpoints */
vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE;
/*
* Make sure the vDSO gets into every core dump.
* Dumping its contents makes post-mortem fully interpretable later
* without matching up the same kernel and hardware config to see
* what PC values meant.
*/
vma->vm_flags |= VM_ALWAYSDUMP;
vma->vm_flags |= mm->def_flags;
vma->vm_page_prot = protection_map[vma->vm_flags & 7];
vma->vm_ops = &syscall_vm_ops;
vma->vm_mm = mm;
ret = insert_vm_struct(mm, vma);
if (unlikely(ret)) {
kmem_cache_free(vm_area_cachep, vma);
goto up_fail;
}
current->mm->context.vdso = (void *)addr;
current_thread_info()->sysenter_return =
(void *)VDSO_SYM(&SYSENTER_RETURN);
mm->total_vm++;
up_fail:
up_write(&mm->mmap_sem);
return ret;
} | 608 |
1 | sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd )
{
struct net_local *nl = (struct net_local *) dev->priv;
struct sbni_flags flags;
int error = 0;
#ifdef CONFIG_SBNI_MULTILINE
struct net_device *slave_dev;
char slave_name[ 8 ];
#endif
switch( cmd ) {
case SIOCDEVGETINSTATS :
if (copy_to_user( ifr->ifr_data, &nl->in_stats,
sizeof(struct sbni_in_stats) ))
error = -EFAULT;
break;
case SIOCDEVRESINSTATS :
if( current->euid != 0 ) /* root only */
return -EPERM;
memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) );
break;
case SIOCDEVGHWSTATE :
flags.mac_addr = *(u32 *)(dev->dev_addr + 3);
flags.rate = nl->csr1.rate;
flags.slow_mode = (nl->state & FL_SLOW_MODE) != 0;
flags.rxl = nl->cur_rxl_index;
flags.fixed_rxl = nl->delta_rxl == 0;
if (copy_to_user( ifr->ifr_data, &flags, sizeof flags ))
error = -EFAULT;
break;
case SIOCDEVSHWSTATE :
if( current->euid != 0 ) /* root only */
return -EPERM;
spin_lock( &nl->lock );
flags = *(struct sbni_flags*) &ifr->ifr_ifru;
if( flags.fixed_rxl )
nl->delta_rxl = 0,
nl->cur_rxl_index = flags.rxl;
else
nl->delta_rxl = DEF_RXL_DELTA,
nl->cur_rxl_index = DEF_RXL;
nl->csr1.rxl = rxl_tab[ nl->cur_rxl_index ];
nl->csr1.rate = flags.rate;
outb( *(u8 *)&nl->csr1 | PR_RES, dev->base_addr + CSR1 );
spin_unlock( &nl->lock );
break;
#ifdef CONFIG_SBNI_MULTILINE
case SIOCDEVENSLAVE :
if( current->euid != 0 ) /* root only */
return -EPERM;
if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name ))
return -EFAULT;
slave_dev = dev_get_by_name(&init_net, slave_name );
if( !slave_dev || !(slave_dev->flags & IFF_UP) ) {
printk( KERN_ERR "%s: trying to enslave non-active "
"device %s\n", dev->name, slave_name );
return -EPERM;
}
return enslave( dev, slave_dev );
case SIOCDEVEMANSIPATE :
if( current->euid != 0 ) /* root only */
return -EPERM;
return emancipate( dev );
#endif /* CONFIG_SBNI_MULTILINE */
default :
return -EOPNOTSUPP;
}
return error;
} | 609 |
0 | void block_job_pause(BlockJob *job) { job->paused = true; } | 610 |
0 | int gs_pop_string ( gs_main_instance * minst , gs_string * result ) {
i_ctx_t * i_ctx_p = minst -> i_ctx_p ;
ref vref ;
int code = pop_value ( i_ctx_p , & vref ) ;
if ( code < 0 ) return code ;
switch ( r_type ( & vref ) ) {
case t_name : name_string_ref ( minst -> heap , & vref , & vref ) ;
code = 1 ;
goto rstr ;
case t_string : code = ( r_has_attr ( & vref , a_write ) ? 0 : 1 ) ;
rstr : result -> data = vref . value . bytes ;
result -> size = r_size ( & vref ) ;
break ;
default : return_error ( gs_error_typecheck ) ;
}
ref_stack_pop ( & o_stack , 1 ) ;
return code ;
} | 611 |
0 | static call_list * call_list_append ( call_list * list , guint16 scallno ) {
call_list * node = wmem_new0 ( wmem_packet_scope ( ) , call_list ) ;
node -> scallno = scallno ;
if ( list ) {
call_list * cur = list ;
while ( cur -> next ) {
cur = cur -> next ;
}
cur -> next = node ;
return list ;
}
else {
return node ;
}
} | 612 |
0 | static void prop_get_fdt(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); Error *err = NULL; int fdt_offset_next, fdt_offset, fdt_depth; void *fdt; if (!drc->fdt) { visit_type_null(v, NULL, errp); return; } fdt = drc->fdt; fdt_offset = drc->fdt_start_offset; fdt_depth = 0; do { const char *name = NULL; const struct fdt_property *prop = NULL; int prop_len = 0, name_len = 0; uint32_t tag; tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next); switch (tag) { case FDT_BEGIN_NODE: fdt_depth++; name = fdt_get_name(fdt, fdt_offset, &name_len); visit_start_struct(v, name, NULL, 0, &err); if (err) { error_propagate(errp, err); return; } break; case FDT_END_NODE: /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */ g_assert(fdt_depth > 0); visit_check_struct(v, &err); visit_end_struct(v); if (err) { error_propagate(errp, err); return; } fdt_depth--; break; case FDT_PROP: { int i; prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len); name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); visit_start_list(v, name, &err); if (err) { error_propagate(errp, err); return; } for (i = 0; i < prop_len; i++) { visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err); if (err) { error_propagate(errp, err); return; } } visit_end_list(v); break; } default: error_setg(&error_abort, "device FDT in unexpected state: %d", tag); } fdt_offset = fdt_offset_next; } while (fdt_depth != 0); } | 614 |
0 | static int pack_options_allow_reuse ( void ) {
return allow_ofs_delta ;
} | 615 |
1 | direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
const struct iovec *iov, loff_t offset, unsigned long nr_segs,
unsigned blkbits, get_block_t get_block, dio_iodone_t end_io,
struct dio *dio)
{
unsigned long user_addr;
unsigned long flags;
int seg;
ssize_t ret = 0;
ssize_t ret2;
size_t bytes;
dio->bio = NULL;
dio->inode = inode;
dio->rw = rw;
dio->blkbits = blkbits;
dio->blkfactor = inode->i_blkbits - blkbits;
dio->start_zero_done = 0;
dio->size = 0;
dio->block_in_file = offset >> blkbits;
dio->blocks_available = 0;
dio->cur_page = NULL;
dio->boundary = 0;
dio->reap_counter = 0;
dio->get_block = get_block;
dio->end_io = end_io;
dio->map_bh.b_private = NULL;
dio->map_bh.b_state = 0;
dio->final_block_in_bio = -1;
dio->next_block_for_io = -1;
dio->page_errors = 0;
dio->io_error = 0;
dio->result = 0;
dio->iocb = iocb;
dio->i_size = i_size_read(inode);
spin_lock_init(&dio->bio_lock);
dio->refcount = 1;
dio->bio_list = NULL;
dio->waiter = NULL;
/*
* In case of non-aligned buffers, we may need 2 more
* pages since we need to zero out first and last block.
*/
if (unlikely(dio->blkfactor))
dio->pages_in_io = 2;
else
dio->pages_in_io = 0;
for (seg = 0; seg < nr_segs; seg++) {
user_addr = (unsigned long)iov[seg].iov_base;
dio->pages_in_io +=
((user_addr+iov[seg].iov_len +PAGE_SIZE-1)/PAGE_SIZE
- user_addr/PAGE_SIZE);
}
for (seg = 0; seg < nr_segs; seg++) {
user_addr = (unsigned long)iov[seg].iov_base;
dio->size += bytes = iov[seg].iov_len;
/* Index into the first page of the first block */
dio->first_block_in_page = (user_addr & ~PAGE_MASK) >> blkbits;
dio->final_block_in_request = dio->block_in_file +
(bytes >> blkbits);
/* Page fetching state */
dio->head = 0;
dio->tail = 0;
dio->curr_page = 0;
dio->total_pages = 0;
if (user_addr & (PAGE_SIZE-1)) {
dio->total_pages++;
bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1));
}
dio->total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE;
dio->curr_user_address = user_addr;
ret = do_direct_IO(dio);
dio->result += iov[seg].iov_len -
((dio->final_block_in_request - dio->block_in_file) <<
blkbits);
if (ret) {
dio_cleanup(dio);
break;
}
} /* end iovec loop */
if (ret == -ENOTBLK && (rw & WRITE)) {
/*
* The remaining part of the request will be
* be handled by buffered I/O when we return
*/
ret = 0;
}
/*
* There may be some unwritten disk at the end of a part-written
* fs-block-sized block. Go zero that now.
*/
dio_zero_block(dio, 1);
if (dio->cur_page) {
ret2 = dio_send_cur_page(dio);
if (ret == 0)
ret = ret2;
page_cache_release(dio->cur_page);
dio->cur_page = NULL;
}
if (dio->bio)
dio_bio_submit(dio);
/* All IO is now issued, send it on its way */
blk_run_address_space(inode->i_mapping);
/*
* It is possible that, we return short IO due to end of file.
* In that case, we need to release all the pages we got hold on.
*/
dio_cleanup(dio);
/*
* All block lookups have been performed. For READ requests
* we can let i_mutex go now that its achieved its purpose
* of protecting us from looking up uninitialized blocks.
*/
if ((rw == READ) && (dio->lock_type == DIO_LOCKING))
mutex_unlock(&dio->inode->i_mutex);
/*
* The only time we want to leave bios in flight is when a successful
* partial aio read or full aio write have been setup. In that case
* bio completion will call aio_complete. The only time it's safe to
* call aio_complete is when we return -EIOCBQUEUED, so we key on that.
* This had *better* be the only place that raises -EIOCBQUEUED.
*/
BUG_ON(ret == -EIOCBQUEUED);
if (dio->is_async && ret == 0 && dio->result &&
((rw & READ) || (dio->result == dio->size)))
ret = -EIOCBQUEUED;
if (ret != -EIOCBQUEUED)
dio_await_completion(dio);
/*
* Sync will always be dropping the final ref and completing the
* operation. AIO can if it was a broken operation described above or
* in fact if all the bios race to complete before we get here. In
* that case dio_complete() translates the EIOCBQUEUED into the proper
* return code that the caller will hand to aio_complete().
*
* This is managed by the bio_lock instead of being an atomic_t so that
* completion paths can drop their ref and use the remaining count to
* decide to wake the submission path atomically.
*/
spin_lock_irqsave(&dio->bio_lock, flags);
ret2 = --dio->refcount;
spin_unlock_irqrestore(&dio->bio_lock, flags);
if (ret2 == 0) {
ret = dio_complete(dio, offset, ret);
kfree(dio);
} else
BUG_ON(ret != -EIOCBQUEUED);
return ret;
} | 616 |
0 | int bdrv_pwrite(BlockDriverState *bs, int64_t offset, const void *buf, int bytes) { QEMUIOVector qiov; struct iovec iov = { .iov_base = (void *) buf, .iov_len = bytes, }; if (bytes < 0) { return -EINVAL; } qemu_iovec_init_external(&qiov, &iov, 1); return bdrv_pwritev(bs, offset, &qiov); } | 617 |