project
stringclasses 788
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 126
values | func
stringlengths 14
482k
| vul
int8 0
1
|
---|---|---|---|---|---|
libcroco | 898e3a8c8c0314d2e6b106809a8e3e93cf9d4394 | NOT_APPLICABLE | NOT_APPLICABLE | cr_input_read_char (CRInput * a_this, guint32 * a_char)
{
enum CRStatus status = CR_OK;
gulong consumed = 0,
nb_bytes_left = 0;
g_return_val_if_fail (a_this && PRIVATE (a_this) && a_char,
CR_BAD_PARAM_ERROR);
if (PRIVATE (a_this)->end_of_input == TRUE)
return CR_END_OF_INPUT_ERROR;
nb_bytes_left = cr_input_get_nb_bytes_left (a_this);
if (nb_bytes_left < 1) {
return CR_END_OF_INPUT_ERROR;
}
status = cr_utils_read_char_from_utf8_buf
(PRIVATE (a_this)->in_buf
+
PRIVATE (a_this)->next_byte_index,
nb_bytes_left, a_char, &consumed);
if (status == CR_OK) {
/*update next byte index */
PRIVATE (a_this)->next_byte_index += consumed;
/*update line and column number */
if (PRIVATE (a_this)->end_of_line == TRUE) {
PRIVATE (a_this)->col = 1;
PRIVATE (a_this)->line++;
PRIVATE (a_this)->end_of_line = FALSE;
} else if (*a_char != '\n') {
PRIVATE (a_this)->col++;
}
if (*a_char == '\n') {
PRIVATE (a_this)->end_of_line = TRUE;
}
}
return status;
} | 0 |
feh | f7a547b7ef8fc8ebdeaa4c28515c9d72e592fb6d | NOT_APPLICABLE | NOT_APPLICABLE | char *enl_wait_for_reply(void)
{
XEvent ev;
static char msg_buffer[20];
register unsigned char i;
alarm(2);
for (; !XCheckTypedWindowEvent(disp, my_ipc_win, ClientMessage, &ev)
&& !timeout;);
alarm(0);
if (ev.xany.type != ClientMessage) {
return(IPC_TIMEOUT);
}
for (i = 0; i < 20; i++) {
msg_buffer[i] = ev.xclient.data.b[i];
}
return(msg_buffer + 8);
}
| 0 |
php-src | 28f80baf3c53e267c9ce46a2a0fadbb981585132?w=1 | CVE-2016-7412 | CWE-119 | php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,
unsigned int field_count, const MYSQLND_FIELD * fields_metadata,
zend_bool as_int_or_float, zend_bool copy_data, MYSQLND_STATS * stats TSRMLS_DC)
{
unsigned int i;
zend_bool last_field_was_string = FALSE;
zval **current_field, **end_field, **start_field;
zend_uchar * p = row_buffer->ptr;
size_t data_size = row_buffer->app;
zend_uchar * bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */
DBG_ENTER("php_mysqlnd_rowp_read_text_protocol_aux");
if (!fields) {
DBG_RETURN(FAIL);
}
end_field = (start_field = fields) + field_count;
for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
DBG_INF("Directly creating zval");
MAKE_STD_ZVAL(*current_field);
if (!*current_field) {
DBG_RETURN(FAIL);
}
}
for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
/* Don't reverse the order. It is significant!*/
zend_uchar *this_field_len_pos = p;
/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */
unsigned long len = php_mysqlnd_net_field_length(&p);
if (copy_data == FALSE && current_field > start_field && last_field_was_string) {
/*
Normal queries:
We have to put \0 now to the end of the previous field, if it was
a string. IS_NULL doesn't matter. Because we have already read our
length, then we can overwrite it in the row buffer.
This statement terminates the previous field, not the current one.
NULL_LENGTH is encoded in one byte, so we can stick a \0 there.
Any string's length is encoded in at least one byte, so we can stick
a \0 there.
*/
*this_field_len_pos = '\0';
}
/* NULL or NOT NULL, this is the question! */
if (len == MYSQLND_NULL_LENGTH) {
ZVAL_NULL(*current_field);
last_field_was_string = FALSE;
} else {
#if defined(MYSQLND_STRING_TO_INT_CONVERSION)
struct st_mysqlnd_perm_bind perm_bind =
mysqlnd_ps_fetch_functions[fields_metadata[i].type];
#endif
if (MYSQLND_G(collect_statistics)) {
enum_mysqlnd_collected_stats statistic;
switch (fields_metadata[i].type) {
case MYSQL_TYPE_DECIMAL: statistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;
case MYSQL_TYPE_TINY: statistic = STAT_TEXT_TYPE_FETCHED_INT8; break;
case MYSQL_TYPE_SHORT: statistic = STAT_TEXT_TYPE_FETCHED_INT16; break;
case MYSQL_TYPE_LONG: statistic = STAT_TEXT_TYPE_FETCHED_INT32; break;
case MYSQL_TYPE_FLOAT: statistic = STAT_TEXT_TYPE_FETCHED_FLOAT; break;
case MYSQL_TYPE_DOUBLE: statistic = STAT_TEXT_TYPE_FETCHED_DOUBLE; break;
case MYSQL_TYPE_NULL: statistic = STAT_TEXT_TYPE_FETCHED_NULL; break;
case MYSQL_TYPE_TIMESTAMP: statistic = STAT_TEXT_TYPE_FETCHED_TIMESTAMP; break;
case MYSQL_TYPE_LONGLONG: statistic = STAT_TEXT_TYPE_FETCHED_INT64; break;
case MYSQL_TYPE_INT24: statistic = STAT_TEXT_TYPE_FETCHED_INT24; break;
case MYSQL_TYPE_DATE: statistic = STAT_TEXT_TYPE_FETCHED_DATE; break;
case MYSQL_TYPE_TIME: statistic = STAT_TEXT_TYPE_FETCHED_TIME; break;
case MYSQL_TYPE_DATETIME: statistic = STAT_TEXT_TYPE_FETCHED_DATETIME; break;
case MYSQL_TYPE_YEAR: statistic = STAT_TEXT_TYPE_FETCHED_YEAR; break;
case MYSQL_TYPE_NEWDATE: statistic = STAT_TEXT_TYPE_FETCHED_DATE; break;
case MYSQL_TYPE_VARCHAR: statistic = STAT_TEXT_TYPE_FETCHED_STRING; break;
case MYSQL_TYPE_BIT: statistic = STAT_TEXT_TYPE_FETCHED_BIT; break;
case MYSQL_TYPE_NEWDECIMAL: statistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;
case MYSQL_TYPE_ENUM: statistic = STAT_TEXT_TYPE_FETCHED_ENUM; break;
case MYSQL_TYPE_SET: statistic = STAT_TEXT_TYPE_FETCHED_SET; break;
case MYSQL_TYPE_JSON: statistic = STAT_TEXT_TYPE_FETCHED_JSON; break;
case MYSQL_TYPE_TINY_BLOB: statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;
case MYSQL_TYPE_MEDIUM_BLOB:statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;
case MYSQL_TYPE_LONG_BLOB: statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;
case MYSQL_TYPE_BLOB: statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;
case MYSQL_TYPE_VAR_STRING: statistic = STAT_TEXT_TYPE_FETCHED_STRING; break;
case MYSQL_TYPE_STRING: statistic = STAT_TEXT_TYPE_FETCHED_STRING; break;
case MYSQL_TYPE_GEOMETRY: statistic = STAT_TEXT_TYPE_FETCHED_GEOMETRY; break;
default: statistic = STAT_TEXT_TYPE_FETCHED_OTHER; break;
}
MYSQLND_INC_CONN_STATISTIC_W_VALUE2(stats, statistic, 1, STAT_BYTES_RECEIVED_PURE_DATA_TEXT, len);
}
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
if (as_int_or_float && perm_bind.php_type == IS_LONG) {
zend_uchar save = *(p + len);
/* We have to make it ASCIIZ temporarily */
*(p + len) = '\0';
if (perm_bind.pack_len < SIZEOF_LONG) {
/* direct conversion */
int64_t v =
#ifndef PHP_WIN32
atoll((char *) p);
#else
_atoi64((char *) p);
#endif
ZVAL_LONG(*current_field, (long) v); /* the cast is safe */
} else {
uint64_t v =
#ifndef PHP_WIN32
(uint64_t) atoll((char *) p);
#else
(uint64_t) _atoi64((char *) p);
#endif
zend_bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;
/* We have to make it ASCIIZ temporarily */
#if SIZEOF_LONG==8
if (uns == TRUE && v > 9223372036854775807L)
#elif SIZEOF_LONG==4
if ((uns == TRUE && v > L64(2147483647)) ||
(uns == FALSE && (( L64(2147483647) < (int64_t) v) ||
(L64(-2147483648) > (int64_t) v))))
#else
#error Need fix for this architecture
#endif /* SIZEOF */
{
ZVAL_STRINGL(*current_field, (char *)p, len, 0);
} else {
ZVAL_LONG(*current_field, (long) v); /* the cast is safe */
}
}
*(p + len) = save;
} else if (as_int_or_float && perm_bind.php_type == IS_DOUBLE) {
zend_uchar save = *(p + len);
/* We have to make it ASCIIZ temporarily */
*(p + len) = '\0';
ZVAL_DOUBLE(*current_field, atof((char *) p));
*(p + len) = save;
} else
#endif /* MYSQLND_STRING_TO_INT_CONVERSION */
if (fields_metadata[i].type == MYSQL_TYPE_BIT) {
/*
BIT fields are specially handled. As they come as bit mask, we have
to convert it to human-readable representation. As the bits take
less space in the protocol than the numbers they represent, we don't
have enough space in the packet buffer to overwrite inside.
Thus, a bit more space is pre-allocated at the end of the buffer,
see php_mysqlnd_rowp_read(). And we add the strings at the end.
Definitely not nice, _hackish_ :(, but works.
*/
zend_uchar *start = bit_area;
ps_fetch_from_1_to_8_bytes(*current_field, &(fields_metadata[i]), 0, &p, len TSRMLS_CC);
/*
We have advanced in ps_fetch_from_1_to_8_bytes. We should go back because
later in this function there will be an advancement.
*/
p -= len;
if (Z_TYPE_PP(current_field) == IS_LONG) {
bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_PP(current_field));
ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, copy_data);
} else if (Z_TYPE_PP(current_field) == IS_STRING){
memcpy(bit_area, Z_STRVAL_PP(current_field), Z_STRLEN_PP(current_field));
bit_area += Z_STRLEN_PP(current_field);
*bit_area++ = '\0';
zval_dtor(*current_field);
ZVAL_STRINGL(*current_field, (char *) start, bit_area - start - 1, copy_data);
}
} else {
ZVAL_STRINGL(*current_field, (char *)p, len, copy_data);
}
p += len;
last_field_was_string = TRUE;
}
}
if (copy_data == FALSE && last_field_was_string) {
/* Normal queries: The buffer has one more byte at the end, because we need it */
row_buffer->ptr[data_size] = '\0';
}
DBG_RETURN(PASS);
}
| 1 |
openldap | 8c1d96ee36ed98b32cd0e28b7069c7b8ea09d793 | NOT_APPLICABLE | NOT_APPLICABLE | ldap_int_tls_start ( LDAP *ld, LDAPConn *conn, LDAPURLDesc *srv )
{
Sockbuf *sb;
char *host;
void *ssl;
int ret, async;
#ifdef LDAP_USE_NON_BLOCKING_TLS
struct timeval start_time_tv, tv, tv0;
ber_socket_t sd = AC_SOCKET_ERROR;
#endif /* LDAP_USE_NON_BLOCKING_TLS */
if ( !conn )
return LDAP_PARAM_ERROR;
sb = conn->lconn_sb;
if( srv ) {
host = srv->lud_host;
} else {
host = conn->lconn_server->lud_host;
}
/* avoid NULL host */
if( host == NULL ) {
host = "localhost";
}
(void) tls_init( tls_imp );
#ifdef LDAP_USE_NON_BLOCKING_TLS
/*
* Use non-blocking io during SSL Handshake when a timeout is configured
*/
async = LDAP_BOOL_GET( &ld->ld_options, LDAP_BOOL_CONNECT_ASYNC );
if ( ld->ld_options.ldo_tm_net.tv_sec >= 0 ) {
if ( !async ) {
/* if async, this has already been set */
ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_NONBLOCK, (void*)1 );
}
ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
tv = ld->ld_options.ldo_tm_net;
tv0 = tv;
#ifdef HAVE_GETTIMEOFDAY
gettimeofday( &start_time_tv, NULL );
#else /* ! HAVE_GETTIMEOFDAY */
time( &start_time_tv.tv_sec );
start_time_tv.tv_usec = 0;
#endif /* ! HAVE_GETTIMEOFDAY */
}
#endif /* LDAP_USE_NON_BLOCKING_TLS */
ld->ld_errno = LDAP_SUCCESS;
ret = ldap_int_tls_connect( ld, conn, host );
/* this mainly only happens for non-blocking io
* but can also happen when the handshake is too
* big for a single network message.
*/
while ( ret > 0 ) {
#ifdef LDAP_USE_NON_BLOCKING_TLS
if ( async ) {
struct timeval curr_time_tv, delta_tv;
int wr=0;
if ( sb->sb_trans_needs_read ) {
wr=0;
} else if ( sb->sb_trans_needs_write ) {
wr=1;
}
Debug( LDAP_DEBUG_TRACE, "ldap_int_tls_start: ldap_int_tls_connect needs %s\n",
wr ? "write": "read", 0, 0 );
/* This is mostly copied from result.c:wait4msg(), should
* probably be moved into a separate function */
#ifdef HAVE_GETTIMEOFDAY
gettimeofday( &curr_time_tv, NULL );
#else /* ! HAVE_GETTIMEOFDAY */
time( &curr_time_tv.tv_sec );
curr_time_tv.tv_usec = 0;
#endif /* ! HAVE_GETTIMEOFDAY */
/* delta = curr - start */
delta_tv.tv_sec = curr_time_tv.tv_sec - start_time_tv.tv_sec;
delta_tv.tv_usec = curr_time_tv.tv_usec - start_time_tv.tv_usec;
if ( delta_tv.tv_usec < 0 ) {
delta_tv.tv_sec--;
delta_tv.tv_usec += 1000000;
}
/* tv0 < delta ? */
if ( ( tv0.tv_sec < delta_tv.tv_sec ) ||
( ( tv0.tv_sec == delta_tv.tv_sec ) &&
( tv0.tv_usec < delta_tv.tv_usec ) ) )
{
ret = -1;
ld->ld_errno = LDAP_TIMEOUT;
break;
}
/* timeout -= delta_time */
tv0.tv_sec -= delta_tv.tv_sec;
tv0.tv_usec -= delta_tv.tv_usec;
if ( tv0.tv_usec < 0 ) {
tv0.tv_sec--;
tv0.tv_usec += 1000000;
}
start_time_tv.tv_sec = curr_time_tv.tv_sec;
start_time_tv.tv_usec = curr_time_tv.tv_usec;
tv = tv0;
Debug( LDAP_DEBUG_TRACE, "ldap_int_tls_start: ld %p %ld s %ld us to go\n",
(void *)ld, (long) tv.tv_sec, (long) tv.tv_usec );
ret = ldap_int_poll( ld, sd, &tv, wr);
if ( ret < 0 ) {
ld->ld_errno = LDAP_TIMEOUT;
break;
}
}
#endif /* LDAP_USE_NON_BLOCKING_TLS */
ret = ldap_int_tls_connect( ld, conn, host );
}
if ( ret < 0 ) {
if ( ld->ld_errno == LDAP_SUCCESS )
ld->ld_errno = LDAP_CONNECT_ERROR;
return (ld->ld_errno);
}
return LDAP_SUCCESS;
} | 0 |
ImageMagick | 4717744e4bb27de8ea978e51c6d5bcddf62ffe49 | NOT_APPLICABLE | NOT_APPLICABLE | MagickExport Image *StatisticImage(const Image *image,const StatisticType type,
const size_t width,const size_t height,ExceptionInfo *exception)
{
#define StatisticImageTag "Statistic/Image"
CacheView
*image_view,
*statistic_view;
Image
*statistic_image;
MagickBooleanType
status;
MagickOffsetType
progress;
PixelList
**magick_restrict pixel_list;
ssize_t
center,
y;
/*
Initialize statistics image attributes.
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
statistic_image=CloneImage(image,0,0,MagickTrue,
exception);
if (statistic_image == (Image *) NULL)
return((Image *) NULL);
status=SetImageStorageClass(statistic_image,DirectClass,exception);
if (status == MagickFalse)
{
statistic_image=DestroyImage(statistic_image);
return((Image *) NULL);
}
pixel_list=AcquirePixelListThreadSet(MagickMax(width,1),MagickMax(height,1));
if (pixel_list == (PixelList **) NULL)
{
statistic_image=DestroyImage(statistic_image);
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Make each pixel the min / max / median / mode / etc. of the neighborhood.
*/
center=(ssize_t) GetPixelChannels(image)*(image->columns+MagickMax(width,1))*
(MagickMax(height,1)/2L)+GetPixelChannels(image)*(MagickMax(width,1)/2L);
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
statistic_view=AcquireAuthenticCacheView(statistic_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,statistic_image,statistic_image->rows,1)
#endif
for (y=0; y < (ssize_t) statistic_image->rows; y++)
{
const int
id = GetOpenMPThreadId();
const Quantum
*magick_restrict p;
Quantum
*magick_restrict q;
ssize_t
x;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,-((ssize_t) MagickMax(width,1)/2L),y-
(ssize_t) (MagickMax(height,1)/2L),image->columns+MagickMax(width,1),
MagickMax(height,1),exception);
q=QueueCacheViewAuthenticPixels(statistic_view,0,y,statistic_image->columns, 1,exception);
if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) statistic_image->columns; x++)
{
ssize_t
i;
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
double
area,
maximum,
minimum,
sum,
sum_squared;
Quantum
pixel;
const Quantum
*magick_restrict pixels;
ssize_t
u;
ssize_t
v;
PixelChannel channel = GetPixelChannelChannel(image,i);
PixelTrait traits = GetPixelChannelTraits(image,channel);
PixelTrait statistic_traits=GetPixelChannelTraits(statistic_image,
channel);
if ((traits == UndefinedPixelTrait) ||
(statistic_traits == UndefinedPixelTrait))
continue;
if (((statistic_traits & CopyPixelTrait) != 0) ||
(GetPixelWriteMask(image,p) <= (QuantumRange/2)))
{
SetPixelChannel(statistic_image,channel,p[center+i],q);
continue;
}
if ((statistic_traits & UpdatePixelTrait) == 0)
continue;
pixels=p;
area=0.0;
minimum=pixels[i];
maximum=pixels[i];
sum=0.0;
sum_squared=0.0;
ResetPixelList(pixel_list[id]);
for (v=0; v < (ssize_t) MagickMax(height,1); v++)
{
for (u=0; u < (ssize_t) MagickMax(width,1); u++)
{
if ((type == MedianStatistic) || (type == ModeStatistic) ||
(type == NonpeakStatistic))
{
InsertPixelList(pixels[i],pixel_list[id]);
pixels+=GetPixelChannels(image);
continue;
}
area++;
if (pixels[i] < minimum)
minimum=(double) pixels[i];
if (pixels[i] > maximum)
maximum=(double) pixels[i];
sum+=(double) pixels[i];
sum_squared+=(double) pixels[i]*pixels[i];
pixels+=GetPixelChannels(image);
}
pixels+=GetPixelChannels(image)*image->columns;
}
switch (type)
{
case GradientStatistic:
{
pixel=ClampToQuantum(MagickAbsoluteValue(maximum-minimum));
break;
}
case MaximumStatistic:
{
pixel=ClampToQuantum(maximum);
break;
}
case MeanStatistic:
default:
{
pixel=ClampToQuantum(sum/area);
break;
}
case MedianStatistic:
{
GetMedianPixelList(pixel_list[id],&pixel);
break;
}
case MinimumStatistic:
{
pixel=ClampToQuantum(minimum);
break;
}
case ModeStatistic:
{
GetModePixelList(pixel_list[id],&pixel);
break;
}
case NonpeakStatistic:
{
GetNonpeakPixelList(pixel_list[id],&pixel);
break;
}
case RootMeanSquareStatistic:
{
pixel=ClampToQuantum(sqrt(sum_squared/area));
break;
}
case StandardDeviationStatistic:
{
pixel=ClampToQuantum(sqrt(sum_squared/area-(sum/area*sum/area)));
break;
}
}
SetPixelChannel(statistic_image,channel,pixel,q);
}
p+=GetPixelChannels(image);
q+=GetPixelChannels(statistic_image);
}
if (SyncCacheViewAuthenticPixels(statistic_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,StatisticImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
statistic_view=DestroyCacheView(statistic_view);
image_view=DestroyCacheView(image_view);
pixel_list=DestroyPixelListThreadSet(pixel_list);
if (status == MagickFalse)
statistic_image=DestroyImage(statistic_image);
return(statistic_image);
} | 0 |
qemu | ff0507c239a246fd7215b31c5658fc6a3ee1e4c5 | NOT_APPLICABLE | NOT_APPLICABLE | static void apply_chap(struct iscsi_context *iscsi, QemuOpts *opts,
Error **errp)
{
const char *user = NULL;
const char *password = NULL;
const char *secretid;
char *secret = NULL;
user = qemu_opt_get(opts, "user");
if (!user) {
return;
}
secretid = qemu_opt_get(opts, "password-secret");
password = qemu_opt_get(opts, "password");
if (secretid && password) {
error_setg(errp, "'password' and 'password-secret' properties are "
"mutually exclusive");
return;
}
if (secretid) {
secret = qcrypto_secret_lookup_as_utf8(secretid, errp);
if (!secret) {
return;
}
password = secret;
} else if (!password) {
error_setg(errp, "CHAP username specified but no password was given");
return;
}
if (iscsi_set_initiator_username_pwd(iscsi, user, password)) {
error_setg(errp, "Failed to set initiator username and password");
}
g_free(secret);
} | 0 |
qcad | 1eeffc5daf5a06cf6213ffc19e95923cdebb2eb8 | NOT_APPLICABLE | NOT_APPLICABLE | void DL_Dxf::addTextStyle(DL_CreationInterface* creationInterface) {
std::string name = getStringValue(2, "");
if (name.length()==0) {
return;
}
DL_StyleData d(
// name:
name,
// flags
getIntValue(70, 0),
// fixed text heigth:
getRealValue(40, 0.0),
// width factor:
getRealValue(41, 0.0),
// oblique angle:
getRealValue(50, 0.0),
// text generation flags:
getIntValue(71, 0),
// last height used:
getRealValue(42, 0.0),
// primart font file:
getStringValue(3, ""),
// big font file:
getStringValue(4, "")
);
creationInterface->addTextStyle(d);
} | 0 |
collectd | b589096f907052b3a4da2b9ccc9b0e2e888dfc18 | NOT_APPLICABLE | NOT_APPLICABLE | static void flush_buffer (void)
{
DEBUG ("network plugin: flush_buffer: send_buffer_fill = %i",
send_buffer_fill);
network_send_buffer (send_buffer, (size_t) send_buffer_fill);
stats_octets_tx += ((uint64_t) send_buffer_fill);
stats_packets_tx++;
network_init_buffer ();
}
| 0 |
ImageMagick | 8c35502217c1879cb8257c617007282eee3fe1cc | NOT_APPLICABLE | NOT_APPLICABLE | void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
{
modifyImage();
GetPPException;
SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
ThrowImageException;
} | 0 |
linux | 3aa02cb664c5fb1042958c8d1aa8c35055a2ebc4 | NOT_APPLICABLE | NOT_APPLICABLE | snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size)
{
struct snd_pcm_runtime *runtime;
int nonblock;
int err;
err = pcm_sanity_check(substream);
if (err < 0)
return err;
runtime = substream->runtime;
nonblock = !!(substream->f_flags & O_NONBLOCK);
if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
runtime->channels > 1)
return -EINVAL;
return snd_pcm_lib_write1(substream, (unsigned long)buf, size, nonblock,
snd_pcm_lib_write_transfer);
}
| 0 |
redcarpet | a699c82292b17c8e6a62e1914d5eccc252272793 | NOT_APPLICABLE | NOT_APPLICABLE | rndr_footnote_ref(struct buf *ob, unsigned int num, void *opaque)
{
bufprintf(ob, "<sup id=\"fnref%d\"><a href=\"#fn%d\">%d</a></sup>", num, num, num);
return 1;
} | 0 |
linux | 8572cea1461a006bce1d06c0c4b0575869125fa4 | NOT_APPLICABLE | NOT_APPLICABLE | nfp_flower_non_repr_priv_lookup(struct nfp_app *app, struct net_device *netdev)
{
struct nfp_flower_priv *priv = app->priv;
struct nfp_flower_non_repr_priv *entry;
ASSERT_RTNL();
list_for_each_entry(entry, &priv->non_repr_priv, list)
if (entry->netdev == netdev)
return entry;
return NULL;
} | 0 |
Chrome | 79cfdeb5fbe79fa2604d37fba467f371cb436bc3 | NOT_APPLICABLE | NOT_APPLICABLE | void BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent(Node* oldFocusedNode, FocusDirection direction)
{
DateTimeEditElement* edit = dateTimeEditElement();
if (!edit || m_isDestroyingShadowSubtree)
return;
if (direction == FocusDirectionBackward) {
if (element()->document()->page())
element()->document()->page()->focusController()->advanceFocus(direction, 0);
} else if (direction == FocusDirectionNone || direction == FocusDirectionMouse) {
edit->focusByOwner(oldFocusedNode);
} else
edit->focusByOwner();
}
| 0 |
Chrome | db97b49fdd856f33bd810db4564c6f2cc14be71a | NOT_APPLICABLE | NOT_APPLICABLE | const char* PixelBufferRasterWorkerPool::StateName() const {
if (scheduled_raster_task_count_)
return "rasterizing";
if (PendingRasterTaskCount())
return "throttled";
if (!tasks_with_pending_upload_.empty())
return "waiting_for_uploads";
return "finishing";
}
| 0 |
kvm-guest-drivers-windows | 723416fa4210b7464b28eab89cc76252e6193ac1 | CVE-2015-3215 | CWE-20 | tPacketIndicationType ParaNdis_PrepareReceivedPacket(
PARANDIS_ADAPTER *pContext,
pRxNetDescriptor pBuffersDesc,
PUINT pnCoalescedSegmentsCount)
{
PMDL pMDL = pBuffersDesc->Holder;
PNET_BUFFER_LIST pNBL = NULL;
*pnCoalescedSegmentsCount = 1;
if (pMDL)
{
ULONG nBytesStripped = 0;
PNET_PACKET_INFO pPacketInfo = &pBuffersDesc->PacketInfo;
if (pContext->ulPriorityVlanSetting && pPacketInfo->hasVlanHeader)
{
nBytesStripped = ParaNdis_StripVlanHeaderMoveHead(pPacketInfo);
}
ParaNdis_PadPacketToMinimalLength(pPacketInfo);
ParaNdis_AdjustRxBufferHolderLength(pBuffersDesc, nBytesStripped);
pNBL = NdisAllocateNetBufferAndNetBufferList(pContext->BufferListsPool, 0, 0, pMDL, nBytesStripped, pPacketInfo->dataLength);
if (pNBL)
{
virtio_net_hdr_basic *pHeader = (virtio_net_hdr_basic *) pBuffersDesc->PhysicalPages[0].Virtual;
tChecksumCheckResult csRes;
pNBL->SourceHandle = pContext->MiniportHandle;
NBLSetRSSInfo(pContext, pNBL, pPacketInfo);
NBLSet8021QInfo(pContext, pNBL, pPacketInfo);
pNBL->MiniportReserved[0] = pBuffersDesc;
#if PARANDIS_SUPPORT_RSC
if(pHeader->gso_type != VIRTIO_NET_HDR_GSO_NONE)
{
*pnCoalescedSegmentsCount = PktGetTCPCoalescedSegmentsCount(pPacketInfo, pContext->MaxPacketSize.nMaxDataSize);
NBLSetRSCInfo(pContext, pNBL, pPacketInfo, *pnCoalescedSegmentsCount);
}
else
#endif
{
csRes = ParaNdis_CheckRxChecksum(
pContext,
pHeader->flags,
&pBuffersDesc->PhysicalPages[PARANDIS_FIRST_RX_DATA_PAGE],
pPacketInfo->dataLength,
nBytesStripped);
if (csRes.value)
{
NDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO qCSInfo;
qCSInfo.Value = NULL;
qCSInfo.Receive.IpChecksumFailed = csRes.flags.IpFailed;
qCSInfo.Receive.IpChecksumSucceeded = csRes.flags.IpOK;
qCSInfo.Receive.TcpChecksumFailed = csRes.flags.TcpFailed;
qCSInfo.Receive.TcpChecksumSucceeded = csRes.flags.TcpOK;
qCSInfo.Receive.UdpChecksumFailed = csRes.flags.UdpFailed;
qCSInfo.Receive.UdpChecksumSucceeded = csRes.flags.UdpOK;
NET_BUFFER_LIST_INFO(pNBL, TcpIpChecksumNetBufferListInfo) = qCSInfo.Value;
DPrintf(1, ("Reporting CS %X->%X\n", csRes.value, (ULONG)(ULONG_PTR)qCSInfo.Value));
}
}
pNBL->Status = NDIS_STATUS_SUCCESS;
#if defined(ENABLE_HISTORY_LOG)
{
tTcpIpPacketParsingResult packetReview = ParaNdis_CheckSumVerify(
RtlOffsetToPointer(pPacketInfo->headersBuffer, ETH_HEADER_SIZE),
pPacketInfo->dataLength,
pcrIpChecksum | pcrTcpChecksum | pcrUdpChecksum,
__FUNCTION__
);
ParaNdis_DebugHistory(pContext, hopPacketReceived, pNBL, pPacketInfo->dataLength, (ULONG)(ULONG_PTR)qInfo.Value, packetReview.value);
}
#endif
}
}
return pNBL;
}
| 1 |
gpac | 2320eb73afba753b39b7147be91f7be7afc0eeb7 | NOT_APPLICABLE | NOT_APPLICABLE | static void gf_m2ts_process_pes(GF_M2TS_Demuxer *ts, GF_M2TS_PES *pes, GF_M2TS_Header *hdr, unsigned char *data, u32 data_size, GF_M2TS_AdaptationField *paf)
{
u8 expect_cc;
Bool disc=0;
Bool flush_pes = 0;
/*duplicated packet, NOT A DISCONTINUITY, we should discard the packet - however we may encounter this configuration in DASH at segment boundaries.
If payload start is set, ignore duplication*/
if (hdr->continuity_counter==pes->cc) {
if (!hdr->payload_start || (hdr->adaptation_field!=3) ) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PES %d: Duplicated Packet found (CC %d) - skipping\n", pes->pid, pes->cc));
return;
}
} else {
expect_cc = (pes->cc<0) ? hdr->continuity_counter : (pes->cc + 1) & 0xf;
if (expect_cc != hdr->continuity_counter)
disc = 1;
}
pes->cc = hdr->continuity_counter;
if (disc) {
if (pes->flags & GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY) {
pes->flags &= ~GF_M2TS_ES_IGNORE_NEXT_DISCONTINUITY;
disc = 0;
}
if (disc) {
if (hdr->payload_start) {
if (pes->pck_data_len) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] PES %d: Packet discontinuity (%d expected - got %d) - may have lost end of previous PES\n", pes->pid, expect_cc, hdr->continuity_counter));
}
} else {
if (pes->pck_data_len) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] PES %d: Packet discontinuity (%d expected - got %d) - trashing PES packet\n", pes->pid, expect_cc, hdr->continuity_counter));
}
pes->pck_data_len = 0;
pes->pes_len = 0;
pes->cc = -1;
return;
}
}
}
if (!pes->reframe) return;
if (hdr->payload_start) {
flush_pes = 1;
pes->pes_start_packet_number = ts->pck_number;
pes->before_last_pcr_value = pes->program->before_last_pcr_value;
pes->before_last_pcr_value_pck_number = pes->program->before_last_pcr_value_pck_number;
pes->last_pcr_value = pes->program->last_pcr_value;
pes->last_pcr_value_pck_number = pes->program->last_pcr_value_pck_number;
} else if (pes->pes_len && (pes->pck_data_len + data_size == pes->pes_len + 6)) {
/* 6 = startcode+stream_id+length*/
/*reassemble pes*/
if (pes->pck_data_len + data_size > pes->pck_alloc_len) {
pes->pck_alloc_len = pes->pck_data_len + data_size;
pes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len);
}
memcpy(pes->pck_data+pes->pck_data_len, data, data_size);
pes->pck_data_len += data_size;
/*force discard*/
data_size = 0;
flush_pes = 1;
}
/*PES first fragment: flush previous packet*/
if (flush_pes && pes->pck_data_len) {
gf_m2ts_flush_pes(ts, pes);
if (!data_size) return;
}
/*we need to wait for first packet of PES*/
if (!pes->pck_data_len && !hdr->payload_start) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d: Waiting for PES header, trashing data\n", hdr->pid));
return;
}
/*reassemble*/
if (pes->pck_data_len + data_size > pes->pck_alloc_len ) {
pes->pck_alloc_len = pes->pck_data_len + data_size;
pes->pck_data = (u8*)gf_realloc(pes->pck_data, pes->pck_alloc_len);
}
memcpy(pes->pck_data + pes->pck_data_len, data, data_size);
pes->pck_data_len += data_size;
if (paf && paf->random_access_indicator) pes->rap = 1;
if (hdr->payload_start && !pes->pes_len && (pes->pck_data_len>=6)) {
pes->pes_len = (pes->pck_data[4]<<8) | pes->pck_data[5];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d: Got PES packet len %d\n", pes->pid, pes->pes_len));
if (pes->pes_len + 6 == pes->pck_data_len) {
gf_m2ts_flush_pes(ts, pes);
}
}
} | 0 |
linux-stable | 59643d1535eb220668692a5359de22545af579f6 | NOT_APPLICABLE | NOT_APPLICABLE | unsigned ring_buffer_event_length(struct ring_buffer_event *event)
{
unsigned length;
if (event->type_len == RINGBUF_TYPE_TIME_EXTEND)
event = skip_time_extend(event);
length = rb_event_length(event);
if (event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
return length;
length -= RB_EVNT_HDR_SIZE;
if (length > RB_MAX_SMALL_DATA + sizeof(event->array[0]))
length -= sizeof(event->array[0]);
return length;
} | 0 |
leptonica | 5ba34b1fe741d69d43a6c8cf767756997eadd87c | CVE-2020-36280 | CWE-125 | pixReadFromTiffStream(TIFF *tif)
{
char *text;
l_uint8 *linebuf, *data, *rowptr;
l_uint16 spp, bps, photometry, tiffcomp, orientation, sample_fmt;
l_uint16 *redmap, *greenmap, *bluemap;
l_int32 d, wpl, bpl, comptype, i, j, k, ncolors, rval, gval, bval, aval;
l_int32 xres, yres, tiffbpl, packedbpl, halfsize;
l_uint32 w, h, tiffword, read_oriented;
l_uint32 *line, *ppixel, *tiffdata, *pixdata;
PIX *pix, *pix1;
PIXCMAP *cmap;
PROCNAME("pixReadFromTiffStream");
if (!tif)
return (PIX *)ERROR_PTR("tif not defined", procName, NULL);
read_oriented = 0;
/* Only accept uint image data:
* SAMPLEFORMAT_UINT = 1;
* SAMPLEFORMAT_INT = 2;
* SAMPLEFORMAT_IEEEFP = 3;
* SAMPLEFORMAT_VOID = 4; */
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLEFORMAT, &sample_fmt);
if (sample_fmt != SAMPLEFORMAT_UINT) {
L_ERROR("sample format = %d is not uint\n", procName, sample_fmt);
return NULL;
}
/* Can't read tiff in tiled format. For what is involved, see, e.g:
* https://www.cs.rochester.edu/~nelson/courses/vision/\
* resources/tiff/libtiff.html#Tiles
* A tiled tiff can be converted to a normal (strip) tif:
* tiffcp -s <input-tiled-tif> <output-strip-tif> */
if (TIFFIsTiled(tif)) {
L_ERROR("tiled format is not supported\n", procName);
return NULL;
}
/* Old style jpeg is not supported. We tried supporting 8 bpp.
* TIFFReadScanline() fails on this format, so we used RGBA
* reading, which generates a 4 spp image, and pulled out the
* red component. However, there were problems with double-frees
* in cleanup. For RGB, tiffbpl is exactly half the size that
* you would expect for the raster data in a scanline, which
* is 3 * w. */
TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &tiffcomp);
if (tiffcomp == COMPRESSION_OJPEG) {
L_ERROR("old style jpeg format is not supported\n", procName);
return NULL;
}
/* Use default fields for bps and spp */
TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bps);
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
if (bps != 1 && bps != 2 && bps != 4 && bps != 8 && bps != 16) {
L_ERROR("invalid bps = %d\n", procName, bps);
return NULL;
}
if (spp == 2 && bps != 8) {
L_WARNING("for 2 spp, only handle 8 bps\n", procName);
return NULL;
}
if (spp == 1)
d = bps;
else if (spp == 2) /* gray plus alpha */
d = 32; /* will convert to RGBA */
else if (spp == 3 || spp == 4)
d = 32;
else
return (PIX *)ERROR_PTR("spp not in set {1,2,3,4}", procName, NULL);
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
if (w > MaxTiffWidth) {
L_ERROR("width = %d pixels; too large\n", procName, w);
return NULL;
}
if (h > MaxTiffHeight) {
L_ERROR("height = %d pixels; too large\n", procName, h);
return NULL;
}
/* The relation between the size of a byte buffer required to hold
a raster of image pixels (packedbpl) and the size of the tiff
buffer (tiffbuf) is either 1:1 or approximately 2:1, depending
on how the data is stored and subsampled. Allow some slop
when validating the relation between buffer size and the image
parameters w, spp and bps. */
tiffbpl = TIFFScanlineSize(tif);
packedbpl = (bps * spp * w + 7) / 8;
halfsize = L_ABS(2 * tiffbpl - packedbpl) <= 8;
#if 0
if (halfsize)
L_INFO("packedbpl = %d is approx. twice tiffbpl = %d\n", procName,
packedbpl, tiffbpl);
#endif
if (tiffbpl != packedbpl && !halfsize) {
L_ERROR("invalid tiffbpl: tiffbpl = %d, packedbpl = %d, "
"bps = %d, spp = %d, w = %d\n",
procName, tiffbpl, packedbpl, bps, spp, w);
return NULL;
}
if ((pix = pixCreate(w, h, d)) == NULL)
return (PIX *)ERROR_PTR("pix not made", procName, NULL);
pixSetInputFormat(pix, IFF_TIFF);
data = (l_uint8 *)pixGetData(pix);
wpl = pixGetWpl(pix);
bpl = 4 * wpl;
if (spp == 1) {
linebuf = (l_uint8 *)LEPT_CALLOC(tiffbpl + 1, sizeof(l_uint8));
for (i = 0; i < h; i++) {
if (TIFFReadScanline(tif, linebuf, i, 0) < 0) {
LEPT_FREE(linebuf);
pixDestroy(&pix);
return (PIX *)ERROR_PTR("line read fail", procName, NULL);
}
memcpy(data, linebuf, tiffbpl);
data += bpl;
}
if (bps <= 8)
pixEndianByteSwap(pix);
else /* bps == 16 */
pixEndianTwoByteSwap(pix);
LEPT_FREE(linebuf);
} else if (spp == 2 && bps == 8) { /* gray plus alpha */
L_INFO("gray+alpha is not supported; converting to RGBA\n", procName);
pixSetSpp(pix, 4);
linebuf = (l_uint8 *)LEPT_CALLOC(tiffbpl + 1, sizeof(l_uint8));
pixdata = pixGetData(pix);
for (i = 0; i < h; i++) {
if (TIFFReadScanline(tif, linebuf, i, 0) < 0) {
LEPT_FREE(linebuf);
pixDestroy(&pix);
return (PIX *)ERROR_PTR("line read fail", procName, NULL);
}
rowptr = linebuf;
ppixel = pixdata + i * wpl;
for (j = k = 0; j < w; j++) {
/* Copy gray value into r, g and b */
SET_DATA_BYTE(ppixel, COLOR_RED, rowptr[k]);
SET_DATA_BYTE(ppixel, COLOR_GREEN, rowptr[k]);
SET_DATA_BYTE(ppixel, COLOR_BLUE, rowptr[k++]);
SET_DATA_BYTE(ppixel, L_ALPHA_CHANNEL, rowptr[k++]);
ppixel++;
}
}
LEPT_FREE(linebuf);
} else { /* rgb and rgba */
if ((tiffdata = (l_uint32 *)LEPT_CALLOC((size_t)w * h,
sizeof(l_uint32))) == NULL) {
pixDestroy(&pix);
return (PIX *)ERROR_PTR("calloc fail for tiffdata", procName, NULL);
}
/* TIFFReadRGBAImageOriented() converts to 8 bps */
if (!TIFFReadRGBAImageOriented(tif, w, h, tiffdata,
ORIENTATION_TOPLEFT, 0)) {
LEPT_FREE(tiffdata);
pixDestroy(&pix);
return (PIX *)ERROR_PTR("failed to read tiffdata", procName, NULL);
} else {
read_oriented = 1;
}
if (spp == 4) pixSetSpp(pix, 4);
line = pixGetData(pix);
for (i = 0; i < h; i++, line += wpl) {
for (j = 0, ppixel = line; j < w; j++) {
/* TIFFGet* are macros */
tiffword = tiffdata[i * w + j];
rval = TIFFGetR(tiffword);
gval = TIFFGetG(tiffword);
bval = TIFFGetB(tiffword);
if (spp == 3) {
composeRGBPixel(rval, gval, bval, ppixel);
} else { /* spp == 4 */
aval = TIFFGetA(tiffword);
composeRGBAPixel(rval, gval, bval, aval, ppixel);
}
ppixel++;
}
}
LEPT_FREE(tiffdata);
}
if (getTiffStreamResolution(tif, &xres, &yres) == 0) {
pixSetXRes(pix, xres);
pixSetYRes(pix, yres);
}
/* Find and save the compression type */
comptype = getTiffCompressedFormat(tiffcomp);
pixSetInputFormat(pix, comptype);
if (TIFFGetField(tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) {
/* Save the colormap as a pix cmap. Because the
* tiff colormap components are 16 bit unsigned,
* and go from black (0) to white (0xffff), the
* the pix cmap takes the most significant byte. */
if (bps > 8) {
pixDestroy(&pix);
return (PIX *)ERROR_PTR("colormap size > 256", procName, NULL);
}
if ((cmap = pixcmapCreate(bps)) == NULL) {
pixDestroy(&pix);
return (PIX *)ERROR_PTR("colormap not made", procName, NULL);
}
ncolors = 1 << bps;
for (i = 0; i < ncolors; i++)
pixcmapAddColor(cmap, redmap[i] >> 8, greenmap[i] >> 8,
bluemap[i] >> 8);
if (pixSetColormap(pix, cmap)) {
pixDestroy(&pix);
return (PIX *)ERROR_PTR("invalid colormap", procName, NULL);
}
/* Remove the colormap for 1 bpp. */
if (bps == 1) {
pix1 = pixRemoveColormap(pix, REMOVE_CMAP_BASED_ON_SRC);
pixDestroy(&pix);
pix = pix1;
}
} else { /* No colormap: check photometry and invert if necessary */
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometry)) {
/* Guess default photometry setting. Assume min_is_white
* if compressed 1 bpp; min_is_black otherwise. */
if (tiffcomp == COMPRESSION_CCITTFAX3 ||
tiffcomp == COMPRESSION_CCITTFAX4 ||
tiffcomp == COMPRESSION_CCITTRLE ||
tiffcomp == COMPRESSION_CCITTRLEW) {
photometry = PHOTOMETRIC_MINISWHITE;
} else {
photometry = PHOTOMETRIC_MINISBLACK;
}
}
if ((d == 1 && photometry == PHOTOMETRIC_MINISBLACK) ||
(d == 8 && photometry == PHOTOMETRIC_MINISWHITE))
pixInvert(pix, pix);
}
if (TIFFGetField(tif, TIFFTAG_ORIENTATION, &orientation)) {
if (orientation >= 1 && orientation <= 8) {
struct tiff_transform *transform = (read_oriented) ?
&tiff_partial_orientation_transforms[orientation - 1] :
&tiff_orientation_transforms[orientation - 1];
if (transform->vflip) pixFlipTB(pix, pix);
if (transform->hflip) pixFlipLR(pix, pix);
if (transform->rotate) {
PIX *oldpix = pix;
pix = pixRotate90(oldpix, transform->rotate);
pixDestroy(&oldpix);
}
}
}
text = NULL;
TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &text);
if (text) pixSetText(pix, text);
return pix;
} | 1 |
linux | 7e6bc1f6cabcd30aba0b11219d8e01b952eacbb6 | NOT_APPLICABLE | NOT_APPLICABLE | static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,
const struct nlattr *attr)
{
struct nlattr *nla[NFTA_SET_ELEM_MAX + 1];
struct nft_set_ext_tmpl tmpl;
struct nft_set_elem elem;
struct nft_set_ext *ext;
struct nft_trans *trans;
u32 flags = 0;
int err;
err = nla_parse_nested_deprecated(nla, NFTA_SET_ELEM_MAX, attr,
nft_set_elem_policy, NULL);
if (err < 0)
return err;
err = nft_setelem_parse_flags(set, nla[NFTA_SET_ELEM_FLAGS], &flags);
if (err < 0)
return err;
if (!nla[NFTA_SET_ELEM_KEY] && !(flags & NFT_SET_ELEM_CATCHALL))
return -EINVAL;
nft_set_ext_prepare(&tmpl);
if (flags != 0)
nft_set_ext_add(&tmpl, NFT_SET_EXT_FLAGS);
if (nla[NFTA_SET_ELEM_KEY]) {
err = nft_setelem_parse_key(ctx, set, &elem.key.val,
nla[NFTA_SET_ELEM_KEY]);
if (err < 0)
return err;
nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY, set->klen);
}
if (nla[NFTA_SET_ELEM_KEY_END]) {
err = nft_setelem_parse_key(ctx, set, &elem.key_end.val,
nla[NFTA_SET_ELEM_KEY_END]);
if (err < 0)
return err;
nft_set_ext_add_length(&tmpl, NFT_SET_EXT_KEY_END, set->klen);
}
err = -ENOMEM;
elem.priv = nft_set_elem_init(set, &tmpl, elem.key.val.data,
elem.key_end.val.data, NULL, 0, 0,
GFP_KERNEL_ACCOUNT);
if (elem.priv == NULL)
goto fail_elem;
ext = nft_set_elem_ext(set, elem.priv);
if (flags)
*nft_set_ext_flags(ext) = flags;
trans = nft_trans_elem_alloc(ctx, NFT_MSG_DELSETELEM, set);
if (trans == NULL)
goto fail_trans;
err = nft_setelem_deactivate(ctx->net, set, &elem, flags);
if (err < 0)
goto fail_ops;
nft_setelem_data_deactivate(ctx->net, set, &elem);
nft_trans_elem(trans) = elem;
nft_trans_commit_list_add_tail(ctx->net, trans);
return 0;
fail_ops:
kfree(trans);
fail_trans:
kfree(elem.priv);
fail_elem:
nft_data_release(&elem.key.val, NFT_DATA_VALUE);
return err;
} | 0 |
linux | 5d26a105b5a73e5635eae0629b42fa0a90e07b7b | NOT_APPLICABLE | NOT_APPLICABLE | static int sha224_sparc64_init(struct shash_desc *desc)
{
struct sha256_state *sctx = shash_desc_ctx(desc);
sctx->state[0] = SHA224_H0;
sctx->state[1] = SHA224_H1;
sctx->state[2] = SHA224_H2;
sctx->state[3] = SHA224_H3;
sctx->state[4] = SHA224_H4;
sctx->state[5] = SHA224_H5;
sctx->state[6] = SHA224_H6;
sctx->state[7] = SHA224_H7;
sctx->count = 0;
return 0;
}
| 0 |
jasper | 1b1c591306817e46e1e6a3300f714992b32f972b | NOT_APPLICABLE | NOT_APPLICABLE | static int jpc_dec_dump(jpc_dec_t *dec, FILE *out)
{
jpc_dec_tile_t *tile;
int tileno;
jpc_dec_tcomp_t *tcomp;
int compno;
jpc_dec_rlvl_t *rlvl;
unsigned rlvlno;
jpc_dec_band_t *band;
int bandno;
jpc_dec_prc_t *prc;
int prcno;
jpc_dec_cblk_t *cblk;
int cblkno;
assert(!dec->numtiles || dec->tiles);
for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles;
++tileno, ++tile) {
assert(!dec->numcomps || tile->tcomps);
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
for (rlvlno = 0, rlvl = tcomp->rlvls; rlvlno <
tcomp->numrlvls; ++rlvlno, ++rlvl) {
fprintf(out, "RESOLUTION LEVEL %d\n", rlvlno);
fprintf(out, "xs = %"PRIuFAST32", ys = %"PRIuFAST32", xe = %"PRIuFAST32", ye = %"PRIuFAST32", w = %"PRIuFAST32", h = %"PRIuFAST32"\n",
rlvl->xstart, rlvl->ystart, rlvl->xend, rlvl->yend,
rlvl->xend - rlvl->xstart, rlvl->yend - rlvl->ystart);
assert(!rlvl->numbands || rlvl->bands);
for (bandno = 0, band = rlvl->bands;
bandno < rlvl->numbands; ++bandno, ++band) {
fprintf(out, "BAND %d\n", bandno);
if (!band->data) {
fprintf(out, "band has no data (null pointer)\n");
assert(!band->prcs);
continue;
}
fprintf(out, "xs = %"PRIiFAST32", ys = %"PRIiFAST32", xe = %"PRIiFAST32", ye = %"PRIiFAST32", w = %"PRIiFAST32", h = %"PRIiFAST32"\n",
jas_seq2d_xstart(band->data),
jas_seq2d_ystart(band->data),
jas_seq2d_xend(band->data),
jas_seq2d_yend(band->data),
jas_seq2d_xend(band->data) -
jas_seq2d_xstart(band->data),
jas_seq2d_yend(band->data) -
jas_seq2d_ystart(band->data));
assert(!rlvl->numprcs || band->prcs);
for (prcno = 0, prc = band->prcs;
prcno < rlvl->numprcs; ++prcno,
++prc) {
fprintf(out, "CODE BLOCK GROUP %d\n", prcno);
fprintf(out, "xs = %"PRIuFAST32", ys = %"PRIuFAST32", xe = %"PRIuFAST32", ye = %"PRIuFAST32", w = %"PRIuFAST32", h = %"PRIuFAST32"\n",
prc->xstart, prc->ystart, prc->xend, prc->yend,
prc->xend - prc->xstart, prc->yend - prc->ystart);
assert(!prc->numcblks || prc->cblks);
for (cblkno = 0, cblk =
prc->cblks; cblkno <
prc->numcblks; ++cblkno,
++cblk) {
fprintf(out, "CODE BLOCK %d\n", cblkno);
fprintf(out, "xs = %"PRIiFAST32", ys = %"PRIiFAST32", xe = %"PRIiFAST32", ye = %"PRIiFAST32", w = %"PRIiFAST32", h = %"PRIiFAST32"\n",
jas_seq2d_xstart(cblk->data),
jas_seq2d_ystart(cblk->data),
jas_seq2d_xend(cblk->data),
jas_seq2d_yend(cblk->data),
jas_seq2d_xend(cblk->data) -
jas_seq2d_xstart(cblk->data),
jas_seq2d_yend(cblk->data) -
jas_seq2d_ystart(cblk->data));
}
}
}
}
}
}
return 0;
} | 0 |
tensorflow | 240655511cd3e701155f944a972db71b6c0b1bb6 | NOT_APPLICABLE | NOT_APPLICABLE | Status ConstantFolding::RunOptimizationPass(Cluster* cluster,
GrapplerItem* item,
GraphProperties* properties,
GraphDef* optimized_graph) {
optimized_graph->Clear();
graph_ = &item->graph;
node_map_.reset(new NodeMap(graph_));
nodes_allowlist_.clear();
// Fold fetch nodes iff it has a single fanout. Note that if a fetch node
// has a single fanout, it would be rewritten as a constant with the same
// node name, and therefore users are still able to fetch it. This is not
// the case if the node has multiple fanouts, and constant folding would
// replace the node with multiple constants (each for one fanout) with
// new names, and as a result users would not be able to fetch the node any
// more with the original node name.
for (const auto& fetch : item->fetch) {
const NodeDef* fetch_node = node_map_->GetNode(fetch);
if (fetch_node && NumOutputs(*fetch_node, graph_) == 1) {
nodes_allowlist_.insert(fetch_node->name());
}
}
absl::flat_hash_set<string> nodes_to_not_simplify;
if (properties->has_properties()) {
TF_RETURN_IF_ERROR(MaterializeShapes(*properties));
TF_RETURN_IF_ERROR(MaterializeConstants(*properties));
TF_RETURN_IF_ERROR(
FoldGraph(*properties, optimized_graph, &nodes_to_not_simplify));
} else {
*optimized_graph = *graph_;
}
node_map_.reset(new NodeMap(optimized_graph));
TF_RETURN_IF_ERROR(
SimplifyGraph(optimized_graph, properties, &nodes_to_not_simplify));
return Status::OK();
} | 0 |
libxml2 | 0bcd05c5cd83dec3406c8f68b769b1d610c72f76 | NOT_APPLICABLE | NOT_APPLICABLE | xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
{
if (ctxt==NULL)
return;
xmlClearNodeInfoSeq(&ctxt->node_seq);
xmlCtxtReset(ctxt);
} | 0 |
ntp | 12f1323d18c8d74eb14fb5ac5574183d779794c5 | NOT_APPLICABLE | NOT_APPLICABLE | tokenize(
const char *line,
char **tokens,
int *ntok
)
{
register const char *cp;
register char *sp;
static char tspace[MAXLINE];
sp = tspace;
cp = line;
for (*ntok = 0; *ntok < MAXTOKENS; (*ntok)++) {
tokens[*ntok] = sp;
/* Skip inter-token whitespace */
while (ISSPACE(*cp))
cp++;
/* If we're at EOL we're done */
if (ISEOL(*cp))
break;
/* If this is the 2nd token and the first token begins
* with a ':', then just grab to EOL.
*/
if (*ntok == 1 && tokens[0][0] == ':') {
do {
if (sp - tspace >= MAXLINE)
goto toobig;
*sp++ = *cp++;
} while (!ISEOL(*cp));
}
/* Check if this token begins with a double quote.
* If yes, continue reading till the next double quote
*/
else if (*cp == '\"') {
++cp;
do {
if (sp - tspace >= MAXLINE)
goto toobig;
*sp++ = *cp++;
} while ((*cp != '\"') && !ISEOL(*cp));
/* HMS: a missing closing " should be an error */
}
else {
do {
if (sp - tspace >= MAXLINE)
goto toobig;
*sp++ = *cp++;
} while ((*cp != '\"') && !ISSPACE(*cp) && !ISEOL(*cp));
/* HMS: Why check for a " in the previous line? */
}
if (sp - tspace >= MAXLINE)
goto toobig;
*sp++ = '\0';
}
return;
toobig:
*ntok = 0;
fprintf(stderr,
"***Line `%s' is too big\n",
line);
return;
} | 0 |
linux | cea4dcfdad926a27a18e188720efe0f2c9403456 | NOT_APPLICABLE | NOT_APPLICABLE | void iscsi_dump_sess_ops(struct iscsi_sess_ops *sess_ops)
{
pr_debug("InitiatorName: %s\n", sess_ops->InitiatorName);
pr_debug("InitiatorAlias: %s\n", sess_ops->InitiatorAlias);
pr_debug("TargetName: %s\n", sess_ops->TargetName);
pr_debug("TargetAlias: %s\n", sess_ops->TargetAlias);
pr_debug("TargetPortalGroupTag: %hu\n",
sess_ops->TargetPortalGroupTag);
pr_debug("MaxConnections: %hu\n", sess_ops->MaxConnections);
pr_debug("InitialR2T: %s\n",
(sess_ops->InitialR2T) ? "Yes" : "No");
pr_debug("ImmediateData: %s\n", (sess_ops->ImmediateData) ?
"Yes" : "No");
pr_debug("MaxBurstLength: %u\n", sess_ops->MaxBurstLength);
pr_debug("FirstBurstLength: %u\n", sess_ops->FirstBurstLength);
pr_debug("DefaultTime2Wait: %hu\n", sess_ops->DefaultTime2Wait);
pr_debug("DefaultTime2Retain: %hu\n",
sess_ops->DefaultTime2Retain);
pr_debug("MaxOutstandingR2T: %hu\n",
sess_ops->MaxOutstandingR2T);
pr_debug("DataPDUInOrder: %s\n",
(sess_ops->DataPDUInOrder) ? "Yes" : "No");
pr_debug("DataSequenceInOrder: %s\n",
(sess_ops->DataSequenceInOrder) ? "Yes" : "No");
pr_debug("ErrorRecoveryLevel: %hu\n",
sess_ops->ErrorRecoveryLevel);
pr_debug("SessionType: %s\n", (sess_ops->SessionType) ?
"Discovery" : "Normal");
}
| 0 |
ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | NOT_APPLICABLE | NOT_APPLICABLE | check_sgr(TERMTYPE2 *tp, char *zero, int num, char *cap, const char *name)
{
char *test;
_nc_tparm_err = 0;
test = TIPARM_9(set_attributes,
num == 1,
num == 2,
num == 3,
num == 4,
num == 5,
num == 6,
num == 7,
num == 8,
num == 9);
if (test != 0) {
if (PRESENT(cap)) {
if (!similar_sgr(num, test, cap)) {
_nc_warning("%s differs from sgr(%d)\n\t%s=%s\n\tsgr(%d)=%s",
name, num,
name, _nc_visbuf2(1, cap),
num, _nc_visbuf2(2, test));
}
} else if (_nc_capcmp(test, zero)) {
_nc_warning("sgr(%d) present, but not %s", num, name);
}
} else if (PRESENT(cap)) {
_nc_warning("sgr(%d) missing, but %s present", num, name);
}
if (_nc_tparm_err)
_nc_warning("stack error in sgr(%d) string", num);
return test;
} | 0 |
FreeRDP | 9fee4ae076b1ec97b97efb79ece08d1dab4df29a | NOT_APPLICABLE | NOT_APPLICABLE | static void setBitOfReversedStream(size_t* bitpointer, unsigned char* bitstream, unsigned char bit)
{
/*the current bit in bitstream may be 0 or 1 for this to work*/
if(bit == 0)
{
size_t pos = (*bitpointer) >> 3;
bitstream[pos] &= (unsigned char)(~(1 << (7 - ((*bitpointer) & 0x7))));
}
else
{
size_t pos = (*bitpointer) >> 3;
bitstream[pos] |= (1 << (7 - ((*bitpointer) & 0x7)));
}
(*bitpointer)++;
} | 0 |
frr | 6d58272b4cf96f0daa846210dd2104877900f921 | NOT_APPLICABLE | NOT_APPLICABLE | DEFUN (bgp_router_id,
bgp_router_id_cmd,
"bgp router-id A.B.C.D",
BGP_STR
"Override configured router identifier\n"
"Manually configured router identifier\n")
{
int ret;
struct in_addr id;
struct bgp *bgp;
bgp = vty->index;
ret = inet_aton (argv[0], &id);
if (! ret)
{
vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
return CMD_WARNING;
}
bgp->router_id_static = id;
bgp_router_id_set (bgp, &id);
return CMD_SUCCESS;
} | 0 |
libvncserver | 7b1ef0ffc4815cab9a96c7278394152bdc89dc4d | NOT_APPLICABLE | NOT_APPLICABLE | HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
{
rfbRREHeader hdr;
int i;
CARDBPP pix;
uint8_t *ptr;
int x, y, w, h;
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))
return FALSE;
hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
return FALSE;
client->GotFillRect(client, rx, ry, rw, rh, pix);
if (hdr.nSubrects > RFB_BUFFER_SIZE / (4 + (BPP / 8)) || !ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8))))
return FALSE;
ptr = (uint8_t *)client->buffer;
for (i = 0; i < hdr.nSubrects; i++) {
pix = *(CARDBPP *)ptr;
ptr += BPP/8;
x = *ptr++;
y = *ptr++;
w = *ptr++;
h = *ptr++;
client->GotFillRect(client, rx+x, ry+y, w, h, pix);
}
return TRUE;
} | 0 |
Little-CMS | 5ca71a7bc18b6897ab21d815d15e218e204581e2 | NOT_APPLICABLE | NOT_APPLICABLE | cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsUInt32Number i, BaseOffset, DirectoryPos, CurrentPos;
int inputChan, outputChan;
cmsUInt32Number ElemCount;
cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL, Before;
cmsStageSignature ElementSig;
cmsPipeline* Lut = (cmsPipeline*) Ptr;
cmsStage* Elem = Lut ->Elements;
cmsTagTypeHandler* TypeHandler;
_cmsTagTypePluginChunkType* MPETypePluginChunk = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(self->ContextID, MPEPlugin);
BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
inputChan = cmsPipelineInputChannels(Lut);
outputChan = cmsPipelineOutputChannels(Lut);
ElemCount = cmsPipelineStageCount(Lut);
ElementOffsets = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
if (ElementOffsets == NULL) goto Error;
ElementSizes = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
if (ElementSizes == NULL) goto Error;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) inputChan)) goto Error;
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) outputChan)) goto Error;
if (!_cmsWriteUInt32Number(io, (cmsUInt16Number) ElemCount)) goto Error;
DirectoryPos = io ->Tell(io);
for (i=0; i < ElemCount; i++) {
if (!_cmsWriteUInt32Number(io, 0)) goto Error; // Offset
if (!_cmsWriteUInt32Number(io, 0)) goto Error; // size
}
for (i=0; i < ElemCount; i++) {
ElementOffsets[i] = io ->Tell(io) - BaseOffset;
ElementSig = Elem ->Type;
TypeHandler = GetHandler((cmsTagTypeSignature) ElementSig, MPETypePluginChunk->TagTypes, SupportedMPEtypes);
if (TypeHandler == NULL) {
char String[5];
_cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Found unknown MPE type '%s'", String);
goto Error;
}
if (!_cmsWriteUInt32Number(io, ElementSig)) goto Error;
if (!_cmsWriteUInt32Number(io, 0)) goto Error;
Before = io ->Tell(io);
if (!TypeHandler ->WritePtr(self, io, Elem, 1)) goto Error;
if (!_cmsWriteAlignment(io)) goto Error;
ElementSizes[i] = io ->Tell(io) - Before;
Elem = Elem ->Next;
}
CurrentPos = io ->Tell(io);
if (!io ->Seek(io, DirectoryPos)) goto Error;
for (i=0; i < ElemCount; i++) {
if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
}
if (!io ->Seek(io, CurrentPos)) goto Error;
if (ElementOffsets != NULL) _cmsFree(self ->ContextID, ElementOffsets);
if (ElementSizes != NULL) _cmsFree(self ->ContextID, ElementSizes);
return TRUE;
Error:
if (ElementOffsets != NULL) _cmsFree(self ->ContextID, ElementOffsets);
if (ElementSizes != NULL) _cmsFree(self ->ContextID, ElementSizes);
return FALSE;
cmsUNUSED_PARAMETER(nItems);
}
| 0 |
ghostpdl | bf72f1a3dd5392ee8291e3b1518a0c2c5dc6ba39 | NOT_APPLICABLE | NOT_APPLICABLE | bjc_put_image_format(gp_file *file, char depth, char format, char ink)
{
bjc_put_command(file, 't', 3);
gp_fputc(depth, file);
gp_fputc(format, file);
gp_fputc(ink, file);
} | 0 |
openssl | 8108e0a6db133f3375608303fdd2083eb5115062 | NOT_APPLICABLE | NOT_APPLICABLE | ossl_cipher_new(const EVP_CIPHER *cipher)
{
VALUE ret;
EVP_CIPHER_CTX *ctx;
ret = ossl_cipher_alloc(cCipher);
AllocCipher(ret, ctx);
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
ossl_raise(eCipherError, NULL);
return ret;
}
| 0 |
libsndfile | 85c877d5072866aadbe8ed0c3e0590fbb5e16788 | NOT_APPLICABLE | NOT_APPLICABLE | d2f_array (const double *src, int count, float *dest)
{ while (--count >= 0)
{ dest [count] = src [count] ;
} ;
} /* d2f_array */ | 0 |
Chrome | 3fe224d430d863880df0050faaa037b0eb00d3c0 | NOT_APPLICABLE | NOT_APPLICABLE | virtual ~TransientWindowObserver() {}
| 0 |
Android | b351eabb428c7ca85a34513c64601f437923d576 | CVE-2016-3824 | CWE-119 | status_t OMXNodeInstance::useGraphicBuffer2_l(
OMX_U32 portIndex, const sp<GraphicBuffer>& graphicBuffer,
OMX::buffer_id *buffer) {
OMX_PARAM_PORTDEFINITIONTYPE def;
InitOMXParams(&def);
def.nPortIndex = portIndex;
OMX_ERRORTYPE err = OMX_GetParameter(mHandle, OMX_IndexParamPortDefinition, &def);
if (err != OMX_ErrorNone) {
OMX_INDEXTYPE index = OMX_IndexParamPortDefinition;
CLOG_ERROR(getParameter, err, "%s(%#x): %s:%u",
asString(index), index, portString(portIndex), portIndex);
return UNKNOWN_ERROR;
}
BufferMeta *bufferMeta = new BufferMeta(graphicBuffer);
OMX_BUFFERHEADERTYPE *header = NULL;
OMX_U8* bufferHandle = const_cast<OMX_U8*>(
reinterpret_cast<const OMX_U8*>(graphicBuffer->handle));
err = OMX_UseBuffer(
mHandle,
&header,
portIndex,
bufferMeta,
def.nBufferSize,
bufferHandle);
if (err != OMX_ErrorNone) {
CLOG_ERROR(useBuffer, err, BUFFER_FMT(portIndex, "%u@%p", def.nBufferSize, bufferHandle));
delete bufferMeta;
bufferMeta = NULL;
*buffer = 0;
return StatusFromOMXError(err);
}
CHECK_EQ(header->pBuffer, bufferHandle);
CHECK_EQ(header->pAppPrivate, bufferMeta);
*buffer = makeBufferID(header);
addActiveBuffer(portIndex, *buffer);
CLOG_BUFFER(useGraphicBuffer2, NEW_BUFFER_FMT(
*buffer, portIndex, "%u@%p", def.nBufferSize, bufferHandle));
return OK;
}
| 1 |
ntp | 3680c2e4d5f88905ce062c7b43305d610a2c9796 | NOT_APPLICABLE | NOT_APPLICABLE | static void read_mru_list(
struct recvbuf *rbufp,
int restrict_mask
)
{
const char nonce_text[] = "nonce";
const char frags_text[] = "frags";
const char limit_text[] = "limit";
const char mincount_text[] = "mincount";
const char resall_text[] = "resall";
const char resany_text[] = "resany";
const char maxlstint_text[] = "maxlstint";
const char laddr_text[] = "laddr";
const char resaxx_fmt[] = "0x%hx";
u_int limit;
u_short frags;
u_short resall;
u_short resany;
int mincount;
u_int maxlstint;
sockaddr_u laddr;
struct interface * lcladr;
u_int count;
u_int ui;
u_int uf;
l_fp last[16];
sockaddr_u addr[COUNTOF(last)];
char buf[128];
struct ctl_var * in_parms;
const struct ctl_var * v;
char * val;
const char * pch;
char * pnonce;
int nonce_valid;
size_t i;
int priors;
u_short hash;
mon_entry * mon;
mon_entry * prior_mon;
l_fp now;
if (RES_NOMRULIST & restrict_mask) {
ctl_error(CERR_PERMISSION);
NLOG(NLOG_SYSINFO)
msyslog(LOG_NOTICE,
"mrulist from %s rejected due to nomrulist restriction",
stoa(&rbufp->recv_srcadr));
sys_restricted++;
return;
}
/*
* fill in_parms var list with all possible input parameters.
*/
in_parms = NULL;
set_var(&in_parms, nonce_text, sizeof(nonce_text), 0);
set_var(&in_parms, frags_text, sizeof(frags_text), 0);
set_var(&in_parms, limit_text, sizeof(limit_text), 0);
set_var(&in_parms, mincount_text, sizeof(mincount_text), 0);
set_var(&in_parms, resall_text, sizeof(resall_text), 0);
set_var(&in_parms, resany_text, sizeof(resany_text), 0);
set_var(&in_parms, maxlstint_text, sizeof(maxlstint_text), 0);
set_var(&in_parms, laddr_text, sizeof(laddr_text), 0);
for (i = 0; i < COUNTOF(last); i++) {
snprintf(buf, sizeof(buf), last_fmt, (int)i);
set_var(&in_parms, buf, strlen(buf) + 1, 0);
snprintf(buf, sizeof(buf), addr_fmt, (int)i);
set_var(&in_parms, buf, strlen(buf) + 1, 0);
}
/* decode input parms */
pnonce = NULL;
frags = 0;
limit = 0;
mincount = 0;
resall = 0;
resany = 0;
maxlstint = 0;
lcladr = NULL;
priors = 0;
ZERO(last);
ZERO(addr);
while (NULL != (v = ctl_getitem(in_parms, &val)) &&
!(EOV & v->flags)) {
int si;
if (!strcmp(nonce_text, v->text)) {
if (NULL != pnonce)
free(pnonce);
pnonce = estrdup(val);
} else if (!strcmp(frags_text, v->text)) {
sscanf(val, "%hu", &frags);
} else if (!strcmp(limit_text, v->text)) {
sscanf(val, "%u", &limit);
} else if (!strcmp(mincount_text, v->text)) {
if (1 != sscanf(val, "%d", &mincount) ||
mincount < 0)
mincount = 0;
} else if (!strcmp(resall_text, v->text)) {
sscanf(val, resaxx_fmt, &resall);
} else if (!strcmp(resany_text, v->text)) {
sscanf(val, resaxx_fmt, &resany);
} else if (!strcmp(maxlstint_text, v->text)) {
sscanf(val, "%u", &maxlstint);
} else if (!strcmp(laddr_text, v->text)) {
if (decodenetnum(val, &laddr))
lcladr = getinterface(&laddr, 0);
} else if (1 == sscanf(v->text, last_fmt, &si) &&
(size_t)si < COUNTOF(last)) {
if (2 == sscanf(val, "0x%08x.%08x", &ui, &uf)) {
last[si].l_ui = ui;
last[si].l_uf = uf;
if (!SOCK_UNSPEC(&addr[si]) &&
si == priors)
priors++;
}
} else if (1 == sscanf(v->text, addr_fmt, &si) &&
(size_t)si < COUNTOF(addr)) {
if (decodenetnum(val, &addr[si])
&& last[si].l_ui && last[si].l_uf &&
si == priors)
priors++;
}
}
free_varlist(in_parms);
in_parms = NULL;
/* return no responses until the nonce is validated */
if (NULL == pnonce)
return;
nonce_valid = validate_nonce(pnonce, rbufp);
free(pnonce);
if (!nonce_valid)
return;
if ((0 == frags && !(0 < limit && limit <= MRU_ROW_LIMIT)) ||
frags > MRU_FRAGS_LIMIT) {
ctl_error(CERR_BADVALUE);
return;
}
/*
* If either frags or limit is not given, use the max.
*/
if (0 != frags && 0 == limit)
limit = UINT_MAX;
else if (0 != limit && 0 == frags)
frags = MRU_FRAGS_LIMIT;
/*
* Find the starting point if one was provided.
*/
mon = NULL;
for (i = 0; i < (size_t)priors; i++) {
hash = MON_HASH(&addr[i]);
for (mon = mon_hash[hash];
mon != NULL;
mon = mon->hash_next)
if (ADDR_PORT_EQ(&mon->rmtadr, &addr[i]))
break;
if (mon != NULL) {
if (L_ISEQU(&mon->last, &last[i]))
break;
mon = NULL;
}
}
/* If a starting point was provided... */
if (priors) {
/* and none could be found unmodified... */
if (NULL == mon) {
/* tell ntpq to try again with older entries */
ctl_error(CERR_UNKNOWNVAR);
return;
}
/* confirm the prior entry used as starting point */
ctl_putts("last.older", &mon->last);
pch = sptoa(&mon->rmtadr);
ctl_putunqstr("addr.older", pch, strlen(pch));
/*
* Move on to the first entry the client doesn't have,
* except in the special case of a limit of one. In
* that case return the starting point entry.
*/
if (limit > 1)
mon = PREV_DLIST(mon_mru_list, mon, mru);
} else { /* start with the oldest */
mon = TAIL_DLIST(mon_mru_list, mru);
}
/*
* send up to limit= entries in up to frags= datagrams
*/
get_systime(&now);
generate_nonce(rbufp, buf, sizeof(buf));
ctl_putunqstr("nonce", buf, strlen(buf));
prior_mon = NULL;
for (count = 0;
mon != NULL && res_frags < frags && count < limit;
mon = PREV_DLIST(mon_mru_list, mon, mru)) {
if (mon->count < mincount)
continue;
if (resall && resall != (resall & mon->flags))
continue;
if (resany && !(resany & mon->flags))
continue;
if (maxlstint > 0 && now.l_ui - mon->last.l_ui >
maxlstint)
continue;
if (lcladr != NULL && mon->lcladr != lcladr)
continue;
send_mru_entry(mon, count);
if (!count)
send_random_tag_value(0);
count++;
prior_mon = mon;
}
/*
* If this batch completes the MRU list, say so explicitly with
* a now= l_fp timestamp.
*/
if (NULL == mon) {
if (count > 1)
send_random_tag_value(count - 1);
ctl_putts("now", &now);
/* if any entries were returned confirm the last */
if (prior_mon != NULL)
ctl_putts("last.newest", &prior_mon->last);
}
ctl_flushpkt(0);
} | 0 |
libvirt | 506e9d6c2d4baaf580d489fff0690c0ff2ff588f | NOT_APPLICABLE | NOT_APPLICABLE | virDomainScreenshot(virDomainPtr domain,
virStreamPtr stream,
unsigned int screen,
unsigned int flags)
{
VIR_DOMAIN_DEBUG(domain, "stream=%p, flags=%x", stream, flags);
virResetLastError();
virCheckDomainReturn(domain, NULL);
virCheckStreamGoto(stream, error);
virCheckReadOnlyGoto(domain->conn->flags, error);
if (domain->conn != stream->conn) {
virReportInvalidArg(stream,
_("stream must match connection of domain '%s'"),
domain->name);
goto error;
}
if (domain->conn->driver->domainScreenshot) {
char *ret;
ret = domain->conn->driver->domainScreenshot(domain, stream,
screen, flags);
if (ret == NULL)
goto error;
return ret;
}
virReportUnsupportedError();
error:
virDispatchError(domain->conn);
return NULL;
}
| 0 |
Chrome | acf2f0799f6f732dd70f45ddd252d773be7afd11 | NOT_APPLICABLE | NOT_APPLICABLE | void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
switch (label->id()) {
case PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_SECURITY_DETAILS:
web_contents()->OpenURL(content::OpenURLParams(
GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(),
WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
false));
presenter_->RecordPageInfoAction(
PageInfo::PAGE_INFO_CONNECTION_HELP_OPENED);
break;
case PageInfoBubbleView::
VIEW_ID_PAGE_INFO_LABEL_RESET_CERTIFICATE_DECISIONS:
presenter_->OnRevokeSSLErrorBypassButtonPressed();
GetWidget()->Close();
break;
default:
NOTREACHED();
}
}
| 0 |
mujs | 1e5479084bc9852854feb1ba9bf68b52cd127e02 | NOT_APPLICABLE | NOT_APPLICABLE | static void cassign(JF, js_Ast *exp)
{
js_Ast *lhs = exp->a;
js_Ast *rhs = exp->b;
switch (lhs->type) {
case EXP_IDENTIFIER:
cexp(J, F, rhs);
emitline(J, F, exp);
emitlocal(J, F, OP_SETLOCAL, OP_SETVAR, lhs);
break;
case EXP_INDEX:
cexp(J, F, lhs->a);
cexp(J, F, lhs->b);
cexp(J, F, rhs);
emitline(J, F, exp);
emit(J, F, OP_SETPROP);
break;
case EXP_MEMBER:
cexp(J, F, lhs->a);
cexp(J, F, rhs);
emitline(J, F, exp);
emitstring(J, F, OP_SETPROP_S, lhs->b->string);
break;
default:
jsC_error(J, lhs, "invalid l-value in assignment");
}
}
| 0 |
php-src | 0a8f28b43212cc2ddbc1f2df710e37b1bec0addd | CVE-2015-1351 | CWE-416 | void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRMLS_DC)
{
void **old_p, *retval;
if (zend_hash_index_find(&xlat_table, (ulong)source, (void **)&old_p) == SUCCESS) {
/* we already duplicated this pointer */
return *old_p;
}
retval = ZCG(mem);;
ZCG(mem) = (void*)(((char*)ZCG(mem)) + ZEND_ALIGNED_SIZE(size));
memcpy(retval, source, size);
if (free_source) {
interned_efree((char*)source);
}
zend_shared_alloc_register_xlat_entry(source, retval);
return retval;
} | 1 |
linux | 592acbf16821288ecdc4192c47e3774a4c48bb64 | NOT_APPLICABLE | NOT_APPLICABLE | int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
{
struct super_block *sb = inode->i_sb;
ext4_lblk_t punch_start, punch_stop;
handle_t *handle;
unsigned int credits;
loff_t new_size, ioffset;
int ret;
/*
* We need to test this early because xfstests assumes that a
* collapse range of (0, 1) will return EOPNOTSUPP if the file
* system does not support collapse range.
*/
if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
return -EOPNOTSUPP;
/* Collapse range works only on fs block size aligned offsets. */
if (offset & (EXT4_CLUSTER_SIZE(sb) - 1) ||
len & (EXT4_CLUSTER_SIZE(sb) - 1))
return -EINVAL;
if (!S_ISREG(inode->i_mode))
return -EINVAL;
trace_ext4_collapse_range(inode, offset, len);
punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb);
punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb);
/* Call ext4_force_commit to flush all data in case of data=journal. */
if (ext4_should_journal_data(inode)) {
ret = ext4_force_commit(inode->i_sb);
if (ret)
return ret;
}
inode_lock(inode);
/*
* There is no need to overlap collapse range with EOF, in which case
* it is effectively a truncate operation
*/
if (offset + len >= i_size_read(inode)) {
ret = -EINVAL;
goto out_mutex;
}
/* Currently just for extent based files */
if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
ret = -EOPNOTSUPP;
goto out_mutex;
}
/* Wait for existing dio to complete */
inode_dio_wait(inode);
/*
* Prevent page faults from reinstantiating pages we have released from
* page cache.
*/
down_write(&EXT4_I(inode)->i_mmap_sem);
ret = ext4_break_layouts(inode);
if (ret)
goto out_mmap;
/*
* Need to round down offset to be aligned with page size boundary
* for page size > block size.
*/
ioffset = round_down(offset, PAGE_SIZE);
/*
* Write tail of the last page before removed range since it will get
* removed from the page cache below.
*/
ret = filemap_write_and_wait_range(inode->i_mapping, ioffset, offset);
if (ret)
goto out_mmap;
/*
* Write data that will be shifted to preserve them when discarding
* page cache below. We are also protected from pages becoming dirty
* by i_mmap_sem.
*/
ret = filemap_write_and_wait_range(inode->i_mapping, offset + len,
LLONG_MAX);
if (ret)
goto out_mmap;
truncate_pagecache(inode, ioffset);
credits = ext4_writepage_trans_blocks(inode);
handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
goto out_mmap;
}
down_write(&EXT4_I(inode)->i_data_sem);
ext4_discard_preallocations(inode);
ret = ext4_es_remove_extent(inode, punch_start,
EXT_MAX_BLOCKS - punch_start);
if (ret) {
up_write(&EXT4_I(inode)->i_data_sem);
goto out_stop;
}
ret = ext4_ext_remove_space(inode, punch_start, punch_stop - 1);
if (ret) {
up_write(&EXT4_I(inode)->i_data_sem);
goto out_stop;
}
ext4_discard_preallocations(inode);
ret = ext4_ext_shift_extents(inode, handle, punch_stop,
punch_stop - punch_start, SHIFT_LEFT);
if (ret) {
up_write(&EXT4_I(inode)->i_data_sem);
goto out_stop;
}
new_size = i_size_read(inode) - len;
i_size_write(inode, new_size);
EXT4_I(inode)->i_disksize = new_size;
up_write(&EXT4_I(inode)->i_data_sem);
if (IS_SYNC(inode))
ext4_handle_sync(handle);
inode->i_mtime = inode->i_ctime = current_time(inode);
ext4_mark_inode_dirty(handle, inode);
ext4_update_inode_fsync_trans(handle, inode, 1);
out_stop:
ext4_journal_stop(handle);
out_mmap:
up_write(&EXT4_I(inode)->i_mmap_sem);
out_mutex:
inode_unlock(inode);
return ret;
}
| 0 |
gnulib | 278b4175c9d7dd47c1a3071554aac02add3b3c35 | NOT_APPLICABLE | NOT_APPLICABLE | divide (mpn_t a, mpn_t b, mpn_t *q)
{
/* Algorithm:
First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]]
with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS).
If m<n, then q:=0 and r:=a.
If m>=n=1, perform a single-precision division:
r:=0, j:=m,
while j>0 do
{Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j =
= a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r<b[0]<beta}
j:=j-1, r:=r*beta+a[j], q[j]:=floor(r/b[0]), r:=r-b[0]*q[j].
Normalise [q[m-1],...,q[0]], yields q.
If m>=n>1, perform a multiple-precision division:
We have a/b < beta^(m-n+1).
s:=intDsize-1-(highest bit in b[n-1]), 0<=s<intDsize.
Shift a and b left by s bits, copying them. r:=a.
r=[r[m],...,r[0]], b=[b[n-1],...,b[0]] with b[n-1]>=beta/2.
For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).}
Compute q* :
q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]).
In case of overflow (q* >= beta) set q* := beta-1.
Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2]
and c3 := b[n-2] * q*.
{We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow
occurred. Furthermore 0 <= c3 < beta^2.
If there was overflow and
r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2,
the next test can be skipped.}
While c3 > c2, {Here 0 <= c2 < c3 < beta^2}
Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2].
If q* > 0:
Put r := r - b * q* * beta^j. In detail:
[r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]].
hence: u:=0, for i:=0 to n-1 do
u := u + q* * b[i],
r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry),
u:=u div beta (+ 1, if carry in subtraction)
r[n+j]:=r[n+j]-u.
{Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1
< q* + 1 <= beta,
the carry u does not overflow.}
If a negative carry occurs, put q* := q* - 1
and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]].
Set q[j] := q*.
Normalise [q[m-n],..,q[0]]; this yields the quotient q.
Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the
rest r.
The room for q[j] can be allocated at the memory location of r[n+j].
Finally, round-to-even:
Shift r left by 1 bit.
If r > b or if r = b and q[0] is odd, q := q+1.
*/
const mp_limb_t *a_ptr = a.limbs;
size_t a_len = a.nlimbs;
const mp_limb_t *b_ptr = b.limbs;
size_t b_len = b.nlimbs;
mp_limb_t *roomptr;
mp_limb_t *tmp_roomptr = NULL;
mp_limb_t *q_ptr;
size_t q_len;
mp_limb_t *r_ptr;
size_t r_len;
/* Allocate room for a_len+2 digits.
(Need a_len+1 digits for the real division and 1 more digit for the
final rounding of q.) */
roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t));
if (roomptr == NULL)
return NULL;
/* Normalise a. */
while (a_len > 0 && a_ptr[a_len - 1] == 0)
a_len--;
/* Normalise b. */
for (;;)
{
if (b_len == 0)
/* Division by zero. */
abort ();
if (b_ptr[b_len - 1] == 0)
b_len--;
else
break;
}
/* Here m = a_len >= 0 and n = b_len > 0. */
if (a_len < b_len)
{
/* m<n: trivial case. q=0, r := copy of a. */
r_ptr = roomptr;
r_len = a_len;
memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
q_ptr = roomptr + a_len;
q_len = 0;
}
else if (b_len == 1)
{
/* n=1: single precision division.
beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */
r_ptr = roomptr;
q_ptr = roomptr + 1;
{
mp_limb_t den = b_ptr[0];
mp_limb_t remainder = 0;
const mp_limb_t *sourceptr = a_ptr + a_len;
mp_limb_t *destptr = q_ptr + a_len;
size_t count;
for (count = a_len; count > 0; count--)
{
mp_twolimb_t num =
((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
*--destptr = num / den;
remainder = num % den;
}
/* Normalise and store r. */
if (remainder > 0)
{
r_ptr[0] = remainder;
r_len = 1;
}
else
r_len = 0;
/* Normalise q. */
q_len = a_len;
if (q_ptr[q_len - 1] == 0)
q_len--;
}
}
else
{
/* n>1: multiple precision division.
beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==>
beta^(m-n-1) <= a/b < beta^(m-n+1). */
/* Determine s. */
size_t s;
{
mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
/* Determine s = GMP_LIMB_BITS - integer_length (msd).
Code copied from gnulib's integer_length.c. */
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
s = __builtin_clz (msd);
# else
# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
if (GMP_LIMB_BITS <= DBL_MANT_BIT)
{
/* Use 'double' operations.
Assumes an IEEE 754 'double' implementation. */
# define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
# define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1)
# define NWORDS \
((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
union { double value; unsigned int word[NWORDS]; } m;
/* Use a single integer to floating-point conversion. */
m.value = msd;
s = GMP_LIMB_BITS
- (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & DBL_EXP_MASK)
- DBL_EXP_BIAS);
}
else
# undef NWORDS
# endif
{
s = 31;
if (msd >= 0x10000)
{
msd = msd >> 16;
s -= 16;
}
if (msd >= 0x100)
{
msd = msd >> 8;
s -= 8;
}
if (msd >= 0x10)
{
msd = msd >> 4;
s -= 4;
}
if (msd >= 0x4)
{
msd = msd >> 2;
s -= 2;
}
if (msd >= 0x2)
{
msd = msd >> 1;
s -= 1;
}
}
# endif
}
/* 0 <= s < GMP_LIMB_BITS.
Copy b, shifting it left by s bits. */
if (s > 0)
{
tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
if (tmp_roomptr == NULL)
{
free (roomptr);
return NULL;
}
{
const mp_limb_t *sourceptr = b_ptr;
mp_limb_t *destptr = tmp_roomptr;
mp_twolimb_t accu = 0;
size_t count;
for (count = b_len; count > 0; count--)
{
accu += (mp_twolimb_t) *sourceptr++ << s;
*destptr++ = (mp_limb_t) accu;
accu = accu >> GMP_LIMB_BITS;
}
/* accu must be zero, since that was how s was determined. */
if (accu != 0)
abort ();
}
b_ptr = tmp_roomptr;
}
/* Copy a, shifting it left by s bits, yields r.
Memory layout:
At the beginning: r = roomptr[0..a_len],
at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */
r_ptr = roomptr;
if (s == 0)
{
memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
r_ptr[a_len] = 0;
}
else
{
const mp_limb_t *sourceptr = a_ptr;
mp_limb_t *destptr = r_ptr;
mp_twolimb_t accu = 0;
size_t count;
for (count = a_len; count > 0; count--)
{
accu += (mp_twolimb_t) *sourceptr++ << s;
*destptr++ = (mp_limb_t) accu;
accu = accu >> GMP_LIMB_BITS;
}
*destptr++ = (mp_limb_t) accu;
}
q_ptr = roomptr + b_len;
q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */
{
size_t j = a_len - b_len; /* m-n */
mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
/* Division loop, traversed m-n+1 times.
j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */
for (;;)
{
mp_limb_t q_star;
mp_limb_t c1;
if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
{
/* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */
mp_twolimb_t num =
((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
| r_ptr[j + b_len - 1];
q_star = num / b_msd;
c1 = num % b_msd;
}
else
{
/* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */
q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
/* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
<==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
<==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
{<= beta !}.
If yes, jump directly to the subtraction loop.
(Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
<==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
if (r_ptr[j + b_len] > b_msd
|| (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
/* r[j+n] >= b[n-1]+1 or
r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
carry. */
goto subtract;
}
/* q_star = q*,
c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */
{
mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
mp_twolimb_t c3 = /* b[n-2] * q* */
(mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
/* While c2 < c3, increase c2 and decrease c3.
Consider c3-c2. While it is > 0, decrease it by
b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2
this can happen only twice. */
if (c3 > c2)
{
q_star = q_star - 1; /* q* := q* - 1 */
if (c3 - c2 > b_msdd)
q_star = q_star - 1; /* q* := q* - 1 */
}
}
if (q_star > 0)
subtract:
{
/* Subtract r := r - b * q* * beta^j. */
mp_limb_t cr;
{
const mp_limb_t *sourceptr = b_ptr;
mp_limb_t *destptr = r_ptr + j;
mp_twolimb_t carry = 0;
size_t count;
for (count = b_len; count > 0; count--)
{
/* Here 0 <= carry <= q*. */
carry =
carry
+ (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
+ (mp_limb_t) ~(*destptr);
/* Here 0 <= carry <= beta*q* + beta-1. */
*destptr++ = ~(mp_limb_t) carry;
carry = carry >> GMP_LIMB_BITS; /* <= q* */
}
cr = (mp_limb_t) carry;
}
/* Subtract cr from r_ptr[j + b_len], then forget about
r_ptr[j + b_len]. */
if (cr > r_ptr[j + b_len])
{
/* Subtraction gave a carry. */
q_star = q_star - 1; /* q* := q* - 1 */
/* Add b back. */
{
const mp_limb_t *sourceptr = b_ptr;
mp_limb_t *destptr = r_ptr + j;
mp_limb_t carry = 0;
size_t count;
for (count = b_len; count > 0; count--)
{
mp_limb_t source1 = *sourceptr++;
mp_limb_t source2 = *destptr;
*destptr++ = source1 + source2 + carry;
carry =
(carry
? source1 >= (mp_limb_t) ~source2
: source1 > (mp_limb_t) ~source2);
}
}
/* Forget about the carry and about r[j+n]. */
}
}
/* q* is determined. Store it as q[j]. */
q_ptr[j] = q_star;
if (j == 0)
break;
j--;
}
}
r_len = b_len;
/* Normalise q. */
if (q_ptr[q_len - 1] == 0)
q_len--;
# if 0 /* Not needed here, since we need r only to compare it with b/2, and
b is shifted left by s bits. */
/* Shift r right by s bits. */
if (s > 0)
{
mp_limb_t ptr = r_ptr + r_len;
mp_twolimb_t accu = 0;
size_t count;
for (count = r_len; count > 0; count--)
{
accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
*ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
}
}
# endif
/* Normalise r. */
while (r_len > 0 && r_ptr[r_len - 1] == 0)
r_len--;
}
/* Compare r << 1 with b. */
if (r_len > b_len)
goto increment_q;
{
size_t i;
for (i = b_len;;)
{
mp_limb_t r_i =
(i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
| (i < r_len ? r_ptr[i] << 1 : 0);
mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
if (r_i > b_i)
goto increment_q;
if (r_i < b_i)
goto keep_q;
if (i == 0)
break;
i--;
}
}
if (q_len > 0 && ((q_ptr[0] & 1) != 0))
/* q is odd. */
increment_q:
{
size_t i;
for (i = 0; i < q_len; i++)
if (++(q_ptr[i]) != 0)
goto keep_q;
q_ptr[q_len++] = 1;
}
keep_q:
if (tmp_roomptr != NULL)
free (tmp_roomptr);
q->limbs = q_ptr;
q->nlimbs = q_len;
return roomptr;
}
| 0 |
mindrot | 2fecfd486bdba9f51b3a789277bb0733ca36e1c0 | NOT_APPLICABLE | NOT_APPLICABLE | ssh_packet_connection_af(struct ssh *ssh)
{
struct sockaddr_storage to;
socklen_t tolen = sizeof(to);
memset(&to, 0, sizeof(to));
if (getsockname(ssh->state->connection_out, (struct sockaddr *)&to,
&tolen) < 0)
return 0;
#ifdef IPV4_IN_IPV6
if (to.ss_family == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr))
return AF_INET;
#endif
return to.ss_family;
}
| 0 |
linux | ec8013beddd717d1740cfefb1a9b900deef85462 | NOT_APPLICABLE | NOT_APPLICABLE | static void multipath_resume(struct dm_target *ti)
{
struct multipath *m = (struct multipath *) ti->private;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
m->queue_if_no_path = m->saved_queue_if_no_path;
spin_unlock_irqrestore(&m->lock, flags);
}
| 0 |
linux | f2e323ec96077642d397bb1c355def536d489d16 | NOT_APPLICABLE | NOT_APPLICABLE | static int ttusbdecfe_dvbt_read_status(struct dvb_frontend *fe,
fe_status_t *status)
{
struct ttusbdecfe_state* state = fe->demodulator_priv;
u8 b[] = { 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
u8 result[4];
int len, ret;
*status=0;
ret=state->config->send_command(fe, 0x73, sizeof(b), b, &len, result);
if(ret)
return ret;
if(len != 4) {
printk(KERN_ERR "%s: unexpected reply\n", __func__);
return -EIO;
}
switch(result[3]) {
case 1: /* not tuned yet */
case 2: /* no signal/no lock*/
break;
case 3: /* signal found and locked*/
*status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
break;
case 4:
*status = FE_TIMEDOUT;
break;
default:
pr_info("%s: returned unknown value: %d\n",
__func__, result[3]);
return -EIO;
}
return 0;
}
| 0 |
Chrome | 0660e08731fd42076d7242068e9eaed1482b14d5 | NOT_APPLICABLE | NOT_APPLICABLE | bool GetTabById(int tab_id,
content::BrowserContext* context,
bool include_incognito,
Browser** browser,
TabStripModel** tab_strip,
content::WebContents** contents,
int* tab_index,
std::string* error_message) {
if (ExtensionTabUtil::GetTabById(tab_id, context, include_incognito, browser,
tab_strip, contents, tab_index)) {
return true;
}
if (error_message) {
*error_message = ErrorUtils::FormatErrorMessage(
tabs_constants::kTabNotFoundError, base::IntToString(tab_id));
}
return false;
}
| 0 |
linux | ec8013beddd717d1740cfefb1a9b900deef85462 | NOT_APPLICABLE | NOT_APPLICABLE | static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector)
{
struct linear_c *lc = ti->private;
return lc->start + dm_target_offset(ti, bi_sector);
}
| 0 |
Chrome | a06c5187775536a68f035f16cdb8bc47b9bfad24 | NOT_APPLICABLE | NOT_APPLICABLE | int64_t SQLiteDatabase::TotalSize() {
int64_t page_count = 0;
{
MutexLocker locker(authorizer_lock_);
EnableAuthorizer(false);
SQLiteStatement statement(*this, "PRAGMA page_count");
page_count = statement.GetColumnInt64(0);
EnableAuthorizer(true);
}
return page_count * PageSize();
}
| 0 |
Chrome | d913f72b4875cf0814fc3f03ad7c00642097c4a4 | NOT_APPLICABLE | NOT_APPLICABLE | void WebRuntimeFeatures::EnableWebGL2ComputeContext(bool enable) {
RuntimeEnabledFeatures::SetWebGL2ComputeContextEnabled(enable);
}
| 0 |
qemu | f9a70e79391f6d7c2a912d785239ee8effc1922d | NOT_APPLICABLE | NOT_APPLICABLE | static int vnc_update_client(VncState *vs, int has_dirty, bool sync)
{
if (vs->need_update && vs->csock != -1) {
VncDisplay *vd = vs->vd;
VncJob *job;
int y;
int height, width;
int n = 0;
if (vs->output.offset && !vs->audio_cap && !vs->force_update)
/* kernel send buffers are full -> drop frames to throttle */
return 0;
if (!has_dirty && !vs->audio_cap && !vs->force_update)
return 0;
/*
* Send screen updates to the vnc client using the server
* surface and server dirty map. guest surface updates
* happening in parallel don't disturb us, the next pass will
* send them to the client.
*/
job = vnc_job_new(vs);
height = MIN(pixman_image_get_height(vd->server), vs->client_height);
width = MIN(pixman_image_get_width(vd->server), vs->client_width);
y = 0;
for (;;) {
int x, h;
unsigned long x2;
unsigned long offset = find_next_bit((unsigned long *) &vs->dirty,
height * VNC_DIRTY_BPL(vs),
y * VNC_DIRTY_BPL(vs));
if (offset == height * VNC_DIRTY_BPL(vs)) {
/* no more dirty bits */
break;
}
y = offset / VNC_DIRTY_BPL(vs);
x = offset % VNC_DIRTY_BPL(vs);
x2 = find_next_zero_bit((unsigned long *) &vs->dirty[y],
VNC_DIRTY_BPL(vs), x);
bitmap_clear(vs->dirty[y], x, x2 - x);
h = find_and_clear_dirty_height(vs, y, x, x2, height);
x2 = MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT);
if (x2 > x) {
n += vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y,
(x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h);
}
}
vnc_job_push(job);
if (sync) {
vnc_jobs_join(vs);
}
vs->force_update = 0;
return n;
}
if (vs->csock == -1) {
vnc_disconnect_finish(vs);
} else if (sync) {
vnc_jobs_join(vs);
}
return 0;
} | 0 |
qemu | 3251bdcf1c67427d964517053c3d185b46e618e8 | NOT_APPLICABLE | NOT_APPLICABLE | void ide_data_writel(void *opaque, uint32_t addr, uint32_t val)
{
IDEBus *bus = opaque;
IDEState *s = idebus_active_if(bus);
uint8_t *p;
/* PIO data access allowed only when DRQ bit is set. The result of a write
* during PIO out is indeterminate, just ignore it. */
if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) {
return;
}
p = s->data_ptr;
*(uint32_t *)p = le32_to_cpu(val);
p += 4;
s->data_ptr = p;
if (p >= s->data_end)
s->end_transfer_func(s);
}
| 0 |
iperf | 91f2fa59e8ed80dfbf400add0164ee0e508e412a | NOT_APPLICABLE | NOT_APPLICABLE | delay(int64_t ns)
{
struct timespec req, rem;
req.tv_sec = 0;
while (ns >= 1000000000L) {
ns -= 1000000000L;
req.tv_sec += 1;
}
req.tv_nsec = ns;
while (nanosleep(&req, &rem) == -1)
if (EINTR == errno)
memcpy(&req, &rem, sizeof(rem));
else
return -1;
return 0;
}
| 0 |
node-sqlite3 | 593c9d498be2510d286349134537e3bf89401c4a | NOT_APPLICABLE | NOT_APPLICABLE | void Statement::AsyncEach(uv_async_t* handle) {
Async* async = static_cast<Async*>(handle->data);
Napi::Env env = async->stmt->Env();
Napi::HandleScope scope(env);
while (true) {
// Get the contents out of the data cache for us to process in the JS callback.
Rows rows;
NODE_SQLITE3_MUTEX_LOCK(&async->mutex)
rows.swap(async->data);
NODE_SQLITE3_MUTEX_UNLOCK(&async->mutex)
if (rows.empty()) {
break;
}
Napi::Function cb = async->item_cb.Value();
if (!cb.IsUndefined() && cb.IsFunction()) {
Napi::Value argv[2];
argv[0] = env.Null();
Rows::const_iterator it = rows.begin();
Rows::const_iterator end = rows.end();
for (int i = 0; it < end; ++it, i++) {
std::unique_ptr<Row> row(*it);
argv[1] = RowToJS(env,row.get());
async->retrieved++;
TRY_CATCH_CALL(async->stmt->Value(), cb, 2, argv);
}
}
}
Napi::Function cb = async->completed_cb.Value();
if (async->completed) {
if (!cb.IsEmpty() &&
cb.IsFunction()) {
Napi::Value argv[] = {
env.Null(),
Napi::Number::New(env, async->retrieved)
};
TRY_CATCH_CALL(async->stmt->Value(), cb, 2, argv);
}
uv_close(reinterpret_cast<uv_handle_t*>(handle), CloseCallback);
}
} | 0 |
linux | dc0b027dfadfcb8a5504f7d8052754bf8d501ab9 | NOT_APPLICABLE | NOT_APPLICABLE | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
{
struct xdr_stream xdr;
struct compound_hdr hdr;
int status;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
status = decode_compound_hdr(&xdr, &hdr);
if (!status)
status = decode_renew(&xdr);
return status;
}
| 0 |
gnupg | b0b3803e8c2959dd67ca96debc54b5c6464f0d41 | NOT_APPLICABLE | NOT_APPLICABLE | scd_update_reader_status_file (void)
{
int err;
err = npth_mutex_lock (&status_file_update_lock);
if (err)
return; /* locked - give up. */
update_reader_status_file (1);
err = npth_mutex_unlock (&status_file_update_lock);
if (err)
log_error ("failed to release status_file_update lock: %s\n",
strerror (err));
} | 0 |
ImageMagick | cb1214c124e1bd61f7dd551b94a794864861592e | NOT_APPLICABLE | NOT_APPLICABLE | static int jpeg_extract(Image *ifile, Image *ofile)
{
unsigned int marker;
unsigned int done = 0;
if (jpeg_skip_1(ifile) != 0xff)
return 0;
if (jpeg_skip_1(ifile) != M_SOI)
return 0;
while (done == MagickFalse)
{
marker = jpeg_skip_till_marker(ifile, M_APP13);
if (marker == M_APP13)
{
marker = jpeg_nextmarker(ifile, ofile);
break;
}
}
return 1;
}
| 0 |
libsoup | 0e7b2c1466434a992b6a387497432e1c97b6125c | NOT_APPLICABLE | NOT_APPLICABLE | calc_hmac_md5 (unsigned char *hmac, const guchar *key, gsize key_sz, const guchar *data, gsize data_sz)
{
char *hmac_hex, *hex_pos;
size_t count;
hmac_hex = g_compute_hmac_for_data(G_CHECKSUM_MD5, key, key_sz, data, data_sz);
hex_pos = hmac_hex;
for (count = 0; count < HMAC_MD5_LENGTH; count++)
{
sscanf(hex_pos, "%2hhx", &hmac[count]);
hex_pos += 2;
}
g_free(hmac_hex);
} | 0 |
rdesktop | 766ebcf6f23ccfe8323ac10242ae6e127d4505d2 | NOT_APPLICABLE | NOT_APPLICABLE | rdp_enum_bmpcache2(void)
{
STREAM s;
HASH_KEY keylist[BMPCACHE2_NUM_PSTCELLS];
uint32 num_keys, offset, count, flags;
offset = 0;
num_keys = pstcache_enumerate(2, keylist);
while (offset < num_keys)
{
count = MIN(num_keys - offset, 169);
s = rdp_init_data(24 + count * sizeof(HASH_KEY));
flags = 0;
if (offset == 0)
flags |= PDU_FLAG_FIRST;
if (num_keys - offset <= 169)
flags |= PDU_FLAG_LAST;
/* header */
out_uint32_le(s, 0);
out_uint16_le(s, count);
out_uint16_le(s, 0);
out_uint16_le(s, 0);
out_uint16_le(s, 0);
out_uint16_le(s, 0);
out_uint16_le(s, num_keys);
out_uint32_le(s, 0);
out_uint32_le(s, flags);
/* list */
out_uint8a(s, keylist[offset], count * sizeof(HASH_KEY));
s_mark_end(s);
rdp_send_data(s, 0x2b);
offset += 169;
}
} | 0 |
linux | 3b1c5a5307fb5277f395efdcf330c064d79df07d | NOT_APPLICABLE | NOT_APPLICABLE | static struct net_device *get_vlan(struct genl_info *info,
struct cfg80211_registered_device *rdev)
{
struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN];
struct net_device *v;
int ret;
if (!vlanattr)
return NULL;
v = dev_get_by_index(genl_info_net(info), nla_get_u32(vlanattr));
if (!v)
return ERR_PTR(-ENODEV);
if (!v->ieee80211_ptr || v->ieee80211_ptr->wiphy != &rdev->wiphy) {
ret = -EINVAL;
goto error;
}
if (!netif_running(v)) {
ret = -ENETDOWN;
goto error;
}
return v;
error:
dev_put(v);
return ERR_PTR(ret);
} | 0 |
php-src | abd159cce48f3e34f08e4751c568e09677d5ec9c?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_NAMED_FUNCTION(php_if_fopen)
{
char *filename, *mode;
int filename_len, mode_len;
zend_bool use_include_path = 0;
zval *zcontext = NULL;
php_stream *stream;
php_stream_context *context = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps|br", &filename, &filename_len, &mode, &mode_len, &use_include_path, &zcontext) == FAILURE) {
RETURN_FALSE;
}
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(filename, mode, (use_include_path ? USE_PATH : 0) | REPORT_ERRORS, NULL, context);
if (stream == NULL) {
RETURN_FALSE;
}
php_stream_to_zval(stream, return_value);
}
| 0 |
linux | 338f977f4eb441e69bb9a46eaa0ac715c931a67f | NOT_APPLICABLE | NOT_APPLICABLE | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const void *frame, size_t frame_len,
const struct ieee80211_tx_info *frame_txctl,
struct ieee80211_cts *cts)
{
const struct ieee80211_hdr *hdr = frame;
cts->frame_control =
cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
cts->duration = ieee80211_ctstoself_duration(hw, vif,
frame_len, frame_txctl);
memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));
}
| 0 |
php-src | 57b997ebf99e0eb9a073e0dafd2ab100bd4a112d | NOT_APPLICABLE | NOT_APPLICABLE | inline static char xml_decode_iso_8859_1(unsigned short c)
{
return (char)(c > 0xff ? '?' : c);
} | 0 |
php-src | 7722455726bec8c53458a32851d2a87982cf0eac?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | gdImagePtr gdImageCreateFromGd2 (FILE * inFile)
{
gdIOCtx *in = gdNewFileCtx(inFile);
gdImagePtr im;
im = gdImageCreateFromGd2Ctx(in);
in->gd_free(in);
return im;
}
| 0 |
FFmpeg | 2a05c8f813de6f2278827734bf8102291e7484aa | NOT_APPLICABLE | NOT_APPLICABLE | static int http_close(URLContext *h)
{
int ret = 0;
HTTPContext *s = h->priv_data;
#if CONFIG_ZLIB
inflateEnd(&s->inflate_stream);
av_freep(&s->inflate_buffer);
#endif /* CONFIG_ZLIB */
if (!s->end_chunked_post)
/* Close the write direction by sending the end of chunked encoding. */
ret = http_shutdown(h, h->flags);
if (s->hd)
ffurl_closep(&s->hd);
av_dict_free(&s->chained_options);
return ret;
}
| 0 |
gpac | 77510778516803b7f7402d7423c6d6bef50254c3 | NOT_APPLICABLE | NOT_APPLICABLE | void trex_box_del(GF_Box *s)
{
GF_TrackExtendsBox *ptr = (GF_TrackExtendsBox *)s;
if (ptr == NULL) return;
gf_free(ptr);
} | 0 |
openssl | 1fb9fdc3027b27d8eb6a1e6a846435b070980770 | NOT_APPLICABLE | NOT_APPLICABLE | int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue)
{
pitem *item;
item = pqueue_pop(queue->q);
if (item) {
dtls1_copy_record(s, item);
OPENSSL_free(item->data);
pitem_free(item);
return (1);
}
return (0);
}
| 0 |
linux | 20e0fa98b751facf9a1101edaefbc19c82616a68 | NOT_APPLICABLE | NOT_APPLICABLE | static void nfs4_opendata_free(struct kref *kref)
{
struct nfs4_opendata *p = container_of(kref,
struct nfs4_opendata, kref);
struct super_block *sb = p->dentry->d_sb;
nfs_free_seqid(p->o_arg.seqid);
if (p->state != NULL)
nfs4_put_open_state(p->state);
nfs4_put_state_owner(p->owner);
dput(p->dir);
dput(p->dentry);
nfs_sb_deactive(sb);
nfs_fattr_free_names(&p->f_attr);
kfree(p);
}
| 0 |
linux | 9ad2de43f1aee7e7274a4e0d41465489299e344b | CVE-2012-6545 | CWE-200 | static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen)
{
struct sock *sk = sock->sk;
struct bt_security sec;
int len, err = 0;
BT_DBG("sk %p", sk);
if (level == SOL_RFCOMM)
return rfcomm_sock_getsockopt_old(sock, optname, optval, optlen);
if (level != SOL_BLUETOOTH)
return -ENOPROTOOPT;
if (get_user(len, optlen))
return -EFAULT;
lock_sock(sk);
switch (optname) {
case BT_SECURITY:
if (sk->sk_type != SOCK_STREAM) {
err = -EINVAL;
break;
}
sec.level = rfcomm_pi(sk)->sec_level;
len = min_t(unsigned int, len, sizeof(sec));
if (copy_to_user(optval, (char *) &sec, len))
err = -EFAULT;
break;
case BT_DEFER_SETUP:
if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) {
err = -EINVAL;
break;
}
if (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags),
(u32 __user *) optval))
err = -EFAULT;
break;
default:
err = -ENOPROTOOPT;
break;
}
release_sock(sk);
return err;
}
| 1 |
Chrome | d27468a832d5316884bd02f459cbf493697fd7e1 | NOT_APPLICABLE | NOT_APPLICABLE | AXNodeObject* AXNodeObject::create(Node* node,
AXObjectCacheImpl& axObjectCache) {
return new AXNodeObject(node, axObjectCache);
}
| 0 |
sleuthkit | 114cd3d0aac8bd1aeaf4b33840feb0163d342d5b | NOT_APPLICABLE | NOT_APPLICABLE | hfs_cat_get_record_offset_cb(HFS_INFO * hfs, int8_t level_type,
const hfs_btree_key_cat * cur_key,
TSK_OFF_T key_off, void *ptr)
{
HFS_CAT_GET_RECORD_OFFSET_DATA *offset_data = (HFS_CAT_GET_RECORD_OFFSET_DATA *)ptr;
const hfs_btree_key_cat *targ_key = offset_data->targ_key;
if (tsk_verbose)
tsk_fprintf(stderr,
"hfs_cat_get_record_offset_cb: %s node want: %" PRIu32
" vs have: %" PRIu32 "\n",
(level_type == HFS_BT_NODE_TYPE_IDX) ? "Index" : "Leaf",
tsk_getu32(hfs->fs_info.endian, targ_key->parent_cnid),
tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid));
if (level_type == HFS_BT_NODE_TYPE_IDX) {
int diff = hfs_cat_compare_keys(hfs, cur_key, targ_key);
if (diff < 0)
return HFS_BTREE_CB_IDX_LT;
else
return HFS_BTREE_CB_IDX_EQGT;
}
else {
int diff = hfs_cat_compare_keys(hfs, cur_key, targ_key);
if (diff < 0) {
return HFS_BTREE_CB_LEAF_GO;
}
else if (diff == 0) {
offset_data->off =
key_off + 2 + tsk_getu16(hfs->fs_info.endian,
cur_key->key_len);
}
return HFS_BTREE_CB_LEAF_STOP;
}
}
| 0 |
lepton | 6a5ceefac1162783fffd9506a3de39c85c725761 | NOT_APPLICABLE | NOT_APPLICABLE | public: bool operator() (const ThreadHandoff &a,
const ThreadHandoff &b) const {
return a.segment_size < b.segment_size;
} | 0 |
Chrome | 0bb3f5c715eb66bb5c1fb05fd81d902ca57f33ca | NOT_APPLICABLE | NOT_APPLICABLE | bool SiteInstance::IsSameWebSite(BrowserContext* browser_context,
const GURL& real_src_url,
const GURL& real_dest_url) {
return SiteInstanceImpl::IsSameWebSite(browser_context, real_src_url,
real_dest_url, true);
}
| 0 |
minetest | b5956bde259faa240a81060ff4e598e25ad52dae | NOT_APPLICABLE | NOT_APPLICABLE | static void sanitize_string(std::string &str)
{
str.erase(std::remove(str.begin(), str.end(), DESERIALIZE_START), str.end());
str.erase(std::remove(str.begin(), str.end(), DESERIALIZE_KV_DELIM), str.end());
str.erase(std::remove(str.begin(), str.end(), DESERIALIZE_PAIR_DELIM), str.end());
} | 0 |
qemu | 99ccfaa1edafd79f7a3a0ff7b58ae4da7c514928 | NOT_APPLICABLE | NOT_APPLICABLE | static void pcnet_poll_timer(void *opaque)
{
PCNetState *s = opaque;
timer_del(s->poll_timer);
if (CSR_TDMD(s)) {
pcnet_transmit(s);
}
pcnet_update_irq(s);
if (!CSR_STOP(s) && !CSR_SPND(s) && !CSR_DPOLL(s)) {
uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) * 33;
if (!s->timer || !now) {
s->timer = now;
} else {
uint64_t t = now - s->timer + CSR_POLL(s);
if (t > 0xffffLL) {
pcnet_poll(s);
CSR_POLL(s) = CSR_PINT(s);
} else {
CSR_POLL(s) = t;
}
}
timer_mod(s->poll_timer,
pcnet_get_next_poll_time(s,qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)));
}
} | 0 |
linux | 212925802454672e6cd2949a727f5e2c1377bf06 | NOT_APPLICABLE | NOT_APPLICABLE | unsigned long do_mmap(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flags, vm_flags_t vm_flags,
unsigned long pgoff, unsigned long *populate,
struct list_head *uf)
{
struct mm_struct *mm = current->mm;
int pkey = 0;
*populate = 0;
if (!len)
return -EINVAL;
/*
* Does the application expect PROT_READ to imply PROT_EXEC?
*
* (the exception is when the underlying filesystem is noexec
* mounted, in which case we dont add PROT_EXEC.)
*/
if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
if (!(file && path_noexec(&file->f_path)))
prot |= PROT_EXEC;
if (!(flags & MAP_FIXED))
addr = round_hint_to_min(addr);
/* Careful about overflows.. */
len = PAGE_ALIGN(len);
if (!len)
return -ENOMEM;
/* offset overflow? */
if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
return -EOVERFLOW;
/* Too many mappings? */
if (mm->map_count > sysctl_max_map_count)
return -ENOMEM;
/* Obtain the address to map to. we verify (or select) it and ensure
* that it represents a valid section of the address space.
*/
addr = get_unmapped_area(file, addr, len, pgoff, flags);
if (offset_in_page(addr))
return addr;
if (prot == PROT_EXEC) {
pkey = execute_only_pkey(mm);
if (pkey < 0)
pkey = 0;
}
/* Do simple checking here so the lower-level routines won't have
* to. we assume access permissions have been handled by the open
* of the memory object, so we don't do any here.
*/
vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(flags) |
mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
if (flags & MAP_LOCKED)
if (!can_do_mlock())
return -EPERM;
if (mlock_future_check(mm, vm_flags, len))
return -EAGAIN;
if (file) {
struct inode *inode = file_inode(file);
switch (flags & MAP_TYPE) {
case MAP_SHARED:
if ((prot&PROT_WRITE) && !(file->f_mode&FMODE_WRITE))
return -EACCES;
/*
* Make sure we don't allow writing to an append-only
* file..
*/
if (IS_APPEND(inode) && (file->f_mode & FMODE_WRITE))
return -EACCES;
/*
* Make sure there are no mandatory locks on the file.
*/
if (locks_verify_locked(file))
return -EAGAIN;
vm_flags |= VM_SHARED | VM_MAYSHARE;
if (!(file->f_mode & FMODE_WRITE))
vm_flags &= ~(VM_MAYWRITE | VM_SHARED);
/* fall through */
case MAP_PRIVATE:
if (!(file->f_mode & FMODE_READ))
return -EACCES;
if (path_noexec(&file->f_path)) {
if (vm_flags & VM_EXEC)
return -EPERM;
vm_flags &= ~VM_MAYEXEC;
}
if (!file->f_op->mmap)
return -ENODEV;
if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP))
return -EINVAL;
break;
default:
return -EINVAL;
}
} else {
switch (flags & MAP_TYPE) {
case MAP_SHARED:
if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP))
return -EINVAL;
/*
* Ignore pgoff.
*/
pgoff = 0;
vm_flags |= VM_SHARED | VM_MAYSHARE;
break;
case MAP_PRIVATE:
/*
* Set pgoff according to addr for anon_vma.
*/
pgoff = addr >> PAGE_SHIFT;
break;
default:
return -EINVAL;
}
}
/*
* Set 'VM_NORESERVE' if we should not account for the
* memory use of this mapping.
*/
if (flags & MAP_NORESERVE) {
/* We honor MAP_NORESERVE if allowed to overcommit */
if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
vm_flags |= VM_NORESERVE;
/* hugetlb applies strict overcommit unless MAP_NORESERVE */
if (file && is_file_hugepages(file))
vm_flags |= VM_NORESERVE;
}
addr = mmap_region(file, addr, len, vm_flags, pgoff, uf);
if (!IS_ERR_VALUE(addr) &&
((vm_flags & VM_LOCKED) ||
(flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
*populate = len;
return addr;
} | 0 |
cyrus-imapd | 621f9e41465b521399f691c241181300fab55995 | NOT_APPLICABLE | NOT_APPLICABLE | static void annotation_get_freespace(annotate_state_t *state,
struct annotate_entry_list *entry)
{
uint64_t tavail = 0;
struct buf value = BUF_INITIALIZER;
(void) partlist_local_find_freespace_most(0, NULL, NULL, &tavail, NULL);
buf_printf(&value, "%" PRIuMAX, (uintmax_t)tavail);
output_entryatt(state, entry->name, "", &value);
buf_free(&value);
} | 0 |
linux | df7e40425813c50cd252e6f5e348a81ef1acae56 | NOT_APPLICABLE | NOT_APPLICABLE | static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
unsigned long event)
{
struct device *dev = hr_dev->dev;
struct net_device *netdev;
int ret = 0;
netdev = hr_dev->iboe.netdevs[port];
if (!netdev) {
dev_err(dev, "port(%d) can't find netdev\n", port);
return -ENODEV;
}
switch (event) {
case NETDEV_UP:
case NETDEV_CHANGE:
case NETDEV_REGISTER:
case NETDEV_CHANGEADDR:
ret = hns_roce_set_mac(hr_dev, port, netdev->dev_addr);
break;
case NETDEV_DOWN:
/*
* In v1 engine, only support all ports closed together.
*/
break;
default:
dev_dbg(dev, "NETDEV event = 0x%x!\n", (u32)(event));
break;
}
return ret;
}
| 0 |
linux | 2172fa709ab32ca60e86179dc67d0857be8e2c98 | NOT_APPLICABLE | NOT_APPLICABLE | static u16 map_class(u16 pol_value)
{
u16 i;
for (i = 1; i < current_mapping_size; i++) {
if (current_mapping[i].value == pol_value)
return i;
}
return SECCLASS_NULL;
}
| 0 |
PDFGen | ee58aff6918b8bbc3be29b9e3089485ea46ff956 | NOT_APPLICABLE | NOT_APPLICABLE | static pdf_object *pdf_add_raw_rgb24(struct pdf_doc *pdf,
uint8_t *data, int width, int height)
{
struct pdf_object *obj;
char line[1024];
int len;
uint8_t *final_data;
const char *endstream = ">\r\nendstream\r\n";
int i;
sprintf(line,
"<<\r\n/Type /XObject\r\n/Name /Image%d\r\n/Subtype /Image\r\n"
"/ColorSpace /DeviceRGB\r\n/Height %d\r\n/Width %d\r\n"
"/BitsPerComponent 8\r\n/Filter /ASCIIHexDecode\r\n"
"/Length %d\r\n>>stream\r\n",
flexarray_size(&pdf->objects), height, width, width * height * 3 * 2 + 1);
len = strlen(line) + width * height * 3 * 2 + strlen(endstream) + 1;
final_data = malloc(len);
if (!final_data) {
pdf_set_err(pdf, -ENOMEM, "Unable to allocate %d bytes memory for image",
len);
return NULL;
}
strcpy((char *)final_data, line);
uint8_t *pos = &final_data[strlen(line)];
for (i = 0; i < width * height * 3; i++) {
*pos++ = "0123456789ABCDEF"[(data[i] >> 4) & 0xf];
*pos++ = "0123456789ABCDEF"[data[i] & 0xf];
}
strcpy((char *)pos, endstream);
pos += strlen(endstream);
obj = pdf_add_object(pdf, OBJ_image);
if (!obj) {
free(final_data);
return NULL;
}
obj->stream.text = (char *)final_data;
obj->stream.len = pos - final_data;
return obj;
}
| 0 |
liblouis | 2e4772befb2b1c37cb4b9d6572945115ee28630a | NOT_APPLICABLE | NOT_APPLICABLE | addForwardRuleWithMultipleChars(TranslationTableOffset ruleOffset,
TranslationTableRule *rule, TranslationTableHeader *table) {
/* direction = 0 rule->charslen > 1 */
TranslationTableOffset *forRule =
&table->forRules[_lou_stringHash(&rule->charsdots[0], 0, NULL)];
while (*forRule) {
TranslationTableRule *r = (TranslationTableRule *)&table->ruleArea[*forRule];
if (rule->charslen > r->charslen) break;
if (rule->charslen == r->charslen)
if ((r->opcode == CTO_Always) && (rule->opcode != CTO_Always)) break;
forRule = &r->charsnext;
}
rule->charsnext = *forRule;
*forRule = ruleOffset;
} | 0 |
openssl | 470990fee0182566d439ef7e82d1abf18b7085d7 | NOT_APPLICABLE | NOT_APPLICABLE | void dtls1_free(SSL *s)
{
ssl3_free(s);
dtls1_clear_queues(s);
pqueue_free(s->d1->unprocessed_rcds.q);
pqueue_free(s->d1->processed_rcds.q);
pqueue_free(s->d1->buffered_messages);
pqueue_free(s->d1->sent_messages);
pqueue_free(s->d1->buffered_app_data.q);
OPENSSL_free(s->d1);
s->d1 = NULL;
}
| 0 |
linux | 90481622d75715bfcb68501280a917dbfe516029 | NOT_APPLICABLE | NOT_APPLICABLE | static int hugetlbfs_mknod(struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
struct inode *inode;
int error = -ENOSPC;
inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev);
if (inode) {
dir->i_ctime = dir->i_mtime = CURRENT_TIME;
d_instantiate(dentry, inode);
dget(dentry); /* Extra count - pin the dentry in core */
error = 0;
}
return error;
}
| 0 |
ceph | fce0b267446d6f3f631bb4680ebc3527bbbea002 | NOT_APPLICABLE | NOT_APPLICABLE | int RGWCopyObj_ObjStore_S3::check_storage_class(const rgw_placement_rule& src_placement)
{
if (src_placement == s->dest_placement) {
/* can only copy object into itself if replacing attrs */
s->err.message = "This copy request is illegal because it is trying to copy "
"an object to itself without changing the object's metadata, "
"storage class, website redirect location or encryption attributes.";
ldout(s->cct, 0) << s->err.message << dendl;
return -ERR_INVALID_REQUEST;
}
return 0;
} | 0 |
Chrome | a263d1cf62a9c75be6aaafdec88aacfcef1e8fd2 | NOT_APPLICABLE | NOT_APPLICABLE | RenderThreadImpl::SharedMainThreadContextProvider() {
DCHECK(IsMainThread());
if (shared_main_thread_contexts_ &&
shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() ==
GL_NO_ERROR)
return shared_main_thread_contexts_;
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
EstablishGpuChannelSync());
if (!gpu_channel_host) {
shared_main_thread_contexts_ = nullptr;
return nullptr;
}
bool support_locking = false;
bool support_oop_rasterization = false;
shared_main_thread_contexts_ = CreateOffscreenContext(
std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking,
support_oop_rasterization,
ui::command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT,
kGpuStreamIdDefault, kGpuStreamPriorityDefault);
auto result = shared_main_thread_contexts_->BindToCurrentThread();
if (result != gpu::ContextResult::kSuccess)
shared_main_thread_contexts_ = nullptr;
return shared_main_thread_contexts_;
}
| 0 |
linux | 2c5816b4beccc8ba709144539f6fdd764f8fa49c | NOT_APPLICABLE | NOT_APPLICABLE | static int cuse_open(struct inode *inode, struct file *file)
{
dev_t devt = inode->i_cdev->dev;
struct cuse_conn *cc = NULL, *pos;
int rc;
/* look up and get the connection */
mutex_lock(&cuse_lock);
list_for_each_entry(pos, cuse_conntbl_head(devt), list)
if (pos->dev->devt == devt) {
fuse_conn_get(&pos->fc);
cc = pos;
break;
}
mutex_unlock(&cuse_lock);
/* dead? */
if (!cc)
return -ENODEV;
/*
* Generic permission check is already done against the chrdev
* file, proceed to open.
*/
rc = fuse_do_open(&cc->fc, 0, file, 0);
if (rc)
fuse_conn_put(&cc->fc);
return rc;
}
| 0 |
bpf | 4b81ccebaeee885ab1aa1438133f2991e3a2b6ea | NOT_APPLICABLE | NOT_APPLICABLE | static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
{
unsigned long cons_pos, prod_pos, new_prod_pos, flags;
u32 len, pg_off;
struct bpf_ringbuf_hdr *hdr;
if (unlikely(size > RINGBUF_MAX_RECORD_SZ))
return NULL;
len = round_up(size + BPF_RINGBUF_HDR_SZ, 8);
if (len > rb->mask + 1)
return NULL;
cons_pos = smp_load_acquire(&rb->consumer_pos);
if (in_nmi()) {
if (!spin_trylock_irqsave(&rb->spinlock, flags))
return NULL;
} else {
spin_lock_irqsave(&rb->spinlock, flags);
}
prod_pos = rb->producer_pos;
new_prod_pos = prod_pos + len;
/* check for out of ringbuf space by ensuring producer position
* doesn't advance more than (ringbuf_size - 1) ahead
*/
if (new_prod_pos - cons_pos > rb->mask) {
spin_unlock_irqrestore(&rb->spinlock, flags);
return NULL;
}
hdr = (void *)rb->data + (prod_pos & rb->mask);
pg_off = bpf_ringbuf_rec_pg_off(rb, hdr);
hdr->len = size | BPF_RINGBUF_BUSY_BIT;
hdr->pg_off = pg_off;
/* pairs with consumer's smp_load_acquire() */
smp_store_release(&rb->producer_pos, new_prod_pos);
spin_unlock_irqrestore(&rb->spinlock, flags);
return (void *)hdr + BPF_RINGBUF_HDR_SZ;
} | 0 |
linux | 0185604c2d82c560dab2f2933a18f797e74ab5a8 | CVE-2015-7513 | CWE-369 | static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
{
int start = 0;
u32 prev_legacy, cur_legacy;
mutex_lock(&kvm->arch.vpit->pit_state.lock);
prev_legacy = kvm->arch.vpit->pit_state.flags & KVM_PIT_FLAGS_HPET_LEGACY;
cur_legacy = ps->flags & KVM_PIT_FLAGS_HPET_LEGACY;
if (!prev_legacy && cur_legacy)
start = 1;
memcpy(&kvm->arch.vpit->pit_state.channels, &ps->channels,
sizeof(kvm->arch.vpit->pit_state.channels));
kvm->arch.vpit->pit_state.flags = ps->flags;
kvm_pit_load_count(kvm, 0, kvm->arch.vpit->pit_state.channels[0].count, start);
mutex_unlock(&kvm->arch.vpit->pit_state.lock);
return 0;
}
| 1 |
samba | eb50fb8f3bf670bd7d1cf8fd4368ef4a73083696 | NOT_APPLICABLE | NOT_APPLICABLE | static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t len)
{
int result = -1;
SMB_STRUCT_STAT *pst;
NTSTATUS status;
char c = 0;
START_PROFILE(syscall_ftruncate);
if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->is_sparse) {
result = strict_allocate_ftruncate(handle, fsp, len);
END_PROFILE(syscall_ftruncate);
return result;
}
/* we used to just check HAVE_FTRUNCATE_EXTEND and only use
ftruncate if the system supports it. Then I discovered that
you can have some filesystems that support ftruncate
expansion and some that don't! On Linux fat can't do
ftruncate extend but ext2 can. */
result = ftruncate(fsp->fh->fd, len);
if (result == 0)
goto done;
/* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
extend a file with ftruncate. Provide alternate implementation
for this */
/* Do an fstat to see if the file is longer than the requested
size in which case the ftruncate above should have
succeeded or shorter, in which case seek to len - 1 and
write 1 byte of zero */
status = vfs_stat_fsp(fsp);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
pst = &fsp->fsp_name->st;
#ifdef S_ISFIFO
if (S_ISFIFO(pst->st_ex_mode)) {
result = 0;
goto done;
}
#endif
if (pst->st_ex_size == len) {
result = 0;
goto done;
}
if (pst->st_ex_size > len) {
/* the ftruncate should have worked */
goto done;
}
if (SMB_VFS_PWRITE(fsp, &c, 1, len-1)!=1) {
goto done;
}
result = 0;
done:
END_PROFILE(syscall_ftruncate);
return result;
} | 0 |
linux | 27d461333459d282ffa4a2bdb6b215a59d493a8f | NOT_APPLICABLE | NOT_APPLICABLE | static void __exit i40e_exit_module(void)
{
pci_unregister_driver(&i40e_driver);
destroy_workqueue(i40e_wq);
i40e_dbg_exit();
} | 0 |
savannah | 422214868061370aeeb0ac9cd0f021a5c350a57d | NOT_APPLICABLE | NOT_APPLICABLE | make_preamble (opaque * uint64_data, opaque type, uint16_t c_length,
opaque ver, opaque * preamble)
{
opaque minor = _gnutls_version_get_minor (ver);
opaque major = _gnutls_version_get_major (ver);
opaque *p = preamble;
memcpy (p, uint64_data, 8);
p += 8;
*p = type;
p++;
if (_gnutls_version_has_variable_padding (ver))
{ /* TLS 1.0 or higher */
*p = major;
p++;
*p = minor;
p++;
}
memcpy (p, &c_length, 2);
p += 2;
return p - preamble;
}
| 0 |
glewlwyd | 125281f1c0d4b6a8b49f7e55a757205a2ef01fbe | NOT_APPLICABLE | NOT_APPLICABLE | int callback_glewlwyd_user_update_password (const struct _u_request * request, struct _u_response * response, void * user_data) {
struct config_elements * config = (struct config_elements *)user_data;
json_t * j_session, * j_password, * j_element = NULL;
char * session_uid = get_session_id(config, request);
const char ** passwords = NULL;
int res;
struct _user_module_instance * user_module;
size_t index = 0;
if (session_uid != NULL && o_strlen(session_uid)) {
j_session = get_current_user_for_session(config, session_uid);
if (check_result_value(j_session, G_OK)) {
j_password = ulfius_get_json_body_request(request, NULL);
user_module = get_user_module_instance(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "source")));
if (user_module && user_module->multiple_passwords) {
if (json_string_length(json_object_get(j_password, "old_password")) && json_is_array(json_object_get(j_password, "password"))) {
if ((passwords = o_malloc(json_array_size(json_object_get(j_password, "password")) * sizeof(char *))) != NULL) {
json_array_foreach(json_object_get(j_password, "password"), index, j_element) {
passwords[index] = json_string_value(j_element);
}
if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "username")), json_string_value(json_object_get(j_password, "old_password")), passwords, json_array_size(json_object_get(j_password, "password")))) == G_ERROR_PARAM) {
response->status = 400;
} else if (res != G_OK) {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error user_update_password (1)");
response->status = 500;
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error allocating resources for passwords (1)");
response->status = 500;
}
o_free(passwords);
} else {
response->status = 400;
}
} else {
if (json_string_length(json_object_get(j_password, "old_password")) && json_string_length(json_object_get(j_password, "password"))) {
if ((passwords = o_malloc(sizeof(char *))) != NULL) {
passwords[0] = json_string_value(json_object_get(j_password, "password"));
if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "username")), json_string_value(json_object_get(j_password, "old_password")), passwords, 1)) == G_ERROR_PARAM) {
response->status = 400;
} else if (res != G_OK) {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error user_update_password (2)");
response->status = 500;
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error allocating resources for passwords (2)");
response->status = 500;
}
o_free(passwords);
} else {
response->status = 400;
}
}
json_decref(j_password);
} else if (check_result_value(j_session, G_ERROR_NOT_FOUND)) {
response->status = 401;
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error get_current_user_for_session");
response->status = 500;
}
json_decref(j_session);
} else {
response->status = 401;
}
o_free(session_uid);
return U_CALLBACK_CONTINUE;
} | 0 |
keepalived | f28015671a4b04785859d1b4b1327b367b6a10e9 | NOT_APPLICABLE | NOT_APPLICABLE | size_t extract_content_length(char *buffer, size_t size)
{
char *clen = strstr(buffer, CONTENT_LENGTH);
size_t len;
char *end;
/* Pattern not found */
if (!clen || clen > buffer + size)
return SIZE_MAX;
/* Content-Length extraction */
len = strtoul(clen + strlen(CONTENT_LENGTH), &end, 10);
if (*end)
return SIZE_MAX;
return len;
}
| 0 |
quagga | 7a42b78be9a4108d98833069a88e6fddb9285008 | NOT_APPLICABLE | NOT_APPLICABLE | aspath_str_update (struct aspath *as)
{
if (as->str)
XFREE (MTYPE_AS_STR, as->str);
aspath_make_str_count (as);
} | 0 |
linux | 9b54d816e00425c3a517514e0d677bb3cec49258 | NOT_APPLICABLE | NOT_APPLICABLE | void blkcg_deactivate_policy(struct request_queue *q,
const struct blkcg_policy *pol)
{
struct blkcg_gq *blkg;
if (!blkcg_policy_enabled(q, pol))
return;
if (q->mq_ops)
blk_mq_freeze_queue(q);
else
blk_queue_bypass_start(q);
spin_lock_irq(q->queue_lock);
__clear_bit(pol->plid, q->blkcg_pols);
list_for_each_entry(blkg, &q->blkg_list, q_node) {
/* grab blkcg lock too while removing @pd from @blkg */
spin_lock(&blkg->blkcg->lock);
if (blkg->pd[pol->plid]) {
if (pol->pd_offline_fn)
pol->pd_offline_fn(blkg->pd[pol->plid]);
pol->pd_free_fn(blkg->pd[pol->plid]);
blkg->pd[pol->plid] = NULL;
}
spin_unlock(&blkg->blkcg->lock);
}
spin_unlock_irq(q->queue_lock);
if (q->mq_ops)
blk_mq_unfreeze_queue(q);
else
blk_queue_bypass_end(q);
}
| 0 |
linux | ef85b67385436ddc1998f45f1d6a210f935b3388 | NOT_APPLICABLE | NOT_APPLICABLE | static int handle_vmcall(struct kvm_vcpu *vcpu)
{
return kvm_emulate_hypercall(vcpu);
}
| 0 |
linux | 6817ae225cd650fb1c3295d769298c38b1eba818 | NOT_APPLICABLE | NOT_APPLICABLE | static int firm_open(struct usb_serial_port *port)
{
struct whiteheat_simple open_command;
open_command.port = port->port_number + 1;
return firm_send_command(port, WHITEHEAT_OPEN,
(__u8 *)&open_command, sizeof(open_command));
}
| 0 |
FFmpeg | dfefc9097e9b4bb20442e65454a40043bd189b3d | NOT_APPLICABLE | NOT_APPLICABLE | static void FUNC(pred_angular_1)(uint8_t *src, const uint8_t *top,
const uint8_t *left,
ptrdiff_t stride, int c_idx, int mode)
{
FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3);
} | 0 |
libsndfile | 708e996c87c5fae77b104ccfeb8f6db784c32074 | NOT_APPLICABLE | NOT_APPLICABLE | psf_cues_dup (const void * ptr)
{ const SF_CUES *pcues = ptr ;
SF_CUES *pnew = psf_cues_alloc (pcues->cue_count) ;
memcpy (pnew, pcues, SF_CUES_VAR_SIZE (pcues->cue_count)) ;
return pnew ;
} /* psf_cues_dup */
| 0 |
frr | ff6db1027f8f36df657ff2e5ea167773752537ed | NOT_APPLICABLE | NOT_APPLICABLE | void bgp_send_delayed_eor(struct bgp *bgp)
{
struct peer *peer;
struct listnode *node, *nnode;
/* EOR message sent in bgp_write_proceed_actions */
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer))
bgp_write_proceed_actions(peer);
} | 0 |
linux | 0837e3242c73566fc1c0196b4ec61779c25ffc93 | NOT_APPLICABLE | NOT_APPLICABLE | static void power_pmu_enable(struct pmu *pmu)
{
struct perf_event *event;
struct cpu_hw_events *cpuhw;
unsigned long flags;
long i;
unsigned long val;
s64 left;
unsigned int hwc_index[MAX_HWEVENTS];
int n_lim;
int idx;
if (!ppmu)
return;
local_irq_save(flags);
cpuhw = &__get_cpu_var(cpu_hw_events);
if (!cpuhw->disabled) {
local_irq_restore(flags);
return;
}
cpuhw->disabled = 0;
/*
* If we didn't change anything, or only removed events,
* no need to recalculate MMCR* settings and reset the PMCs.
* Just reenable the PMU with the current MMCR* settings
* (possibly updated for removal of events).
*/
if (!cpuhw->n_added) {
mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE);
mtspr(SPRN_MMCR1, cpuhw->mmcr[1]);
if (cpuhw->n_events == 0)
ppc_set_pmu_inuse(0);
goto out_enable;
}
/*
* Compute MMCR* values for the new set of events
*/
if (ppmu->compute_mmcr(cpuhw->events, cpuhw->n_events, hwc_index,
cpuhw->mmcr)) {
/* shouldn't ever get here */
printk(KERN_ERR "oops compute_mmcr failed\n");
goto out;
}
/*
* Add in MMCR0 freeze bits corresponding to the
* attr.exclude_* bits for the first event.
* We have already checked that all events have the
* same values for these bits as the first event.
*/
event = cpuhw->event[0];
if (event->attr.exclude_user)
cpuhw->mmcr[0] |= MMCR0_FCP;
if (event->attr.exclude_kernel)
cpuhw->mmcr[0] |= freeze_events_kernel;
if (event->attr.exclude_hv)
cpuhw->mmcr[0] |= MMCR0_FCHV;
/*
* Write the new configuration to MMCR* with the freeze
* bit set and set the hardware events to their initial values.
* Then unfreeze the events.
*/
ppc_set_pmu_inuse(1);
mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE);
mtspr(SPRN_MMCR1, cpuhw->mmcr[1]);
mtspr(SPRN_MMCR0, (cpuhw->mmcr[0] & ~(MMCR0_PMC1CE | MMCR0_PMCjCE))
| MMCR0_FC);
/*
* Read off any pre-existing events that need to move
* to another PMC.
*/
for (i = 0; i < cpuhw->n_events; ++i) {
event = cpuhw->event[i];
if (event->hw.idx && event->hw.idx != hwc_index[i] + 1) {
power_pmu_read(event);
write_pmc(event->hw.idx, 0);
event->hw.idx = 0;
}
}
/*
* Initialize the PMCs for all the new and moved events.
*/
cpuhw->n_limited = n_lim = 0;
for (i = 0; i < cpuhw->n_events; ++i) {
event = cpuhw->event[i];
if (event->hw.idx)
continue;
idx = hwc_index[i] + 1;
if (is_limited_pmc(idx)) {
cpuhw->limited_counter[n_lim] = event;
cpuhw->limited_hwidx[n_lim] = idx;
++n_lim;
continue;
}
val = 0;
if (event->hw.sample_period) {
left = local64_read(&event->hw.period_left);
if (left < 0x80000000L)
val = 0x80000000L - left;
}
local64_set(&event->hw.prev_count, val);
event->hw.idx = idx;
if (event->hw.state & PERF_HES_STOPPED)
val = 0;
write_pmc(idx, val);
perf_event_update_userpage(event);
}
cpuhw->n_limited = n_lim;
cpuhw->mmcr[0] |= MMCR0_PMXE | MMCR0_FCECE;
out_enable:
mb();
write_mmcr0(cpuhw, cpuhw->mmcr[0]);
/*
* Enable instruction sampling if necessary
*/
if (cpuhw->mmcr[2] & MMCRA_SAMPLE_ENABLE) {
mb();
mtspr(SPRN_MMCRA, cpuhw->mmcr[2]);
}
out:
local_irq_restore(flags);
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.