idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
5,000
|
static void date_object_free_storage_interval(void *object TSRMLS_DC)
{
php_interval_obj *intern = (php_interval_obj *)object;
timelib_rel_time_dtor(intern->diff);
zend_object_std_dtor(&intern->std TSRMLS_CC);
efree(object);
}
|
Exec Code
| 0
|
static void date_object_free_storage_interval(void *object TSRMLS_DC)
{
php_interval_obj *intern = (php_interval_obj *)object;
timelib_rel_time_dtor(intern->diff);
zend_object_std_dtor(&intern->std TSRMLS_CC);
efree(object);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,001
|
static void date_object_free_storage_period(void *object TSRMLS_DC)
{
php_period_obj *intern = (php_period_obj *)object;
if (intern->start) {
timelib_time_dtor(intern->start);
}
if (intern->current) {
timelib_time_dtor(intern->current);
}
if (intern->end) {
timelib_time_dtor(intern->end);
}
timelib_rel_time_dtor(intern->interval);
zend_object_std_dtor(&intern->std TSRMLS_CC);
efree(object);
}
|
Exec Code
| 0
|
static void date_object_free_storage_period(void *object TSRMLS_DC)
{
php_period_obj *intern = (php_period_obj *)object;
if (intern->start) {
timelib_time_dtor(intern->start);
}
if (intern->current) {
timelib_time_dtor(intern->current);
}
if (intern->end) {
timelib_time_dtor(intern->end);
}
timelib_rel_time_dtor(intern->interval);
zend_object_std_dtor(&intern->std TSRMLS_CC);
efree(object);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,002
|
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
|
Exec Code
| 0
|
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,003
|
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
|
Exec Code
| 0
|
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,004
|
static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
|
Exec Code
| 0
|
static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *n TSRMLS_DC)
{
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,005
|
static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
{
HashTable *props;
zval *zv;
php_date_obj *dateobj;
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
props = zend_std_get_properties(object TSRMLS_CC);
if (!dateobj->time || GC_G(gc_active)) {
return props;
}
/* first we add the date and time in ISO format */
MAKE_STD_ZVAL(zv);
ZVAL_STRING(zv, date_format("Y-m-d H:i:s.u", 14, dateobj->time, 1), 0);
zend_hash_update(props, "date", 5, &zv, sizeof(zv), NULL);
/* then we add the timezone name (or similar) */
if (dateobj->time->is_localtime) {
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, dateobj->time->zone_type);
zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
switch (dateobj->time->zone_type) {
case TIMELIB_ZONETYPE_ID:
ZVAL_STRING(zv, dateobj->time->tz_info->name, 1);
break;
case TIMELIB_ZONETYPE_OFFSET: {
char *tmpstr = emalloc(sizeof("UTC+05:00"));
timelib_sll utc_offset = dateobj->time->z;
snprintf(tmpstr, sizeof("+05:00"), "%c%02d:%02d",
utc_offset > 0 ? '-' : '+',
abs(utc_offset / 60),
abs((utc_offset % 60)));
ZVAL_STRING(zv, tmpstr, 0);
}
break;
case TIMELIB_ZONETYPE_ABBR:
ZVAL_STRING(zv, dateobj->time->tz_abbr, 1);
break;
}
zend_hash_update(props, "timezone", 9, &zv, sizeof(zv), NULL);
}
return props;
}
|
Exec Code
| 0
|
static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
{
HashTable *props;
zval *zv;
php_date_obj *dateobj;
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
props = zend_std_get_properties(object TSRMLS_CC);
if (!dateobj->time || GC_G(gc_active)) {
return props;
}
/* first we add the date and time in ISO format */
MAKE_STD_ZVAL(zv);
ZVAL_STRING(zv, date_format("Y-m-d H:i:s.u", 14, dateobj->time, 1), 0);
zend_hash_update(props, "date", 5, &zv, sizeof(zv), NULL);
/* then we add the timezone name (or similar) */
if (dateobj->time->is_localtime) {
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, dateobj->time->zone_type);
zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
switch (dateobj->time->zone_type) {
case TIMELIB_ZONETYPE_ID:
ZVAL_STRING(zv, dateobj->time->tz_info->name, 1);
break;
case TIMELIB_ZONETYPE_OFFSET: {
char *tmpstr = emalloc(sizeof("UTC+05:00"));
timelib_sll utc_offset = dateobj->time->z;
snprintf(tmpstr, sizeof("+05:00"), "%c%02d:%02d",
utc_offset > 0 ? '-' : '+',
abs(utc_offset / 60),
abs((utc_offset % 60)));
ZVAL_STRING(zv, tmpstr, 0);
}
break;
case TIMELIB_ZONETYPE_ABBR:
ZVAL_STRING(zv, dateobj->time->tz_abbr, 1);
break;
}
zend_hash_update(props, "timezone", 9, &zv, sizeof(zv), NULL);
}
return props;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,006
|
static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC)
{
HashTable *props;
zval *zv;
php_timezone_obj *tzobj;
tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC);
props = zend_std_get_properties(object TSRMLS_CC);
if (!tzobj->initialized) {
return props;
}
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, tzobj->type);
zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
switch (tzobj->type) {
case TIMELIB_ZONETYPE_ID:
ZVAL_STRING(zv, tzobj->tzi.tz->name, 1);
break;
case TIMELIB_ZONETYPE_OFFSET: {
char *tmpstr = emalloc(sizeof("UTC+05:00"));
snprintf(tmpstr, sizeof("+05:00"), "%c%02d:%02d",
tzobj->tzi.utc_offset > 0 ? '-' : '+',
abs(tzobj->tzi.utc_offset / 60),
abs((tzobj->tzi.utc_offset % 60)));
ZVAL_STRING(zv, tmpstr, 0);
}
break;
case TIMELIB_ZONETYPE_ABBR:
ZVAL_STRING(zv, tzobj->tzi.z.abbr, 1);
break;
}
zend_hash_update(props, "timezone", 9, &zv, sizeof(zv), NULL);
return props;
}
|
Exec Code
| 0
|
static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC)
{
HashTable *props;
zval *zv;
php_timezone_obj *tzobj;
tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC);
props = zend_std_get_properties(object TSRMLS_CC);
if (!tzobj->initialized) {
return props;
}
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, tzobj->type);
zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zv), NULL);
MAKE_STD_ZVAL(zv);
switch (tzobj->type) {
case TIMELIB_ZONETYPE_ID:
ZVAL_STRING(zv, tzobj->tzi.tz->name, 1);
break;
case TIMELIB_ZONETYPE_OFFSET: {
char *tmpstr = emalloc(sizeof("UTC+05:00"));
snprintf(tmpstr, sizeof("+05:00"), "%c%02d:%02d",
tzobj->tzi.utc_offset > 0 ? '-' : '+',
abs(tzobj->tzi.utc_offset / 60),
abs((tzobj->tzi.utc_offset % 60)));
ZVAL_STRING(zv, tmpstr, 0);
}
break;
case TIMELIB_ZONETYPE_ABBR:
ZVAL_STRING(zv, tzobj->tzi.z.abbr, 1);
break;
}
zend_hash_update(props, "timezone", 9, &zv, sizeof(zv), NULL);
return props;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,007
|
static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC)
{
return date_object_new_date_ex(class_type, NULL TSRMLS_CC);
}
|
Exec Code
| 0
|
static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC)
{
return date_object_new_date_ex(class_type, NULL TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,008
|
static inline zend_object_value date_object_new_date_ex(zend_class_entry *class_type, php_date_obj **ptr TSRMLS_DC)
{
php_date_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_date_obj));
memset(intern, 0, sizeof(php_date_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_date, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_date;
return retval;
}
|
Exec Code
| 0
|
static inline zend_object_value date_object_new_date_ex(zend_class_entry *class_type, php_date_obj **ptr TSRMLS_DC)
{
php_date_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_date_obj));
memset(intern, 0, sizeof(php_date_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_date, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_date;
return retval;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,009
|
static inline zend_object_value date_object_new_interval_ex(zend_class_entry *class_type, php_interval_obj **ptr TSRMLS_DC)
{
php_interval_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_interval_obj));
memset(intern, 0, sizeof(php_interval_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_interval, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_interval;
return retval;
}
|
Exec Code
| 0
|
static inline zend_object_value date_object_new_interval_ex(zend_class_entry *class_type, php_interval_obj **ptr TSRMLS_DC)
{
php_interval_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_interval_obj));
memset(intern, 0, sizeof(php_interval_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_interval, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_interval;
return retval;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,010
|
static inline zend_object_value date_object_new_period_ex(zend_class_entry *class_type, php_period_obj **ptr TSRMLS_DC)
{
php_period_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_period_obj));
memset(intern, 0, sizeof(php_period_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_period, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_period;
return retval;
}
|
Exec Code
| 0
|
static inline zend_object_value date_object_new_period_ex(zend_class_entry *class_type, php_period_obj **ptr TSRMLS_DC)
{
php_period_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_period_obj));
memset(intern, 0, sizeof(php_period_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_period, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_period;
return retval;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,011
|
static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC)
{
return date_object_new_timezone_ex(class_type, NULL TSRMLS_CC);
}
|
Exec Code
| 0
|
static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC)
{
return date_object_new_timezone_ex(class_type, NULL TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,012
|
static inline zend_object_value date_object_new_timezone_ex(zend_class_entry *class_type, php_timezone_obj **ptr TSRMLS_DC)
{
php_timezone_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_timezone_obj));
memset(intern, 0, sizeof(php_timezone_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_timezone, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_timezone;
return retval;
}
|
Exec Code
| 0
|
static inline zend_object_value date_object_new_timezone_ex(zend_class_entry *class_type, php_timezone_obj **ptr TSRMLS_DC)
{
php_timezone_obj *intern;
zend_object_value retval;
intern = emalloc(sizeof(php_timezone_obj));
memset(intern, 0, sizeof(php_timezone_obj));
if (ptr) {
*ptr = intern;
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_timezone, NULL TSRMLS_CC);
retval.handlers = &date_object_handlers_timezone;
return retval;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,013
|
static void date_period_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
php_period_obj *object = iterator->object;
timelib_time *it_time = object->current;
php_date_obj *newdateobj;
/* Create new object */
MAKE_STD_ZVAL(iterator->current);
php_date_instantiate(object->start_ce, iterator->current TSRMLS_CC);
newdateobj = (php_date_obj *) zend_object_store_get_object(iterator->current TSRMLS_CC);
newdateobj->time = timelib_time_ctor();
*newdateobj->time = *it_time;
if (it_time->tz_abbr) {
newdateobj->time->tz_abbr = strdup(it_time->tz_abbr);
}
if (it_time->tz_info) {
newdateobj->time->tz_info = it_time->tz_info;
}
*data = &iterator->current;
}
|
Exec Code
| 0
|
static void date_period_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
php_period_obj *object = iterator->object;
timelib_time *it_time = object->current;
php_date_obj *newdateobj;
/* Create new object */
MAKE_STD_ZVAL(iterator->current);
php_date_instantiate(object->start_ce, iterator->current TSRMLS_CC);
newdateobj = (php_date_obj *) zend_object_store_get_object(iterator->current TSRMLS_CC);
newdateobj->time = timelib_time_ctor();
*newdateobj->time = *it_time;
if (it_time->tz_abbr) {
newdateobj->time->tz_abbr = strdup(it_time->tz_abbr);
}
if (it_time->tz_info) {
newdateobj->time->tz_info = it_time->tz_info;
}
*data = &iterator->current;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,014
|
static void date_period_it_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
ZVAL_LONG(key, iterator->current_index);
}
|
Exec Code
| 0
|
static void date_period_it_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
ZVAL_LONG(key, iterator->current_index);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,015
|
static void date_period_it_dtor(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
date_period_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iterator->date_period_zval);
efree(iterator);
}
|
Exec Code
| 0
|
static void date_period_it_dtor(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
date_period_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iterator->date_period_zval);
efree(iterator);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,016
|
static void date_period_it_invalidate_current(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
if (iterator->current) {
zval_ptr_dtor(&iterator->current);
iterator->current = NULL;
}
}
|
Exec Code
| 0
|
static void date_period_it_invalidate_current(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
if (iterator->current) {
zval_ptr_dtor(&iterator->current);
iterator->current = NULL;
}
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,017
|
static void date_period_it_move_forward(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
iterator->current_index++;
date_period_it_invalidate_current(iter TSRMLS_CC);
}
|
Exec Code
| 0
|
static void date_period_it_move_forward(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
iterator->current_index++;
date_period_it_invalidate_current(iter TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,018
|
static void date_period_it_rewind(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
iterator->current_index = 0;
if (iterator->object->current) {
timelib_time_dtor(iterator->object->current);
}
iterator->object->current = timelib_time_clone(iterator->object->start);
date_period_it_invalidate_current(iter TSRMLS_CC);
}
|
Exec Code
| 0
|
static void date_period_it_rewind(zend_object_iterator *iter TSRMLS_DC)
{
date_period_it *iterator = (date_period_it *)iter;
iterator->current_index = 0;
if (iterator->object->current) {
timelib_time_dtor(iterator->object->current);
}
iterator->object->current = timelib_time_clone(iterator->object->start);
date_period_it_invalidate_current(iter TSRMLS_CC);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,019
|
static void date_register_classes(TSRMLS_D)
{
zend_class_entry ce_date, ce_immutable, ce_timezone, ce_interval, ce_period, ce_interface;
INIT_CLASS_ENTRY(ce_interface, "DateTimeInterface", date_funcs_interface);
date_ce_interface = zend_register_internal_interface(&ce_interface TSRMLS_CC);
date_ce_interface->interface_gets_implemented = implement_date_interface_handler;
INIT_CLASS_ENTRY(ce_date, "DateTime", date_funcs_date);
ce_date.create_object = date_object_new_date;
date_ce_date = zend_register_internal_class_ex(&ce_date, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_date, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_date.clone_obj = date_object_clone_date;
date_object_handlers_date.compare_objects = date_object_compare_date;
date_object_handlers_date.get_properties = date_object_get_properties;
date_object_handlers_date.get_gc = date_object_get_gc;
zend_class_implements(date_ce_date TSRMLS_CC, 1, date_ce_interface);
#define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC);
REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_RFC3339);
REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE);
REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC822);
REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC850);
REGISTER_DATE_CLASS_CONST_STRING("RFC1036", DATE_FORMAT_RFC1036);
REGISTER_DATE_CLASS_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
REGISTER_DATE_CLASS_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
REGISTER_DATE_CLASS_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_RFC3339);
INIT_CLASS_ENTRY(ce_immutable, "DateTimeImmutable", date_funcs_immutable);
ce_immutable.create_object = date_object_new_date;
date_ce_immutable = zend_register_internal_class_ex(&ce_immutable, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_immutable, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_immutable.clone_obj = date_object_clone_date;
date_object_handlers_immutable.compare_objects = date_object_compare_date;
date_object_handlers_immutable.get_properties = date_object_get_properties;
zend_class_implements(date_ce_immutable TSRMLS_CC, 1, date_ce_interface);
INIT_CLASS_ENTRY(ce_timezone, "DateTimeZone", date_funcs_timezone);
ce_timezone.create_object = date_object_new_timezone;
date_ce_timezone = zend_register_internal_class_ex(&ce_timezone, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_timezone, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_timezone.clone_obj = date_object_clone_timezone;
date_object_handlers_timezone.get_properties = date_object_get_properties_timezone;
date_object_handlers_timezone.get_gc = date_object_get_gc_timezone;
#define REGISTER_TIMEZONE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_timezone, const_name, sizeof(const_name)-1, value TSRMLS_CC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("AFRICA", PHP_DATE_TIMEZONE_GROUP_AFRICA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("AMERICA", PHP_DATE_TIMEZONE_GROUP_AMERICA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ANTARCTICA", PHP_DATE_TIMEZONE_GROUP_ANTARCTICA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ARCTIC", PHP_DATE_TIMEZONE_GROUP_ARCTIC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ASIA", PHP_DATE_TIMEZONE_GROUP_ASIA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ATLANTIC", PHP_DATE_TIMEZONE_GROUP_ATLANTIC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("AUSTRALIA", PHP_DATE_TIMEZONE_GROUP_AUSTRALIA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("EUROPE", PHP_DATE_TIMEZONE_GROUP_EUROPE);
REGISTER_TIMEZONE_CLASS_CONST_STRING("INDIAN", PHP_DATE_TIMEZONE_GROUP_INDIAN);
REGISTER_TIMEZONE_CLASS_CONST_STRING("PACIFIC", PHP_DATE_TIMEZONE_GROUP_PACIFIC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("UTC", PHP_DATE_TIMEZONE_GROUP_UTC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ALL", PHP_DATE_TIMEZONE_GROUP_ALL);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ALL_WITH_BC", PHP_DATE_TIMEZONE_GROUP_ALL_W_BC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("PER_COUNTRY", PHP_DATE_TIMEZONE_PER_COUNTRY);
INIT_CLASS_ENTRY(ce_interval, "DateInterval", date_funcs_interval);
ce_interval.create_object = date_object_new_interval;
date_ce_interval = zend_register_internal_class_ex(&ce_interval, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_interval, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_interval.clone_obj = date_object_clone_interval;
date_object_handlers_interval.read_property = date_interval_read_property;
date_object_handlers_interval.write_property = date_interval_write_property;
date_object_handlers_interval.get_properties = date_object_get_properties_interval;
date_object_handlers_interval.get_property_ptr_ptr = NULL;
date_object_handlers_interval.get_gc = date_object_get_gc_interval;
INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period);
ce_period.create_object = date_object_new_period;
date_ce_period = zend_register_internal_class_ex(&ce_period, NULL, NULL TSRMLS_CC);
date_ce_period->get_iterator = date_object_period_get_iterator;
date_ce_period->iterator_funcs.funcs = &date_period_it_funcs;
zend_class_implements(date_ce_period TSRMLS_CC, 1, zend_ce_traversable);
memcpy(&date_object_handlers_period, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_period.clone_obj = date_object_clone_period;
date_object_handlers_period.get_properties = date_object_get_properties_period;
date_object_handlers_period.get_property_ptr_ptr = NULL;
date_object_handlers_period.get_gc = date_object_get_gc_period;
date_object_handlers_period.read_property = date_period_read_property;
date_object_handlers_period.write_property = date_period_write_property;
#define REGISTER_PERIOD_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_period, const_name, sizeof(const_name)-1, value TSRMLS_CC);
REGISTER_PERIOD_CLASS_CONST_STRING("EXCLUDE_START_DATE", PHP_DATE_PERIOD_EXCLUDE_START_DATE);
}
|
Exec Code
| 0
|
static void date_register_classes(TSRMLS_D)
{
zend_class_entry ce_date, ce_immutable, ce_timezone, ce_interval, ce_period, ce_interface;
INIT_CLASS_ENTRY(ce_interface, "DateTimeInterface", date_funcs_interface);
date_ce_interface = zend_register_internal_interface(&ce_interface TSRMLS_CC);
date_ce_interface->interface_gets_implemented = implement_date_interface_handler;
INIT_CLASS_ENTRY(ce_date, "DateTime", date_funcs_date);
ce_date.create_object = date_object_new_date;
date_ce_date = zend_register_internal_class_ex(&ce_date, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_date, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_date.clone_obj = date_object_clone_date;
date_object_handlers_date.compare_objects = date_object_compare_date;
date_object_handlers_date.get_properties = date_object_get_properties;
date_object_handlers_date.get_gc = date_object_get_gc;
zend_class_implements(date_ce_date TSRMLS_CC, 1, date_ce_interface);
#define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC);
REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_RFC3339);
REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE);
REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC822);
REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC850);
REGISTER_DATE_CLASS_CONST_STRING("RFC1036", DATE_FORMAT_RFC1036);
REGISTER_DATE_CLASS_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
REGISTER_DATE_CLASS_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
REGISTER_DATE_CLASS_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_RFC3339);
INIT_CLASS_ENTRY(ce_immutable, "DateTimeImmutable", date_funcs_immutable);
ce_immutable.create_object = date_object_new_date;
date_ce_immutable = zend_register_internal_class_ex(&ce_immutable, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_immutable, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_immutable.clone_obj = date_object_clone_date;
date_object_handlers_immutable.compare_objects = date_object_compare_date;
date_object_handlers_immutable.get_properties = date_object_get_properties;
zend_class_implements(date_ce_immutable TSRMLS_CC, 1, date_ce_interface);
INIT_CLASS_ENTRY(ce_timezone, "DateTimeZone", date_funcs_timezone);
ce_timezone.create_object = date_object_new_timezone;
date_ce_timezone = zend_register_internal_class_ex(&ce_timezone, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_timezone, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_timezone.clone_obj = date_object_clone_timezone;
date_object_handlers_timezone.get_properties = date_object_get_properties_timezone;
date_object_handlers_timezone.get_gc = date_object_get_gc_timezone;
#define REGISTER_TIMEZONE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_timezone, const_name, sizeof(const_name)-1, value TSRMLS_CC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("AFRICA", PHP_DATE_TIMEZONE_GROUP_AFRICA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("AMERICA", PHP_DATE_TIMEZONE_GROUP_AMERICA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ANTARCTICA", PHP_DATE_TIMEZONE_GROUP_ANTARCTICA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ARCTIC", PHP_DATE_TIMEZONE_GROUP_ARCTIC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ASIA", PHP_DATE_TIMEZONE_GROUP_ASIA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ATLANTIC", PHP_DATE_TIMEZONE_GROUP_ATLANTIC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("AUSTRALIA", PHP_DATE_TIMEZONE_GROUP_AUSTRALIA);
REGISTER_TIMEZONE_CLASS_CONST_STRING("EUROPE", PHP_DATE_TIMEZONE_GROUP_EUROPE);
REGISTER_TIMEZONE_CLASS_CONST_STRING("INDIAN", PHP_DATE_TIMEZONE_GROUP_INDIAN);
REGISTER_TIMEZONE_CLASS_CONST_STRING("PACIFIC", PHP_DATE_TIMEZONE_GROUP_PACIFIC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("UTC", PHP_DATE_TIMEZONE_GROUP_UTC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ALL", PHP_DATE_TIMEZONE_GROUP_ALL);
REGISTER_TIMEZONE_CLASS_CONST_STRING("ALL_WITH_BC", PHP_DATE_TIMEZONE_GROUP_ALL_W_BC);
REGISTER_TIMEZONE_CLASS_CONST_STRING("PER_COUNTRY", PHP_DATE_TIMEZONE_PER_COUNTRY);
INIT_CLASS_ENTRY(ce_interval, "DateInterval", date_funcs_interval);
ce_interval.create_object = date_object_new_interval;
date_ce_interval = zend_register_internal_class_ex(&ce_interval, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_interval, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_interval.clone_obj = date_object_clone_interval;
date_object_handlers_interval.read_property = date_interval_read_property;
date_object_handlers_interval.write_property = date_interval_write_property;
date_object_handlers_interval.get_properties = date_object_get_properties_interval;
date_object_handlers_interval.get_property_ptr_ptr = NULL;
date_object_handlers_interval.get_gc = date_object_get_gc_interval;
INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period);
ce_period.create_object = date_object_new_period;
date_ce_period = zend_register_internal_class_ex(&ce_period, NULL, NULL TSRMLS_CC);
date_ce_period->get_iterator = date_object_period_get_iterator;
date_ce_period->iterator_funcs.funcs = &date_period_it_funcs;
zend_class_implements(date_ce_period TSRMLS_CC, 1, zend_ce_traversable);
memcpy(&date_object_handlers_period, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_period.clone_obj = date_object_clone_period;
date_object_handlers_period.get_properties = date_object_get_properties_period;
date_object_handlers_period.get_property_ptr_ptr = NULL;
date_object_handlers_period.get_gc = date_object_get_gc_period;
date_object_handlers_period.read_property = date_period_read_property;
date_object_handlers_period.write_property = date_period_write_property;
#define REGISTER_PERIOD_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_period, const_name, sizeof(const_name)-1, value TSRMLS_CC);
REGISTER_PERIOD_CLASS_CONST_STRING("EXCLUDE_START_DATE", PHP_DATE_PERIOD_EXCLUDE_START_DATE);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,020
|
static char *english_suffix(timelib_sll number)
{
if (number >= 10 && number <= 19) {
return "th";
} else {
switch (number % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
}
}
return "th";
}
|
Exec Code
| 0
|
static char *english_suffix(timelib_sll number)
{
if (number >= 10 && number <= 19) {
return "th";
} else {
switch (number % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
}
}
return "th";
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,021
|
PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D)
{
char *tz;
timelib_tzinfo *tzi;
tz = guess_timezone(DATE_TIMEZONEDB TSRMLS_CC);
tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB TSRMLS_CC);
if (! tzi) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Timezone database is corrupt - this should *never* happen!");
}
return tzi;
}
|
Exec Code
| 0
|
PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D)
{
char *tz;
timelib_tzinfo *tzi;
tz = guess_timezone(DATE_TIMEZONEDB TSRMLS_CC);
tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB TSRMLS_CC);
if (! tzi) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Timezone database is corrupt - this should *never* happen!");
}
return tzi;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,022
|
static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC)
{
/* Checking configure timezone */
if (DATEG(timezone) && (strlen(DATEG(timezone))) > 0) {
return DATEG(timezone);
}
/* Check config setting for default timezone */
if (!DATEG(default_timezone)) {
/* Special case: ext/date wasn't initialized yet */
zval ztz;
if (SUCCESS == zend_get_configuration_directive("date.timezone", sizeof("date.timezone"), &ztz)
&& Z_TYPE(ztz) == IS_STRING && Z_STRLEN(ztz) > 0 && timelib_timezone_id_is_valid(Z_STRVAL(ztz), tzdb)) {
return Z_STRVAL(ztz);
}
} else if (*DATEG(default_timezone)) {
if (DATEG(timezone_valid) == 1) {
return DATEG(default_timezone);
}
if (!timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid date.timezone value '%s', we selected the timezone 'UTC' for now.", DATEG(default_timezone));
return "UTC";
}
DATEG(timezone_valid) = 1;
return DATEG(default_timezone);
}
/* Fallback to UTC */
php_error_docref(NULL TSRMLS_CC, E_WARNING, DATE_TZ_ERRMSG "We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.");
return "UTC";
}
|
Exec Code
| 0
|
static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC)
{
/* Checking configure timezone */
if (DATEG(timezone) && (strlen(DATEG(timezone))) > 0) {
return DATEG(timezone);
}
/* Check config setting for default timezone */
if (!DATEG(default_timezone)) {
/* Special case: ext/date wasn't initialized yet */
zval ztz;
if (SUCCESS == zend_get_configuration_directive("date.timezone", sizeof("date.timezone"), &ztz)
&& Z_TYPE(ztz) == IS_STRING && Z_STRLEN(ztz) > 0 && timelib_timezone_id_is_valid(Z_STRVAL(ztz), tzdb)) {
return Z_STRVAL(ztz);
}
} else if (*DATEG(default_timezone)) {
if (DATEG(timezone_valid) == 1) {
return DATEG(default_timezone);
}
if (!timelib_timezone_id_is_valid(DATEG(default_timezone), tzdb)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid date.timezone value '%s', we selected the timezone 'UTC' for now.", DATEG(default_timezone));
return "UTC";
}
DATEG(timezone_valid) = 1;
return DATEG(default_timezone);
}
/* Fallback to UTC */
php_error_docref(NULL TSRMLS_CC, E_WARNING, DATE_TZ_ERRMSG "We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.");
return "UTC";
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,023
|
static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
{
char *format;
int format_len;
long ts;
char *string;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) {
RETURN_FALSE;
}
if (ZEND_NUM_ARGS() == 1) {
ts = time(NULL);
}
string = php_format_date(format, format_len, ts, localtime TSRMLS_CC);
RETVAL_STRING(string, 0);
}
|
Exec Code
| 0
|
static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
{
char *format;
int format_len;
long ts;
char *string;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) {
RETURN_FALSE;
}
if (ZEND_NUM_ARGS() == 1) {
ts = time(NULL);
}
string = php_format_date(format, format_len, ts, localtime TSRMLS_CC);
RETVAL_STRING(string, 0);
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,024
|
char *php_date_full_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
{
timelib_sll day_of_week = timelib_day_of_week(y, m, d);
if (day_of_week < 0) {
return "Unknown";
}
return day_full_names[day_of_week];
}
|
Exec Code
| 0
|
char *php_date_full_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
{
timelib_sll day_of_week = timelib_day_of_week(y, m, d);
if (day_of_week < 0) {
return "Unknown";
}
return day_full_names[day_of_week];
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,025
|
PHPAPI zend_class_entry *php_date_get_date_ce(void)
{
return date_ce_date;
}
|
Exec Code
| 0
|
PHPAPI zend_class_entry *php_date_get_date_ce(void)
{
return date_ce_date;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,026
|
PHPAPI zend_class_entry *php_date_get_immutable_ce(void)
{
return date_ce_immutable;
}
|
Exec Code
| 0
|
PHPAPI zend_class_entry *php_date_get_immutable_ce(void)
{
return date_ce_immutable;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,027
|
PHPAPI zend_class_entry *php_date_get_timezone_ce(void)
{
return date_ce_timezone;
}
|
Exec Code
| 0
|
PHPAPI zend_class_entry *php_date_get_timezone_ce(void)
{
return date_ce_timezone;
}
|
@@ -2807,12 +2807,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2827,7 +2824,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3744,9 +3740,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3771,7 +3766,9 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3787,7 +3784,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
| null | null | null |
5,028
|
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
{
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
}
|
DoS
| 0
|
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
{
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
}
|
@@ -283,6 +283,7 @@ typedef struct {
NMIP6Config * wwan_ip6_config;
NMIP6Config * ext_ip6_config; /* Stuff added outside NM */
gboolean nm_ipv6ll; /* TRUE if NM handles the device's IPv6LL address */
+ guint32 ip6_mtu;
NMRDisc * rdisc;
gulong rdisc_changed_id;
@@ -463,6 +464,12 @@ nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *val
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
}
+static guint32
+nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback)
+{
+ return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
+}
+
static gboolean
device_has_capability (NMDevice *self, NMDeviceCapabilities caps)
{
@@ -4078,6 +4085,58 @@ print_support_extended_ifa_flags (NMSettingIP6ConfigPrivacy use_tempaddr)
warn = 2;
}
+static void nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu);
+
+static void
+nm_device_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ int ifindex = nm_device_get_ifindex (self);
+
+ if (mtu)
+ priv->mtu = mtu;
+
+ /* Ensure the IPv6 MTU is still alright. */
+ if (priv->ip6_mtu)
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
+
+ if (priv->mtu != nm_platform_link_get_mtu (ifindex))
+ nm_platform_link_set_mtu (ifindex, priv->mtu);
+}
+
+static void
+nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ guint32 plat_mtu = nm_device_ipv6_sysctl_get_int32 (self, "mtu", priv->mtu);
+ char val[16];
+
+ priv->ip6_mtu = mtu ?: plat_mtu;
+
+ if (priv->ip6_mtu && priv->mtu < priv->ip6_mtu) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)",
+ priv->ip6_mtu, priv->mtu);
+ priv->ip6_mtu = priv->mtu;
+ }
+
+ if (priv->ip6_mtu < 1280) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting",
+ priv->ip6_mtu);
+ priv->ip6_mtu = 1280;
+ }
+
+ if (priv->mtu < priv->ip6_mtu) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)",
+ priv->mtu, priv->ip6_mtu);
+ nm_device_set_mtu (self, priv->ip6_mtu);
+ }
+
+ if (priv->ip6_mtu != plat_mtu) {
+ g_snprintf (val, sizeof (val), "%d", mtu);
+ nm_device_ipv6_sysctl_set (self, "mtu", val);
+ }
+}
+
static void
rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
{
@@ -4224,12 +4283,8 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
nm_device_ipv6_sysctl_set (self, "hop_limit", val);
}
- if (changed & NM_RDISC_CONFIG_MTU) {
- char val[16];
-
- g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
- nm_device_ipv6_sysctl_set (self, "mtu", val);
- }
+ if (changed & NM_RDISC_CONFIG_MTU)
+ priv->ip6_mtu = rdisc->mtu;
nm_device_activate_schedule_ip6_config_result (self);
}
@@ -4581,6 +4636,13 @@ act_stage3_ip6_config_start (NMDevice *self,
return NM_ACT_STAGE_RETURN_STOP;
}
+ /* Ensure the MTU makes sense. If it was below 1280 the kernel would not
+ * expose any ipv6 sysctls or allow presence of any addresses on the interface,
+ * including LL, which * would make it impossible to autoconfigure MTU to a
+ * correct value. */
+ if (!nm_device_uses_assumed_connection (self))
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
+
/* Any method past this point requires an IPv6LL address. Use NM-controlled
* IPv6LL if this is not an assumed connection, since assumed connections
* will already have IPv6 set up.
@@ -5919,6 +5981,8 @@ nm_device_set_ip4_config (NMDevice *self,
if (commit && new_config) {
gboolean assumed = nm_device_uses_assumed_connection (self);
+ nm_device_set_mtu (self, nm_ip4_config_get_mtu (new_config));
+
/* for assumed devices we set the device_route_metric to the default which will
* stop nm_platform_ip4_address_sync() to replace the device routes. */
success = nm_ip4_config_commit (new_config, ip_ifindex,
@@ -6053,6 +6117,7 @@ nm_device_set_ip6_config (NMDevice *self,
/* Always commit to nm-platform to update lifetimes */
if (commit && new_config) {
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
success = nm_ip6_config_commit (new_config, ip_ifindex);
if (!success)
reason_local = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
CWE-20
| null | null |
5,029
|
queued_state_to_string (NMDeviceState state)
{
if ((gsize) state < G_N_ELEMENTS (state_table))
return state_table[state];
return state_table[NM_DEVICE_STATE_UNKNOWN];
}
|
DoS
| 0
|
queued_state_to_string (NMDeviceState state)
{
if ((gsize) state < G_N_ELEMENTS (state_table))
return state_table[state];
return state_table[NM_DEVICE_STATE_UNKNOWN];
}
|
@@ -283,6 +283,7 @@ typedef struct {
NMIP6Config * wwan_ip6_config;
NMIP6Config * ext_ip6_config; /* Stuff added outside NM */
gboolean nm_ipv6ll; /* TRUE if NM handles the device's IPv6LL address */
+ guint32 ip6_mtu;
NMRDisc * rdisc;
gulong rdisc_changed_id;
@@ -463,6 +464,12 @@ nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *val
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
}
+static guint32
+nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback)
+{
+ return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
+}
+
static gboolean
device_has_capability (NMDevice *self, NMDeviceCapabilities caps)
{
@@ -4078,6 +4085,58 @@ print_support_extended_ifa_flags (NMSettingIP6ConfigPrivacy use_tempaddr)
warn = 2;
}
+static void nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu);
+
+static void
+nm_device_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ int ifindex = nm_device_get_ifindex (self);
+
+ if (mtu)
+ priv->mtu = mtu;
+
+ /* Ensure the IPv6 MTU is still alright. */
+ if (priv->ip6_mtu)
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
+
+ if (priv->mtu != nm_platform_link_get_mtu (ifindex))
+ nm_platform_link_set_mtu (ifindex, priv->mtu);
+}
+
+static void
+nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ guint32 plat_mtu = nm_device_ipv6_sysctl_get_int32 (self, "mtu", priv->mtu);
+ char val[16];
+
+ priv->ip6_mtu = mtu ?: plat_mtu;
+
+ if (priv->ip6_mtu && priv->mtu < priv->ip6_mtu) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)",
+ priv->ip6_mtu, priv->mtu);
+ priv->ip6_mtu = priv->mtu;
+ }
+
+ if (priv->ip6_mtu < 1280) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting",
+ priv->ip6_mtu);
+ priv->ip6_mtu = 1280;
+ }
+
+ if (priv->mtu < priv->ip6_mtu) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)",
+ priv->mtu, priv->ip6_mtu);
+ nm_device_set_mtu (self, priv->ip6_mtu);
+ }
+
+ if (priv->ip6_mtu != plat_mtu) {
+ g_snprintf (val, sizeof (val), "%d", mtu);
+ nm_device_ipv6_sysctl_set (self, "mtu", val);
+ }
+}
+
static void
rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
{
@@ -4224,12 +4283,8 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
nm_device_ipv6_sysctl_set (self, "hop_limit", val);
}
- if (changed & NM_RDISC_CONFIG_MTU) {
- char val[16];
-
- g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
- nm_device_ipv6_sysctl_set (self, "mtu", val);
- }
+ if (changed & NM_RDISC_CONFIG_MTU)
+ priv->ip6_mtu = rdisc->mtu;
nm_device_activate_schedule_ip6_config_result (self);
}
@@ -4581,6 +4636,13 @@ act_stage3_ip6_config_start (NMDevice *self,
return NM_ACT_STAGE_RETURN_STOP;
}
+ /* Ensure the MTU makes sense. If it was below 1280 the kernel would not
+ * expose any ipv6 sysctls or allow presence of any addresses on the interface,
+ * including LL, which * would make it impossible to autoconfigure MTU to a
+ * correct value. */
+ if (!nm_device_uses_assumed_connection (self))
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
+
/* Any method past this point requires an IPv6LL address. Use NM-controlled
* IPv6LL if this is not an assumed connection, since assumed connections
* will already have IPv6 set up.
@@ -5919,6 +5981,8 @@ nm_device_set_ip4_config (NMDevice *self,
if (commit && new_config) {
gboolean assumed = nm_device_uses_assumed_connection (self);
+ nm_device_set_mtu (self, nm_ip4_config_get_mtu (new_config));
+
/* for assumed devices we set the device_route_metric to the default which will
* stop nm_platform_ip4_address_sync() to replace the device routes. */
success = nm_ip4_config_commit (new_config, ip_ifindex,
@@ -6053,6 +6117,7 @@ nm_device_set_ip6_config (NMDevice *self,
/* Always commit to nm-platform to update lifetimes */
if (commit && new_config) {
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
success = nm_ip6_config_commit (new_config, ip_ifindex);
if (!success)
reason_local = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
CWE-20
| null | null |
5,030
|
reason_to_string (NMDeviceStateReason reason)
{
if ((gsize) reason < G_N_ELEMENTS (reason_table))
return reason_table[reason];
return reason_table[NM_DEVICE_STATE_REASON_UNKNOWN];
}
|
DoS
| 0
|
reason_to_string (NMDeviceStateReason reason)
{
if ((gsize) reason < G_N_ELEMENTS (reason_table))
return reason_table[reason];
return reason_table[NM_DEVICE_STATE_REASON_UNKNOWN];
}
|
@@ -283,6 +283,7 @@ typedef struct {
NMIP6Config * wwan_ip6_config;
NMIP6Config * ext_ip6_config; /* Stuff added outside NM */
gboolean nm_ipv6ll; /* TRUE if NM handles the device's IPv6LL address */
+ guint32 ip6_mtu;
NMRDisc * rdisc;
gulong rdisc_changed_id;
@@ -463,6 +464,12 @@ nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *val
return nm_platform_sysctl_set (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value);
}
+static guint32
+nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback)
+{
+ return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback);
+}
+
static gboolean
device_has_capability (NMDevice *self, NMDeviceCapabilities caps)
{
@@ -4078,6 +4085,58 @@ print_support_extended_ifa_flags (NMSettingIP6ConfigPrivacy use_tempaddr)
warn = 2;
}
+static void nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu);
+
+static void
+nm_device_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ int ifindex = nm_device_get_ifindex (self);
+
+ if (mtu)
+ priv->mtu = mtu;
+
+ /* Ensure the IPv6 MTU is still alright. */
+ if (priv->ip6_mtu)
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
+
+ if (priv->mtu != nm_platform_link_get_mtu (ifindex))
+ nm_platform_link_set_mtu (ifindex, priv->mtu);
+}
+
+static void
+nm_device_ipv6_set_mtu (NMDevice *self, guint32 mtu)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ guint32 plat_mtu = nm_device_ipv6_sysctl_get_int32 (self, "mtu", priv->mtu);
+ char val[16];
+
+ priv->ip6_mtu = mtu ?: plat_mtu;
+
+ if (priv->ip6_mtu && priv->mtu < priv->ip6_mtu) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "Lowering IPv6 MTU (%d) to match device MTU (%d)",
+ priv->ip6_mtu, priv->mtu);
+ priv->ip6_mtu = priv->mtu;
+ }
+
+ if (priv->ip6_mtu < 1280) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "IPv6 MTU (%d) smaller than 1280, adjusting",
+ priv->ip6_mtu);
+ priv->ip6_mtu = 1280;
+ }
+
+ if (priv->mtu < priv->ip6_mtu) {
+ _LOGW (LOGD_DEVICE | LOGD_IP6, "Raising device MTU (%d) to match IPv6 MTU (%d)",
+ priv->mtu, priv->ip6_mtu);
+ nm_device_set_mtu (self, priv->ip6_mtu);
+ }
+
+ if (priv->ip6_mtu != plat_mtu) {
+ g_snprintf (val, sizeof (val), "%d", mtu);
+ nm_device_ipv6_sysctl_set (self, "mtu", val);
+ }
+}
+
static void
rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
{
@@ -4224,12 +4283,8 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self)
nm_device_ipv6_sysctl_set (self, "hop_limit", val);
}
- if (changed & NM_RDISC_CONFIG_MTU) {
- char val[16];
-
- g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
- nm_device_ipv6_sysctl_set (self, "mtu", val);
- }
+ if (changed & NM_RDISC_CONFIG_MTU)
+ priv->ip6_mtu = rdisc->mtu;
nm_device_activate_schedule_ip6_config_result (self);
}
@@ -4581,6 +4636,13 @@ act_stage3_ip6_config_start (NMDevice *self,
return NM_ACT_STAGE_RETURN_STOP;
}
+ /* Ensure the MTU makes sense. If it was below 1280 the kernel would not
+ * expose any ipv6 sysctls or allow presence of any addresses on the interface,
+ * including LL, which * would make it impossible to autoconfigure MTU to a
+ * correct value. */
+ if (!nm_device_uses_assumed_connection (self))
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
+
/* Any method past this point requires an IPv6LL address. Use NM-controlled
* IPv6LL if this is not an assumed connection, since assumed connections
* will already have IPv6 set up.
@@ -5919,6 +5981,8 @@ nm_device_set_ip4_config (NMDevice *self,
if (commit && new_config) {
gboolean assumed = nm_device_uses_assumed_connection (self);
+ nm_device_set_mtu (self, nm_ip4_config_get_mtu (new_config));
+
/* for assumed devices we set the device_route_metric to the default which will
* stop nm_platform_ip4_address_sync() to replace the device routes. */
success = nm_ip4_config_commit (new_config, ip_ifindex,
@@ -6053,6 +6117,7 @@ nm_device_set_ip6_config (NMDevice *self,
/* Always commit to nm-platform to update lifetimes */
if (commit && new_config) {
+ nm_device_ipv6_set_mtu (self, priv->ip6_mtu);
success = nm_ip6_config_commit (new_config, ip_ifindex);
if (!success)
reason_local = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
CWE-20
| null | null |
5,031
|
addresses_are_duplicate (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b, gboolean consider_plen)
{
return a->address == b->address && (!consider_plen || a->plen == b->plen);
}
|
DoS
| 0
|
addresses_are_duplicate (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b, gboolean consider_plen)
{
return a->address == b->address && (!consider_plen || a->plen == b->plen);
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,032
|
nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
{
NMIP4Config *config;
NMIP4ConfigPrivate *priv;
guint i;
guint32 lowest_metric = G_MAXUINT32;
guint32 old_gateway = 0;
gboolean has_gateway = FALSE;
/* Slaves have no IP configuration */
if (nm_platform_link_get_master (ifindex) > 0)
return NULL;
config = nm_ip4_config_new (ifindex);
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
priv->addresses = nm_platform_ip4_address_get_all (ifindex);
priv->routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
/* Extract gateway from default route */
old_gateway = priv->gateway;
for (i = 0; i < priv->routes->len; i++) {
const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
if (route->metric < lowest_metric) {
priv->gateway = route->gateway;
lowest_metric = route->metric;
}
has_gateway = TRUE;
/* Remove the default route from the list */
g_array_remove_index (priv->routes, i);
i--;
}
}
/* If there is a host route to the gateway, ignore that route. It is
* automatically added by NetworkManager when needed.
*/
if (has_gateway) {
for (i = 0; i < priv->routes->len; i++) {
const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
if ( (route->plen == 32)
&& (route->network == priv->gateway)
&& (route->gateway == 0)) {
g_array_remove_index (priv->routes, i);
i--;
}
}
}
/* If the interface has the default route, and has IPv4 addresses, capture
* nameservers from /etc/resolv.conf.
*/
if (priv->addresses->len && has_gateway && capture_resolv_conf) {
if (nm_ip4_config_capture_resolv_conf (priv->nameservers, NULL))
_NOTIFY (config, PROP_NAMESERVERS);
}
/* actually, nobody should be connected to the signal, just to be sure, notify */
_NOTIFY (config, PROP_ADDRESS_DATA);
_NOTIFY (config, PROP_ROUTE_DATA);
_NOTIFY (config, PROP_ADDRESSES);
_NOTIFY (config, PROP_ROUTES);
if (priv->gateway != old_gateway)
_NOTIFY (config, PROP_GATEWAY);
return config;
}
|
DoS
| 0
|
nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
{
NMIP4Config *config;
NMIP4ConfigPrivate *priv;
guint i;
guint32 lowest_metric = G_MAXUINT32;
guint32 old_gateway = 0;
gboolean has_gateway = FALSE;
/* Slaves have no IP configuration */
if (nm_platform_link_get_master (ifindex) > 0)
return NULL;
config = nm_ip4_config_new (ifindex);
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
priv->addresses = nm_platform_ip4_address_get_all (ifindex);
priv->routes = nm_platform_ip4_route_get_all (ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
/* Extract gateway from default route */
old_gateway = priv->gateway;
for (i = 0; i < priv->routes->len; i++) {
const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
if (route->metric < lowest_metric) {
priv->gateway = route->gateway;
lowest_metric = route->metric;
}
has_gateway = TRUE;
/* Remove the default route from the list */
g_array_remove_index (priv->routes, i);
i--;
}
}
/* If there is a host route to the gateway, ignore that route. It is
* automatically added by NetworkManager when needed.
*/
if (has_gateway) {
for (i = 0; i < priv->routes->len; i++) {
const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
if ( (route->plen == 32)
&& (route->network == priv->gateway)
&& (route->gateway == 0)) {
g_array_remove_index (priv->routes, i);
i--;
}
}
}
/* If the interface has the default route, and has IPv4 addresses, capture
* nameservers from /etc/resolv.conf.
*/
if (priv->addresses->len && has_gateway && capture_resolv_conf) {
if (nm_ip4_config_capture_resolv_conf (priv->nameservers, NULL))
_NOTIFY (config, PROP_NAMESERVERS);
}
/* actually, nobody should be connected to the signal, just to be sure, notify */
_NOTIFY (config, PROP_ADDRESS_DATA);
_NOTIFY (config, PROP_ROUTE_DATA);
_NOTIFY (config, PROP_ADDRESSES);
_NOTIFY (config, PROP_ROUTES);
if (priv->gateway != old_gateway)
_NOTIFY (config, PROP_GATEWAY);
return config;
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,033
|
nm_ip4_config_capture_resolv_conf (GArray *nameservers,
const char *rc_contents)
{
GPtrArray *read_ns;
guint i, j;
gboolean changed = FALSE;
g_return_val_if_fail (nameservers != NULL, FALSE);
read_ns = nm_utils_read_resolv_conf_nameservers (rc_contents);
if (!read_ns)
return FALSE;
for (i = 0; i < read_ns->len; i++) {
const char *s = g_ptr_array_index (read_ns, i);
guint32 ns = 0;
if (!inet_pton (AF_INET, s, (void *) &ns) || !ns)
continue;
/* Ignore duplicates */
for (j = 0; j < nameservers->len; j++) {
if (g_array_index (nameservers, guint32, j) == ns)
break;
}
if (j == nameservers->len) {
g_array_append_val (nameservers, ns);
changed = TRUE;
}
}
g_ptr_array_unref (read_ns);
return changed;
}
|
DoS
| 0
|
nm_ip4_config_capture_resolv_conf (GArray *nameservers,
const char *rc_contents)
{
GPtrArray *read_ns;
guint i, j;
gboolean changed = FALSE;
g_return_val_if_fail (nameservers != NULL, FALSE);
read_ns = nm_utils_read_resolv_conf_nameservers (rc_contents);
if (!read_ns)
return FALSE;
for (i = 0; i < read_ns->len; i++) {
const char *s = g_ptr_array_index (read_ns, i);
guint32 ns = 0;
if (!inet_pton (AF_INET, s, (void *) &ns) || !ns)
continue;
/* Ignore duplicates */
for (j = 0; j < nameservers->len; j++) {
if (g_array_index (nameservers, guint32, j) == ns)
break;
}
if (j == nameservers->len) {
g_array_append_val (nameservers, ns);
changed = TRUE;
}
}
g_ptr_array_unref (read_ns);
return changed;
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,034
|
nm_ip4_config_export (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
static guint32 counter = 0;
if (!priv->path) {
priv->path = g_strdup_printf (NM_DBUS_PATH "/IP4Config/%d", counter++);
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, config);
}
}
|
DoS
| 0
|
nm_ip4_config_export (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
static guint32 counter = 0;
if (!priv->path) {
priv->path = g_strdup_printf (NM_DBUS_PATH "/IP4Config/%d", counter++);
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, config);
}
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,035
|
nm_ip4_config_get_dbus_path (const NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return priv->path;
}
|
DoS
| 0
|
nm_ip4_config_get_dbus_path (const NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
return priv->path;
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,036
|
nm_ip4_config_get_ifindex (const NMIP4Config *config)
{
return NM_IP4_CONFIG_GET_PRIVATE (config)->ifindex;
}
|
DoS
| 0
|
nm_ip4_config_get_ifindex (const NMIP4Config *config)
{
return NM_IP4_CONFIG_GET_PRIVATE (config)->ifindex;
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,037
|
nm_ip4_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
NM_IP4_CONFIG_IFINDEX, ifindex,
NULL);
}
|
DoS
| 0
|
nm_ip4_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
NM_IP4_CONFIG_IFINDEX, ifindex,
NULL);
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,038
|
routes_are_duplicate (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, gboolean consider_gateway_and_metric)
{
return a->network == b->network && a->plen == b->plen &&
(!consider_gateway_and_metric || (a->gateway == b->gateway && a->metric == b->metric));
}
|
DoS
| 0
|
routes_are_duplicate (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, gboolean consider_gateway_and_metric)
{
return a->network == b->network && a->plen == b->plen &&
(!consider_gateway_and_metric || (a->gateway == b->gateway && a->metric == b->metric));
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,039
|
same_prefix (guint32 address1, guint32 address2, int plen)
{
guint32 masked1 = ntohl (address1) >> (32 - plen);
guint32 masked2 = ntohl (address2) >> (32 - plen);
return masked1 == masked2;
}
|
DoS
| 0
|
same_prefix (guint32 address1, guint32 address2, int plen)
{
guint32 masked1 = ntohl (address1) >> (32 - plen);
guint32 masked2 = ntohl (address2) >> (32 - plen);
return masked1 == masked2;
}
|
@@ -264,7 +264,6 @@ gboolean
nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_route_metric)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
- guint32 mtu = nm_ip4_config_get_mtu (config);
int i;
g_return_val_if_fail (ifindex > 0, FALSE);
@@ -299,10 +298,6 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
return FALSE;
}
- /* MTU */
- if (mtu && mtu != nm_platform_link_get_mtu (ifindex))
- nm_platform_link_set_mtu (ifindex, mtu);
-
return TRUE;
}
|
CWE-20
| null | null |
5,040
|
import (ctrl_t ctrl, IOBUF inp, const char* fname,struct stats_s *stats,
unsigned char **fpr,size_t *fpr_len,unsigned int options )
{
PACKET *pending_pkt = NULL;
KBNODE keyblock = NULL; /* Need to initialize because gcc can't
grasp the return semantics of
read_block. */
int rc = 0;
getkey_disable_caches();
if( !opt.no_armor ) { /* armored reading is not disabled */
armor_filter_context_t *afx;
afx = new_armor_context ();
afx->only_keyblocks = 1;
push_armor_filter (afx, inp);
release_armor_context (afx);
}
while( !(rc = read_block( inp, &pending_pkt, &keyblock) )) {
if( keyblock->pkt->pkttype == PKT_PUBLIC_KEY )
rc = import_one (ctrl, fname, keyblock,
stats, fpr, fpr_len, options, 0);
else if( keyblock->pkt->pkttype == PKT_SECRET_KEY )
rc = import_secret_one (ctrl, fname, keyblock, stats, options);
else if( keyblock->pkt->pkttype == PKT_SIGNATURE
&& keyblock->pkt->pkt.signature->sig_class == 0x20 )
rc = import_revoke_cert( fname, keyblock, stats );
else {
log_info( _("skipping block of type %d\n"),
keyblock->pkt->pkttype );
}
release_kbnode(keyblock);
/* fixme: we should increment the not imported counter but this
does only make sense if we keep on going despite of errors. */
if( rc )
break;
if( !(++stats->count % 100) && !opt.quiet )
log_info(_("%lu keys processed so far\n"), stats->count );
}
if( rc == -1 )
rc = 0;
else if( rc && rc != G10ERR_INV_KEYRING )
log_error( _("error reading '%s': %s\n"), fname, g10_errstr(rc));
return rc;
}
|
DoS
| 0
|
import (ctrl_t ctrl, IOBUF inp, const char* fname,struct stats_s *stats,
unsigned char **fpr,size_t *fpr_len,unsigned int options )
{
PACKET *pending_pkt = NULL;
KBNODE keyblock = NULL; /* Need to initialize because gcc can't
grasp the return semantics of
read_block. */
int rc = 0;
getkey_disable_caches();
if( !opt.no_armor ) { /* armored reading is not disabled */
armor_filter_context_t *afx;
afx = new_armor_context ();
afx->only_keyblocks = 1;
push_armor_filter (afx, inp);
release_armor_context (afx);
}
while( !(rc = read_block( inp, &pending_pkt, &keyblock) )) {
if( keyblock->pkt->pkttype == PKT_PUBLIC_KEY )
rc = import_one (ctrl, fname, keyblock,
stats, fpr, fpr_len, options, 0);
else if( keyblock->pkt->pkttype == PKT_SECRET_KEY )
rc = import_secret_one (ctrl, fname, keyblock, stats, options);
else if( keyblock->pkt->pkttype == PKT_SIGNATURE
&& keyblock->pkt->pkt.signature->sig_class == 0x20 )
rc = import_revoke_cert( fname, keyblock, stats );
else {
log_info( _("skipping block of type %d\n"),
keyblock->pkt->pkttype );
}
release_kbnode(keyblock);
/* fixme: we should increment the not imported counter but this
does only make sense if we keep on going despite of errors. */
if( rc )
break;
if( !(++stats->count % 100) && !opt.quiet )
log_info(_("%lu keys processed so far\n"), stats->count );
}
if( rc == -1 )
rc = 0;
else if( rc && rc != G10ERR_INV_KEYRING )
log_error( _("error reading '%s': %s\n"), fname, g10_errstr(rc));
return rc;
}
|
@@ -384,6 +384,27 @@ import_print_stats (void *hd)
}
+/* Return true if PKTTYPE is valid in a keyblock. */
+static int
+valid_keyblock_packet (int pkttype)
+{
+ switch (pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ case PKT_SIGNATURE:
+ case PKT_USER_ID:
+ case PKT_ATTRIBUTE:
+ case PKT_RING_TRUST:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
/****************
* Read the next keyblock from stream A.
* PENDING_PKT should be initialzed to NULL
@@ -461,7 +482,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
in_cert = 1;
default:
- if( in_cert ) {
+ if (in_cert && valid_keyblock_packet (pkt->pkttype)) {
if( !root )
root = new_kbnode( pkt );
else
|
CWE-20
| null | null |
5,041
|
import_keys (ctrl_t ctrl, char **fnames, int nnames,
void *stats_handle, unsigned int options )
{
import_keys_internal (ctrl, NULL, fnames, nnames, stats_handle,
NULL, NULL, options);
}
|
DoS
| 0
|
import_keys (ctrl_t ctrl, char **fnames, int nnames,
void *stats_handle, unsigned int options )
{
import_keys_internal (ctrl, NULL, fnames, nnames, stats_handle,
NULL, NULL, options);
}
|
@@ -384,6 +384,27 @@ import_print_stats (void *hd)
}
+/* Return true if PKTTYPE is valid in a keyblock. */
+static int
+valid_keyblock_packet (int pkttype)
+{
+ switch (pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ case PKT_SIGNATURE:
+ case PKT_USER_ID:
+ case PKT_ATTRIBUTE:
+ case PKT_RING_TRUST:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
/****************
* Read the next keyblock from stream A.
* PENDING_PKT should be initialzed to NULL
@@ -461,7 +482,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
in_cert = 1;
default:
- if( in_cert ) {
+ if (in_cert && valid_keyblock_packet (pkt->pkttype)) {
if( !root )
root = new_kbnode( pkt );
else
|
CWE-20
| null | null |
5,042
|
import_keys_es_stream (ctrl_t ctrl, estream_t fp, void *stats_handle,
unsigned char **fpr, size_t *fpr_len,
unsigned int options)
{
int rc;
iobuf_t inp;
inp = iobuf_esopen (fp, "r", 1);
if (!inp)
{
rc = gpg_error_from_syserror ();
log_error ("iobuf_esopen failed: %s\n", gpg_strerror (rc));
return rc;
}
rc = import_keys_internal (ctrl, inp, NULL, 0, stats_handle,
fpr, fpr_len, options);
iobuf_close (inp);
return rc;
}
|
DoS
| 0
|
import_keys_es_stream (ctrl_t ctrl, estream_t fp, void *stats_handle,
unsigned char **fpr, size_t *fpr_len,
unsigned int options)
{
int rc;
iobuf_t inp;
inp = iobuf_esopen (fp, "r", 1);
if (!inp)
{
rc = gpg_error_from_syserror ();
log_error ("iobuf_esopen failed: %s\n", gpg_strerror (rc));
return rc;
}
rc = import_keys_internal (ctrl, inp, NULL, 0, stats_handle,
fpr, fpr_len, options);
iobuf_close (inp);
return rc;
}
|
@@ -384,6 +384,27 @@ import_print_stats (void *hd)
}
+/* Return true if PKTTYPE is valid in a keyblock. */
+static int
+valid_keyblock_packet (int pkttype)
+{
+ switch (pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ case PKT_SIGNATURE:
+ case PKT_USER_ID:
+ case PKT_ATTRIBUTE:
+ case PKT_RING_TRUST:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
/****************
* Read the next keyblock from stream A.
* PENDING_PKT should be initialzed to NULL
@@ -461,7 +482,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
in_cert = 1;
default:
- if( in_cert ) {
+ if (in_cert && valid_keyblock_packet (pkt->pkttype)) {
if( !root )
root = new_kbnode( pkt );
else
|
CWE-20
| null | null |
5,043
|
import_new_stats_handle (void)
{
return xmalloc_clear ( sizeof (struct stats_s) );
}
|
DoS
| 0
|
import_new_stats_handle (void)
{
return xmalloc_clear ( sizeof (struct stats_s) );
}
|
@@ -384,6 +384,27 @@ import_print_stats (void *hd)
}
+/* Return true if PKTTYPE is valid in a keyblock. */
+static int
+valid_keyblock_packet (int pkttype)
+{
+ switch (pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ case PKT_SIGNATURE:
+ case PKT_USER_ID:
+ case PKT_ATTRIBUTE:
+ case PKT_RING_TRUST:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
/****************
* Read the next keyblock from stream A.
* PENDING_PKT should be initialzed to NULL
@@ -461,7 +482,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
in_cert = 1;
default:
- if( in_cert ) {
+ if (in_cert && valid_keyblock_packet (pkt->pkttype)) {
if( !root )
root = new_kbnode( pkt );
else
|
CWE-20
| null | null |
5,044
|
import_print_stats (void *hd)
{
struct stats_s *stats = hd;
if( !opt.quiet ) {
log_info(_("Total number processed: %lu\n"), stats->count );
if( stats->skipped_new_keys )
log_info(_(" skipped new keys: %lu\n"),
stats->skipped_new_keys );
if( stats->no_user_id )
log_info(_(" w/o user IDs: %lu\n"), stats->no_user_id );
if( stats->imported || stats->imported_rsa ) {
log_info(_(" imported: %lu"), stats->imported );
if (stats->imported_rsa)
log_printf (" (RSA: %lu)", stats->imported_rsa );
log_printf ("\n");
}
if( stats->unchanged )
log_info(_(" unchanged: %lu\n"), stats->unchanged );
if( stats->n_uids )
log_info(_(" new user IDs: %lu\n"), stats->n_uids );
if( stats->n_subk )
log_info(_(" new subkeys: %lu\n"), stats->n_subk );
if( stats->n_sigs )
log_info(_(" new signatures: %lu\n"), stats->n_sigs );
if( stats->n_revoc )
log_info(_(" new key revocations: %lu\n"), stats->n_revoc );
if( stats->secret_read )
log_info(_(" secret keys read: %lu\n"), stats->secret_read );
if( stats->secret_imported )
log_info(_(" secret keys imported: %lu\n"), stats->secret_imported );
if( stats->secret_dups )
log_info(_(" secret keys unchanged: %lu\n"), stats->secret_dups );
if( stats->not_imported )
log_info(_(" not imported: %lu\n"), stats->not_imported );
if( stats->n_sigs_cleaned)
log_info(_(" signatures cleaned: %lu\n"),stats->n_sigs_cleaned);
if( stats->n_uids_cleaned)
log_info(_(" user IDs cleaned: %lu\n"),stats->n_uids_cleaned);
}
if( is_status_enabled() ) {
char buf[14*20];
sprintf(buf, "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
stats->count,
stats->no_user_id,
stats->imported,
stats->imported_rsa,
stats->unchanged,
stats->n_uids,
stats->n_subk,
stats->n_sigs,
stats->n_revoc,
stats->secret_read,
stats->secret_imported,
stats->secret_dups,
stats->skipped_new_keys,
stats->not_imported );
write_status_text( STATUS_IMPORT_RES, buf );
}
}
|
DoS
| 0
|
import_print_stats (void *hd)
{
struct stats_s *stats = hd;
if( !opt.quiet ) {
log_info(_("Total number processed: %lu\n"), stats->count );
if( stats->skipped_new_keys )
log_info(_(" skipped new keys: %lu\n"),
stats->skipped_new_keys );
if( stats->no_user_id )
log_info(_(" w/o user IDs: %lu\n"), stats->no_user_id );
if( stats->imported || stats->imported_rsa ) {
log_info(_(" imported: %lu"), stats->imported );
if (stats->imported_rsa)
log_printf (" (RSA: %lu)", stats->imported_rsa );
log_printf ("\n");
}
if( stats->unchanged )
log_info(_(" unchanged: %lu\n"), stats->unchanged );
if( stats->n_uids )
log_info(_(" new user IDs: %lu\n"), stats->n_uids );
if( stats->n_subk )
log_info(_(" new subkeys: %lu\n"), stats->n_subk );
if( stats->n_sigs )
log_info(_(" new signatures: %lu\n"), stats->n_sigs );
if( stats->n_revoc )
log_info(_(" new key revocations: %lu\n"), stats->n_revoc );
if( stats->secret_read )
log_info(_(" secret keys read: %lu\n"), stats->secret_read );
if( stats->secret_imported )
log_info(_(" secret keys imported: %lu\n"), stats->secret_imported );
if( stats->secret_dups )
log_info(_(" secret keys unchanged: %lu\n"), stats->secret_dups );
if( stats->not_imported )
log_info(_(" not imported: %lu\n"), stats->not_imported );
if( stats->n_sigs_cleaned)
log_info(_(" signatures cleaned: %lu\n"),stats->n_sigs_cleaned);
if( stats->n_uids_cleaned)
log_info(_(" user IDs cleaned: %lu\n"),stats->n_uids_cleaned);
}
if( is_status_enabled() ) {
char buf[14*20];
sprintf(buf, "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
stats->count,
stats->no_user_id,
stats->imported,
stats->imported_rsa,
stats->unchanged,
stats->n_uids,
stats->n_subk,
stats->n_sigs,
stats->n_revoc,
stats->secret_read,
stats->secret_imported,
stats->secret_dups,
stats->skipped_new_keys,
stats->not_imported );
write_status_text( STATUS_IMPORT_RES, buf );
}
}
|
@@ -384,6 +384,27 @@ import_print_stats (void *hd)
}
+/* Return true if PKTTYPE is valid in a keyblock. */
+static int
+valid_keyblock_packet (int pkttype)
+{
+ switch (pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ case PKT_SIGNATURE:
+ case PKT_USER_ID:
+ case PKT_ATTRIBUTE:
+ case PKT_RING_TRUST:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
/****************
* Read the next keyblock from stream A.
* PENDING_PKT should be initialzed to NULL
@@ -461,7 +482,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
in_cert = 1;
default:
- if( in_cert ) {
+ if (in_cert && valid_keyblock_packet (pkt->pkttype)) {
if( !root )
root = new_kbnode( pkt );
else
|
CWE-20
| null | null |
5,045
|
import_release_stats_handle (void *p)
{
xfree (p);
}
|
DoS
| 0
|
import_release_stats_handle (void *p)
{
xfree (p);
}
|
@@ -384,6 +384,27 @@ import_print_stats (void *hd)
}
+/* Return true if PKTTYPE is valid in a keyblock. */
+static int
+valid_keyblock_packet (int pkttype)
+{
+ switch (pkttype)
+ {
+ case PKT_PUBLIC_KEY:
+ case PKT_PUBLIC_SUBKEY:
+ case PKT_SECRET_KEY:
+ case PKT_SECRET_SUBKEY:
+ case PKT_SIGNATURE:
+ case PKT_USER_ID:
+ case PKT_ATTRIBUTE:
+ case PKT_RING_TRUST:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
/****************
* Read the next keyblock from stream A.
* PENDING_PKT should be initialzed to NULL
@@ -461,7 +482,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
in_cert = 1;
default:
- if( in_cert ) {
+ if (in_cert && valid_keyblock_packet (pkt->pkttype)) {
if( !root )
root = new_kbnode( pkt );
else
|
CWE-20
| null | null |
5,046
|
e1000_autoneg_timer(void *opaque)
{
E1000State *s = opaque;
s->nic->nc.link_down = false;
e1000_link_up(s);
s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
DBGOUT(PHY, "Auto negotiation is completed\n");
}
|
DoS Exec Code Overflow
| 0
|
e1000_autoneg_timer(void *opaque)
{
E1000State *s = opaque;
s->nic->nc.link_down = false;
e1000_link_up(s);
s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
DBGOUT(PHY, "Auto negotiation is completed\n");
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,047
|
static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
{
int bufs;
/* Fast-path short packets */
if (total_size <= s->rxbuf_size) {
return s->mac_reg[RDH] != s->mac_reg[RDT];
}
if (s->mac_reg[RDH] < s->mac_reg[RDT]) {
bufs = s->mac_reg[RDT] - s->mac_reg[RDH];
} else if (s->mac_reg[RDH] > s->mac_reg[RDT]) {
bufs = s->mac_reg[RDLEN] / sizeof(struct e1000_rx_desc) +
s->mac_reg[RDT] - s->mac_reg[RDH];
} else {
return false;
}
return total_size <= bufs * s->rxbuf_size;
}
|
DoS Exec Code Overflow
| 0
|
static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
{
int bufs;
/* Fast-path short packets */
if (total_size <= s->rxbuf_size) {
return s->mac_reg[RDH] != s->mac_reg[RDT];
}
if (s->mac_reg[RDH] < s->mac_reg[RDT]) {
bufs = s->mac_reg[RDT] - s->mac_reg[RDH];
} else if (s->mac_reg[RDH] > s->mac_reg[RDT]) {
bufs = s->mac_reg[RDLEN] / sizeof(struct e1000_rx_desc) +
s->mac_reg[RDT] - s->mac_reg[RDH];
} else {
return false;
}
return total_size <= bufs * s->rxbuf_size;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,048
|
e1000_link_down(E1000State *s)
{
s->mac_reg[STATUS] &= ~E1000_STATUS_LU;
s->phy_reg[PHY_STATUS] &= ~MII_SR_LINK_STATUS;
}
|
DoS Exec Code Overflow
| 0
|
e1000_link_down(E1000State *s)
{
s->mac_reg[STATUS] &= ~E1000_STATUS_LU;
s->phy_reg[PHY_STATUS] &= ~MII_SR_LINK_STATUS;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,049
|
e1000_send_packet(E1000State *s, const uint8_t *buf, int size)
{
if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) {
s->nic->nc.info->receive(&s->nic->nc, buf, size);
} else {
qemu_send_packet(&s->nic->nc, buf, size);
}
}
|
DoS Exec Code Overflow
| 0
|
e1000_send_packet(E1000State *s, const uint8_t *buf, int size)
{
if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) {
s->nic->nc.info->receive(&s->nic->nc, buf, size);
} else {
qemu_send_packet(&s->nic->nc, buf, size);
}
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,050
|
fcs_len(E1000State *s)
{
return (s->mac_reg[RCTL] & E1000_RCTL_SECRC) ? 0 : 4;
}
|
DoS Exec Code Overflow
| 0
|
fcs_len(E1000State *s)
{
return (s->mac_reg[RCTL] & E1000_RCTL_SECRC) ? 0 : 4;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,051
|
flash_eerd_read(E1000State *s, int x)
{
unsigned int index, r = s->mac_reg[EERD] & ~E1000_EEPROM_RW_REG_START;
if ((s->mac_reg[EERD] & E1000_EEPROM_RW_REG_START) == 0)
return (s->mac_reg[EERD]);
if ((index = r >> E1000_EEPROM_RW_ADDR_SHIFT) > EEPROM_CHECKSUM_REG)
return (E1000_EEPROM_RW_REG_DONE | r);
return ((s->eeprom_data[index] << E1000_EEPROM_RW_REG_DATA) |
E1000_EEPROM_RW_REG_DONE | r);
}
|
DoS Exec Code Overflow
| 0
|
flash_eerd_read(E1000State *s, int x)
{
unsigned int index, r = s->mac_reg[EERD] & ~E1000_EEPROM_RW_REG_START;
if ((s->mac_reg[EERD] & E1000_EEPROM_RW_REG_START) == 0)
return (s->mac_reg[EERD]);
if ((index = r >> E1000_EEPROM_RW_ADDR_SHIFT) > EEPROM_CHECKSUM_REG)
return (E1000_EEPROM_RW_REG_DONE | r);
return ((s->eeprom_data[index] << E1000_EEPROM_RW_REG_DATA) |
E1000_EEPROM_RW_REG_DONE | r);
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,052
|
get_eecd(E1000State *s, int index)
{
uint32_t ret = E1000_EECD_PRES|E1000_EECD_GNT | s->eecd_state.old_eecd;
DBGOUT(EEPROM, "reading eeprom bit %d (reading %d)\n",
s->eecd_state.bitnum_out, s->eecd_state.reading);
if (!s->eecd_state.reading ||
((s->eeprom_data[(s->eecd_state.bitnum_out >> 4) & 0x3f] >>
((s->eecd_state.bitnum_out & 0xf) ^ 0xf))) & 1)
ret |= E1000_EECD_DO;
return ret;
}
|
DoS Exec Code Overflow
| 0
|
get_eecd(E1000State *s, int index)
{
uint32_t ret = E1000_EECD_PRES|E1000_EECD_GNT | s->eecd_state.old_eecd;
DBGOUT(EEPROM, "reading eeprom bit %d (reading %d)\n",
s->eecd_state.bitnum_out, s->eecd_state.reading);
if (!s->eecd_state.reading ||
((s->eeprom_data[(s->eecd_state.bitnum_out >> 4) & 0x3f] >>
((s->eecd_state.bitnum_out & 0xf) ^ 0xf))) & 1)
ret |= E1000_EECD_DO;
return ret;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,053
|
is_vlan_packet(E1000State *s, const uint8_t *buf)
{
return (be16_to_cpup((uint16_t *)(buf + 12)) ==
le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
}
|
DoS Exec Code Overflow
| 0
|
is_vlan_packet(E1000State *s, const uint8_t *buf)
{
return (be16_to_cpup((uint16_t *)(buf + 12)) ==
le16_to_cpup((uint16_t *)(s->mac_reg + VET)));
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,054
|
static uint64_t rx_desc_base(E1000State *s)
{
uint64_t bah = s->mac_reg[RDBAH];
uint64_t bal = s->mac_reg[RDBAL] & ~0xf;
return (bah << 32) + bal;
}
|
DoS Exec Code Overflow
| 0
|
static uint64_t rx_desc_base(E1000State *s)
{
uint64_t bah = s->mac_reg[RDBAH];
uint64_t bal = s->mac_reg[RDBAL] & ~0xf;
return (bah << 32) + bal;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,055
|
set_ctrl(E1000State *s, int index, uint32_t val)
{
/* RST is self clearing */
s->mac_reg[CTRL] = val & ~E1000_CTRL_RST;
}
|
DoS Exec Code Overflow
| 0
|
set_ctrl(E1000State *s, int index, uint32_t val)
{
/* RST is self clearing */
s->mac_reg[CTRL] = val & ~E1000_CTRL_RST;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,056
|
set_eecd(E1000State *s, int index, uint32_t val)
{
uint32_t oldval = s->eecd_state.old_eecd;
s->eecd_state.old_eecd = val & (E1000_EECD_SK | E1000_EECD_CS |
E1000_EECD_DI|E1000_EECD_FWE_MASK|E1000_EECD_REQ);
if (!(E1000_EECD_CS & val)) // CS inactive; nothing to do
return;
if (E1000_EECD_CS & (val ^ oldval)) { // CS rise edge; reset state
s->eecd_state.val_in = 0;
s->eecd_state.bitnum_in = 0;
s->eecd_state.bitnum_out = 0;
s->eecd_state.reading = 0;
}
if (!(E1000_EECD_SK & (val ^ oldval))) // no clock edge
return;
if (!(E1000_EECD_SK & val)) { // falling edge
s->eecd_state.bitnum_out++;
return;
}
s->eecd_state.val_in <<= 1;
if (val & E1000_EECD_DI)
s->eecd_state.val_in |= 1;
if (++s->eecd_state.bitnum_in == 9 && !s->eecd_state.reading) {
s->eecd_state.bitnum_out = ((s->eecd_state.val_in & 0x3f)<<4)-1;
s->eecd_state.reading = (((s->eecd_state.val_in >> 6) & 7) ==
EEPROM_READ_OPCODE_MICROWIRE);
}
DBGOUT(EEPROM, "eeprom bitnum in %d out %d, reading %d\n",
s->eecd_state.bitnum_in, s->eecd_state.bitnum_out,
s->eecd_state.reading);
}
|
DoS Exec Code Overflow
| 0
|
set_eecd(E1000State *s, int index, uint32_t val)
{
uint32_t oldval = s->eecd_state.old_eecd;
s->eecd_state.old_eecd = val & (E1000_EECD_SK | E1000_EECD_CS |
E1000_EECD_DI|E1000_EECD_FWE_MASK|E1000_EECD_REQ);
if (!(E1000_EECD_CS & val)) // CS inactive; nothing to do
return;
if (E1000_EECD_CS & (val ^ oldval)) { // CS rise edge; reset state
s->eecd_state.val_in = 0;
s->eecd_state.bitnum_in = 0;
s->eecd_state.bitnum_out = 0;
s->eecd_state.reading = 0;
}
if (!(E1000_EECD_SK & (val ^ oldval))) // no clock edge
return;
if (!(E1000_EECD_SK & val)) { // falling edge
s->eecd_state.bitnum_out++;
return;
}
s->eecd_state.val_in <<= 1;
if (val & E1000_EECD_DI)
s->eecd_state.val_in |= 1;
if (++s->eecd_state.bitnum_in == 9 && !s->eecd_state.reading) {
s->eecd_state.bitnum_out = ((s->eecd_state.val_in & 0x3f)<<4)-1;
s->eecd_state.reading = (((s->eecd_state.val_in >> 6) & 7) ==
EEPROM_READ_OPCODE_MICROWIRE);
}
DBGOUT(EEPROM, "eeprom bitnum in %d out %d, reading %d\n",
s->eecd_state.bitnum_in, s->eecd_state.bitnum_out,
s->eecd_state.reading);
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,057
|
set_ics(E1000State *s, int index, uint32_t val)
{
DBGOUT(INTERRUPT, "set_ics %x, ICR %x, IMR %x\n", val, s->mac_reg[ICR],
s->mac_reg[IMS]);
set_interrupt_cause(s, 0, val | s->mac_reg[ICR]);
}
|
DoS Exec Code Overflow
| 0
|
set_ics(E1000State *s, int index, uint32_t val)
{
DBGOUT(INTERRUPT, "set_ics %x, ICR %x, IMR %x\n", val, s->mac_reg[ICR],
s->mac_reg[IMS]);
set_interrupt_cause(s, 0, val | s->mac_reg[ICR]);
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,058
|
set_interrupt_cause(E1000State *s, int index, uint32_t val)
{
if (val && (E1000_DEVID >= E1000_DEV_ID_82547EI_MOBILE)) {
/* Only for 8257x */
val |= E1000_ICR_INT_ASSERTED;
}
s->mac_reg[ICR] = val;
s->mac_reg[ICS] = val;
qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);
}
|
DoS Exec Code Overflow
| 0
|
set_interrupt_cause(E1000State *s, int index, uint32_t val)
{
if (val && (E1000_DEVID >= E1000_DEV_ID_82547EI_MOBILE)) {
/* Only for 8257x */
val |= E1000_ICR_INT_ASSERTED;
}
s->mac_reg[ICR] = val;
s->mac_reg[ICS] = val;
qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,059
|
set_mdic(E1000State *s, int index, uint32_t val)
{
uint32_t data = val & E1000_MDIC_DATA_MASK;
uint32_t addr = ((val & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT);
if ((val & E1000_MDIC_PHY_MASK) >> E1000_MDIC_PHY_SHIFT != 1) // phy #
val = s->mac_reg[MDIC] | E1000_MDIC_ERROR;
else if (val & E1000_MDIC_OP_READ) {
DBGOUT(MDIC, "MDIC read reg 0x%x\n", addr);
if (!(phy_regcap[addr] & PHY_R)) {
DBGOUT(MDIC, "MDIC read reg %x unhandled\n", addr);
val |= E1000_MDIC_ERROR;
} else
val = (val ^ data) | s->phy_reg[addr];
} else if (val & E1000_MDIC_OP_WRITE) {
DBGOUT(MDIC, "MDIC write reg 0x%x, value 0x%x\n", addr, data);
if (!(phy_regcap[addr] & PHY_W)) {
DBGOUT(MDIC, "MDIC write reg %x unhandled\n", addr);
val |= E1000_MDIC_ERROR;
} else {
if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) {
phyreg_writeops[addr](s, index, data);
}
s->phy_reg[addr] = data;
}
}
s->mac_reg[MDIC] = val | E1000_MDIC_READY;
if (val & E1000_MDIC_INT_EN) {
set_ics(s, 0, E1000_ICR_MDAC);
}
}
|
DoS Exec Code Overflow
| 0
|
set_mdic(E1000State *s, int index, uint32_t val)
{
uint32_t data = val & E1000_MDIC_DATA_MASK;
uint32_t addr = ((val & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT);
if ((val & E1000_MDIC_PHY_MASK) >> E1000_MDIC_PHY_SHIFT != 1) // phy #
val = s->mac_reg[MDIC] | E1000_MDIC_ERROR;
else if (val & E1000_MDIC_OP_READ) {
DBGOUT(MDIC, "MDIC read reg 0x%x\n", addr);
if (!(phy_regcap[addr] & PHY_R)) {
DBGOUT(MDIC, "MDIC read reg %x unhandled\n", addr);
val |= E1000_MDIC_ERROR;
} else
val = (val ^ data) | s->phy_reg[addr];
} else if (val & E1000_MDIC_OP_WRITE) {
DBGOUT(MDIC, "MDIC write reg 0x%x, value 0x%x\n", addr, data);
if (!(phy_regcap[addr] & PHY_W)) {
DBGOUT(MDIC, "MDIC write reg %x unhandled\n", addr);
val |= E1000_MDIC_ERROR;
} else {
if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) {
phyreg_writeops[addr](s, index, data);
}
s->phy_reg[addr] = data;
}
}
s->mac_reg[MDIC] = val | E1000_MDIC_READY;
if (val & E1000_MDIC_INT_EN) {
set_ics(s, 0, E1000_ICR_MDAC);
}
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,060
|
set_phy_ctrl(E1000State *s, int index, uint16_t val)
{
if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
s->nic->nc.link_down = true;
e1000_link_down(s);
s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;
DBGOUT(PHY, "Start link auto negotiation\n");
qemu_mod_timer(s->autoneg_timer, qemu_get_clock_ms(vm_clock) + 500);
}
}
|
DoS Exec Code Overflow
| 0
|
set_phy_ctrl(E1000State *s, int index, uint16_t val)
{
if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
s->nic->nc.link_down = true;
e1000_link_down(s);
s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;
DBGOUT(PHY, "Start link auto negotiation\n");
qemu_mod_timer(s->autoneg_timer, qemu_get_clock_ms(vm_clock) + 500);
}
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,061
|
static uint64_t tx_desc_base(E1000State *s)
{
uint64_t bah = s->mac_reg[TDBAH];
uint64_t bal = s->mac_reg[TDBAL] & ~0xf;
return (bah << 32) + bal;
}
|
DoS Exec Code Overflow
| 0
|
static uint64_t tx_desc_base(E1000State *s)
{
uint64_t bah = s->mac_reg[TDBAH];
uint64_t bal = s->mac_reg[TDBAL] & ~0xf;
return (bah << 32) + bal;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,062
|
txdesc_writeback(E1000State *s, dma_addr_t base, struct e1000_tx_desc *dp)
{
uint32_t txd_upper, txd_lower = le32_to_cpu(dp->lower.data);
if (!(txd_lower & (E1000_TXD_CMD_RS|E1000_TXD_CMD_RPS)))
return 0;
txd_upper = (le32_to_cpu(dp->upper.data) | E1000_TXD_STAT_DD) &
~(E1000_TXD_STAT_EC | E1000_TXD_STAT_LC | E1000_TXD_STAT_TU);
dp->upper.data = cpu_to_le32(txd_upper);
pci_dma_write(&s->dev, base + ((char *)&dp->upper - (char *)dp),
&dp->upper, sizeof(dp->upper));
return E1000_ICR_TXDW;
}
|
DoS Exec Code Overflow
| 0
|
txdesc_writeback(E1000State *s, dma_addr_t base, struct e1000_tx_desc *dp)
{
uint32_t txd_upper, txd_lower = le32_to_cpu(dp->lower.data);
if (!(txd_lower & (E1000_TXD_CMD_RS|E1000_TXD_CMD_RPS)))
return 0;
txd_upper = (le32_to_cpu(dp->upper.data) | E1000_TXD_STAT_DD) &
~(E1000_TXD_STAT_EC | E1000_TXD_STAT_LC | E1000_TXD_STAT_TU);
dp->upper.data = cpu_to_le32(txd_upper);
pci_dma_write(&s->dev, base + ((char *)&dp->upper - (char *)dp),
&dp->upper, sizeof(dp->upper));
return E1000_ICR_TXDW;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,063
|
vlan_enabled(E1000State *s)
{
return ((s->mac_reg[CTRL] & E1000_CTRL_VME) != 0);
}
|
DoS Exec Code Overflow
| 0
|
vlan_enabled(E1000State *s)
{
return ((s->mac_reg[CTRL] & E1000_CTRL_VME) != 0);
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,064
|
vlan_rx_filter_enabled(E1000State *s)
{
return ((s->mac_reg[RCTL] & E1000_RCTL_VFE) != 0);
}
|
DoS Exec Code Overflow
| 0
|
vlan_rx_filter_enabled(E1000State *s)
{
return ((s->mac_reg[RCTL] & E1000_RCTL_VFE) != 0);
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,065
|
xmit_seg(E1000State *s)
{
uint16_t len, *sp;
unsigned int frames = s->tx.tso_frames, css, sofar, n;
struct e1000_tx *tp = &s->tx;
if (tp->tse && tp->cptse) {
css = tp->ipcss;
DBGOUT(TXSUM, "frames %d size %d ipcss %d\n",
frames, tp->size, css);
if (tp->ip) { // IPv4
cpu_to_be16wu((uint16_t *)(tp->data+css+2),
tp->size - css);
cpu_to_be16wu((uint16_t *)(tp->data+css+4),
be16_to_cpup((uint16_t *)(tp->data+css+4))+frames);
} else // IPv6
cpu_to_be16wu((uint16_t *)(tp->data+css+4),
tp->size - css);
css = tp->tucss;
len = tp->size - css;
DBGOUT(TXSUM, "tcp %d tucss %d len %d\n", tp->tcp, css, len);
if (tp->tcp) {
sofar = frames * tp->mss;
cpu_to_be32wu((uint32_t *)(tp->data+css+4), // seq
be32_to_cpupu((uint32_t *)(tp->data+css+4))+sofar);
if (tp->paylen - sofar > tp->mss)
tp->data[css + 13] &= ~9; // PSH, FIN
} else // UDP
cpu_to_be16wu((uint16_t *)(tp->data+css+4), len);
if (tp->sum_needed & E1000_TXD_POPTS_TXSM) {
unsigned int phsum;
sp = (uint16_t *)(tp->data + tp->tucso);
phsum = be16_to_cpup(sp) + len;
phsum = (phsum >> 16) + (phsum & 0xffff);
cpu_to_be16wu(sp, phsum);
}
tp->tso_frames++;
}
if (tp->sum_needed & E1000_TXD_POPTS_TXSM)
putsum(tp->data, tp->size, tp->tucso, tp->tucss, tp->tucse);
if (tp->sum_needed & E1000_TXD_POPTS_IXSM)
putsum(tp->data, tp->size, tp->ipcso, tp->ipcss, tp->ipcse);
if (tp->vlan_needed) {
memmove(tp->vlan, tp->data, 4);
memmove(tp->data, tp->data + 4, 8);
memcpy(tp->data + 8, tp->vlan_header, 4);
e1000_send_packet(s, tp->vlan, tp->size + 4);
} else
e1000_send_packet(s, tp->data, tp->size);
s->mac_reg[TPT]++;
s->mac_reg[GPTC]++;
n = s->mac_reg[TOTL];
if ((s->mac_reg[TOTL] += s->tx.size) < n)
s->mac_reg[TOTH]++;
}
|
DoS Exec Code Overflow
| 0
|
xmit_seg(E1000State *s)
{
uint16_t len, *sp;
unsigned int frames = s->tx.tso_frames, css, sofar, n;
struct e1000_tx *tp = &s->tx;
if (tp->tse && tp->cptse) {
css = tp->ipcss;
DBGOUT(TXSUM, "frames %d size %d ipcss %d\n",
frames, tp->size, css);
if (tp->ip) { // IPv4
cpu_to_be16wu((uint16_t *)(tp->data+css+2),
tp->size - css);
cpu_to_be16wu((uint16_t *)(tp->data+css+4),
be16_to_cpup((uint16_t *)(tp->data+css+4))+frames);
} else // IPv6
cpu_to_be16wu((uint16_t *)(tp->data+css+4),
tp->size - css);
css = tp->tucss;
len = tp->size - css;
DBGOUT(TXSUM, "tcp %d tucss %d len %d\n", tp->tcp, css, len);
if (tp->tcp) {
sofar = frames * tp->mss;
cpu_to_be32wu((uint32_t *)(tp->data+css+4), // seq
be32_to_cpupu((uint32_t *)(tp->data+css+4))+sofar);
if (tp->paylen - sofar > tp->mss)
tp->data[css + 13] &= ~9; // PSH, FIN
} else // UDP
cpu_to_be16wu((uint16_t *)(tp->data+css+4), len);
if (tp->sum_needed & E1000_TXD_POPTS_TXSM) {
unsigned int phsum;
sp = (uint16_t *)(tp->data + tp->tucso);
phsum = be16_to_cpup(sp) + len;
phsum = (phsum >> 16) + (phsum & 0xffff);
cpu_to_be16wu(sp, phsum);
}
tp->tso_frames++;
}
if (tp->sum_needed & E1000_TXD_POPTS_TXSM)
putsum(tp->data, tp->size, tp->tucso, tp->tucss, tp->tucse);
if (tp->sum_needed & E1000_TXD_POPTS_IXSM)
putsum(tp->data, tp->size, tp->ipcso, tp->ipcss, tp->ipcse);
if (tp->vlan_needed) {
memmove(tp->vlan, tp->data, 4);
memmove(tp->data, tp->data + 4, 8);
memcpy(tp->data + 8, tp->vlan_header, 4);
e1000_send_packet(s, tp->vlan, tp->size + 4);
} else
e1000_send_packet(s, tp->data, tp->size);
s->mac_reg[TPT]++;
s->mac_reg[GPTC]++;
n = s->mac_reg[TOTL];
if ((s->mac_reg[TOTL] += s->tx.size) < n)
s->mac_reg[TOTH]++;
}
|
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
#define PNPMMIO_SIZE 0x20000
#define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
/*
* HW models:
* E1000_DEV_ID_82540EM works with Windows and Linux
@@ -805,6 +808,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)
size = sizeof(min_buf);
}
+ /* Discard oversized packets if !LPE and !SBP. */
+ if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+ && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+ && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+ return size;
+ }
+
if (!receive_filter(s, buf, size))
return size;
|
CWE-119
| null | null |
5,066
|
PHP_FUNCTION(exif_tagname)
{
long tag;
char *szTemp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &tag) == FAILURE) {
return;
}
szTemp = exif_get_tagname(tag, NULL, 0, tag_table_IFD TSRMLS_CC);
if (tag < 0 || !szTemp || !szTemp[0]) {
RETURN_FALSE;
}
RETURN_STRING(szTemp, 1)
}
|
DoS Exec Code
| 0
|
PHP_FUNCTION(exif_tagname)
{
long tag;
char *szTemp;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &tag) == FAILURE) {
return;
}
szTemp = exif_get_tagname(tag, NULL, 0, tag_table_IFD TSRMLS_CC);
if (tag < 0 || !szTemp || !szTemp[0]) {
RETURN_FALSE;
}
RETURN_STRING(szTemp, 1)
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,067
|
PHP_FUNCTION(exif_read_data)
{
char *p_name, *p_sections_needed = NULL;
int p_name_len, p_sections_needed_len = 0;
zend_bool sub_arrays=0, read_thumbnail=0, read_all=0;
int i, ret, sections_needed=0;
image_info_type ImageInfo;
char tmp[64], *sections_str, *s;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbb", &p_name, &p_name_len, &p_sections_needed, &p_sections_needed_len, &sub_arrays, &read_thumbnail) == FAILURE) {
return;
}
memset(&ImageInfo, 0, sizeof(ImageInfo));
if (p_sections_needed) {
spprintf(§ions_str, 0, ",%s,", p_sections_needed);
/* sections_str DOES start with , and SPACES are NOT allowed in names */
s = sections_str;
while (*++s) {
if (*s == ' ') {
*s = ',';
}
}
for (i = 0; i < SECTION_COUNT; i++) {
snprintf(tmp, sizeof(tmp), ",%s,", exif_get_sectionname(i));
if (strstr(sections_str, tmp)) {
sections_needed |= 1<<i;
}
}
EFREE_IF(sections_str);
/* now see what we need */
#ifdef EXIF_DEBUG
sections_str = exif_get_sectionlist(sections_needed TSRMLS_CC);
if (!sections_str) {
RETURN_FALSE;
}
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? sections_str : "None");
EFREE_IF(sections_str);
#endif
}
ret = exif_read_file(&ImageInfo, p_name, read_thumbnail, read_all TSRMLS_CC);
sections_str = exif_get_sectionlist(ImageInfo.sections_found TSRMLS_CC);
#ifdef EXIF_DEBUG
if (sections_str)
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? sections_str : "None");
#endif
ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/
if (ret == FALSE || (sections_needed && !(sections_needed&ImageInfo.sections_found))) {
/* array_init must be checked at last! otherwise the array must be freed if a later test fails. */
exif_discard_imageinfo(&ImageInfo);
EFREE_IF(sections_str);
RETURN_FALSE;
}
array_init(return_value);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section FILE");
#endif
/* now we can add our information */
exif_iif_add_str(&ImageInfo, SECTION_FILE, "FileName", ImageInfo.FileName TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileDateTime", ImageInfo.FileDateTime TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileSize", ImageInfo.FileSize TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileType", ImageInfo.FileType TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_FILE, "MimeType", (char*)php_image_type_to_mime_type(ImageInfo.FileType) TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_FILE, "SectionsFound", sections_str ? sections_str : "NONE" TSRMLS_CC);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section COMPUTED");
#endif
if (ImageInfo.Width>0 && ImageInfo.Height>0) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "html" TSRMLS_CC, "width=\"%d\" height=\"%d\"", ImageInfo.Width, ImageInfo.Height);
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Height", ImageInfo.Height TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Width", ImageInfo.Width TSRMLS_CC);
}
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "IsColor", ImageInfo.IsColor TSRMLS_CC);
if (ImageInfo.motorola_intel != -1) {
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "ByteOrderMotorola", ImageInfo.motorola_intel TSRMLS_CC);
}
if (ImageInfo.FocalLength) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocalLength" TSRMLS_CC, "%4.1Fmm", ImageInfo.FocalLength);
if(ImageInfo.CCDWidth) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "35mmFocalLength" TSRMLS_CC, "%dmm", (int)(ImageInfo.FocalLength/ImageInfo.CCDWidth*35+0.5));
}
}
if(ImageInfo.CCDWidth) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "CCDWidth" TSRMLS_CC, "%dmm", (int)ImageInfo.CCDWidth);
}
if(ImageInfo.ExposureTime>0) {
if(ImageInfo.ExposureTime <= 0.5) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime" TSRMLS_CC, "%0.3F s (1/%d)", ImageInfo.ExposureTime, (int)(0.5 + 1/ImageInfo.ExposureTime));
} else {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime" TSRMLS_CC, "%0.3F s", ImageInfo.ExposureTime);
}
}
if(ImageInfo.ApertureFNumber) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ApertureFNumber" TSRMLS_CC, "f/%.1F", ImageInfo.ApertureFNumber);
}
if(ImageInfo.Distance) {
if(ImageInfo.Distance<0) {
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "Infinite" TSRMLS_CC);
} else {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocusDistance" TSRMLS_CC, "%0.2Fm", ImageInfo.Distance);
}
}
if (ImageInfo.UserComment) {
exif_iif_add_buffer(&ImageInfo, SECTION_COMPUTED, "UserComment", ImageInfo.UserCommentLength, ImageInfo.UserComment TSRMLS_CC);
if (ImageInfo.UserCommentEncoding && strlen(ImageInfo.UserCommentEncoding)) {
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", ImageInfo.UserCommentEncoding TSRMLS_CC);
}
}
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright", ImageInfo.Copyright TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", ImageInfo.CopyrightPhotographer TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Editor", ImageInfo.CopyrightEditor TSRMLS_CC);
for (i=0; i<ImageInfo.xp_fields.count; i++) {
exif_iif_add_str(&ImageInfo, SECTION_WINXP, exif_get_tagname(ImageInfo.xp_fields.list[i].tag, NULL, 0, exif_get_tag_table(SECTION_WINXP) TSRMLS_CC), ImageInfo.xp_fields.list[i].value TSRMLS_CC);
}
if (ImageInfo.Thumbnail.size) {
if (read_thumbnail) {
/* not exif_iif_add_str : this is a buffer */
exif_iif_add_tag(&ImageInfo, SECTION_THUMBNAIL, "THUMBNAIL", TAG_NONE, TAG_FMT_UNDEFINED, ImageInfo.Thumbnail.size, ImageInfo.Thumbnail.data TSRMLS_CC);
}
if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {
/* try to evaluate if thumbnail data is present */
exif_scan_thumbnail(&ImageInfo TSRMLS_CC);
}
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.FileType", ImageInfo.Thumbnail.filetype TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Thumbnail.MimeType", (char*)php_image_type_to_mime_type(ImageInfo.Thumbnail.filetype) TSRMLS_CC);
}
if (ImageInfo.Thumbnail.width && ImageInfo.Thumbnail.height) {
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Height", ImageInfo.Thumbnail.height TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Width", ImageInfo.Thumbnail.width TSRMLS_CC);
}
EFREE_IF(sections_str);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Adding image infos");
#endif
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FILE TSRMLS_CC);
add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMPUTED TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_ANY_TAG TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_IFD0 TSRMLS_CC);
add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_THUMBNAIL TSRMLS_CC);
add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMMENT TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_EXIF TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_GPS TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_INTEROP TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FPIX TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_APP12 TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_WINXP TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_MAKERNOTE TSRMLS_CC);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info");
#endif
exif_discard_imageinfo(&ImageInfo);
#ifdef EXIF_DEBUG
php_error_docref1(NULL TSRMLS_CC, Z_STRVAL_PP(p_name), E_NOTICE, "done");
#endif
}
|
DoS Exec Code
| 0
|
PHP_FUNCTION(exif_read_data)
{
char *p_name, *p_sections_needed = NULL;
int p_name_len, p_sections_needed_len = 0;
zend_bool sub_arrays=0, read_thumbnail=0, read_all=0;
int i, ret, sections_needed=0;
image_info_type ImageInfo;
char tmp[64], *sections_str, *s;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbb", &p_name, &p_name_len, &p_sections_needed, &p_sections_needed_len, &sub_arrays, &read_thumbnail) == FAILURE) {
return;
}
memset(&ImageInfo, 0, sizeof(ImageInfo));
if (p_sections_needed) {
spprintf(§ions_str, 0, ",%s,", p_sections_needed);
/* sections_str DOES start with , and SPACES are NOT allowed in names */
s = sections_str;
while (*++s) {
if (*s == ' ') {
*s = ',';
}
}
for (i = 0; i < SECTION_COUNT; i++) {
snprintf(tmp, sizeof(tmp), ",%s,", exif_get_sectionname(i));
if (strstr(sections_str, tmp)) {
sections_needed |= 1<<i;
}
}
EFREE_IF(sections_str);
/* now see what we need */
#ifdef EXIF_DEBUG
sections_str = exif_get_sectionlist(sections_needed TSRMLS_CC);
if (!sections_str) {
RETURN_FALSE;
}
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections needed: %s", sections_str[0] ? sections_str : "None");
EFREE_IF(sections_str);
#endif
}
ret = exif_read_file(&ImageInfo, p_name, read_thumbnail, read_all TSRMLS_CC);
sections_str = exif_get_sectionlist(ImageInfo.sections_found TSRMLS_CC);
#ifdef EXIF_DEBUG
if (sections_str)
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Sections found: %s", sections_str[0] ? sections_str : "None");
#endif
ImageInfo.sections_found |= FOUND_COMPUTED|FOUND_FILE;/* do not inform about in debug*/
if (ret == FALSE || (sections_needed && !(sections_needed&ImageInfo.sections_found))) {
/* array_init must be checked at last! otherwise the array must be freed if a later test fails. */
exif_discard_imageinfo(&ImageInfo);
EFREE_IF(sections_str);
RETURN_FALSE;
}
array_init(return_value);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section FILE");
#endif
/* now we can add our information */
exif_iif_add_str(&ImageInfo, SECTION_FILE, "FileName", ImageInfo.FileName TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileDateTime", ImageInfo.FileDateTime TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileSize", ImageInfo.FileSize TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_FILE, "FileType", ImageInfo.FileType TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_FILE, "MimeType", (char*)php_image_type_to_mime_type(ImageInfo.FileType) TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_FILE, "SectionsFound", sections_str ? sections_str : "NONE" TSRMLS_CC);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Generate section COMPUTED");
#endif
if (ImageInfo.Width>0 && ImageInfo.Height>0) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "html" TSRMLS_CC, "width=\"%d\" height=\"%d\"", ImageInfo.Width, ImageInfo.Height);
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Height", ImageInfo.Height TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Width", ImageInfo.Width TSRMLS_CC);
}
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "IsColor", ImageInfo.IsColor TSRMLS_CC);
if (ImageInfo.motorola_intel != -1) {
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "ByteOrderMotorola", ImageInfo.motorola_intel TSRMLS_CC);
}
if (ImageInfo.FocalLength) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocalLength" TSRMLS_CC, "%4.1Fmm", ImageInfo.FocalLength);
if(ImageInfo.CCDWidth) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "35mmFocalLength" TSRMLS_CC, "%dmm", (int)(ImageInfo.FocalLength/ImageInfo.CCDWidth*35+0.5));
}
}
if(ImageInfo.CCDWidth) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "CCDWidth" TSRMLS_CC, "%dmm", (int)ImageInfo.CCDWidth);
}
if(ImageInfo.ExposureTime>0) {
if(ImageInfo.ExposureTime <= 0.5) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime" TSRMLS_CC, "%0.3F s (1/%d)", ImageInfo.ExposureTime, (int)(0.5 + 1/ImageInfo.ExposureTime));
} else {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ExposureTime" TSRMLS_CC, "%0.3F s", ImageInfo.ExposureTime);
}
}
if(ImageInfo.ApertureFNumber) {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "ApertureFNumber" TSRMLS_CC, "f/%.1F", ImageInfo.ApertureFNumber);
}
if(ImageInfo.Distance) {
if(ImageInfo.Distance<0) {
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "FocusDistance", "Infinite" TSRMLS_CC);
} else {
exif_iif_add_fmt(&ImageInfo, SECTION_COMPUTED, "FocusDistance" TSRMLS_CC, "%0.2Fm", ImageInfo.Distance);
}
}
if (ImageInfo.UserComment) {
exif_iif_add_buffer(&ImageInfo, SECTION_COMPUTED, "UserComment", ImageInfo.UserCommentLength, ImageInfo.UserComment TSRMLS_CC);
if (ImageInfo.UserCommentEncoding && strlen(ImageInfo.UserCommentEncoding)) {
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", ImageInfo.UserCommentEncoding TSRMLS_CC);
}
}
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright", ImageInfo.Copyright TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", ImageInfo.CopyrightPhotographer TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Copyright.Editor", ImageInfo.CopyrightEditor TSRMLS_CC);
for (i=0; i<ImageInfo.xp_fields.count; i++) {
exif_iif_add_str(&ImageInfo, SECTION_WINXP, exif_get_tagname(ImageInfo.xp_fields.list[i].tag, NULL, 0, exif_get_tag_table(SECTION_WINXP) TSRMLS_CC), ImageInfo.xp_fields.list[i].value TSRMLS_CC);
}
if (ImageInfo.Thumbnail.size) {
if (read_thumbnail) {
/* not exif_iif_add_str : this is a buffer */
exif_iif_add_tag(&ImageInfo, SECTION_THUMBNAIL, "THUMBNAIL", TAG_NONE, TAG_FMT_UNDEFINED, ImageInfo.Thumbnail.size, ImageInfo.Thumbnail.data TSRMLS_CC);
}
if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {
/* try to evaluate if thumbnail data is present */
exif_scan_thumbnail(&ImageInfo TSRMLS_CC);
}
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.FileType", ImageInfo.Thumbnail.filetype TSRMLS_CC);
exif_iif_add_str(&ImageInfo, SECTION_COMPUTED, "Thumbnail.MimeType", (char*)php_image_type_to_mime_type(ImageInfo.Thumbnail.filetype) TSRMLS_CC);
}
if (ImageInfo.Thumbnail.width && ImageInfo.Thumbnail.height) {
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Height", ImageInfo.Thumbnail.height TSRMLS_CC);
exif_iif_add_int(&ImageInfo, SECTION_COMPUTED, "Thumbnail.Width", ImageInfo.Thumbnail.width TSRMLS_CC);
}
EFREE_IF(sections_str);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Adding image infos");
#endif
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FILE TSRMLS_CC);
add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMPUTED TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_ANY_TAG TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_IFD0 TSRMLS_CC);
add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_THUMBNAIL TSRMLS_CC);
add_assoc_image_info(return_value, 1, &ImageInfo, SECTION_COMMENT TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_EXIF TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_GPS TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_INTEROP TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_FPIX TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_APP12 TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_WINXP TSRMLS_CC);
add_assoc_image_info(return_value, sub_arrays, &ImageInfo, SECTION_MAKERNOTE TSRMLS_CC);
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Discarding info");
#endif
exif_discard_imageinfo(&ImageInfo);
#ifdef EXIF_DEBUG
php_error_docref1(NULL TSRMLS_CC, Z_STRVAL_PP(p_name), E_NOTICE, "done");
#endif
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,068
|
PHP_FUNCTION(exif_imagetype)
{
char *imagefile;
int imagefile_len;
php_stream * stream;
int itype = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &imagefile, &imagefile_len) == FAILURE) {
return;
}
stream = php_stream_open_wrapper(imagefile, "rb", IGNORE_PATH|REPORT_ERRORS, NULL);
if (stream == NULL) {
RETURN_FALSE;
}
itype = php_getimagetype(stream, NULL TSRMLS_CC);
php_stream_close(stream);
if (itype == IMAGE_FILETYPE_UNKNOWN) {
RETURN_FALSE;
} else {
ZVAL_LONG(return_value, itype);
}
}
|
DoS Exec Code
| 0
|
PHP_FUNCTION(exif_imagetype)
{
char *imagefile;
int imagefile_len;
php_stream * stream;
int itype = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &imagefile, &imagefile_len) == FAILURE) {
return;
}
stream = php_stream_open_wrapper(imagefile, "rb", IGNORE_PATH|REPORT_ERRORS, NULL);
if (stream == NULL) {
RETURN_FALSE;
}
itype = php_getimagetype(stream, NULL TSRMLS_CC);
php_stream_close(stream);
if (itype == IMAGE_FILETYPE_UNKNOWN) {
RETURN_FALSE;
} else {
ZVAL_LONG(return_value, itype);
}
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,069
|
static PHP_GINIT_FUNCTION(exif)
{
exif_globals->encode_unicode = NULL;
exif_globals->decode_unicode_be = NULL;
exif_globals->decode_unicode_le = NULL;
exif_globals->encode_jis = NULL;
exif_globals->decode_jis_be = NULL;
exif_globals->decode_jis_le = NULL;
}
|
DoS Exec Code
| 0
|
static PHP_GINIT_FUNCTION(exif)
{
exif_globals->encode_unicode = NULL;
exif_globals->decode_unicode_be = NULL;
exif_globals->decode_unicode_le = NULL;
exif_globals->encode_jis = NULL;
exif_globals->decode_jis_be = NULL;
exif_globals->decode_jis_le = NULL;
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,070
|
PHP_MINFO_FUNCTION(exif)
{
php_info_print_table_start();
php_info_print_table_row(2, "EXIF Support", "enabled");
php_info_print_table_row(2, "EXIF Version", EXIF_VERSION);
php_info_print_table_row(2, "Supported EXIF Version", "0220");
php_info_print_table_row(2, "Supported filetypes", "JPEG,TIFF");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
|
DoS Exec Code
| 0
|
PHP_MINFO_FUNCTION(exif)
{
php_info_print_table_start();
php_info_print_table_row(2, "EXIF Support", "enabled");
php_info_print_table_row(2, "EXIF Version", EXIF_VERSION);
php_info_print_table_row(2, "Supported EXIF Version", "0220");
php_info_print_table_row(2, "Supported filetypes", "JPEG,TIFF");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,071
|
PHP_MINIT_FUNCTION(exif)
{
REGISTER_INI_ENTRIES();
if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) {
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 1, CONST_CS | CONST_PERSISTENT);
} else {
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 0, CONST_CS | CONST_PERSISTENT);
}
return SUCCESS;
}
|
DoS Exec Code
| 0
|
PHP_MINIT_FUNCTION(exif)
{
REGISTER_INI_ENTRIES();
if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) {
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 1, CONST_CS | CONST_PERSISTENT);
} else {
REGISTER_LONG_CONSTANT("EXIF_USE_MBSTRING", 0, CONST_CS | CONST_PERSISTENT);
}
return SUCCESS;
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,072
|
PHP_MSHUTDOWN_FUNCTION(exif)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
|
DoS Exec Code
| 0
|
PHP_MSHUTDOWN_FUNCTION(exif)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,073
|
ZEND_INI_MH(OnUpdateEncode)
{
if (new_value && new_value_length) {
const zend_encoding **return_list;
size_t return_size;
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length,
&return_list, &return_size, 0 TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal encoding ignored: '%s'", new_value);
return FAILURE;
}
efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
|
DoS Exec Code
| 0
|
ZEND_INI_MH(OnUpdateEncode)
{
if (new_value && new_value_length) {
const zend_encoding **return_list;
size_t return_size;
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length,
&return_list, &return_size, 0 TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal encoding ignored: '%s'", new_value);
return FAILURE;
}
efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,074
|
ZEND_INI_MH(OnUpdateDecode)
{
if (new_value) {
const zend_encoding **return_list;
size_t return_size;
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length,
&return_list, &return_size, 0 TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal encoding ignored: '%s'", new_value);
return FAILURE;
}
efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
|
DoS Exec Code
| 0
|
ZEND_INI_MH(OnUpdateDecode)
{
if (new_value) {
const zend_encoding **return_list;
size_t return_size;
if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length,
&return_list, &return_size, 0 TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Illegal encoding ignored: '%s'", new_value);
return FAILURE;
}
efree(return_list);
}
return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,075
|
static double exif_convert_any_format(void *value, int format, int motorola_intel TSRMLS_DC)
{
int s_den;
unsigned u_den;
switch(format) {
case TAG_FMT_SBYTE: return *(signed char *)value;
case TAG_FMT_BYTE: return *(uchar *)value;
case TAG_FMT_USHORT: return php_ifd_get16u(value, motorola_intel);
case TAG_FMT_ULONG: return php_ifd_get32u(value, motorola_intel);
case TAG_FMT_URATIONAL:
u_den = php_ifd_get32u(4+(char *)value, motorola_intel);
if (u_den == 0) {
return 0;
} else {
return (double)php_ifd_get32u(value, motorola_intel) / u_den;
}
case TAG_FMT_SRATIONAL:
s_den = php_ifd_get32s(4+(char *)value, motorola_intel);
if (s_den == 0) {
return 0;
} else {
return (double)php_ifd_get32s(value, motorola_intel) / s_den;
}
case TAG_FMT_SSHORT: return (signed short)php_ifd_get16u(value, motorola_intel);
case TAG_FMT_SLONG: return php_ifd_get32s(value, motorola_intel);
/* Not sure if this is correct (never seen float used in Exif format) */
case TAG_FMT_SINGLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type single");
#endif
return (double)*(float *)value;
case TAG_FMT_DOUBLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type double");
#endif
return *(double *)value;
}
return 0;
}
|
DoS Exec Code
| 0
|
static double exif_convert_any_format(void *value, int format, int motorola_intel TSRMLS_DC)
{
int s_den;
unsigned u_den;
switch(format) {
case TAG_FMT_SBYTE: return *(signed char *)value;
case TAG_FMT_BYTE: return *(uchar *)value;
case TAG_FMT_USHORT: return php_ifd_get16u(value, motorola_intel);
case TAG_FMT_ULONG: return php_ifd_get32u(value, motorola_intel);
case TAG_FMT_URATIONAL:
u_den = php_ifd_get32u(4+(char *)value, motorola_intel);
if (u_den == 0) {
return 0;
} else {
return (double)php_ifd_get32u(value, motorola_intel) / u_den;
}
case TAG_FMT_SRATIONAL:
s_den = php_ifd_get32s(4+(char *)value, motorola_intel);
if (s_den == 0) {
return 0;
} else {
return (double)php_ifd_get32s(value, motorola_intel) / s_den;
}
case TAG_FMT_SSHORT: return (signed short)php_ifd_get16u(value, motorola_intel);
case TAG_FMT_SLONG: return php_ifd_get32s(value, motorola_intel);
/* Not sure if this is correct (never seen float used in Exif format) */
case TAG_FMT_SINGLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type single");
#endif
return (double)*(float *)value;
case TAG_FMT_DOUBLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type double");
#endif
return *(double *)value;
}
return 0;
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,076
|
static size_t exif_convert_any_to_int(void *value, int format, int motorola_intel TSRMLS_DC)
{
int s_den;
unsigned u_den;
switch(format) {
case TAG_FMT_SBYTE: return *(signed char *)value;
case TAG_FMT_BYTE: return *(uchar *)value;
case TAG_FMT_USHORT: return php_ifd_get16u(value, motorola_intel);
case TAG_FMT_ULONG: return php_ifd_get32u(value, motorola_intel);
case TAG_FMT_URATIONAL:
u_den = php_ifd_get32u(4+(char *)value, motorola_intel);
if (u_den == 0) {
return 0;
} else {
return php_ifd_get32u(value, motorola_intel) / u_den;
}
case TAG_FMT_SRATIONAL:
s_den = php_ifd_get32s(4+(char *)value, motorola_intel);
if (s_den == 0) {
return 0;
} else {
return php_ifd_get32s(value, motorola_intel) / s_den;
}
case TAG_FMT_SSHORT: return php_ifd_get16u(value, motorola_intel);
case TAG_FMT_SLONG: return php_ifd_get32s(value, motorola_intel);
/* Not sure if this is correct (never seen float used in Exif format) */
case TAG_FMT_SINGLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type single");
#endif
return (size_t)*(float *)value;
case TAG_FMT_DOUBLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type double");
#endif
return (size_t)*(double *)value;
}
return 0;
}
|
DoS Exec Code
| 0
|
static size_t exif_convert_any_to_int(void *value, int format, int motorola_intel TSRMLS_DC)
{
int s_den;
unsigned u_den;
switch(format) {
case TAG_FMT_SBYTE: return *(signed char *)value;
case TAG_FMT_BYTE: return *(uchar *)value;
case TAG_FMT_USHORT: return php_ifd_get16u(value, motorola_intel);
case TAG_FMT_ULONG: return php_ifd_get32u(value, motorola_intel);
case TAG_FMT_URATIONAL:
u_den = php_ifd_get32u(4+(char *)value, motorola_intel);
if (u_den == 0) {
return 0;
} else {
return php_ifd_get32u(value, motorola_intel) / u_den;
}
case TAG_FMT_SRATIONAL:
s_den = php_ifd_get32s(4+(char *)value, motorola_intel);
if (s_den == 0) {
return 0;
} else {
return php_ifd_get32s(value, motorola_intel) / s_den;
}
case TAG_FMT_SSHORT: return php_ifd_get16u(value, motorola_intel);
case TAG_FMT_SLONG: return php_ifd_get32s(value, motorola_intel);
/* Not sure if this is correct (never seen float used in Exif format) */
case TAG_FMT_SINGLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type single");
#endif
return (size_t)*(float *)value;
case TAG_FMT_DOUBLE:
#ifdef EXIF_DEBUG
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found value of type double");
#endif
return (size_t)*(double *)value;
}
return 0;
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,077
|
static int exif_discard_imageinfo(image_info_type *ImageInfo)
{
int i;
EFREE_IF(ImageInfo->FileName);
EFREE_IF(ImageInfo->UserComment);
EFREE_IF(ImageInfo->UserCommentEncoding);
EFREE_IF(ImageInfo->Copyright);
EFREE_IF(ImageInfo->CopyrightPhotographer);
EFREE_IF(ImageInfo->CopyrightEditor);
EFREE_IF(ImageInfo->Thumbnail.data);
EFREE_IF(ImageInfo->encode_unicode);
EFREE_IF(ImageInfo->decode_unicode_be);
EFREE_IF(ImageInfo->decode_unicode_le);
EFREE_IF(ImageInfo->encode_jis);
EFREE_IF(ImageInfo->decode_jis_be);
EFREE_IF(ImageInfo->decode_jis_le);
EFREE_IF(ImageInfo->make);
EFREE_IF(ImageInfo->model);
for (i=0; i<ImageInfo->xp_fields.count; i++) {
EFREE_IF(ImageInfo->xp_fields.list[i].value);
}
EFREE_IF(ImageInfo->xp_fields.list);
for (i=0; i<SECTION_COUNT; i++) {
exif_iif_free(ImageInfo, i);
}
exif_file_sections_free(ImageInfo);
memset(ImageInfo, 0, sizeof(*ImageInfo));
return TRUE;
}
|
DoS Exec Code
| 0
|
static int exif_discard_imageinfo(image_info_type *ImageInfo)
{
int i;
EFREE_IF(ImageInfo->FileName);
EFREE_IF(ImageInfo->UserComment);
EFREE_IF(ImageInfo->UserCommentEncoding);
EFREE_IF(ImageInfo->Copyright);
EFREE_IF(ImageInfo->CopyrightPhotographer);
EFREE_IF(ImageInfo->CopyrightEditor);
EFREE_IF(ImageInfo->Thumbnail.data);
EFREE_IF(ImageInfo->encode_unicode);
EFREE_IF(ImageInfo->decode_unicode_be);
EFREE_IF(ImageInfo->decode_unicode_le);
EFREE_IF(ImageInfo->encode_jis);
EFREE_IF(ImageInfo->decode_jis_be);
EFREE_IF(ImageInfo->decode_jis_le);
EFREE_IF(ImageInfo->make);
EFREE_IF(ImageInfo->model);
for (i=0; i<ImageInfo->xp_fields.count; i++) {
EFREE_IF(ImageInfo->xp_fields.list[i].value);
}
EFREE_IF(ImageInfo->xp_fields.list);
for (i=0; i<SECTION_COUNT; i++) {
exif_iif_free(ImageInfo, i);
}
exif_file_sections_free(ImageInfo);
memset(ImageInfo, 0, sizeof(*ImageInfo));
return TRUE;
}
|
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
| null | null | null |
5,078
|
static gboolean on_client_socket_event(GIOChannel* ioc, GIOCondition cond, gpointer user_data)
{
SingleInstClient* client = (SingleInstClient*)user_data;
if ( cond & (G_IO_IN|G_IO_PRI) )
{
GString *str = g_string_sized_new(1024);
gsize got;
gchar ch;
GIOStatus status;
while((status = g_io_channel_read_chars(ioc, &ch, 1, &got, NULL)) == G_IO_STATUS_NORMAL)
{
if(ch != '\n')
{
if(ch < 0x20) /* zero or control char */
{
g_error("client connection: invalid char %#x", (int)ch);
break;
}
g_string_append_c(str, ch);
continue;
}
if(str->len)
{
char *line = g_strndup(str->str, str->len);
g_string_truncate(str, 0);
g_debug("line = %s", line);
if(!client->cwd)
client->cwd = g_strcompress(line);
else if(client->screen_num == -1)
{
client->screen_num = atoi(line);
if(client->screen_num < 0)
client->screen_num = 0;
}
else
{
char* str = g_strcompress(line);
g_ptr_array_add(client->argv, str);
}
g_free(line);
}
}
g_string_free(str, TRUE);
switch(status)
{
case G_IO_STATUS_ERROR:
cond |= G_IO_ERR;
break;
case G_IO_STATUS_EOF:
cond |= G_IO_HUP;
default:
break;
}
}
if(cond & (G_IO_ERR|G_IO_HUP))
{
if(! (cond & G_IO_ERR) ) /* if there is no error */
{
/* try to parse argv */
parse_args(client);
}
clients = g_list_remove(clients, client);
single_inst_client_free(client);
return FALSE;
}
return TRUE;
}
|
DoS
| 0
|
static gboolean on_client_socket_event(GIOChannel* ioc, GIOCondition cond, gpointer user_data)
{
SingleInstClient* client = (SingleInstClient*)user_data;
if ( cond & (G_IO_IN|G_IO_PRI) )
{
GString *str = g_string_sized_new(1024);
gsize got;
gchar ch;
GIOStatus status;
while((status = g_io_channel_read_chars(ioc, &ch, 1, &got, NULL)) == G_IO_STATUS_NORMAL)
{
if(ch != '\n')
{
if(ch < 0x20) /* zero or control char */
{
g_error("client connection: invalid char %#x", (int)ch);
break;
}
g_string_append_c(str, ch);
continue;
}
if(str->len)
{
char *line = g_strndup(str->str, str->len);
g_string_truncate(str, 0);
g_debug("line = %s", line);
if(!client->cwd)
client->cwd = g_strcompress(line);
else if(client->screen_num == -1)
{
client->screen_num = atoi(line);
if(client->screen_num < 0)
client->screen_num = 0;
}
else
{
char* str = g_strcompress(line);
g_ptr_array_add(client->argv, str);
}
g_free(line);
}
}
g_string_free(str, TRUE);
switch(status)
{
case G_IO_STATUS_ERROR:
cond |= G_IO_ERR;
break;
case G_IO_STATUS_EOF:
cond |= G_IO_HUP;
default:
break;
}
}
if(cond & (G_IO_ERR|G_IO_HUP))
{
if(! (cond & G_IO_ERR) ) /* if there is no error */
{
/* try to parse argv */
parse_args(client);
}
clients = g_list_remove(clients, client);
single_inst_client_free(client);
return FALSE;
}
return TRUE;
}
|
@@ -2,7 +2,7 @@
* single-inst.c: simple IPC mechanism for single instance app
*
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- * Copyright 2012 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -404,11 +404,16 @@ static void get_socket_name(SingleInstData* data, char* buf, int len)
}
else
dpynum = 0;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf(buf, len, "%s/%s-socket-%s-%d", g_get_user_runtime_dir(),
+ data->prog_name, host ? host : "", dpynum);
+#else
g_snprintf(buf, len, "%s/.%s-socket-%s-%d-%s",
g_get_tmp_dir(),
data->prog_name,
host ? host : "",
dpynum,
g_get_user_name());
+#endif
}
|
CWE-20
| null | null |
5,079
|
static gboolean on_server_socket_event(GIOChannel* ioc, GIOCondition cond, gpointer user_data)
{
SingleInstData* data = user_data;
if ( cond & (G_IO_IN|G_IO_PRI) )
{
int client_sock = accept(g_io_channel_unix_get_fd(ioc), NULL, 0);
if(client_sock != -1)
{
SingleInstClient* client = g_slice_new0(SingleInstClient);
client->channel = g_io_channel_unix_new(client_sock);
g_io_channel_set_encoding(client->channel, NULL, NULL);
client->screen_num = -1;
client->argv = g_ptr_array_new();
client->callback = data->cb;
client->opt_entries = data->opt_entries;
g_ptr_array_add(client->argv, g_strdup(g_get_prgname()));
client->watch = g_io_add_watch(client->channel, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP,
on_client_socket_event, client);
clients = g_list_prepend(clients, client);
/* g_debug("accept new client"); */
}
else
g_debug("accept() failed!\n%s", g_strerror(errno));
}
if(cond & (G_IO_ERR|G_IO_HUP))
{
single_inst_finalize(data);
single_inst_init(data);
return FALSE;
}
return TRUE;
}
|
DoS
| 0
|
static gboolean on_server_socket_event(GIOChannel* ioc, GIOCondition cond, gpointer user_data)
{
SingleInstData* data = user_data;
if ( cond & (G_IO_IN|G_IO_PRI) )
{
int client_sock = accept(g_io_channel_unix_get_fd(ioc), NULL, 0);
if(client_sock != -1)
{
SingleInstClient* client = g_slice_new0(SingleInstClient);
client->channel = g_io_channel_unix_new(client_sock);
g_io_channel_set_encoding(client->channel, NULL, NULL);
client->screen_num = -1;
client->argv = g_ptr_array_new();
client->callback = data->cb;
client->opt_entries = data->opt_entries;
g_ptr_array_add(client->argv, g_strdup(g_get_prgname()));
client->watch = g_io_add_watch(client->channel, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP,
on_client_socket_event, client);
clients = g_list_prepend(clients, client);
/* g_debug("accept new client"); */
}
else
g_debug("accept() failed!\n%s", g_strerror(errno));
}
if(cond & (G_IO_ERR|G_IO_HUP))
{
single_inst_finalize(data);
single_inst_init(data);
return FALSE;
}
return TRUE;
}
|
@@ -2,7 +2,7 @@
* single-inst.c: simple IPC mechanism for single instance app
*
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- * Copyright 2012 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -404,11 +404,16 @@ static void get_socket_name(SingleInstData* data, char* buf, int len)
}
else
dpynum = 0;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf(buf, len, "%s/%s-socket-%s-%d", g_get_user_runtime_dir(),
+ data->prog_name, host ? host : "", dpynum);
+#else
g_snprintf(buf, len, "%s/.%s-socket-%s-%d-%s",
g_get_tmp_dir(),
data->prog_name,
host ? host : "",
dpynum,
g_get_user_name());
+#endif
}
|
CWE-20
| null | null |
5,080
|
static void single_inst_client_free(SingleInstClient* client)
{
g_io_channel_shutdown(client->channel, FALSE, NULL);
g_io_channel_unref(client->channel);
g_source_remove(client->watch);
g_free(client->cwd);
g_ptr_array_foreach(client->argv, (GFunc)g_free, NULL);
g_ptr_array_free(client->argv, TRUE);
g_slice_free(SingleInstClient, client);
/* g_debug("free client"); */
}
|
DoS
| 0
|
static void single_inst_client_free(SingleInstClient* client)
{
g_io_channel_shutdown(client->channel, FALSE, NULL);
g_io_channel_unref(client->channel);
g_source_remove(client->watch);
g_free(client->cwd);
g_ptr_array_foreach(client->argv, (GFunc)g_free, NULL);
g_ptr_array_free(client->argv, TRUE);
g_slice_free(SingleInstClient, client);
/* g_debug("free client"); */
}
|
@@ -2,7 +2,7 @@
* single-inst.c: simple IPC mechanism for single instance app
*
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- * Copyright 2012 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -404,11 +404,16 @@ static void get_socket_name(SingleInstData* data, char* buf, int len)
}
else
dpynum = 0;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf(buf, len, "%s/%s-socket-%s-%d", g_get_user_runtime_dir(),
+ data->prog_name, host ? host : "", dpynum);
+#else
g_snprintf(buf, len, "%s/.%s-socket-%s-%d-%s",
g_get_tmp_dir(),
data->prog_name,
host ? host : "",
dpynum,
g_get_user_name());
+#endif
}
|
CWE-20
| null | null |
5,081
|
void single_inst_finalize(SingleInstData* data)
{
if(data->sock >=0)
{
close(data->sock);
data->sock = -1;
if(data->io_channel)
{
char sock_path[256];
/* disconnect all clients */
if(clients)
{
g_list_foreach(clients, (GFunc)single_inst_client_free, NULL);
g_list_free(clients);
clients = NULL;
}
if(data->io_watch)
{
g_source_remove(data->io_watch);
data->io_watch = 0;
}
g_io_channel_unref(data->io_channel);
data->io_channel = NULL;
/* remove the file */
get_socket_name(data, sock_path, 256);
unlink(sock_path);
}
}
}
|
DoS
| 0
|
void single_inst_finalize(SingleInstData* data)
{
if(data->sock >=0)
{
close(data->sock);
data->sock = -1;
if(data->io_channel)
{
char sock_path[256];
/* disconnect all clients */
if(clients)
{
g_list_foreach(clients, (GFunc)single_inst_client_free, NULL);
g_list_free(clients);
clients = NULL;
}
if(data->io_watch)
{
g_source_remove(data->io_watch);
data->io_watch = 0;
}
g_io_channel_unref(data->io_channel);
data->io_channel = NULL;
/* remove the file */
get_socket_name(data, sock_path, 256);
unlink(sock_path);
}
}
}
|
@@ -2,7 +2,7 @@
* single-inst.c: simple IPC mechanism for single instance app
*
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- * Copyright 2012 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -404,11 +404,16 @@ static void get_socket_name(SingleInstData* data, char* buf, int len)
}
else
dpynum = 0;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf(buf, len, "%s/%s-socket-%s-%d", g_get_user_runtime_dir(),
+ data->prog_name, host ? host : "", dpynum);
+#else
g_snprintf(buf, len, "%s/.%s-socket-%s-%d-%s",
g_get_tmp_dir(),
data->prog_name,
host ? host : "",
dpynum,
g_get_user_name());
+#endif
}
|
CWE-20
| null | null |
5,082
|
SingleInstResult single_inst_init(SingleInstData* data)
{
struct sockaddr_un addr;
int addr_len;
int ret;
int reuse;
data->io_channel = NULL;
data->io_watch = 0;
if((data->sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
return SINGLE_INST_ERROR;
/* FIXME: use abstract socket? */
addr.sun_family = AF_UNIX;
get_socket_name(data, addr.sun_path, sizeof(addr.sun_path));
#ifdef SUN_LEN
addr_len = SUN_LEN(&addr);
#else
addr_len = strlen(addr.sun_path) + sizeof(addr.sun_family);
#endif
/* try to connect to existing instance */
if(connect(data->sock, (struct sockaddr*)&addr, addr_len) == 0)
{
/* connected successfully, pass args in opt_entries to server process as argv and exit. */
pass_args_to_existing_instance(data->opt_entries, data->screen_num, data->sock);
return SINGLE_INST_CLIENT;
}
/* There is no existing server, and we are in the first instance. */
unlink(addr.sun_path); /* delete old socket file if it exists. */
reuse = 1;
ret = setsockopt( data->sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse) );
if(ret || bind(data->sock, (struct sockaddr*)&addr, addr_len) == -1)
return SINGLE_INST_ERROR;
data->io_channel = g_io_channel_unix_new(data->sock);
if(data->io_channel == NULL)
return SINGLE_INST_ERROR;
g_io_channel_set_encoding(data->io_channel, NULL, NULL);
g_io_channel_set_buffered(data->io_channel, FALSE);
if(listen(data->sock, 5) == -1)
return SINGLE_INST_ERROR;
data->io_watch = g_io_add_watch(data->io_channel,
G_IO_IN|G_IO_ERR|G_IO_PRI|G_IO_HUP,
(GIOFunc)on_server_socket_event, data);
return SINGLE_INST_SERVER;
}
|
DoS
| 0
|
SingleInstResult single_inst_init(SingleInstData* data)
{
struct sockaddr_un addr;
int addr_len;
int ret;
int reuse;
data->io_channel = NULL;
data->io_watch = 0;
if((data->sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
return SINGLE_INST_ERROR;
/* FIXME: use abstract socket? */
addr.sun_family = AF_UNIX;
get_socket_name(data, addr.sun_path, sizeof(addr.sun_path));
#ifdef SUN_LEN
addr_len = SUN_LEN(&addr);
#else
addr_len = strlen(addr.sun_path) + sizeof(addr.sun_family);
#endif
/* try to connect to existing instance */
if(connect(data->sock, (struct sockaddr*)&addr, addr_len) == 0)
{
/* connected successfully, pass args in opt_entries to server process as argv and exit. */
pass_args_to_existing_instance(data->opt_entries, data->screen_num, data->sock);
return SINGLE_INST_CLIENT;
}
/* There is no existing server, and we are in the first instance. */
unlink(addr.sun_path); /* delete old socket file if it exists. */
reuse = 1;
ret = setsockopt( data->sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse) );
if(ret || bind(data->sock, (struct sockaddr*)&addr, addr_len) == -1)
return SINGLE_INST_ERROR;
data->io_channel = g_io_channel_unix_new(data->sock);
if(data->io_channel == NULL)
return SINGLE_INST_ERROR;
g_io_channel_set_encoding(data->io_channel, NULL, NULL);
g_io_channel_set_buffered(data->io_channel, FALSE);
if(listen(data->sock, 5) == -1)
return SINGLE_INST_ERROR;
data->io_watch = g_io_add_watch(data->io_channel,
G_IO_IN|G_IO_ERR|G_IO_PRI|G_IO_HUP,
(GIOFunc)on_server_socket_event, data);
return SINGLE_INST_SERVER;
}
|
@@ -2,7 +2,7 @@
* single-inst.c: simple IPC mechanism for single instance app
*
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
- * Copyright 2012 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -404,11 +404,16 @@ static void get_socket_name(SingleInstData* data, char* buf, int len)
}
else
dpynum = 0;
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf(buf, len, "%s/%s-socket-%s-%d", g_get_user_runtime_dir(),
+ data->prog_name, host ? host : "", dpynum);
+#else
g_snprintf(buf, len, "%s/.%s-socket-%s-%d-%s",
g_get_tmp_dir(),
data->prog_name,
host ? host : "",
dpynum,
g_get_user_name());
+#endif
}
|
CWE-20
| null | null |
5,083
|
static int _check_var(pam_handle_t *pamh, VAR *var)
{
/*
* Examine the variable and determine what action to take.
* Returns DEFINE_VAR, UNDEFINE_VAR depending on action to take
* or a PAM_* error code if passed back from other routines
*
* if no DEFAULT provided, the empty string is assumed
* if no OVERRIDE provided, the empty string is assumed
* if DEFAULT= and OVERRIDE evaluates to the empty string,
* this variable should be undefined
* if DEFAULT="" and OVERRIDE evaluates to the empty string,
* this variable should be defined with no value
* if OVERRIDE=value and value turns into the empty string, DEFAULT is used
*
* If DEFINE_VAR is to be returned, the correct value to define will
* be pointed to by var->value
*/
int retval;
D(("Called."));
/*
* First thing to do is to expand any arguments, but only
* if they are not the special quote values (cause expand_arg
* changes memory).
*/
if (var->defval && ("e != var->defval) &&
((retval = _expand_arg(pamh, &(var->defval))) != PAM_SUCCESS)) {
return retval;
}
if (var->override && ("e != var->override) &&
((retval = _expand_arg(pamh, &(var->override))) != PAM_SUCCESS)) {
return retval;
}
/* Now its easy */
if (var->override && *(var->override) && "e != var->override) {
/* if there is a non-empty string in var->override, we use it */
D(("OVERRIDE variable <%s> being used: <%s>", var->name, var->override));
var->value = var->override;
retval = DEFINE_VAR;
} else {
var->value = var->defval;
if ("e == var->defval) {
/*
* This means that the empty string was given for defval value
* which indicates that a variable should be defined with no value
*/
*var->defval = '\0';
D(("An empty variable: <%s>", var->name));
retval = DEFINE_VAR;
} else if (var->defval) {
D(("DEFAULT variable <%s> being used: <%s>", var->name, var->defval));
retval = DEFINE_VAR;
} else {
D(("UNDEFINE variable <%s>", var->name));
retval = UNDEFINE_VAR;
}
}
D(("Exit."));
return retval;
}
|
+Info
| 0
|
static int _check_var(pam_handle_t *pamh, VAR *var)
{
/*
* Examine the variable and determine what action to take.
* Returns DEFINE_VAR, UNDEFINE_VAR depending on action to take
* or a PAM_* error code if passed back from other routines
*
* if no DEFAULT provided, the empty string is assumed
* if no OVERRIDE provided, the empty string is assumed
* if DEFAULT= and OVERRIDE evaluates to the empty string,
* this variable should be undefined
* if DEFAULT="" and OVERRIDE evaluates to the empty string,
* this variable should be defined with no value
* if OVERRIDE=value and value turns into the empty string, DEFAULT is used
*
* If DEFINE_VAR is to be returned, the correct value to define will
* be pointed to by var->value
*/
int retval;
D(("Called."));
/*
* First thing to do is to expand any arguments, but only
* if they are not the special quote values (cause expand_arg
* changes memory).
*/
if (var->defval && ("e != var->defval) &&
((retval = _expand_arg(pamh, &(var->defval))) != PAM_SUCCESS)) {
return retval;
}
if (var->override && ("e != var->override) &&
((retval = _expand_arg(pamh, &(var->override))) != PAM_SUCCESS)) {
return retval;
}
/* Now its easy */
if (var->override && *(var->override) && "e != var->override) {
/* if there is a non-empty string in var->override, we use it */
D(("OVERRIDE variable <%s> being used: <%s>", var->name, var->override));
var->value = var->override;
retval = DEFINE_VAR;
} else {
var->value = var->defval;
if ("e == var->defval) {
/*
* This means that the empty string was given for defval value
* which indicates that a variable should be defined with no value
*/
*var->defval = '\0';
D(("An empty variable: <%s>", var->name));
retval = DEFINE_VAR;
} else if (var->defval) {
D(("DEFAULT variable <%s> being used: <%s>", var->name, var->defval));
retval = DEFINE_VAR;
} else {
D(("UNDEFINE variable <%s>", var->name));
retval = UNDEFINE_VAR;
}
}
D(("Exit."));
return retval;
}
|
@@ -23,6 +23,7 @@
#include <string.h>
#include <syslog.h>
#include <sys/stat.h>
+#include <sys/fsuid.h>
#include <sys/types.h>
#include <unistd.h>
@@ -772,13 +773,14 @@ handle_env (pam_handle_t *pamh, int argc, const char **argv)
if(user_readenv && retval == PAM_SUCCESS) {
char *envpath = NULL;
- struct passwd *user_entry;
+ struct passwd *user_entry = NULL;
const char *username;
struct stat statbuf;
username = _pam_get_item_byname(pamh, "PAM_USER");
- user_entry = pam_modutil_getpwnam (pamh, username);
+ if (username)
+ user_entry = pam_modutil_getpwnam (pamh, username);
if (!user_entry) {
pam_syslog(pamh, LOG_ERR, "No such user!?");
}
@@ -789,7 +791,10 @@ handle_env (pam_handle_t *pamh, int argc, const char **argv)
return PAM_BUF_ERR;
}
if (stat(envpath, &statbuf) == 0) {
+ uid_t euid = geteuid();
+ setfsuid (user_entry->pw_uid);
retval = _parse_config_file(pamh, envpath);
+ setfsuid (euid);
if (retval == PAM_IGNORE)
retval = PAM_SUCCESS;
}
| null | null | null |
5,084
|
static int _define_var(pam_handle_t *pamh, VAR *var)
{
/* We have a variable to define, this is a simple function */
char *envvar;
int retval = PAM_SUCCESS;
D(("Called."));
if (asprintf(&envvar, "%s=%s", var->name, var->value) < 0) {
pam_syslog(pamh, LOG_ERR, "out of memory");
return PAM_BUF_ERR;
}
retval = pam_putenv(pamh, envvar);
_pam_drop(envvar);
D(("Exit."));
return retval;
}
|
+Info
| 0
|
static int _define_var(pam_handle_t *pamh, VAR *var)
{
/* We have a variable to define, this is a simple function */
char *envvar;
int retval = PAM_SUCCESS;
D(("Called."));
if (asprintf(&envvar, "%s=%s", var->name, var->value) < 0) {
pam_syslog(pamh, LOG_ERR, "out of memory");
return PAM_BUF_ERR;
}
retval = pam_putenv(pamh, envvar);
_pam_drop(envvar);
D(("Exit."));
return retval;
}
|
@@ -23,6 +23,7 @@
#include <string.h>
#include <syslog.h>
#include <sys/stat.h>
+#include <sys/fsuid.h>
#include <sys/types.h>
#include <unistd.h>
@@ -772,13 +773,14 @@ handle_env (pam_handle_t *pamh, int argc, const char **argv)
if(user_readenv && retval == PAM_SUCCESS) {
char *envpath = NULL;
- struct passwd *user_entry;
+ struct passwd *user_entry = NULL;
const char *username;
struct stat statbuf;
username = _pam_get_item_byname(pamh, "PAM_USER");
- user_entry = pam_modutil_getpwnam (pamh, username);
+ if (username)
+ user_entry = pam_modutil_getpwnam (pamh, username);
if (!user_entry) {
pam_syslog(pamh, LOG_ERR, "No such user!?");
}
@@ -789,7 +791,10 @@ handle_env (pam_handle_t *pamh, int argc, const char **argv)
return PAM_BUF_ERR;
}
if (stat(envpath, &statbuf) == 0) {
+ uid_t euid = geteuid();
+ setfsuid (user_entry->pw_uid);
retval = _parse_config_file(pamh, envpath);
+ setfsuid (euid);
if (retval == PAM_IGNORE)
retval = PAM_SUCCESS;
}
| null | null | null |
5,085
|
static gboolean _can_be_exec(MenuCacheApp *app)
{
char *path;
if (app->try_exec == NULL)
return TRUE;
path = g_find_program_in_path(app->try_exec);
g_free(path);
return (path != NULL);
}
|
DoS
| 0
|
static gboolean _can_be_exec(MenuCacheApp *app)
{
char *path;
if (app->try_exec == NULL)
return TRUE;
path = g_find_program_in_path(app->try_exec);
g_free(path);
return (path != NULL);
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,086
|
static char *_unescape_lf(char *str)
{
char *c, *p = str;
gsize len = 0;
while ((c = strchr(p, '\\')) != NULL)
{
if (p != &str[len])
memmove(&str[len], p, c - p);
len += (c - p);
if (c[1] == 'n')
{
str[len++] = '\n';
c++;
}
else if (c != &str[len])
str[len++] = *c;
p = &c[1];
}
if (p != &str[len])
memmove(&str[len], p, strlen(p) + 1);
return str;
}
|
DoS
| 0
|
static char *_unescape_lf(char *str)
{
char *c, *p = str;
gsize len = 0;
while ((c = strchr(p, '\\')) != NULL)
{
if (p != &str[len])
memmove(&str[len], p, c - p);
len += (c - p);
if (c[1] == 'n')
{
str[len++] = '\n';
c++;
}
else if (c != &str[len])
str[len++] = *c;
p = &c[1];
}
if (p != &str[len])
memmove(&str[len], p, strlen(p) + 1);
return str;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,087
|
const char* menu_cache_app_get_exec( MenuCacheApp* app )
{
return app->exec;
}
|
DoS
| 0
|
const char* menu_cache_app_get_exec( MenuCacheApp* app )
{
return app->exec;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,088
|
const char* menu_cache_app_get_generic_name( MenuCacheApp* app )
{
return app->generic_name;
}
|
DoS
| 0
|
const char* menu_cache_app_get_generic_name( MenuCacheApp* app )
{
return app->generic_name;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,089
|
gboolean menu_cache_app_get_is_visible( MenuCacheApp* app, guint32 de_flags )
{
if(app->flags & FLAG_IS_NODISPLAY)
return FALSE;
return (!app->show_in_flags || (app->show_in_flags & de_flags)) &&
_can_be_exec(app);
}
|
DoS
| 0
|
gboolean menu_cache_app_get_is_visible( MenuCacheApp* app, guint32 de_flags )
{
if(app->flags & FLAG_IS_NODISPLAY)
return FALSE;
return (!app->show_in_flags || (app->show_in_flags & de_flags)) &&
_can_be_exec(app);
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,090
|
guint32 menu_cache_app_get_show_flags( MenuCacheApp* app )
{
return app->show_in_flags;
}
|
DoS
| 0
|
guint32 menu_cache_app_get_show_flags( MenuCacheApp* app )
{
return app->show_in_flags;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,091
|
gboolean menu_cache_app_get_use_sn( MenuCacheApp* app )
{
return ( (app->flags & FLAG_USE_SN) != 0 );
}
|
DoS
| 0
|
gboolean menu_cache_app_get_use_sn( MenuCacheApp* app )
{
return ( (app->flags & FLAG_USE_SN) != 0 );
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,092
|
const char* menu_cache_app_get_working_dir( MenuCacheApp* app )
{
return app->working_dir;
}
|
DoS
| 0
|
const char* menu_cache_app_get_working_dir( MenuCacheApp* app )
{
return app->working_dir;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,093
|
GSList* menu_cache_dir_get_children( MenuCacheDir* dir )
{
/* NOTE: this is very ugly hack but dir may be freed by cache reload
in server-io thread, so we should keep it alive :( */
g_timeout_add_seconds(10, (GSourceFunc)menu_cache_item_unref,
menu_cache_item_ref(MENU_CACHE_ITEM(dir)));
return dir->children;
}
|
DoS
| 0
|
GSList* menu_cache_dir_get_children( MenuCacheDir* dir )
{
/* NOTE: this is very ugly hack but dir may be freed by cache reload
in server-io thread, so we should keep it alive :( */
g_timeout_add_seconds(10, (GSourceFunc)menu_cache_item_unref,
menu_cache_item_ref(MENU_CACHE_ITEM(dir)));
return dir->children;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,094
|
gboolean menu_cache_dir_is_visible(MenuCacheDir *dir)
{
return ((dir->flags & FLAG_IS_NODISPLAY) == 0);
}
|
DoS
| 0
|
gboolean menu_cache_dir_is_visible(MenuCacheDir *dir)
{
return ((dir->flags & FLAG_IS_NODISPLAY) == 0);
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,095
|
GSList* menu_cache_dir_list_children(MenuCacheDir* dir)
{
GSList *children, *l;
if(MENU_CACHE_ITEM(dir)->type != MENU_CACHE_TYPE_DIR)
return NULL;
MENU_CACHE_LOCK;
children = g_slist_copy(dir->children);
for(l = children; l; l = l->next)
menu_cache_item_ref(l->data);
MENU_CACHE_UNLOCK;
return children;
}
|
DoS
| 0
|
GSList* menu_cache_dir_list_children(MenuCacheDir* dir)
{
GSList *children, *l;
if(MENU_CACHE_ITEM(dir)->type != MENU_CACHE_TYPE_DIR)
return NULL;
MENU_CACHE_LOCK;
children = g_slist_copy(dir->children);
for(l = children; l; l = l->next)
menu_cache_item_ref(l->data);
MENU_CACHE_UNLOCK;
return children;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,096
|
MenuCacheDir* menu_cache_dup_root_dir( MenuCache* cache )
{
MenuCacheDir* dir;
MENU_CACHE_LOCK;
dir = cache->root_dir;
if(G_LIKELY(dir))
menu_cache_item_ref(MENU_CACHE_ITEM(dir));
MENU_CACHE_UNLOCK;
return dir;
}
|
DoS
| 0
|
MenuCacheDir* menu_cache_dup_root_dir( MenuCache* cache )
{
MenuCacheDir* dir;
MENU_CACHE_LOCK;
dir = cache->root_dir;
if(G_LIKELY(dir))
menu_cache_item_ref(MENU_CACHE_ITEM(dir));
MENU_CACHE_UNLOCK;
return dir;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,097
|
static void menu_cache_file_dir_unref(MenuCacheFileDir *file_dir)
{
if (file_dir && g_atomic_int_dec_and_test(&file_dir->n_ref))
{
g_free(file_dir->dir);
g_free(file_dir);
}
}
|
DoS
| 0
|
static void menu_cache_file_dir_unref(MenuCacheFileDir *file_dir)
{
if (file_dir && g_atomic_int_dec_and_test(&file_dir->n_ref))
{
g_free(file_dir->dir);
g_free(file_dir);
}
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,098
|
MenuCacheItem *menu_cache_find_child_by_id(MenuCacheDir *dir, const char *id)
{
GSList *child;
MenuCacheItem *item = NULL;
if (MENU_CACHE_ITEM(dir)->type != MENU_CACHE_TYPE_DIR || id == NULL)
return NULL;
MENU_CACHE_LOCK;
for (child = dir->children; child; child = child->next)
if (g_strcmp0(MENU_CACHE_ITEM(child->data)->id, id) == 0)
{
item = menu_cache_item_ref(child->data);
break;
}
MENU_CACHE_UNLOCK;
return item;
}
|
DoS
| 0
|
MenuCacheItem *menu_cache_find_child_by_id(MenuCacheDir *dir, const char *id)
{
GSList *child;
MenuCacheItem *item = NULL;
if (MENU_CACHE_ITEM(dir)->type != MENU_CACHE_TYPE_DIR || id == NULL)
return NULL;
MENU_CACHE_LOCK;
for (child = dir->children; child; child = child->next)
if (g_strcmp0(MENU_CACHE_ITEM(child->data)->id, id) == 0)
{
item = menu_cache_item_ref(child->data);
break;
}
MENU_CACHE_UNLOCK;
return item;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
5,099
|
MenuCacheItem *menu_cache_find_child_by_name(MenuCacheDir *dir, const char *name)
{
GSList *child;
MenuCacheItem *item = NULL;
if (MENU_CACHE_ITEM(dir)->type != MENU_CACHE_TYPE_DIR || name == NULL)
return NULL;
MENU_CACHE_LOCK;
for (child = dir->children; child; child = child->next)
if (g_strcmp0(MENU_CACHE_ITEM(child->data)->name, name) == 0)
{
item = menu_cache_item_ref(child->data);
break;
}
MENU_CACHE_UNLOCK;
return item;
}
|
DoS
| 0
|
MenuCacheItem *menu_cache_find_child_by_name(MenuCacheDir *dir, const char *name)
{
GSList *child;
MenuCacheItem *item = NULL;
if (MENU_CACHE_ITEM(dir)->type != MENU_CACHE_TYPE_DIR || name == NULL)
return NULL;
MENU_CACHE_LOCK;
for (child = dir->children; child; child = child->next)
if (g_strcmp0(MENU_CACHE_ITEM(child->data)->name, name) == 0)
{
item = menu_cache_item_ref(child->data);
break;
}
MENU_CACHE_UNLOCK;
return item;
}
|
@@ -3,7 +3,7 @@
*
* Copyright 2008 PCMan <pcman.tw@gmail.com>
* Copyright 2009 Jürgen Hötzel <juergen@archlinux.org>
- * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
+ * Copyright 2012-2017 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1538,8 +1538,13 @@ static void get_socket_name( char* buf, int len )
if(*p)
*p = '\0';
}
+#if GLIB_CHECK_VERSION(2, 28, 0)
+ g_snprintf( buf, len, "%s/menu-cached-%s", g_get_user_runtime_dir(),
+ dpy ? dpy : ":0" );
+#else
g_snprintf( buf, len, "%s/.menu-cached-%s-%s", g_get_tmp_dir(),
dpy ? dpy : ":0", g_get_user_name() );
+#endif
g_free(dpy);
}
|
CWE-20
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.