idx int64 | func_before string | Vulnerability Classification string | vul int64 | func_after string | patch string | CWE ID string | lines_before string | lines_after string |
|---|---|---|---|---|---|---|---|---|
9,900 | SPL_METHOD(SplObjectStorage, getHash)
{
zval *obj;
char *hash;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
hash = emalloc(33);
php_spl_object_hash(obj, hash TSRMLS_CC);
RETVAL_STRING(hash, 0);
} /* }}} */
/* {{{ proto mixed SplObjectStorage::offsetGet($object)
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, getHash)
{
zval *obj;
char *hash;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
hash = emalloc(33);
php_spl_object_hash(obj, hash TSRMLS_CC);
RETVAL_STRING(hash, 0);
} /* }}} */
/* {{{ proto mixed SplObjectStorage::offsetGet($object)
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,901 | SPL_METHOD(SplObjectStorage, offsetGet)
{
zval *obj;
spl_SplObjectStorageElement *element;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
char *hash;
int hash_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
hash = spl_object_storage_get_hash(intern, getThis(), obj, &hash_len TSRMLS_CC);
if (!hash) {
return;
}
element = spl_object_storage_get(intern, hash, hash_len TSRMLS_CC);
spl_object_storage_free_hash(intern, hash);
if (!element) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Object not found");
} else {
RETURN_ZVAL(element->inf,1, 0);
}
} /* }}} */
/* {{{ proto bool SplObjectStorage::addAll(SplObjectStorage $os)
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, offsetGet)
{
zval *obj;
spl_SplObjectStorageElement *element;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
char *hash;
int hash_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
hash = spl_object_storage_get_hash(intern, getThis(), obj, &hash_len TSRMLS_CC);
if (!hash) {
return;
}
element = spl_object_storage_get(intern, hash, hash_len TSRMLS_CC);
spl_object_storage_free_hash(intern, hash);
if (!element) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Object not found");
} else {
RETURN_ZVAL(element->inf,1, 0);
}
} /* }}} */
/* {{{ proto bool SplObjectStorage::addAll(SplObjectStorage $os)
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,902 | SPL_METHOD(SplObjectStorage, addAll)
{
zval *obj;
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorage *other;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
return;
}
other = (spl_SplObjectStorage *)zend_object_store_get_object(obj TSRMLS_CC);
spl_object_storage_addall(intern, getThis(), other TSRMLS_CC);
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
/* {{{ proto bool SplObjectStorage::removeAll(SplObjectStorage $os)
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, addAll)
{
zval *obj;
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorage *other;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
return;
}
other = (spl_SplObjectStorage *)zend_object_store_get_object(obj TSRMLS_CC);
spl_object_storage_addall(intern, getThis(), other TSRMLS_CC);
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
/* {{{ proto bool SplObjectStorage::removeAll(SplObjectStorage $os)
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,903 | SPL_METHOD(SplObjectStorage, removeAll)
{
zval *obj;
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorage *other;
spl_SplObjectStorageElement *element;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
return;
}
other = (spl_SplObjectStorage *)zend_object_store_get_object(obj TSRMLS_CC);
zend_hash_internal_pointer_reset(&other->storage);
while (zend_hash_get_current_data(&other->storage, (void **)&element) == SUCCESS) {
if (spl_object_storage_detach(intern, getThis(), element->obj TSRMLS_CC) == FAILURE) {
zend_hash_move_forward(&other->storage);
}
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
/* {{{ proto bool SplObjectStorage::removeAllExcept(SplObjectStorage $os)
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, removeAll)
{
zval *obj;
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorage *other;
spl_SplObjectStorageElement *element;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
return;
}
other = (spl_SplObjectStorage *)zend_object_store_get_object(obj TSRMLS_CC);
zend_hash_internal_pointer_reset(&other->storage);
while (zend_hash_get_current_data(&other->storage, (void **)&element) == SUCCESS) {
if (spl_object_storage_detach(intern, getThis(), element->obj TSRMLS_CC) == FAILURE) {
zend_hash_move_forward(&other->storage);
}
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
/* {{{ proto bool SplObjectStorage::removeAllExcept(SplObjectStorage $os)
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,904 | SPL_METHOD(SplObjectStorage, contains)
{
zval *obj;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
RETURN_BOOL(spl_object_storage_contains(intern, getThis(), obj TSRMLS_CC));
} /* }}} */
/* {{{ proto int SplObjectStorage::count()
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, contains)
{
zval *obj;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
RETURN_BOOL(spl_object_storage_contains(intern, getThis(), obj TSRMLS_CC));
} /* }}} */
/* {{{ proto int SplObjectStorage::count()
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,905 | SPL_METHOD(SplObjectStorage, count)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
/* {{{ proto void SplObjectStorage::rewind()
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, count)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
/* {{{ proto void SplObjectStorage::rewind()
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,906 | SPL_METHOD(SplObjectStorage, rewind)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
} /* }}} */
/* {{{ proto bool SplObjectStorage::valid()
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, rewind)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
} /* }}} */
/* {{{ proto bool SplObjectStorage::valid()
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,907 | SPL_METHOD(SplObjectStorage, valid)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(zend_hash_has_more_elements_ex(&intern->storage, &intern->pos) == SUCCESS);
} /* }}} */
/* {{{ proto mixed SplObjectStorage::key()
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, valid)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(zend_hash_has_more_elements_ex(&intern->storage, &intern->pos) == SUCCESS);
} /* }}} */
/* {{{ proto mixed SplObjectStorage::key()
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,908 | SPL_METHOD(SplObjectStorage, current)
{
spl_SplObjectStorageElement *element;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == FAILURE) {
return;
}
RETVAL_ZVAL(element->obj, 1, 0);
} /* }}} */
/* {{{ proto mixed SplObjectStorage::getInfo()
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, current)
{
spl_SplObjectStorageElement *element;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == FAILURE) {
return;
}
RETVAL_ZVAL(element->obj, 1, 0);
} /* }}} */
/* {{{ proto mixed SplObjectStorage::getInfo()
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,909 | SPL_METHOD(SplObjectStorage, next)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
intern->index++;
} /* }}} */
/* {{{ proto string SplObjectStorage::serialize()
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, next)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
intern->index++;
} /* }}} */
/* {{{ proto string SplObjectStorage::serialize()
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,910 | SPL_METHOD(SplObjectStorage, serialize)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorageElement *element;
zval members, *pmembers, *flags;
HashPosition pos;
php_serialize_data_t var_hash;
smart_str buf = {0};
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHP_VAR_SERIALIZE_INIT(var_hash);
/* storage */
smart_str_appendl(&buf, "x:", 2);
MAKE_STD_ZVAL(flags);
ZVAL_LONG(flags, zend_hash_num_elements(&intern->storage));
php_var_serialize(&buf, &flags, &var_hash TSRMLS_CC);
zval_ptr_dtor(&flags);
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
while(zend_hash_has_more_elements_ex(&intern->storage, &pos) == SUCCESS) {
if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &pos) == FAILURE) {
smart_str_free(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
RETURN_NULL();
}
php_var_serialize(&buf, &element->obj, &var_hash TSRMLS_CC);
smart_str_appendc(&buf, ',');
php_var_serialize(&buf, &element->inf, &var_hash TSRMLS_CC);
smart_str_appendc(&buf, ';');
zend_hash_move_forward_ex(&intern->storage, &pos);
}
/* members */
smart_str_appendl(&buf, "m:", 2);
INIT_PZVAL(&members);
Z_ARRVAL(members) = zend_std_get_properties(getThis() TSRMLS_CC);
Z_TYPE(members) = IS_ARRAY;
pmembers = &members;
php_var_serialize(&buf, &pmembers, &var_hash TSRMLS_CC); /* finishes the string */
/* done */
PHP_VAR_SERIALIZE_DESTROY(var_hash);
if (buf.c) {
RETURN_STRINGL(buf.c, buf.len, 0);
} else {
RETURN_NULL();
}
} /* }}} */
/* {{{ proto void SplObjectStorage::unserialize(string serialized)
| Exec Code | 0 | SPL_METHOD(SplObjectStorage, serialize)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_SplObjectStorageElement *element;
zval members, *pmembers, *flags;
HashPosition pos;
php_serialize_data_t var_hash;
smart_str buf = {0};
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHP_VAR_SERIALIZE_INIT(var_hash);
/* storage */
smart_str_appendl(&buf, "x:", 2);
MAKE_STD_ZVAL(flags);
ZVAL_LONG(flags, zend_hash_num_elements(&intern->storage));
php_var_serialize(&buf, &flags, &var_hash TSRMLS_CC);
zval_ptr_dtor(&flags);
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
while(zend_hash_has_more_elements_ex(&intern->storage, &pos) == SUCCESS) {
if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &pos) == FAILURE) {
smart_str_free(&buf);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
RETURN_NULL();
}
php_var_serialize(&buf, &element->obj, &var_hash TSRMLS_CC);
smart_str_appendc(&buf, ',');
php_var_serialize(&buf, &element->inf, &var_hash TSRMLS_CC);
smart_str_appendc(&buf, ';');
zend_hash_move_forward_ex(&intern->storage, &pos);
}
/* members */
smart_str_appendl(&buf, "m:", 2);
INIT_PZVAL(&members);
Z_ARRVAL(members) = zend_std_get_properties(getThis() TSRMLS_CC);
Z_TYPE(members) = IS_ARRAY;
pmembers = &members;
php_var_serialize(&buf, &pmembers, &var_hash TSRMLS_CC); /* finishes the string */
/* done */
PHP_VAR_SERIALIZE_DESTROY(var_hash);
if (buf.c) {
RETURN_STRINGL(buf.c, buf.len, 0);
} else {
RETURN_NULL();
}
} /* }}} */
/* {{{ proto void SplObjectStorage::unserialize(string serialized)
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,911 | SPL_METHOD(MultipleIterator, __construct)
{
spl_SplObjectStorage *intern;
long flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->flags = flags;
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, __construct)
{
spl_SplObjectStorage *intern;
long flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->flags = flags;
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,912 | SPL_METHOD(MultipleIterator, getFlags)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->flags);
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, getFlags)
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->flags);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,913 | SPL_METHOD(MultipleIterator, setFlags)
{
spl_SplObjectStorage *intern;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intern->flags) == FAILURE) {
return;
}
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, setFlags)
{
spl_SplObjectStorage *intern;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intern->flags) == FAILURE) {
return;
}
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,914 | SPL_METHOD(MultipleIterator, attachIterator)
{
spl_SplObjectStorage *intern;
zval *iterator = NULL, *info = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|z!", &iterator, zend_ce_iterator, &info) == FAILURE) {
return;
}
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (info != NULL) {
spl_SplObjectStorageElement *element;
zval compare_result;
if (Z_TYPE_P(info) != IS_LONG && Z_TYPE_P(info) != IS_STRING) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Info must be NULL, integer or string", 0 TSRMLS_CC);
return;
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS) {
is_identical_function(&compare_result, info, element->inf TSRMLS_CC);
if (Z_LVAL(compare_result)) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Key duplication error", 0 TSRMLS_CC);
return;
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
}
spl_object_storage_attach(intern, getThis(), iterator, info TSRMLS_CC);
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, attachIterator)
{
spl_SplObjectStorage *intern;
zval *iterator = NULL, *info = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|z!", &iterator, zend_ce_iterator, &info) == FAILURE) {
return;
}
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (info != NULL) {
spl_SplObjectStorageElement *element;
zval compare_result;
if (Z_TYPE_P(info) != IS_LONG && Z_TYPE_P(info) != IS_STRING) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Info must be NULL, integer or string", 0 TSRMLS_CC);
return;
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS) {
is_identical_function(&compare_result, info, element->inf TSRMLS_CC);
if (Z_LVAL(compare_result)) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Key duplication error", 0 TSRMLS_CC);
return;
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
}
spl_object_storage_attach(intern, getThis(), iterator, info TSRMLS_CC);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,915 | SPL_METHOD(MultipleIterator, rewind)
{
spl_SplObjectStorage *intern;
spl_SplObjectStorageElement *element;
zval *it;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
it = element->obj;
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_rewind, "rewind", NULL);
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, rewind)
{
spl_SplObjectStorage *intern;
spl_SplObjectStorageElement *element;
zval *it;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
it = element->obj;
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_rewind, "rewind", NULL);
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,916 | SPL_METHOD(MultipleIterator, valid)
{
spl_SplObjectStorage *intern;
spl_SplObjectStorageElement *element;
zval *it, *retval = NULL;
long expect, valid;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (!zend_hash_num_elements(&intern->storage)) {
RETURN_FALSE;
}
expect = (intern->flags & MIT_NEED_ALL) ? 1 : 0;
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
it = element->obj;
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_valid, "valid", &retval);
if (retval) {
valid = Z_LVAL_P(retval);
zval_ptr_dtor(&retval);
} else {
valid = 0;
}
if (expect != valid) {
RETURN_BOOL(!expect);
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
RETURN_BOOL(expect);
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, valid)
{
spl_SplObjectStorage *intern;
spl_SplObjectStorageElement *element;
zval *it, *retval = NULL;
long expect, valid;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (!zend_hash_num_elements(&intern->storage)) {
RETURN_FALSE;
}
expect = (intern->flags & MIT_NEED_ALL) ? 1 : 0;
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
it = element->obj;
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_valid, "valid", &retval);
if (retval) {
valid = Z_LVAL_P(retval);
zval_ptr_dtor(&retval);
} else {
valid = 0;
}
if (expect != valid) {
RETURN_BOOL(!expect);
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
RETURN_BOOL(expect);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,917 | SPL_METHOD(MultipleIterator, current)
{
spl_SplObjectStorage *intern;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT, return_value TSRMLS_CC);
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, current)
{
spl_SplObjectStorage *intern;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT, return_value TSRMLS_CC);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,918 | SPL_METHOD(MultipleIterator, key)
{
spl_SplObjectStorage *intern;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_KEY, return_value TSRMLS_CC);
}
| Exec Code | 0 | SPL_METHOD(MultipleIterator, key)
{
spl_SplObjectStorage *intern;
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_KEY, return_value TSRMLS_CC);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,919 | static zend_object_value spl_SplObjectStorage_new(zend_class_entry *class_type TSRMLS_DC)
{
spl_SplObjectStorage *tmp;
return spl_object_storage_new_ex(class_type, &tmp, NULL TSRMLS_CC);
}
| Exec Code | 0 | static zend_object_value spl_SplObjectStorage_new(zend_class_entry *class_type TSRMLS_DC)
{
spl_SplObjectStorage *tmp;
return spl_object_storage_new_ex(class_type, &tmp, NULL TSRMLS_CC);
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,920 | void spl_SplOjectStorage_free_storage(void *object TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
zend_hash_destroy(&intern->storage);
if (intern->debug_info != NULL) {
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
efree(object);
} /* }}} */
| Exec Code | 0 | void spl_SplOjectStorage_free_storage(void *object TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
zend_hash_destroy(&intern->storage);
if (intern->debug_info != NULL) {
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
efree(object);
} /* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,921 | static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_type, zval *return_value TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorageElement *element;
zval *it, *retval = NULL;
int valid = 1, num_elements;
num_elements = zend_hash_num_elements(&intern->storage);
if (num_elements < 1) {
RETURN_FALSE;
}
array_init_size(return_value, num_elements);
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
it = element->obj;
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_valid, "valid", &retval);
if (retval) {
valid = Z_LVAL_P(retval);
zval_ptr_dtor(&retval);
} else {
valid = 0;
}
if (valid) {
if (SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT == get_type) {
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_current, "current", &retval);
} else {
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_key, "key", &retval);
}
if (!retval) {
zend_throw_exception(spl_ce_RuntimeException, "Failed to call sub iterator method", 0 TSRMLS_CC);
return;
}
} else if (intern->flags & MIT_NEED_ALL) {
if (SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT == get_type) {
zend_throw_exception(spl_ce_RuntimeException, "Called current() with non valid sub iterator", 0 TSRMLS_CC);
} else {
zend_throw_exception(spl_ce_RuntimeException, "Called key() with non valid sub iterator", 0 TSRMLS_CC);
}
return;
} else {
ALLOC_INIT_ZVAL(retval);
}
if (intern->flags & MIT_KEYS_ASSOC) {
switch (Z_TYPE_P(element->inf)) {
case IS_LONG:
add_index_zval(return_value, Z_LVAL_P(element->inf), retval);
break;
case IS_STRING:
add_assoc_zval_ex(return_value, Z_STRVAL_P(element->inf), Z_STRLEN_P(element->inf)+1U, retval);
break;
default:
zval_ptr_dtor(&retval);
zend_throw_exception(spl_ce_InvalidArgumentException, "Sub-Iterator is associated with NULL", 0 TSRMLS_CC);
return;
}
} else {
add_next_index_zval(return_value, retval);
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
}
/* }}} */
| Exec Code | 0 | static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_type, zval *return_value TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorageElement *element;
zval *it, *retval = NULL;
int valid = 1, num_elements;
num_elements = zend_hash_num_elements(&intern->storage);
if (num_elements < 1) {
RETURN_FALSE;
}
array_init_size(return_value, num_elements);
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
it = element->obj;
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_valid, "valid", &retval);
if (retval) {
valid = Z_LVAL_P(retval);
zval_ptr_dtor(&retval);
} else {
valid = 0;
}
if (valid) {
if (SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT == get_type) {
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_current, "current", &retval);
} else {
zend_call_method_with_0_params(&it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_key, "key", &retval);
}
if (!retval) {
zend_throw_exception(spl_ce_RuntimeException, "Failed to call sub iterator method", 0 TSRMLS_CC);
return;
}
} else if (intern->flags & MIT_NEED_ALL) {
if (SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT == get_type) {
zend_throw_exception(spl_ce_RuntimeException, "Called current() with non valid sub iterator", 0 TSRMLS_CC);
} else {
zend_throw_exception(spl_ce_RuntimeException, "Called key() with non valid sub iterator", 0 TSRMLS_CC);
}
return;
} else {
ALLOC_INIT_ZVAL(retval);
}
if (intern->flags & MIT_KEYS_ASSOC) {
switch (Z_TYPE_P(element->inf)) {
case IS_LONG:
add_index_zval(return_value, Z_LVAL_P(element->inf), retval);
break;
case IS_STRING:
add_assoc_zval_ex(return_value, Z_STRVAL_P(element->inf), Z_STRLEN_P(element->inf)+1U, retval);
break;
default:
zval_ptr_dtor(&retval);
zend_throw_exception(spl_ce_InvalidArgumentException, "Sub-Iterator is associated with NULL", 0 TSRMLS_CC);
return;
}
} else {
add_next_index_zval(return_value, retval);
}
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
}
}
/* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,922 | void spl_object_storage_addall(spl_SplObjectStorage *intern, zval *this, spl_SplObjectStorage *other TSRMLS_DC) { /* {{{ */
HashPosition pos;
spl_SplObjectStorageElement *element;
zend_hash_internal_pointer_reset_ex(&other->storage, &pos);
while (zend_hash_get_current_data_ex(&other->storage, (void **)&element, &pos) == SUCCESS) {
spl_object_storage_attach(intern, this, element->obj, element->inf TSRMLS_CC);
zend_hash_move_forward_ex(&other->storage, &pos);
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
} /* }}} */
| Exec Code | 0 | void spl_object_storage_addall(spl_SplObjectStorage *intern, zval *this, spl_SplObjectStorage *other TSRMLS_DC) { /* {{{ */
HashPosition pos;
spl_SplObjectStorageElement *element;
zend_hash_internal_pointer_reset_ex(&other->storage, &pos);
while (zend_hash_get_current_data_ex(&other->storage, (void **)&element, &pos) == SUCCESS) {
spl_object_storage_attach(intern, this, element->obj, element->inf TSRMLS_CC);
zend_hash_move_forward_ex(&other->storage, &pos);
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
} /* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,923 | void spl_object_storage_attach(spl_SplObjectStorage *intern, zval *this, zval *obj, zval *inf TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorageElement *pelement, element;
int hash_len;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
return;
}
pelement = spl_object_storage_get(intern, hash, hash_len TSRMLS_CC);
if (inf) {
Z_ADDREF_P(inf);
} else {
ALLOC_INIT_ZVAL(inf);
}
if (pelement) {
zval_ptr_dtor(&pelement->inf);
pelement->inf = inf;
spl_object_storage_free_hash(intern, hash);
return;
}
Z_ADDREF_P(obj);
element.obj = obj;
element.inf = inf;
zend_hash_update(&intern->storage, hash, hash_len, &element, sizeof(spl_SplObjectStorageElement), NULL);
spl_object_storage_free_hash(intern, hash);
} /* }}} */
| Exec Code | 0 | void spl_object_storage_attach(spl_SplObjectStorage *intern, zval *this, zval *obj, zval *inf TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorageElement *pelement, element;
int hash_len;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
return;
}
pelement = spl_object_storage_get(intern, hash, hash_len TSRMLS_CC);
if (inf) {
Z_ADDREF_P(inf);
} else {
ALLOC_INIT_ZVAL(inf);
}
if (pelement) {
zval_ptr_dtor(&pelement->inf);
pelement->inf = inf;
spl_object_storage_free_hash(intern, hash);
return;
}
Z_ADDREF_P(obj);
element.obj = obj;
element.inf = inf;
zend_hash_update(&intern->storage, hash, hash_len, &element, sizeof(spl_SplObjectStorageElement), NULL);
spl_object_storage_free_hash(intern, hash);
} /* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,924 | static zend_object_value spl_object_storage_clone(zval *zobject TSRMLS_DC)
{
zend_object_value new_obj_val;
zend_object *old_object;
zend_object *new_object;
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
spl_SplObjectStorage *intern;
old_object = zend_objects_get_address(zobject TSRMLS_CC);
new_obj_val = spl_object_storage_new_ex(old_object->ce, &intern, zobject TSRMLS_CC);
new_object = &intern->std;
zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC);
return new_obj_val;
}
| Exec Code | 0 | static zend_object_value spl_object_storage_clone(zval *zobject TSRMLS_DC)
{
zend_object_value new_obj_val;
zend_object *old_object;
zend_object *new_object;
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
spl_SplObjectStorage *intern;
old_object = zend_objects_get_address(zobject TSRMLS_CC);
new_obj_val = spl_object_storage_new_ex(old_object->ce, &intern, zobject TSRMLS_CC);
new_object = &intern->std;
zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC);
return new_obj_val;
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,925 | static int spl_object_storage_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
zend_object *zo1 = (zend_object *)zend_object_store_get_object(o1 TSRMLS_CC);
zend_object *zo2 = (zend_object *)zend_object_store_get_object(o2 TSRMLS_CC);
if (zo1->ce != spl_ce_SplObjectStorage || zo2->ce != spl_ce_SplObjectStorage) {
return 1;
}
return zend_hash_compare(&((spl_SplObjectStorage *)zo1)->storage, &((spl_SplObjectStorage *)zo2)->storage, (compare_func_t) spl_object_storage_compare_info, 0 TSRMLS_CC);
}
/* }}} */
| Exec Code | 0 | static int spl_object_storage_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
zend_object *zo1 = (zend_object *)zend_object_store_get_object(o1 TSRMLS_CC);
zend_object *zo2 = (zend_object *)zend_object_store_get_object(o2 TSRMLS_CC);
if (zo1->ce != spl_ce_SplObjectStorage || zo2->ce != spl_ce_SplObjectStorage) {
return 1;
}
return zend_hash_compare(&((spl_SplObjectStorage *)zo1)->storage, &((spl_SplObjectStorage *)zo2)->storage, (compare_func_t) spl_object_storage_compare_info, 0 TSRMLS_CC);
}
/* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,926 | int spl_object_storage_contains(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) /* {{{ */
{
int hash_len, found;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
return 0;
}
found = zend_hash_exists(&intern->storage, hash, hash_len);
spl_object_storage_free_hash(intern, hash);
return found;
} /* }}} */
| Exec Code | 0 | int spl_object_storage_contains(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) /* {{{ */
{
int hash_len, found;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
return 0;
}
found = zend_hash_exists(&intern->storage, hash, hash_len);
spl_object_storage_free_hash(intern, hash);
return found;
} /* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,927 | static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
spl_SplObjectStorageElement *element;
HashTable *props;
HashPosition pos;
zval *tmp, *storage;
char md5str[33];
int name_len;
char *zname;
*is_temp = 0;
props = Z_OBJPROP_P(obj);
zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
if (intern->debug_info == NULL) {
ALLOC_HASHTABLE(intern->debug_info);
ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(props) + 1, 0);
}
if (intern->debug_info->nApplyCount == 0) {
zend_hash_copy(intern->debug_info, props, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
MAKE_STD_ZVAL(storage);
array_init(storage);
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
php_spl_object_hash(element->obj, md5str TSRMLS_CC);
MAKE_STD_ZVAL(tmp);
array_init(tmp);
/* Incrementing the refcount of obj and inf would confuse the garbage collector.
* Prefer to null the destructor */
Z_ARRVAL_P(tmp)->pDestructor = NULL;
add_assoc_zval_ex(tmp, "obj", sizeof("obj"), element->obj);
add_assoc_zval_ex(tmp, "inf", sizeof("inf"), element->inf);
add_assoc_zval_ex(storage, md5str, 33, tmp);
zend_hash_move_forward_ex(&intern->storage, &pos);
}
zname = spl_gen_private_prop_name(spl_ce_SplObjectStorage, "storage", sizeof("storage")-1, &name_len TSRMLS_CC);
zend_symtable_update(intern->debug_info, zname, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname);
}
return intern->debug_info;
}
/* }}} */
| Exec Code | 0 | static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
spl_SplObjectStorageElement *element;
HashTable *props;
HashPosition pos;
zval *tmp, *storage;
char md5str[33];
int name_len;
char *zname;
*is_temp = 0;
props = Z_OBJPROP_P(obj);
zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
if (intern->debug_info == NULL) {
ALLOC_HASHTABLE(intern->debug_info);
ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(props) + 1, 0);
}
if (intern->debug_info->nApplyCount == 0) {
zend_hash_copy(intern->debug_info, props, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
MAKE_STD_ZVAL(storage);
array_init(storage);
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
php_spl_object_hash(element->obj, md5str TSRMLS_CC);
MAKE_STD_ZVAL(tmp);
array_init(tmp);
/* Incrementing the refcount of obj and inf would confuse the garbage collector.
* Prefer to null the destructor */
Z_ARRVAL_P(tmp)->pDestructor = NULL;
add_assoc_zval_ex(tmp, "obj", sizeof("obj"), element->obj);
add_assoc_zval_ex(tmp, "inf", sizeof("inf"), element->inf);
add_assoc_zval_ex(storage, md5str, 33, tmp);
zend_hash_move_forward_ex(&intern->storage, &pos);
}
zname = spl_gen_private_prop_name(spl_ce_SplObjectStorage, "storage", sizeof("storage")-1, &name_len TSRMLS_CC);
zend_symtable_update(intern->debug_info, zname, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname);
}
return intern->debug_info;
}
/* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,928 | int spl_object_storage_detach(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) /* {{{ */
{
int hash_len, ret = FAILURE;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
return ret;
}
ret = zend_hash_del(&intern->storage, hash, hash_len);
spl_object_storage_free_hash(intern, hash);
return ret;
} /* }}}*/
| Exec Code | 0 | int spl_object_storage_detach(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) /* {{{ */
{
int hash_len, ret = FAILURE;
char *hash = spl_object_storage_get_hash(intern, this, obj, &hash_len TSRMLS_CC);
if (!hash) {
return ret;
}
ret = zend_hash_del(&intern->storage, hash, hash_len);
spl_object_storage_free_hash(intern, hash);
return ret;
} /* }}}*/
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,929 | static void spl_object_storage_dtor(spl_SplObjectStorageElement *element) /* {{{ */
{
zval_ptr_dtor(&element->obj);
zval_ptr_dtor(&element->inf);
} /* }}} */
| Exec Code | 0 | static void spl_object_storage_dtor(spl_SplObjectStorageElement *element) /* {{{ */
{
zval_ptr_dtor(&element->obj);
zval_ptr_dtor(&element->inf);
} /* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,930 | static void spl_object_storage_free_hash(spl_SplObjectStorage *intern, char *hash) {
if (intern->fptr_get_hash) {
efree(hash);
} else {
#if HAVE_PACKED_OBJECT_VALUE
/* Nothing to do */
#else
efree(hash);
#endif
}
}
| Exec Code | 0 | static void spl_object_storage_free_hash(spl_SplObjectStorage *intern, char *hash) {
if (intern->fptr_get_hash) {
efree(hash);
} else {
#if HAVE_PACKED_OBJECT_VALUE
/* Nothing to do */
#else
efree(hash);
#endif
}
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,931 | spl_SplObjectStorageElement* spl_object_storage_get(spl_SplObjectStorage *intern, char *hash, int hash_len TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorageElement *element;
if (zend_hash_find(&intern->storage, hash, hash_len, (void**)&element) == SUCCESS) {
return element;
} else {
return NULL;
}
} /* }}} */
| Exec Code | 0 | spl_SplObjectStorageElement* spl_object_storage_get(spl_SplObjectStorage *intern, char *hash, int hash_len TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorageElement *element;
if (zend_hash_find(&intern->storage, hash, hash_len, (void**)&element) == SUCCESS) {
return element;
} else {
return NULL;
}
} /* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,932 | static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
spl_SplObjectStorageElement *element;
HashTable *props;
HashPosition pos;
zval *gcdata_arr = NULL,
**gcdata_arr_pp;
props = std_object_handlers.get_properties(obj TSRMLS_CC);
*table = NULL;
*n = 0;
/* clean \x00gcdata, as it may be out of date */
if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) &gcdata_arr_pp) == SUCCESS) {
gcdata_arr = *gcdata_arr_pp;
zend_hash_clean(Z_ARRVAL_P(gcdata_arr));
}
if (gcdata_arr == NULL) {
MAKE_STD_ZVAL(gcdata_arr);
array_init(gcdata_arr);
/* don't decrease refcount of members when destroying */
Z_ARRVAL_P(gcdata_arr)->pDestructor = NULL;
/* name starts with \x00 to make tampering in user-land more difficult */
zend_hash_add(props, "\x00gcdata", sizeof("\x00gcdata"), &gcdata_arr, sizeof(gcdata_arr), NULL);
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
add_next_index_zval(gcdata_arr, element->obj);
add_next_index_zval(gcdata_arr, element->inf);
zend_hash_move_forward_ex(&intern->storage, &pos);
}
return props;
}
/* }}} */
| Exec Code | 0 | static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSRMLS_DC) /* {{{ */
{
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
spl_SplObjectStorageElement *element;
HashTable *props;
HashPosition pos;
zval *gcdata_arr = NULL,
**gcdata_arr_pp;
props = std_object_handlers.get_properties(obj TSRMLS_CC);
*table = NULL;
*n = 0;
/* clean \x00gcdata, as it may be out of date */
if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) &gcdata_arr_pp) == SUCCESS) {
gcdata_arr = *gcdata_arr_pp;
zend_hash_clean(Z_ARRVAL_P(gcdata_arr));
}
if (gcdata_arr == NULL) {
MAKE_STD_ZVAL(gcdata_arr);
array_init(gcdata_arr);
/* don't decrease refcount of members when destroying */
Z_ARRVAL_P(gcdata_arr)->pDestructor = NULL;
/* name starts with \x00 to make tampering in user-land more difficult */
zend_hash_add(props, "\x00gcdata", sizeof("\x00gcdata"), &gcdata_arr, sizeof(gcdata_arr), NULL);
}
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
add_next_index_zval(gcdata_arr, element->obj);
add_next_index_zval(gcdata_arr, element->inf);
zend_hash_move_forward_ex(&intern->storage, &pos);
}
return props;
}
/* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,933 | static char *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zval *this, zval *obj, int *hash_len_ptr TSRMLS_DC) {
if (intern->fptr_get_hash) {
zval *rv;
zend_call_method_with_1_params(&this, intern->std.ce, &intern->fptr_get_hash, "getHash", &rv, obj);
if (rv) {
if (Z_TYPE_P(rv) == IS_STRING) {
int hash_len = Z_STRLEN_P(rv);
char *hash = emalloc((hash_len+1)*sizeof(char));
strncpy(hash, Z_STRVAL_P(rv), hash_len);
hash[hash_len] = 0;
zval_ptr_dtor(&rv);
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return hash;
} else {
zend_throw_exception(spl_ce_RuntimeException, "Hash needs to be a string", 0 TSRMLS_CC);
zval_ptr_dtor(&rv);
return NULL;
}
} else {
return NULL;
}
} else {
int hash_len = sizeof(zend_object_value);
#if HAVE_PACKED_OBJECT_VALUE
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return (char*)&Z_OBJVAL_P(obj);
#else
char *hash = emalloc(hash_len + 1);
zend_object_value zvalue;
memset(&zvalue, 0, sizeof(zend_object_value));
zvalue.handle = Z_OBJ_HANDLE_P(obj);
zvalue.handlers = Z_OBJ_HT_P(obj);
memcpy(hash, (char *)&zvalue, hash_len);
hash[hash_len] = 0;
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return hash;
#endif
}
}
| Exec Code | 0 | static char *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zval *this, zval *obj, int *hash_len_ptr TSRMLS_DC) {
if (intern->fptr_get_hash) {
zval *rv;
zend_call_method_with_1_params(&this, intern->std.ce, &intern->fptr_get_hash, "getHash", &rv, obj);
if (rv) {
if (Z_TYPE_P(rv) == IS_STRING) {
int hash_len = Z_STRLEN_P(rv);
char *hash = emalloc((hash_len+1)*sizeof(char));
strncpy(hash, Z_STRVAL_P(rv), hash_len);
hash[hash_len] = 0;
zval_ptr_dtor(&rv);
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return hash;
} else {
zend_throw_exception(spl_ce_RuntimeException, "Hash needs to be a string", 0 TSRMLS_CC);
zval_ptr_dtor(&rv);
return NULL;
}
} else {
return NULL;
}
} else {
int hash_len = sizeof(zend_object_value);
#if HAVE_PACKED_OBJECT_VALUE
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return (char*)&Z_OBJVAL_P(obj);
#else
char *hash = emalloc(hash_len + 1);
zend_object_value zvalue;
memset(&zvalue, 0, sizeof(zend_object_value));
zvalue.handle = Z_OBJ_HANDLE_P(obj);
zvalue.handlers = Z_OBJ_HT_P(obj);
memcpy(hash, (char *)&zvalue, hash_len);
hash[hash_len] = 0;
if (hash_len_ptr) {
*hash_len_ptr = hash_len;
}
return hash;
#endif
}
}
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,934 | static zend_object_value spl_object_storage_new_ex(zend_class_entry *class_type, spl_SplObjectStorage **obj, zval *orig TSRMLS_DC) /* {{{ */
{
zend_object_value retval;
spl_SplObjectStorage *intern;
zend_class_entry *parent = class_type;
intern = emalloc(sizeof(spl_SplObjectStorage));
memset(intern, 0, sizeof(spl_SplObjectStorage));
*obj = intern;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
zend_hash_init(&intern->storage, 0, NULL, (void (*)(void *))spl_object_storage_dtor, 0);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_SplOjectStorage_free_storage, NULL TSRMLS_CC);
retval.handlers = &spl_handler_SplObjectStorage;
if (orig) {
spl_SplObjectStorage *other = (spl_SplObjectStorage*)zend_object_store_get_object(orig TSRMLS_CC);
spl_object_storage_addall(intern, orig, other TSRMLS_CC);
}
while (parent) {
if (parent == spl_ce_SplObjectStorage) {
if (class_type != spl_ce_SplObjectStorage) {
zend_hash_find(&class_type->function_table, "gethash", sizeof("gethash"), (void **) &intern->fptr_get_hash);
if (intern->fptr_get_hash->common.scope == spl_ce_SplObjectStorage) {
intern->fptr_get_hash = NULL;
}
}
break;
}
parent = parent->parent;
}
return retval;
}
/* }}} */
| Exec Code | 0 | static zend_object_value spl_object_storage_new_ex(zend_class_entry *class_type, spl_SplObjectStorage **obj, zval *orig TSRMLS_DC) /* {{{ */
{
zend_object_value retval;
spl_SplObjectStorage *intern;
zend_class_entry *parent = class_type;
intern = emalloc(sizeof(spl_SplObjectStorage));
memset(intern, 0, sizeof(spl_SplObjectStorage));
*obj = intern;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
zend_hash_init(&intern->storage, 0, NULL, (void (*)(void *))spl_object_storage_dtor, 0);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_SplOjectStorage_free_storage, NULL TSRMLS_CC);
retval.handlers = &spl_handler_SplObjectStorage;
if (orig) {
spl_SplObjectStorage *other = (spl_SplObjectStorage*)zend_object_store_get_object(orig TSRMLS_CC);
spl_object_storage_addall(intern, orig, other TSRMLS_CC);
}
while (parent) {
if (parent == spl_ce_SplObjectStorage) {
if (class_type != spl_ce_SplObjectStorage) {
zend_hash_find(&class_type->function_table, "gethash", sizeof("gethash"), (void **) &intern->fptr_get_hash);
if (intern->fptr_get_hash->common.scope == spl_ce_SplObjectStorage) {
intern->fptr_get_hash = NULL;
}
}
break;
}
parent = parent->parent;
}
return retval;
}
/* }}} */
| @@ -898,7 +898,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
++p;
ALLOC_INIT_ZVAL(pmembers);
- if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC)) {
+ if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(pmembers) != IS_ARRAY) {
zval_ptr_dtor(&pmembers);
goto outexcept;
} | null | null | null |
9,935 | check_mountpoint(const char *progname, char *mountpoint)
{
int err;
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
return EX_USAGE;
}
if (!S_ISDIR(statbuf.st_mode)) {
fprintf(stderr, "%s: %s is not a directory!", progname,
mountpoint);
return EX_USAGE;
}
#if CIFS_LEGACY_SETUID_CHECK
/* do extra checks on mountpoint for legacy setuid behavior */
if (!getuid() || geteuid())
return 0;
if (statbuf.st_uid != getuid()) {
fprintf(stderr, "%s: %s is not owned by user\n", progname,
mountpoint);
return EX_USAGE;
}
if ((statbuf.st_mode & S_IRWXU) != S_IRWXU) {
fprintf(stderr, "%s: invalid permissions on %s\n", progname,
mountpoint);
return EX_USAGE;
}
#endif /* CIFS_LEGACY_SETUID_CHECK */
return 0;
}
| +Priv | 0 | check_mountpoint(const char *progname, char *mountpoint)
{
int err;
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
return EX_USAGE;
}
if (!S_ISDIR(statbuf.st_mode)) {
fprintf(stderr, "%s: %s is not a directory!", progname,
mountpoint);
return EX_USAGE;
}
#if CIFS_LEGACY_SETUID_CHECK
/* do extra checks on mountpoint for legacy setuid behavior */
if (!getuid() || geteuid())
return 0;
if (statbuf.st_uid != getuid()) {
fprintf(stderr, "%s: %s is not owned by user\n", progname,
mountpoint);
return EX_USAGE;
}
if ((statbuf.st_mode & S_IRWXU) != S_IRWXU) {
fprintf(stderr, "%s: invalid permissions on %s\n", progname,
mountpoint);
return EX_USAGE;
}
#endif /* CIFS_LEGACY_SETUID_CHECK */
return 0;
}
| @@ -43,7 +43,7 @@
#include "mount.h"
#define MOUNT_CIFS_VERSION_MAJOR "1"
-#define MOUNT_CIFS_VERSION_MINOR "13"
+#define MOUNT_CIFS_VERSION_MINOR "14"
#ifndef MOUNT_CIFS_VENDOR_SUFFIX
#ifdef _SAMBA_BUILD_
@@ -86,6 +86,17 @@
/* currently maximum length of IPv6 address string */
#define MAX_ADDRESS_LEN INET6_ADDRSTRLEN
+/*
+ * mount.cifs has been the subject of many "security" bugs that have arisen
+ * because of users and distributions installing it as a setuid root program.
+ * mount.cifs has not been audited for security. Thus, we strongly recommend
+ * that it not be installed setuid root. To make that abundantly clear,
+ * mount.cifs now check whether it's running setuid root and exit with an
+ * error if it is. If you wish to disable this check, then set the following
+ * #define to 1, but please realize that you do so at your own peril.
+ */
+#define CIFS_DISABLE_SETUID_CHECK 0
+
/*
* By default, mount.cifs follows the conventions set forth by /bin/mount
* for user mounts. That is, it requires that the mount be listed in
@@ -212,6 +223,29 @@ check_mountpoint(const char *progname, char *mountpoint)
return 0;
}
+#if CIFS_DISABLE_SETUID_CHECK
+static int
+check_setuid(void)
+{
+ return 0;
+}
+#else /* CIFS_DISABLE_SETUID_CHECK */
+static int
+check_setuid(void)
+{
+ if (getuid() && !geteuid()) {
+ printf("This mount.cifs program has been built with the "
+ "ability to run as a setuid root program disabled.\n"
+ "mount.cifs has not been well audited for security "
+ "holes. Therefore the Samba team does not recommend "
+ "installing it as a setuid root program.\n");
+ return 1;
+ }
+
+ return 0;
+}
+#endif /* CIFS_DISABLE_SETUID_CHECK */
+
#if CIFS_LEGACY_SETUID_CHECK
static int
check_fstab(const char *progname, char *mountpoint, char *devname,
@@ -1226,6 +1260,9 @@ int main(int argc, char ** argv)
struct sockaddr_in6 *addr6;
FILE * pmntfile;
+ if (check_setuid())
+ return EX_USAGE;
+
/* setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); */ | CWE-59 | null | null |
9,936 | static size_t strlcpy(char *d, const char *s, size_t bufsize)
{
size_t len = strlen(s);
size_t ret = len;
if (bufsize <= 0) return 0;
if (len >= bufsize) len = bufsize-1;
memcpy(d, s, len);
d[len] = 0;
return ret;
}
| +Priv | 0 | static size_t strlcpy(char *d, const char *s, size_t bufsize)
{
size_t len = strlen(s);
size_t ret = len;
if (bufsize <= 0) return 0;
if (len >= bufsize) len = bufsize-1;
memcpy(d, s, len);
d[len] = 0;
return ret;
}
| @@ -43,7 +43,7 @@
#include "mount.h"
#define MOUNT_CIFS_VERSION_MAJOR "1"
-#define MOUNT_CIFS_VERSION_MINOR "13"
+#define MOUNT_CIFS_VERSION_MINOR "14"
#ifndef MOUNT_CIFS_VENDOR_SUFFIX
#ifdef _SAMBA_BUILD_
@@ -86,6 +86,17 @@
/* currently maximum length of IPv6 address string */
#define MAX_ADDRESS_LEN INET6_ADDRSTRLEN
+/*
+ * mount.cifs has been the subject of many "security" bugs that have arisen
+ * because of users and distributions installing it as a setuid root program.
+ * mount.cifs has not been audited for security. Thus, we strongly recommend
+ * that it not be installed setuid root. To make that abundantly clear,
+ * mount.cifs now check whether it's running setuid root and exit with an
+ * error if it is. If you wish to disable this check, then set the following
+ * #define to 1, but please realize that you do so at your own peril.
+ */
+#define CIFS_DISABLE_SETUID_CHECK 0
+
/*
* By default, mount.cifs follows the conventions set forth by /bin/mount
* for user mounts. That is, it requires that the mount be listed in
@@ -212,6 +223,29 @@ check_mountpoint(const char *progname, char *mountpoint)
return 0;
}
+#if CIFS_DISABLE_SETUID_CHECK
+static int
+check_setuid(void)
+{
+ return 0;
+}
+#else /* CIFS_DISABLE_SETUID_CHECK */
+static int
+check_setuid(void)
+{
+ if (getuid() && !geteuid()) {
+ printf("This mount.cifs program has been built with the "
+ "ability to run as a setuid root program disabled.\n"
+ "mount.cifs has not been well audited for security "
+ "holes. Therefore the Samba team does not recommend "
+ "installing it as a setuid root program.\n");
+ return 1;
+ }
+
+ return 0;
+}
+#endif /* CIFS_DISABLE_SETUID_CHECK */
+
#if CIFS_LEGACY_SETUID_CHECK
static int
check_fstab(const char *progname, char *mountpoint, char *devname,
@@ -1226,6 +1260,9 @@ int main(int argc, char ** argv)
struct sockaddr_in6 *addr6;
FILE * pmntfile;
+ if (check_setuid())
+ return EX_USAGE;
+
/* setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); */ | CWE-59 | null | null |
9,937 | static void check_for_comma(char ** ppasswrd)
{
char *new_pass_buf;
char *pass;
int i,j;
int number_of_commas = 0;
int len;
if(ppasswrd == NULL)
return;
else
(pass = *ppasswrd);
len = strlen(pass);
for(i=0;i<len;i++) {
if(pass[i] == ',')
number_of_commas++;
}
if(number_of_commas == 0)
return;
if(number_of_commas > MOUNT_PASSWD_SIZE) {
/* would otherwise overflow the mount options buffer */
fprintf(stderr, "\nInvalid password. Password contains too many commas.\n");
return;
}
new_pass_buf = (char *)malloc(len+number_of_commas+1);
if(new_pass_buf == NULL)
return;
for(i=0,j=0;i<len;i++,j++) {
new_pass_buf[j] = pass[i];
if(pass[i] == ',') {
j++;
new_pass_buf[j] = pass[i];
}
}
new_pass_buf[len+number_of_commas] = 0;
SAFE_FREE(*ppasswrd);
*ppasswrd = new_pass_buf;
return;
}
| +Priv | 0 | static void check_for_comma(char ** ppasswrd)
{
char *new_pass_buf;
char *pass;
int i,j;
int number_of_commas = 0;
int len;
if(ppasswrd == NULL)
return;
else
(pass = *ppasswrd);
len = strlen(pass);
for(i=0;i<len;i++) {
if(pass[i] == ',')
number_of_commas++;
}
if(number_of_commas == 0)
return;
if(number_of_commas > MOUNT_PASSWD_SIZE) {
/* would otherwise overflow the mount options buffer */
fprintf(stderr, "\nInvalid password. Password contains too many commas.\n");
return;
}
new_pass_buf = (char *)malloc(len+number_of_commas+1);
if(new_pass_buf == NULL)
return;
for(i=0,j=0;i<len;i++,j++) {
new_pass_buf[j] = pass[i];
if(pass[i] == ',') {
j++;
new_pass_buf[j] = pass[i];
}
}
new_pass_buf[len+number_of_commas] = 0;
SAFE_FREE(*ppasswrd);
*ppasswrd = new_pass_buf;
return;
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,938 | static char * check_for_domain(char **ppuser)
{
char * original_string;
char * usernm;
char * domainnm;
int original_len;
int len;
int i;
if(ppuser == NULL)
return NULL;
original_string = *ppuser;
if (original_string == NULL)
return NULL;
original_len = strlen(original_string);
usernm = strchr(*ppuser,'/');
if (usernm == NULL) {
usernm = strchr(*ppuser,'\\');
if (usernm == NULL)
return NULL;
}
if(got_domain) {
fprintf(stderr, "Domain name specified twice. Username probably malformed\n");
return NULL;
}
usernm[0] = 0;
domainnm = *ppuser;
if (domainnm[0] != 0) {
got_domain = 1;
} else {
fprintf(stderr, "null domain\n");
}
len = strlen(domainnm);
/* reset domainm to new buffer, and copy
domain name into it */
domainnm = (char *)malloc(len+1);
if(domainnm == NULL)
return NULL;
strlcpy(domainnm,*ppuser,len+1);
/* move_string(*ppuser, usernm+1) */
len = strlen(usernm+1);
if(len >= original_len) {
/* should not happen */
return domainnm;
}
for(i=0;i<original_len;i++) {
if(i<len)
original_string[i] = usernm[i+1];
else /* stuff with commas to remove last parm */
original_string[i] = ',';
}
/* BB add check for more than one slash?
strchr(*ppuser,'/');
strchr(*ppuser,'\\')
*/
return domainnm;
}
| +Priv | 0 | static char * check_for_domain(char **ppuser)
{
char * original_string;
char * usernm;
char * domainnm;
int original_len;
int len;
int i;
if(ppuser == NULL)
return NULL;
original_string = *ppuser;
if (original_string == NULL)
return NULL;
original_len = strlen(original_string);
usernm = strchr(*ppuser,'/');
if (usernm == NULL) {
usernm = strchr(*ppuser,'\\');
if (usernm == NULL)
return NULL;
}
if(got_domain) {
fprintf(stderr, "Domain name specified twice. Username probably malformed\n");
return NULL;
}
usernm[0] = 0;
domainnm = *ppuser;
if (domainnm[0] != 0) {
got_domain = 1;
} else {
fprintf(stderr, "null domain\n");
}
len = strlen(domainnm);
/* reset domainm to new buffer, and copy
domain name into it */
domainnm = (char *)malloc(len+1);
if(domainnm == NULL)
return NULL;
strlcpy(domainnm,*ppuser,len+1);
/* move_string(*ppuser, usernm+1) */
len = strlen(usernm+1);
if(len >= original_len) {
/* should not happen */
return domainnm;
}
for(i=0;i<original_len;i++) {
if(i<len)
original_string[i] = usernm[i+1];
else /* stuff with commas to remove last parm */
original_string[i] = ',';
}
/* BB add check for more than one slash?
strchr(*ppuser,'/');
strchr(*ppuser,'\\')
*/
return domainnm;
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,939 | check_fstab(const char *progname, char *mountpoint, char *devname,
char **options)
{
FILE *fstab;
struct mntent *mnt;
/* make sure this mount is listed in /etc/fstab */
fstab = setmntent(_PATH_FSTAB, "r");
if (!fstab) {
fprintf(stderr, "Couldn't open %s for reading!\n",
_PATH_FSTAB);
return EX_FILEIO;
}
while((mnt = getmntent(fstab))) {
if (!strcmp(mountpoint, mnt->mnt_dir))
break;
}
endmntent(fstab);
if (mnt == NULL || strcmp(mnt->mnt_fsname, devname)) {
fprintf(stderr, "%s: permission denied: no match for "
"%s found in %s\n", progname, mountpoint,
_PATH_FSTAB);
return EX_USAGE;
}
/*
* 'mount' munges the options from fstab before passing them
* to us. It is non-trivial to test that we have the correct
* set of options. We don't want to trust what the user
* gave us, so just take whatever is in /etc/fstab.
*/
free(*options);
*options = strdup(mnt->mnt_opts);
return 0;
}
| +Priv | 0 | check_fstab(const char *progname, char *mountpoint, char *devname,
char **options)
{
FILE *fstab;
struct mntent *mnt;
/* make sure this mount is listed in /etc/fstab */
fstab = setmntent(_PATH_FSTAB, "r");
if (!fstab) {
fprintf(stderr, "Couldn't open %s for reading!\n",
_PATH_FSTAB);
return EX_FILEIO;
}
while((mnt = getmntent(fstab))) {
if (!strcmp(mountpoint, mnt->mnt_dir))
break;
}
endmntent(fstab);
if (mnt == NULL || strcmp(mnt->mnt_fsname, devname)) {
fprintf(stderr, "%s: permission denied: no match for "
"%s found in %s\n", progname, mountpoint,
_PATH_FSTAB);
return EX_USAGE;
}
/*
* 'mount' munges the options from fstab before passing them
* to us. It is non-trivial to test that we have the correct
* set of options. We don't want to trust what the user
* gave us, so just take whatever is in /etc/fstab.
*/
free(*options);
*options = strdup(mnt->mnt_opts);
return 0;
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,940 | static int get_password_from_file(int file_descript, char * filename)
{
int rc = 0;
int i;
char c;
if(mountpassword == NULL)
mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1);
else
memset(mountpassword, 0, MOUNT_PASSWD_SIZE);
if (mountpassword == NULL) {
fprintf(stderr, "malloc failed\n");
exit(EX_SYSERR);
}
if(filename != NULL) {
rc = access(filename, R_OK);
if (rc) {
fprintf(stderr, "mount.cifs failed: access check of %s failed: %s\n",
filename, strerror(errno));
exit(EX_SYSERR);
}
file_descript = open(filename, O_RDONLY);
if(file_descript < 0) {
fprintf(stderr, "mount.cifs failed. %s attempting to open password file %s\n",
strerror(errno),filename);
exit(EX_SYSERR);
}
}
/* else file already open and fd provided */
for(i=0;i<MOUNT_PASSWD_SIZE;i++) {
rc = read(file_descript,&c,1);
if(rc < 0) {
fprintf(stderr, "mount.cifs failed. Error %s reading password file\n",strerror(errno));
if(filename != NULL)
close(file_descript);
exit(EX_SYSERR);
} else if(rc == 0) {
if(mountpassword[0] == 0) {
if(verboseflag)
fprintf(stderr, "\nWarning: null password used since cifs password file empty");
}
break;
} else /* read valid character */ {
if((c == 0) || (c == '\n')) {
mountpassword[i] = '\0';
break;
} else
mountpassword[i] = c;
}
}
if((i == MOUNT_PASSWD_SIZE) && (verboseflag)) {
fprintf(stderr, "\nWarning: password longer than %d characters specified in cifs password file",
MOUNT_PASSWD_SIZE);
}
got_password = 1;
if(filename != NULL) {
close(file_descript);
}
return rc;
}
| +Priv | 0 | static int get_password_from_file(int file_descript, char * filename)
{
int rc = 0;
int i;
char c;
if(mountpassword == NULL)
mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1);
else
memset(mountpassword, 0, MOUNT_PASSWD_SIZE);
if (mountpassword == NULL) {
fprintf(stderr, "malloc failed\n");
exit(EX_SYSERR);
}
if(filename != NULL) {
rc = access(filename, R_OK);
if (rc) {
fprintf(stderr, "mount.cifs failed: access check of %s failed: %s\n",
filename, strerror(errno));
exit(EX_SYSERR);
}
file_descript = open(filename, O_RDONLY);
if(file_descript < 0) {
fprintf(stderr, "mount.cifs failed. %s attempting to open password file %s\n",
strerror(errno),filename);
exit(EX_SYSERR);
}
}
/* else file already open and fd provided */
for(i=0;i<MOUNT_PASSWD_SIZE;i++) {
rc = read(file_descript,&c,1);
if(rc < 0) {
fprintf(stderr, "mount.cifs failed. Error %s reading password file\n",strerror(errno));
if(filename != NULL)
close(file_descript);
exit(EX_SYSERR);
} else if(rc == 0) {
if(mountpassword[0] == 0) {
if(verboseflag)
fprintf(stderr, "\nWarning: null password used since cifs password file empty");
}
break;
} else /* read valid character */ {
if((c == 0) || (c == '\n')) {
mountpassword[i] = '\0';
break;
} else
mountpassword[i] = c;
}
}
if((i == MOUNT_PASSWD_SIZE) && (verboseflag)) {
fprintf(stderr, "\nWarning: password longer than %d characters specified in cifs password file",
MOUNT_PASSWD_SIZE);
}
got_password = 1;
if(filename != NULL) {
close(file_descript);
}
return rc;
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,941 | static char * getusername(void) {
char *username = NULL;
struct passwd *password = getpwuid(getuid());
if (password) {
username = password->pw_name;
}
return username;
}
| +Priv | 0 | static char * getusername(void) {
char *username = NULL;
struct passwd *password = getpwuid(getuid());
if (password) {
username = password->pw_name;
}
return username;
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,942 | static void mount_cifs_usage(FILE *stream)
{
fprintf(stream, "\nUsage: %s <remotetarget> <dir> -o <options>\n", thisprogram);
fprintf(stream, "\nMount the remote target, specified as a UNC name,");
fprintf(stream, " to a local directory.\n\nOptions:\n");
fprintf(stream, "\tuser=<arg>\n\tpass=<arg>\n\tdom=<arg>\n");
fprintf(stream, "\nLess commonly used options:");
fprintf(stream, "\n\tcredentials=<filename>,guest,perm,noperm,setuids,nosetuids,rw,ro,");
fprintf(stream, "\n\tsep=<char>,iocharset=<codepage>,suid,nosuid,exec,noexec,serverino,");
fprintf(stream, "\n\tmapchars,nomapchars,nolock,servernetbiosname=<SRV_RFC1001NAME>");
fprintf(stream, "\n\tdirectio,nounix,cifsacl,sec=<authentication mechanism>,sign");
fprintf(stream, "\n\nOptions not needed for servers supporting CIFS Unix extensions");
fprintf(stream, "\n\t(e.g. unneeded for mounts to most Samba versions):");
fprintf(stream, "\n\tuid=<uid>,gid=<gid>,dir_mode=<mode>,file_mode=<mode>,sfu");
fprintf(stream, "\n\nRarely used options:");
fprintf(stream, "\n\tport=<tcpport>,rsize=<size>,wsize=<size>,unc=<unc_name>,ip=<ip_address>,");
fprintf(stream, "\n\tdev,nodev,nouser_xattr,netbiosname=<OUR_RFC1001NAME>,hard,soft,intr,");
fprintf(stream, "\n\tnointr,ignorecase,noposixpaths,noacl,prefixpath=<path>,nobrl");
fprintf(stream, "\n\nOptions are described in more detail in the manual page");
fprintf(stream, "\n\tman 8 mount.cifs\n");
fprintf(stream, "\nTo display the version number of the mount helper:");
fprintf(stream, "\n\t%s -V\n",thisprogram);
SAFE_FREE(mountpassword);
if (stream == stderr)
exit(EX_USAGE);
exit(0);
}
| +Priv | 0 | static void mount_cifs_usage(FILE *stream)
{
fprintf(stream, "\nUsage: %s <remotetarget> <dir> -o <options>\n", thisprogram);
fprintf(stream, "\nMount the remote target, specified as a UNC name,");
fprintf(stream, " to a local directory.\n\nOptions:\n");
fprintf(stream, "\tuser=<arg>\n\tpass=<arg>\n\tdom=<arg>\n");
fprintf(stream, "\nLess commonly used options:");
fprintf(stream, "\n\tcredentials=<filename>,guest,perm,noperm,setuids,nosetuids,rw,ro,");
fprintf(stream, "\n\tsep=<char>,iocharset=<codepage>,suid,nosuid,exec,noexec,serverino,");
fprintf(stream, "\n\tmapchars,nomapchars,nolock,servernetbiosname=<SRV_RFC1001NAME>");
fprintf(stream, "\n\tdirectio,nounix,cifsacl,sec=<authentication mechanism>,sign");
fprintf(stream, "\n\nOptions not needed for servers supporting CIFS Unix extensions");
fprintf(stream, "\n\t(e.g. unneeded for mounts to most Samba versions):");
fprintf(stream, "\n\tuid=<uid>,gid=<gid>,dir_mode=<mode>,file_mode=<mode>,sfu");
fprintf(stream, "\n\nRarely used options:");
fprintf(stream, "\n\tport=<tcpport>,rsize=<size>,wsize=<size>,unc=<unc_name>,ip=<ip_address>,");
fprintf(stream, "\n\tdev,nodev,nouser_xattr,netbiosname=<OUR_RFC1001NAME>,hard,soft,intr,");
fprintf(stream, "\n\tnointr,ignorecase,noposixpaths,noacl,prefixpath=<path>,nobrl");
fprintf(stream, "\n\nOptions are described in more detail in the manual page");
fprintf(stream, "\n\tman 8 mount.cifs\n");
fprintf(stream, "\nTo display the version number of the mount helper:");
fprintf(stream, "\n\t%s -V\n",thisprogram);
SAFE_FREE(mountpassword);
if (stream == stderr)
exit(EX_USAGE);
exit(0);
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,943 | static int open_cred_file(char * file_name)
{
char * line_buf;
char * temp_val;
FILE * fs;
int i, length;
i = access(file_name, R_OK);
if (i)
return i;
fs = fopen(file_name,"r");
if(fs == NULL)
return errno;
line_buf = (char *)malloc(4096);
if(line_buf == NULL) {
fclose(fs);
return ENOMEM;
}
while(fgets(line_buf,4096,fs)) {
/* parse line from credential file */
/* eat leading white space */
for(i=0;i<4086;i++) {
if((line_buf[i] != ' ') && (line_buf[i] != '\t'))
break;
/* if whitespace - skip past it */
}
if (strncasecmp("username",line_buf+i,8) == 0) {
temp_val = strchr(line_buf + i,'=');
if(temp_val) {
/* go past equals sign */
temp_val++;
for(length = 0;length<4087;length++) {
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
temp_val[length] = '\0';
break;
}
}
if(length > 4086) {
fprintf(stderr, "mount.cifs failed due to malformed username in credentials file\n");
memset(line_buf,0,4096);
exit(EX_USAGE);
} else {
got_user = 1;
user_name = (char *)calloc(1 + length,1);
/* BB adding free of user_name string before exit,
not really necessary but would be cleaner */
strlcpy(user_name,temp_val, length+1);
}
}
} else if (strncasecmp("password",line_buf+i,8) == 0) {
temp_val = strchr(line_buf+i,'=');
if(temp_val) {
/* go past equals sign */
temp_val++;
for(length = 0;length<MOUNT_PASSWD_SIZE+1;length++) {
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
temp_val[length] = '\0';
break;
}
}
if(length > MOUNT_PASSWD_SIZE) {
fprintf(stderr, "mount.cifs failed: password in credentials file too long\n");
memset(line_buf,0, 4096);
exit(EX_USAGE);
} else {
if(mountpassword == NULL) {
mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1);
} else
memset(mountpassword,0,MOUNT_PASSWD_SIZE);
if(mountpassword) {
strlcpy(mountpassword,temp_val,MOUNT_PASSWD_SIZE+1);
got_password = 1;
}
}
}
} else if (strncasecmp("domain",line_buf+i,6) == 0) {
temp_val = strchr(line_buf+i,'=');
if(temp_val) {
/* go past equals sign */
temp_val++;
if(verboseflag)
fprintf(stderr, "\nDomain %s\n",temp_val);
for(length = 0;length<DOMAIN_SIZE+1;length++) {
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
temp_val[length] = '\0';
break;
}
}
if(length > DOMAIN_SIZE) {
fprintf(stderr, "mount.cifs failed: domain in credentials file too long\n");
exit(EX_USAGE);
} else {
if(domain_name == NULL) {
domain_name = (char *)calloc(DOMAIN_SIZE+1,1);
} else
memset(domain_name,0,DOMAIN_SIZE);
if(domain_name) {
strlcpy(domain_name,temp_val,DOMAIN_SIZE+1);
got_domain = 1;
}
}
}
}
}
fclose(fs);
SAFE_FREE(line_buf);
return 0;
}
| +Priv | 0 | static int open_cred_file(char * file_name)
{
char * line_buf;
char * temp_val;
FILE * fs;
int i, length;
i = access(file_name, R_OK);
if (i)
return i;
fs = fopen(file_name,"r");
if(fs == NULL)
return errno;
line_buf = (char *)malloc(4096);
if(line_buf == NULL) {
fclose(fs);
return ENOMEM;
}
while(fgets(line_buf,4096,fs)) {
/* parse line from credential file */
/* eat leading white space */
for(i=0;i<4086;i++) {
if((line_buf[i] != ' ') && (line_buf[i] != '\t'))
break;
/* if whitespace - skip past it */
}
if (strncasecmp("username",line_buf+i,8) == 0) {
temp_val = strchr(line_buf + i,'=');
if(temp_val) {
/* go past equals sign */
temp_val++;
for(length = 0;length<4087;length++) {
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
temp_val[length] = '\0';
break;
}
}
if(length > 4086) {
fprintf(stderr, "mount.cifs failed due to malformed username in credentials file\n");
memset(line_buf,0,4096);
exit(EX_USAGE);
} else {
got_user = 1;
user_name = (char *)calloc(1 + length,1);
/* BB adding free of user_name string before exit,
not really necessary but would be cleaner */
strlcpy(user_name,temp_val, length+1);
}
}
} else if (strncasecmp("password",line_buf+i,8) == 0) {
temp_val = strchr(line_buf+i,'=');
if(temp_val) {
/* go past equals sign */
temp_val++;
for(length = 0;length<MOUNT_PASSWD_SIZE+1;length++) {
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
temp_val[length] = '\0';
break;
}
}
if(length > MOUNT_PASSWD_SIZE) {
fprintf(stderr, "mount.cifs failed: password in credentials file too long\n");
memset(line_buf,0, 4096);
exit(EX_USAGE);
} else {
if(mountpassword == NULL) {
mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1);
} else
memset(mountpassword,0,MOUNT_PASSWD_SIZE);
if(mountpassword) {
strlcpy(mountpassword,temp_val,MOUNT_PASSWD_SIZE+1);
got_password = 1;
}
}
}
} else if (strncasecmp("domain",line_buf+i,6) == 0) {
temp_val = strchr(line_buf+i,'=');
if(temp_val) {
/* go past equals sign */
temp_val++;
if(verboseflag)
fprintf(stderr, "\nDomain %s\n",temp_val);
for(length = 0;length<DOMAIN_SIZE+1;length++) {
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
temp_val[length] = '\0';
break;
}
}
if(length > DOMAIN_SIZE) {
fprintf(stderr, "mount.cifs failed: domain in credentials file too long\n");
exit(EX_USAGE);
} else {
if(domain_name == NULL) {
domain_name = (char *)calloc(DOMAIN_SIZE+1,1);
} else
memset(domain_name,0,DOMAIN_SIZE);
if(domain_name) {
strlcpy(domain_name,temp_val,DOMAIN_SIZE+1);
got_domain = 1;
}
}
}
}
}
fclose(fs);
SAFE_FREE(line_buf);
return 0;
}
| @@ -178,7 +178,7 @@ check_mountpoint(const char *progname, char *mountpoint)
struct stat statbuf;
/* does mountpoint exist and is it a directory? */
- err = stat(mountpoint, &statbuf);
+ err = stat(".", &statbuf);
if (err) {
fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
mountpoint, strerror(errno));
@@ -1377,6 +1377,14 @@ int main(int argc, char ** argv)
}
/* make sure mountpoint is legit */
+ rc = chdir(mountpoint);
+ if (rc) {
+ fprintf(stderr, "Couldn't chdir to %s: %s\n", mountpoint,
+ strerror(errno));
+ rc = EX_USAGE;
+ goto mount_exit;
+ }
+
rc = check_mountpoint(thisprogram, mountpoint);
if (rc)
goto mount_exit;
@@ -1439,13 +1447,23 @@ int main(int argc, char ** argv)
/* BB save off path and pop after mount returns? */
resolved_path = (char *)malloc(PATH_MAX+1);
- if(resolved_path) {
- /* Note that if we can not canonicalize the name, we get
- another chance to see if it is valid when we chdir to it */
- if (realpath(mountpoint, resolved_path)) {
- mountpoint = resolved_path;
- }
+ if (!resolved_path) {
+ fprintf(stderr, "Unable to allocate memory.\n");
+ rc = EX_SYSERR;
+ goto mount_exit;
}
+
+ /* Note that if we can not canonicalize the name, we get
+ another chance to see if it is valid when we chdir to it */
+ if(!realpath(".", resolved_path)) {
+ fprintf(stderr, "Unable to resolve %s to canonical path: %s\n",
+ mountpoint, strerror(errno));
+ rc = EX_SYSERR;
+ goto mount_exit;
+ }
+
+ mountpoint = resolved_path;
+
if(got_user == 0) {
/* Note that the password will not be retrieved from the
USER env variable (ie user%password form) as there is
@@ -1589,7 +1607,7 @@ mount_retry:
if (verboseflag)
fprintf(stderr, "\n");
- if (!fakemnt && mount(dev_name, mountpoint, cifs_fstype, flags, options)) {
+ if (!fakemnt && mount(dev_name, ".", cifs_fstype, flags, options)) {
switch (errno) {
case ECONNREFUSED:
case EHOSTUNREACH: | CWE-59 | null | null |
9,944 | static int tls12_find_nid(int id, tls12_lookup *table, size_t tlen)
{
size_t i;
for (i = 0; i < tlen; i++)
{
if (table[i].id == id)
return table[i].nid;
}
return -1;
}
| DoS | 0 | static int tls12_find_nid(int id, tls12_lookup *table, size_t tlen)
{
size_t i;
for (i = 0; i < tlen; i++)
{
if (table[i].id == id)
return table[i].nid;
}
return -1;
}
| @@ -643,7 +643,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned c
#endif
#ifndef OPENSSL_NO_SRTP
- if(SSL_get_srtp_profiles(s))
+ if(SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s))
{
int el;
@@ -806,7 +806,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned c
#endif
#ifndef OPENSSL_NO_SRTP
- if(s->srtp_profile)
+ if(SSL_IS_DTLS(s) && s->srtp_profile)
{
int el;
@@ -1444,7 +1444,8 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in
/* session ticket processed earlier */
#ifndef OPENSSL_NO_SRTP
- else if (type == TLSEXT_TYPE_use_srtp)
+ else if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s)
+ && type == TLSEXT_TYPE_use_srtp)
{
if(ssl_parse_clienthello_use_srtp_ext(s, data, size,
al))
@@ -1698,7 +1699,7 @@ int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in
}
#endif
#ifndef OPENSSL_NO_SRTP
- else if (type == TLSEXT_TYPE_use_srtp)
+ else if (SSL_IS_DTLS(s) && type == TLSEXT_TYPE_use_srtp)
{
if(ssl_parse_serverhello_use_srtp_ext(s, data, size,
al)) | CWE-20 | null | null |
9,945 | BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g)
{
BN_CTX *bn_ctx;
BIGNUM * A = NULL;
if (a == NULL || N == NULL || g == NULL ||
(bn_ctx = BN_CTX_new()) == NULL)
return NULL;
if ((A = BN_new()) != NULL &&
!BN_mod_exp(A,g,a,N,bn_ctx))
{
BN_free(A);
A = NULL;
}
BN_CTX_free(bn_ctx);
return A;
}
| DoS Overflow | 0 | BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g)
{
BN_CTX *bn_ctx;
BIGNUM * A = NULL;
if (a == NULL || N == NULL || g == NULL ||
(bn_ctx = BN_CTX_new()) == NULL)
return NULL;
if ((A = BN_new()) != NULL &&
!BN_mod_exp(A,g,a,N,bn_ctx))
{
BN_free(A);
A = NULL;
}
BN_CTX_free(bn_ctx);
return A;
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,946 | BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x, BIGNUM *a, BIGNUM *u)
{
BIGNUM *tmp = NULL, *tmp2 = NULL, *tmp3 = NULL , *k = NULL, *K = NULL;
BN_CTX *bn_ctx;
if (u == NULL || B == NULL || N == NULL || g == NULL || x == NULL || a == NULL ||
(bn_ctx = BN_CTX_new()) == NULL)
return NULL;
if ((tmp = BN_new()) == NULL ||
(tmp2 = BN_new())== NULL ||
(tmp3 = BN_new())== NULL ||
(K = BN_new()) == NULL)
goto err;
if (!BN_mod_exp(tmp,g,x,N,bn_ctx))
goto err;
if (!(k = srp_Calc_k(N,g)))
goto err;
if (!BN_mod_mul(tmp2,tmp,k,N,bn_ctx))
goto err;
if (!BN_mod_sub(tmp,B,tmp2,N,bn_ctx))
goto err;
if (!BN_mod_mul(tmp3,u,x,N,bn_ctx))
goto err;
if (!BN_mod_add(tmp2,a,tmp3,N,bn_ctx))
goto err;
if (!BN_mod_exp(K,tmp,tmp2,N,bn_ctx))
goto err;
err :
BN_CTX_free(bn_ctx);
BN_clear_free(tmp);
BN_clear_free(tmp2);
BN_clear_free(tmp3);
BN_free(k);
return K;
}
| DoS Overflow | 0 | BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x, BIGNUM *a, BIGNUM *u)
{
BIGNUM *tmp = NULL, *tmp2 = NULL, *tmp3 = NULL , *k = NULL, *K = NULL;
BN_CTX *bn_ctx;
if (u == NULL || B == NULL || N == NULL || g == NULL || x == NULL || a == NULL ||
(bn_ctx = BN_CTX_new()) == NULL)
return NULL;
if ((tmp = BN_new()) == NULL ||
(tmp2 = BN_new())== NULL ||
(tmp3 = BN_new())== NULL ||
(K = BN_new()) == NULL)
goto err;
if (!BN_mod_exp(tmp,g,x,N,bn_ctx))
goto err;
if (!(k = srp_Calc_k(N,g)))
goto err;
if (!BN_mod_mul(tmp2,tmp,k,N,bn_ctx))
goto err;
if (!BN_mod_sub(tmp,B,tmp2,N,bn_ctx))
goto err;
if (!BN_mod_mul(tmp3,u,x,N,bn_ctx))
goto err;
if (!BN_mod_add(tmp2,a,tmp3,N,bn_ctx))
goto err;
if (!BN_mod_exp(K,tmp,tmp2,N,bn_ctx))
goto err;
err :
BN_CTX_free(bn_ctx);
BN_clear_free(tmp);
BN_clear_free(tmp2);
BN_clear_free(tmp3);
BN_free(k);
return K;
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,947 | BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b, BIGNUM *N)
{
BIGNUM *tmp = NULL, *S = NULL;
BN_CTX *bn_ctx;
if (u == NULL || A == NULL || v == NULL || b == NULL || N == NULL)
return NULL;
if ((bn_ctx = BN_CTX_new()) == NULL ||
(tmp = BN_new()) == NULL ||
(S = BN_new()) == NULL )
goto err;
/* S = (A*v**u) ** b */
if (!BN_mod_exp(tmp,v,u,N,bn_ctx))
goto err;
if (!BN_mod_mul(tmp,A,tmp,N,bn_ctx))
goto err;
if (!BN_mod_exp(S,tmp,b,N,bn_ctx))
goto err;
err:
BN_CTX_free(bn_ctx);
BN_clear_free(tmp);
return S;
}
| DoS Overflow | 0 | BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b, BIGNUM *N)
{
BIGNUM *tmp = NULL, *S = NULL;
BN_CTX *bn_ctx;
if (u == NULL || A == NULL || v == NULL || b == NULL || N == NULL)
return NULL;
if ((bn_ctx = BN_CTX_new()) == NULL ||
(tmp = BN_new()) == NULL ||
(S = BN_new()) == NULL )
goto err;
/* S = (A*v**u) ** b */
if (!BN_mod_exp(tmp,v,u,N,bn_ctx))
goto err;
if (!BN_mod_mul(tmp,A,tmp,N,bn_ctx))
goto err;
if (!BN_mod_exp(S,tmp,b,N,bn_ctx))
goto err;
err:
BN_CTX_free(bn_ctx);
BN_clear_free(tmp);
return S;
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,948 | BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
{
unsigned char dig[SHA_DIGEST_LENGTH];
EVP_MD_CTX ctxt;
unsigned char *cs;
if ((s == NULL) ||
(user == NULL) ||
(pass == NULL))
return NULL;
if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
return NULL;
EVP_MD_CTX_init(&ctxt);
EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
EVP_DigestUpdate(&ctxt, user, strlen(user));
EVP_DigestUpdate(&ctxt, ":", 1);
EVP_DigestUpdate(&ctxt, pass, strlen(pass));
EVP_DigestFinal_ex(&ctxt, dig, NULL);
EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
BN_bn2bin(s,cs);
EVP_DigestUpdate(&ctxt, cs, BN_num_bytes(s));
OPENSSL_free(cs);
EVP_DigestUpdate(&ctxt, dig, sizeof(dig));
EVP_DigestFinal_ex(&ctxt, dig, NULL);
EVP_MD_CTX_cleanup(&ctxt);
return BN_bin2bn(dig, sizeof(dig), NULL);
}
| DoS Overflow | 0 | BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
{
unsigned char dig[SHA_DIGEST_LENGTH];
EVP_MD_CTX ctxt;
unsigned char *cs;
if ((s == NULL) ||
(user == NULL) ||
(pass == NULL))
return NULL;
if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
return NULL;
EVP_MD_CTX_init(&ctxt);
EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
EVP_DigestUpdate(&ctxt, user, strlen(user));
EVP_DigestUpdate(&ctxt, ":", 1);
EVP_DigestUpdate(&ctxt, pass, strlen(pass));
EVP_DigestFinal_ex(&ctxt, dig, NULL);
EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
BN_bn2bin(s,cs);
EVP_DigestUpdate(&ctxt, cs, BN_num_bytes(s));
OPENSSL_free(cs);
EVP_DigestUpdate(&ctxt, dig, sizeof(dig));
EVP_DigestFinal_ex(&ctxt, dig, NULL);
EVP_MD_CTX_cleanup(&ctxt);
return BN_bin2bn(dig, sizeof(dig), NULL);
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,949 | int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N)
{
BIGNUM *r;
BN_CTX *bn_ctx;
int ret = 0;
if (B == NULL || N == NULL ||
(bn_ctx = BN_CTX_new()) == NULL)
return 0;
if ((r = BN_new()) == NULL)
goto err;
/* Checks if B % N == 0 */
if (!BN_nnmod(r,B,N,bn_ctx))
goto err;
ret = !BN_is_zero(r);
err:
BN_CTX_free(bn_ctx);
BN_free(r);
return ret;
}
| DoS Overflow | 0 | int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N)
{
BIGNUM *r;
BN_CTX *bn_ctx;
int ret = 0;
if (B == NULL || N == NULL ||
(bn_ctx = BN_CTX_new()) == NULL)
return 0;
if ((r = BN_new()) == NULL)
goto err;
/* Checks if B % N == 0 */
if (!BN_nnmod(r,B,N,bn_ctx))
goto err;
ret = !BN_is_zero(r);
err:
BN_CTX_free(bn_ctx);
BN_free(r);
return ret;
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,950 | char * SRP_check_known_gN_param(BIGNUM* g, BIGNUM* N)
{
size_t i;
if ((g == NULL) || (N == NULL))
return 0;
srp_bn_print(g);
srp_bn_print(N);
for(i = 0; i < KNOWN_GN_NUMBER; i++)
{
if (BN_cmp(knowngN[i].g, g) == 0 && BN_cmp(knowngN[i].N, N) == 0)
return knowngN[i].id;
}
return NULL;
}
| DoS Overflow | 0 | char * SRP_check_known_gN_param(BIGNUM* g, BIGNUM* N)
{
size_t i;
if ((g == NULL) || (N == NULL))
return 0;
srp_bn_print(g);
srp_bn_print(N);
for(i = 0; i < KNOWN_GN_NUMBER; i++)
{
if (BN_cmp(knowngN[i].g, g) == 0 && BN_cmp(knowngN[i].N, N) == 0)
return knowngN[i].id;
}
return NULL;
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,951 | SRP_gN *SRP_get_default_gN(const char *id)
{
size_t i;
if (id == NULL)
return knowngN;
for(i = 0; i < KNOWN_GN_NUMBER; i++)
{
if (strcmp(knowngN[i].id, id)==0)
return knowngN + i;
}
return NULL;
}
| DoS Overflow | 0 | SRP_gN *SRP_get_default_gN(const char *id)
{
size_t i;
if (id == NULL)
return knowngN;
for(i = 0; i < KNOWN_GN_NUMBER; i++)
{
if (strcmp(knowngN[i].id, id)==0)
return knowngN + i;
}
return NULL;
}
| @@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
int longg ;
int longN = BN_num_bytes(N);
+ if (BN_ucmp(g, N) >= 0)
+ return NULL;
+
if ((tmp = OPENSSL_malloc(longN)) == NULL)
return NULL;
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
if ((A == NULL) ||(B == NULL) || (N == NULL))
return NULL;
+ if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
+ return NULL;
+
longN= BN_num_bytes(N);
if ((cAB = OPENSSL_malloc(2*longN)) == NULL) | CWE-119 | null | null |
9,952 | int ssl_cipher_disabled(SSL *s, const SSL_CIPHER *c, int op)
{
CERT *ct = s->cert;
if (c->algorithm_ssl & ct->mask_ssl || c->algorithm_mkey & ct->mask_k || c->algorithm_auth & ct->mask_a)
return 1;
return !ssl_security(s, op, c->strength_bits, 0, (void *)c);
}
| DoS | 0 | int ssl_cipher_disabled(SSL *s, const SSL_CIPHER *c, int op)
{
CERT *ct = s->cert;
if (c->algorithm_ssl & ct->mask_ssl || c->algorithm_mkey & ct->mask_k || c->algorithm_auth & ct->mask_a)
return 1;
return !ssl_security(s, op, c->strength_bits, 0, (void *)c);
}
| @@ -2647,15 +2647,18 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char
*al = TLS1_AD_DECODE_ERROR;
return 0;
}
- s->session->tlsext_ecpointformatlist_length = 0;
- if (s->session->tlsext_ecpointformatlist != NULL) OPENSSL_free(s->session->tlsext_ecpointformatlist);
- if ((s->session->tlsext_ecpointformatlist = OPENSSL_malloc(ecpointformatlist_length)) == NULL)
+ if (!s->hit)
{
- *al = TLS1_AD_INTERNAL_ERROR;
- return 0;
+ s->session->tlsext_ecpointformatlist_length = 0;
+ if (s->session->tlsext_ecpointformatlist != NULL) OPENSSL_free(s->session->tlsext_ecpointformatlist);
+ if ((s->session->tlsext_ecpointformatlist = OPENSSL_malloc(ecpointformatlist_length)) == NULL)
+ {
+ *al = TLS1_AD_INTERNAL_ERROR;
+ return 0;
+ }
+ s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length;
+ memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length);
}
- s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length;
- memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length);
#if 0
fprintf(stderr,"ssl_parse_serverhello_tlsext s->session->tlsext_ecpointformatlist ");
sdata = s->session->tlsext_ecpointformatlist; | CWE-362 | null | null |
9,953 | void ssl_set_client_disabled(SSL *s)
{
CERT *c = s->cert;
c->mask_a = 0;
c->mask_k = 0;
/* Don't allow TLS 1.2 only ciphers if we don't suppport them */
if (!SSL_CLIENT_USE_TLS1_2_CIPHERS(s))
c->mask_ssl = SSL_TLSV1_2;
else
c->mask_ssl = 0;
ssl_set_sig_mask(&c->mask_a, s, SSL_SECOP_SIGALG_MASK);
/* Disable static DH if we don't include any appropriate
* signature algorithms.
*/
if (c->mask_a & SSL_aRSA)
c->mask_k |= SSL_kDHr|SSL_kECDHr;
if (c->mask_a & SSL_aDSS)
c->mask_k |= SSL_kDHd;
if (c->mask_a & SSL_aECDSA)
c->mask_k |= SSL_kECDHe;
#ifndef OPENSSL_NO_KRB5
if (!kssl_tgt_is_available(s->kssl_ctx))
{
c->mask_a |= SSL_aKRB5;
c->mask_k |= SSL_kKRB5;
}
#endif
#ifndef OPENSSL_NO_PSK
/* with PSK there must be client callback set */
if (!s->psk_client_callback)
{
c->mask_a |= SSL_aPSK;
c->mask_k |= SSL_kPSK;
}
#endif /* OPENSSL_NO_PSK */
c->valid = 1;
}
| DoS | 0 | void ssl_set_client_disabled(SSL *s)
{
CERT *c = s->cert;
c->mask_a = 0;
c->mask_k = 0;
/* Don't allow TLS 1.2 only ciphers if we don't suppport them */
if (!SSL_CLIENT_USE_TLS1_2_CIPHERS(s))
c->mask_ssl = SSL_TLSV1_2;
else
c->mask_ssl = 0;
ssl_set_sig_mask(&c->mask_a, s, SSL_SECOP_SIGALG_MASK);
/* Disable static DH if we don't include any appropriate
* signature algorithms.
*/
if (c->mask_a & SSL_aRSA)
c->mask_k |= SSL_kDHr|SSL_kECDHr;
if (c->mask_a & SSL_aDSS)
c->mask_k |= SSL_kDHd;
if (c->mask_a & SSL_aECDSA)
c->mask_k |= SSL_kECDHe;
#ifndef OPENSSL_NO_KRB5
if (!kssl_tgt_is_available(s->kssl_ctx))
{
c->mask_a |= SSL_aKRB5;
c->mask_k |= SSL_kKRB5;
}
#endif
#ifndef OPENSSL_NO_PSK
/* with PSK there must be client callback set */
if (!s->psk_client_callback)
{
c->mask_a |= SSL_aPSK;
c->mask_k |= SSL_kPSK;
}
#endif /* OPENSSL_NO_PSK */
c->valid = 1;
}
| @@ -2647,15 +2647,18 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char
*al = TLS1_AD_DECODE_ERROR;
return 0;
}
- s->session->tlsext_ecpointformatlist_length = 0;
- if (s->session->tlsext_ecpointformatlist != NULL) OPENSSL_free(s->session->tlsext_ecpointformatlist);
- if ((s->session->tlsext_ecpointformatlist = OPENSSL_malloc(ecpointformatlist_length)) == NULL)
+ if (!s->hit)
{
- *al = TLS1_AD_INTERNAL_ERROR;
- return 0;
+ s->session->tlsext_ecpointformatlist_length = 0;
+ if (s->session->tlsext_ecpointformatlist != NULL) OPENSSL_free(s->session->tlsext_ecpointformatlist);
+ if ((s->session->tlsext_ecpointformatlist = OPENSSL_malloc(ecpointformatlist_length)) == NULL)
+ {
+ *al = TLS1_AD_INTERNAL_ERROR;
+ return 0;
+ }
+ s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length;
+ memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length);
}
- s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length;
- memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length);
#if 0
fprintf(stderr,"ssl_parse_serverhello_tlsext s->session->tlsext_ecpointformatlist ");
sdata = s->session->tlsext_ecpointformatlist; | CWE-362 | null | null |
9,954 | int OBJ_add_object(const ASN1_OBJECT *obj)
{
ASN1_OBJECT *o;
ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
int i;
if (added == NULL)
if (!init_added()) return(0);
if ((o=OBJ_dup(obj)) == NULL) goto err;
if (!(ao[ADDED_NID]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
if ((o->length != 0) && (obj->data != NULL))
if (!(ao[ADDED_DATA]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
if (o->sn != NULL)
if (!(ao[ADDED_SNAME]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
if (o->ln != NULL)
if (!(ao[ADDED_LNAME]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
for (i=ADDED_DATA; i<=ADDED_NID; i++)
{
if (ao[i] != NULL)
{
ao[i]->type=i;
ao[i]->obj=o;
aop=lh_ADDED_OBJ_insert(added,ao[i]);
/* memory leak, buit should not normally matter */
if (aop != NULL)
OPENSSL_free(aop);
}
}
o->flags&= ~(ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
ASN1_OBJECT_FLAG_DYNAMIC_DATA);
return(o->nid);
err2:
OBJerr(OBJ_F_OBJ_ADD_OBJECT,ERR_R_MALLOC_FAILURE);
err:
for (i=ADDED_DATA; i<=ADDED_NID; i++)
if (ao[i] != NULL) OPENSSL_free(ao[i]);
if (o != NULL) OPENSSL_free(o);
return(NID_undef);
}
| +Info | 0 | int OBJ_add_object(const ASN1_OBJECT *obj)
{
ASN1_OBJECT *o;
ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
int i;
if (added == NULL)
if (!init_added()) return(0);
if ((o=OBJ_dup(obj)) == NULL) goto err;
if (!(ao[ADDED_NID]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
if ((o->length != 0) && (obj->data != NULL))
if (!(ao[ADDED_DATA]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
if (o->sn != NULL)
if (!(ao[ADDED_SNAME]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
if (o->ln != NULL)
if (!(ao[ADDED_LNAME]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err2;
for (i=ADDED_DATA; i<=ADDED_NID; i++)
{
if (ao[i] != NULL)
{
ao[i]->type=i;
ao[i]->obj=o;
aop=lh_ADDED_OBJ_insert(added,ao[i]);
/* memory leak, buit should not normally matter */
if (aop != NULL)
OPENSSL_free(aop);
}
}
o->flags&= ~(ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
ASN1_OBJECT_FLAG_DYNAMIC_DATA);
return(o->nid);
err2:
OBJerr(OBJ_F_OBJ_ADD_OBJECT,ERR_R_MALLOC_FAILURE);
err:
for (i=ADDED_DATA; i<=ADDED_NID; i++)
if (ao[i] != NULL) OPENSSL_free(ao[i]);
if (o != NULL) OPENSSL_free(o);
return(NID_undef);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,955 | void OBJ_cleanup(void)
{
if (obj_cleanup_defer)
{
obj_cleanup_defer = 2;
return ;
}
if (added == NULL) return;
lh_ADDED_OBJ_down_load(added) = 0;
lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
lh_ADDED_OBJ_free(added);
added=NULL;
}
| +Info | 0 | void OBJ_cleanup(void)
{
if (obj_cleanup_defer)
{
obj_cleanup_defer = 2;
return ;
}
if (added == NULL) return;
lh_ADDED_OBJ_down_load(added) = 0;
lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
lh_ADDED_OBJ_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
lh_ADDED_OBJ_free(added);
added=NULL;
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,956 | int OBJ_ln2nid(const char *s)
{
ASN1_OBJECT o;
const ASN1_OBJECT *oo= &o;
ADDED_OBJ ad,*adp;
const unsigned int *op;
o.ln=s;
if (added != NULL)
{
ad.type=ADDED_LNAME;
ad.obj= &o;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid);
}
op=OBJ_bsearch_ln(&oo, ln_objs, NUM_LN);
if (op == NULL) return(NID_undef);
return(nid_objs[*op].nid);
}
| +Info | 0 | int OBJ_ln2nid(const char *s)
{
ASN1_OBJECT o;
const ASN1_OBJECT *oo= &o;
ADDED_OBJ ad,*adp;
const unsigned int *op;
o.ln=s;
if (added != NULL)
{
ad.type=ADDED_LNAME;
ad.obj= &o;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid);
}
op=OBJ_bsearch_ln(&oo, ln_objs, NUM_LN);
if (op == NULL) return(NID_undef);
return(nid_objs[*op].nid);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,957 | int OBJ_new_nid(int num)
{
int i;
i=new_nid;
new_nid+=num;
return(i);
}
| +Info | 0 | int OBJ_new_nid(int num)
{
int i;
i=new_nid;
new_nid+=num;
return(i);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,958 | const char *OBJ_nid2ln(int n)
{
ADDED_OBJ ad,*adp;
ASN1_OBJECT ob;
if ((n >= 0) && (n < NUM_NID))
{
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
{
OBJerr(OBJ_F_OBJ_NID2LN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
return(nid_objs[n].ln);
}
else if (added == NULL)
return(NULL);
else
{
ad.type=ADDED_NID;
ad.obj= &ob;
ob.nid=n;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL)
return(adp->obj->ln);
else
{
OBJerr(OBJ_F_OBJ_NID2LN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
}
}
| +Info | 0 | const char *OBJ_nid2ln(int n)
{
ADDED_OBJ ad,*adp;
ASN1_OBJECT ob;
if ((n >= 0) && (n < NUM_NID))
{
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
{
OBJerr(OBJ_F_OBJ_NID2LN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
return(nid_objs[n].ln);
}
else if (added == NULL)
return(NULL);
else
{
ad.type=ADDED_NID;
ad.obj= &ob;
ob.nid=n;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL)
return(adp->obj->ln);
else
{
OBJerr(OBJ_F_OBJ_NID2LN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
}
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,959 | ASN1_OBJECT *OBJ_nid2obj(int n)
{
ADDED_OBJ ad,*adp;
ASN1_OBJECT ob;
if ((n >= 0) && (n < NUM_NID))
{
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
{
OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);
return(NULL);
}
return((ASN1_OBJECT *)&(nid_objs[n]));
}
else if (added == NULL)
return(NULL);
else
{
ad.type=ADDED_NID;
ad.obj= &ob;
ob.nid=n;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL)
return(adp->obj);
else
{
OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);
return(NULL);
}
}
}
| +Info | 0 | ASN1_OBJECT *OBJ_nid2obj(int n)
{
ADDED_OBJ ad,*adp;
ASN1_OBJECT ob;
if ((n >= 0) && (n < NUM_NID))
{
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
{
OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);
return(NULL);
}
return((ASN1_OBJECT *)&(nid_objs[n]));
}
else if (added == NULL)
return(NULL);
else
{
ad.type=ADDED_NID;
ad.obj= &ob;
ob.nid=n;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL)
return(adp->obj);
else
{
OBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);
return(NULL);
}
}
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,960 | const char *OBJ_nid2sn(int n)
{
ADDED_OBJ ad,*adp;
ASN1_OBJECT ob;
if ((n >= 0) && (n < NUM_NID))
{
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
{
OBJerr(OBJ_F_OBJ_NID2SN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
return(nid_objs[n].sn);
}
else if (added == NULL)
return(NULL);
else
{
ad.type=ADDED_NID;
ad.obj= &ob;
ob.nid=n;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL)
return(adp->obj->sn);
else
{
OBJerr(OBJ_F_OBJ_NID2SN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
}
}
| +Info | 0 | const char *OBJ_nid2sn(int n)
{
ADDED_OBJ ad,*adp;
ASN1_OBJECT ob;
if ((n >= 0) && (n < NUM_NID))
{
if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))
{
OBJerr(OBJ_F_OBJ_NID2SN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
return(nid_objs[n].sn);
}
else if (added == NULL)
return(NULL);
else
{
ad.type=ADDED_NID;
ad.obj= &ob;
ob.nid=n;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL)
return(adp->obj->sn);
else
{
OBJerr(OBJ_F_OBJ_NID2SN,OBJ_R_UNKNOWN_NID);
return(NULL);
}
}
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,961 | int OBJ_obj2nid(const ASN1_OBJECT *a)
{
const unsigned int *op;
ADDED_OBJ ad,*adp;
if (a == NULL)
return(NID_undef);
if (a->nid != 0)
return(a->nid);
if (added != NULL)
{
ad.type=ADDED_DATA;
ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid);
}
op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);
if (op == NULL)
return(NID_undef);
return(nid_objs[*op].nid);
}
| +Info | 0 | int OBJ_obj2nid(const ASN1_OBJECT *a)
{
const unsigned int *op;
ADDED_OBJ ad,*adp;
if (a == NULL)
return(NID_undef);
if (a->nid != 0)
return(a->nid);
if (added != NULL)
{
ad.type=ADDED_DATA;
ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid);
}
op=OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);
if (op == NULL)
return(NID_undef);
return(nid_objs[*op].nid);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,962 | int OBJ_sn2nid(const char *s)
{
ASN1_OBJECT o;
const ASN1_OBJECT *oo= &o;
ADDED_OBJ ad,*adp;
const unsigned int *op;
o.sn=s;
if (added != NULL)
{
ad.type=ADDED_SNAME;
ad.obj= &o;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid);
}
op=OBJ_bsearch_sn(&oo, sn_objs, NUM_SN);
if (op == NULL) return(NID_undef);
return(nid_objs[*op].nid);
}
| +Info | 0 | int OBJ_sn2nid(const char *s)
{
ASN1_OBJECT o;
const ASN1_OBJECT *oo= &o;
ADDED_OBJ ad,*adp;
const unsigned int *op;
o.sn=s;
if (added != NULL)
{
ad.type=ADDED_SNAME;
ad.obj= &o;
adp=lh_ADDED_OBJ_retrieve(added,&ad);
if (adp != NULL) return (adp->obj->nid);
}
op=OBJ_bsearch_sn(&oo, sn_objs, NUM_SN);
if (op == NULL) return(NID_undef);
return(nid_objs[*op].nid);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,963 | int OBJ_txt2nid(const char *s)
{
ASN1_OBJECT *obj;
int nid;
obj = OBJ_txt2obj(s, 0);
nid = OBJ_obj2nid(obj);
ASN1_OBJECT_free(obj);
return nid;
}
| +Info | 0 | int OBJ_txt2nid(const char *s)
{
ASN1_OBJECT *obj;
int nid;
obj = OBJ_txt2obj(s, 0);
nid = OBJ_obj2nid(obj);
ASN1_OBJECT_free(obj);
return nid;
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,964 | ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
{
int nid = NID_undef;
ASN1_OBJECT *op=NULL;
unsigned char *buf;
unsigned char *p;
const unsigned char *cp;
int i, j;
if(!no_name) {
if( ((nid = OBJ_sn2nid(s)) != NID_undef) ||
((nid = OBJ_ln2nid(s)) != NID_undef) )
return OBJ_nid2obj(nid);
}
/* Work out size of content octets */
i=a2d_ASN1_OBJECT(NULL,0,s,-1);
if (i <= 0) {
/* Don't clear the error */
/*ERR_clear_error();*/
return NULL;
}
/* Work out total size */
j = ASN1_object_size(0,i,V_ASN1_OBJECT);
if((buf=(unsigned char *)OPENSSL_malloc(j)) == NULL) return NULL;
p = buf;
/* Write out tag+length */
ASN1_put_object(&p,0,i,V_ASN1_OBJECT,V_ASN1_UNIVERSAL);
/* Write out contents */
a2d_ASN1_OBJECT(p,i,s,-1);
cp=buf;
op=d2i_ASN1_OBJECT(NULL,&cp,j);
OPENSSL_free(buf);
return op;
}
| +Info | 0 | ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
{
int nid = NID_undef;
ASN1_OBJECT *op=NULL;
unsigned char *buf;
unsigned char *p;
const unsigned char *cp;
int i, j;
if(!no_name) {
if( ((nid = OBJ_sn2nid(s)) != NID_undef) ||
((nid = OBJ_ln2nid(s)) != NID_undef) )
return OBJ_nid2obj(nid);
}
/* Work out size of content octets */
i=a2d_ASN1_OBJECT(NULL,0,s,-1);
if (i <= 0) {
/* Don't clear the error */
/*ERR_clear_error();*/
return NULL;
}
/* Work out total size */
j = ASN1_object_size(0,i,V_ASN1_OBJECT);
if((buf=(unsigned char *)OPENSSL_malloc(j)) == NULL) return NULL;
p = buf;
/* Write out tag+length */
ASN1_put_object(&p,0,i,V_ASN1_OBJECT,V_ASN1_UNIVERSAL);
/* Write out contents */
a2d_ASN1_OBJECT(p,i,s,-1);
cp=buf;
op=d2i_ASN1_OBJECT(NULL,&cp,j);
OPENSSL_free(buf);
return op;
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,965 | static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
{
ASN1_OBJECT *a,*b;
int i;
i=ca->type-cb->type;
if (i) return(i);
a=ca->obj;
b=cb->obj;
switch (ca->type)
{
case ADDED_DATA:
i=(a->length - b->length);
if (i) return(i);
return(memcmp(a->data,b->data,(size_t)a->length));
case ADDED_SNAME:
if (a->sn == NULL) return(-1);
else if (b->sn == NULL) return(1);
else return(strcmp(a->sn,b->sn));
case ADDED_LNAME:
if (a->ln == NULL) return(-1);
else if (b->ln == NULL) return(1);
else return(strcmp(a->ln,b->ln));
case ADDED_NID:
return(a->nid-b->nid);
default:
/* abort(); */
return 0;
}
}
| +Info | 0 | static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)
{
ASN1_OBJECT *a,*b;
int i;
i=ca->type-cb->type;
if (i) return(i);
a=ca->obj;
b=cb->obj;
switch (ca->type)
{
case ADDED_DATA:
i=(a->length - b->length);
if (i) return(i);
return(memcmp(a->data,b->data,(size_t)a->length));
case ADDED_SNAME:
if (a->sn == NULL) return(-1);
else if (b->sn == NULL) return(1);
else return(strcmp(a->sn,b->sn));
case ADDED_LNAME:
if (a->ln == NULL) return(-1);
else if (b->ln == NULL) return(1);
else return(strcmp(a->ln,b->ln));
case ADDED_NID:
return(a->nid-b->nid);
default:
/* abort(); */
return 0;
}
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,966 | static unsigned long added_obj_hash(const ADDED_OBJ *ca)
{
const ASN1_OBJECT *a;
int i;
unsigned long ret=0;
unsigned char *p;
a=ca->obj;
switch (ca->type)
{
case ADDED_DATA:
ret=a->length<<20L;
p=(unsigned char *)a->data;
for (i=0; i<a->length; i++)
ret^=p[i]<<((i*3)%24);
break;
case ADDED_SNAME:
ret=lh_strhash(a->sn);
break;
case ADDED_LNAME:
ret=lh_strhash(a->ln);
break;
case ADDED_NID:
ret=a->nid;
break;
default:
/* abort(); */
return 0;
}
ret&=0x3fffffffL;
ret|=((unsigned long)ca->type)<<30L;
return(ret);
}
| +Info | 0 | static unsigned long added_obj_hash(const ADDED_OBJ *ca)
{
const ASN1_OBJECT *a;
int i;
unsigned long ret=0;
unsigned char *p;
a=ca->obj;
switch (ca->type)
{
case ADDED_DATA:
ret=a->length<<20L;
p=(unsigned char *)a->data;
for (i=0; i<a->length; i++)
ret^=p[i]<<((i*3)%24);
break;
case ADDED_SNAME:
ret=lh_strhash(a->sn);
break;
case ADDED_LNAME:
ret=lh_strhash(a->ln);
break;
case ADDED_NID:
ret=a->nid;
break;
default:
/* abort(); */
return 0;
}
ret&=0x3fffffffL;
ret|=((unsigned long)ca->type)<<30L;
return(ret);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,967 | void check_defer(int nid)
{
if (!obj_cleanup_defer && nid >= NUM_NID)
obj_cleanup_defer = 1;
}
| +Info | 0 | void check_defer(int nid)
{
if (!obj_cleanup_defer && nid >= NUM_NID)
obj_cleanup_defer = 1;
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,968 | static void cleanup1_doall(ADDED_OBJ *a)
{
a->obj->nid=0;
a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC|
ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
ASN1_OBJECT_FLAG_DYNAMIC_DATA;
}
| +Info | 0 | static void cleanup1_doall(ADDED_OBJ *a)
{
a->obj->nid=0;
a->obj->flags|=ASN1_OBJECT_FLAG_DYNAMIC|
ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
ASN1_OBJECT_FLAG_DYNAMIC_DATA;
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,969 | static void cleanup2_doall(ADDED_OBJ *a)
{ a->obj->nid++; }
| +Info | 0 | static void cleanup2_doall(ADDED_OBJ *a)
{ a->obj->nid++; }
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,970 | static int init_added(void)
{
if (added != NULL) return(1);
added=lh_ADDED_OBJ_new();
return(added != NULL);
}
| +Info | 0 | static int init_added(void)
{
if (added != NULL) return(1);
added=lh_ADDED_OBJ_new();
return(added != NULL);
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,971 | static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
{ return(strcmp((*a)->ln,nid_objs[*b].ln)); }
| +Info | 0 | static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
{ return(strcmp((*a)->ln,nid_objs[*b].ln)); }
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,972 | static int obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp)
{
int j;
const ASN1_OBJECT *a= *ap;
const ASN1_OBJECT *b= &nid_objs[*bp];
j=(a->length - b->length);
if (j) return(j);
return(memcmp(a->data,b->data,a->length));
}
| +Info | 0 | static int obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp)
{
int j;
const ASN1_OBJECT *a= *ap;
const ASN1_OBJECT *b= &nid_objs[*bp];
j=(a->length - b->length);
if (j) return(j);
return(memcmp(a->data,b->data,a->length));
}
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,973 | static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
{ return(strcmp((*a)->sn,nid_objs[*b].sn)); }
| +Info | 0 | static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b)
{ return(strcmp((*a)->sn,nid_objs[*b].sn)); }
| @@ -471,11 +471,12 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
const unsigned char *p;
char tbuf[DECIMAL_SIZE(i)+DECIMAL_SIZE(l)+2];
- if ((a == NULL) || (a->data == NULL)) {
- buf[0]='\0';
- return(0);
- }
+ /* Ensure that, at every state, |buf| is NUL-terminated. */
+ if (buf && buf_len > 0)
+ buf[0] = '\0';
+ if ((a == NULL) || (a->data == NULL))
+ return(0);
if (!no_name && (nid=OBJ_obj2nid(a)) != NID_undef)
{
@@ -554,9 +555,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i=(int)(l/40);
l-=(long)(i*40);
}
- if (buf && (buf_len > 0))
+ if (buf && (buf_len > 1))
{
*buf++ = i + '0';
+ *buf = '\0';
buf_len--;
}
n++;
@@ -571,9 +573,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
i = strlen(bndec);
if (buf)
{
- if (buf_len > 0)
+ if (buf_len > 1)
{
*buf++ = '.';
+ *buf = '\0';
buf_len--;
}
BUF_strlcpy(buf,bndec,buf_len);
@@ -807,4 +810,3 @@ err:
OPENSSL_free(buf);
return(ok);
}
- | CWE-200 | null | null |
9,974 | int dtls1_do_write(SSL *s, int type)
{
int ret;
int curr_mtu;
unsigned int len, frag_off, mac_size, blocksize;
/* AHA! Figure out the MTU, and stick to the right size */
if (s->d1->mtu < dtls1_min_mtu() && !(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
{
s->d1->mtu =
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
/* I've seen the kernel return bogus numbers when it doesn't know
* (initial write), so just make sure we have a reasonable number */
if (s->d1->mtu < dtls1_min_mtu())
{
s->d1->mtu = 0;
s->d1->mtu = dtls1_guess_mtu(s->d1->mtu);
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SET_MTU,
s->d1->mtu, NULL);
}
}
#if 0
mtu = s->d1->mtu;
fprintf(stderr, "using MTU = %d\n", mtu);
mtu -= (DTLS1_HM_HEADER_LENGTH + DTLS1_RT_HEADER_LENGTH);
curr_mtu = mtu - BIO_wpending(SSL_get_wbio(s));
if ( curr_mtu > 0)
mtu = curr_mtu;
else if ( ( ret = BIO_flush(SSL_get_wbio(s))) <= 0)
return ret;
if ( BIO_wpending(SSL_get_wbio(s)) + s->init_num >= mtu)
{
ret = BIO_flush(SSL_get_wbio(s));
if ( ret <= 0)
return ret;
mtu = s->d1->mtu - (DTLS1_HM_HEADER_LENGTH + DTLS1_RT_HEADER_LENGTH);
}
#endif
OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu()); /* should have something reasonable now */
if ( s->init_off == 0 && type == SSL3_RT_HANDSHAKE)
OPENSSL_assert(s->init_num ==
(int)s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH);
if (s->write_hash)
{
if (s->enc_write_ctx && EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_GCM_MODE)
mac_size = 0;
else
mac_size = EVP_MD_CTX_size(s->write_hash);
}
else
mac_size = 0;
if (s->enc_write_ctx &&
(EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_CBC_MODE))
blocksize = 2 * EVP_CIPHER_block_size(s->enc_write_ctx->cipher);
else
blocksize = 0;
frag_off = 0;
while( s->init_num)
{
curr_mtu = s->d1->mtu - BIO_wpending(SSL_get_wbio(s)) -
DTLS1_RT_HEADER_LENGTH - mac_size - blocksize;
if ( curr_mtu <= DTLS1_HM_HEADER_LENGTH)
{
/* grr.. we could get an error if MTU picked was wrong */
ret = BIO_flush(SSL_get_wbio(s));
if ( ret <= 0)
return ret;
curr_mtu = s->d1->mtu - DTLS1_RT_HEADER_LENGTH -
mac_size - blocksize;
}
if ( s->init_num > curr_mtu)
len = curr_mtu;
else
len = s->init_num;
/* XDTLS: this function is too long. split out the CCS part */
if ( type == SSL3_RT_HANDSHAKE)
{
if ( s->init_off != 0)
{
OPENSSL_assert(s->init_off > DTLS1_HM_HEADER_LENGTH);
s->init_off -= DTLS1_HM_HEADER_LENGTH;
s->init_num += DTLS1_HM_HEADER_LENGTH;
if ( s->init_num > curr_mtu)
len = curr_mtu;
else
len = s->init_num;
}
dtls1_fix_message_header(s, frag_off,
len - DTLS1_HM_HEADER_LENGTH);
dtls1_write_message_header(s, (unsigned char *)&s->init_buf->data[s->init_off]);
OPENSSL_assert(len >= DTLS1_HM_HEADER_LENGTH);
}
ret=dtls1_write_bytes(s,type,&s->init_buf->data[s->init_off],
len);
if (ret < 0)
{
/* might need to update MTU here, but we don't know
* which previous packet caused the failure -- so can't
* really retransmit anything. continue as if everything
* is fine and wait for an alert to handle the
* retransmit
*/
if ( BIO_ctrl(SSL_get_wbio(s),
BIO_CTRL_DGRAM_MTU_EXCEEDED, 0, NULL) > 0 )
s->d1->mtu = BIO_ctrl(SSL_get_wbio(s),
BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
else
return(-1);
}
else
{
/* bad if this assert fails, only part of the handshake
* message got sent. but why would this happen? */
OPENSSL_assert(len == (unsigned int)ret);
if (type == SSL3_RT_HANDSHAKE && ! s->d1->retransmitting)
{
/* should not be done for 'Hello Request's, but in that case
* we'll ignore the result anyway */
unsigned char *p = (unsigned char *)&s->init_buf->data[s->init_off];
const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr;
int xlen;
if (frag_off == 0 && s->version != DTLS1_BAD_VER)
{
/* reconstruct message header is if it
* is being sent in single fragment */
*p++ = msg_hdr->type;
l2n3(msg_hdr->msg_len,p);
s2n (msg_hdr->seq,p);
l2n3(0,p);
l2n3(msg_hdr->msg_len,p);
p -= DTLS1_HM_HEADER_LENGTH;
xlen = ret;
}
else
{
p += DTLS1_HM_HEADER_LENGTH;
xlen = ret - DTLS1_HM_HEADER_LENGTH;
}
ssl3_finish_mac(s, p, xlen);
}
if (ret == s->init_num)
{
if (s->msg_callback)
s->msg_callback(1, s->version, type, s->init_buf->data,
(size_t)(s->init_off + s->init_num), s,
s->msg_callback_arg);
s->init_off = 0; /* done writing this message */
s->init_num = 0;
return(1);
}
s->init_off+=ret;
s->init_num-=ret;
frag_off += (ret -= DTLS1_HM_HEADER_LENGTH);
}
}
return(0);
}
| DoS | 0 | int dtls1_do_write(SSL *s, int type)
{
int ret;
int curr_mtu;
unsigned int len, frag_off, mac_size, blocksize;
/* AHA! Figure out the MTU, and stick to the right size */
if (s->d1->mtu < dtls1_min_mtu() && !(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
{
s->d1->mtu =
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
/* I've seen the kernel return bogus numbers when it doesn't know
* (initial write), so just make sure we have a reasonable number */
if (s->d1->mtu < dtls1_min_mtu())
{
s->d1->mtu = 0;
s->d1->mtu = dtls1_guess_mtu(s->d1->mtu);
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SET_MTU,
s->d1->mtu, NULL);
}
}
#if 0
mtu = s->d1->mtu;
fprintf(stderr, "using MTU = %d\n", mtu);
mtu -= (DTLS1_HM_HEADER_LENGTH + DTLS1_RT_HEADER_LENGTH);
curr_mtu = mtu - BIO_wpending(SSL_get_wbio(s));
if ( curr_mtu > 0)
mtu = curr_mtu;
else if ( ( ret = BIO_flush(SSL_get_wbio(s))) <= 0)
return ret;
if ( BIO_wpending(SSL_get_wbio(s)) + s->init_num >= mtu)
{
ret = BIO_flush(SSL_get_wbio(s));
if ( ret <= 0)
return ret;
mtu = s->d1->mtu - (DTLS1_HM_HEADER_LENGTH + DTLS1_RT_HEADER_LENGTH);
}
#endif
OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu()); /* should have something reasonable now */
if ( s->init_off == 0 && type == SSL3_RT_HANDSHAKE)
OPENSSL_assert(s->init_num ==
(int)s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH);
if (s->write_hash)
{
if (s->enc_write_ctx && EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_GCM_MODE)
mac_size = 0;
else
mac_size = EVP_MD_CTX_size(s->write_hash);
}
else
mac_size = 0;
if (s->enc_write_ctx &&
(EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_CBC_MODE))
blocksize = 2 * EVP_CIPHER_block_size(s->enc_write_ctx->cipher);
else
blocksize = 0;
frag_off = 0;
while( s->init_num)
{
curr_mtu = s->d1->mtu - BIO_wpending(SSL_get_wbio(s)) -
DTLS1_RT_HEADER_LENGTH - mac_size - blocksize;
if ( curr_mtu <= DTLS1_HM_HEADER_LENGTH)
{
/* grr.. we could get an error if MTU picked was wrong */
ret = BIO_flush(SSL_get_wbio(s));
if ( ret <= 0)
return ret;
curr_mtu = s->d1->mtu - DTLS1_RT_HEADER_LENGTH -
mac_size - blocksize;
}
if ( s->init_num > curr_mtu)
len = curr_mtu;
else
len = s->init_num;
/* XDTLS: this function is too long. split out the CCS part */
if ( type == SSL3_RT_HANDSHAKE)
{
if ( s->init_off != 0)
{
OPENSSL_assert(s->init_off > DTLS1_HM_HEADER_LENGTH);
s->init_off -= DTLS1_HM_HEADER_LENGTH;
s->init_num += DTLS1_HM_HEADER_LENGTH;
if ( s->init_num > curr_mtu)
len = curr_mtu;
else
len = s->init_num;
}
dtls1_fix_message_header(s, frag_off,
len - DTLS1_HM_HEADER_LENGTH);
dtls1_write_message_header(s, (unsigned char *)&s->init_buf->data[s->init_off]);
OPENSSL_assert(len >= DTLS1_HM_HEADER_LENGTH);
}
ret=dtls1_write_bytes(s,type,&s->init_buf->data[s->init_off],
len);
if (ret < 0)
{
/* might need to update MTU here, but we don't know
* which previous packet caused the failure -- so can't
* really retransmit anything. continue as if everything
* is fine and wait for an alert to handle the
* retransmit
*/
if ( BIO_ctrl(SSL_get_wbio(s),
BIO_CTRL_DGRAM_MTU_EXCEEDED, 0, NULL) > 0 )
s->d1->mtu = BIO_ctrl(SSL_get_wbio(s),
BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
else
return(-1);
}
else
{
/* bad if this assert fails, only part of the handshake
* message got sent. but why would this happen? */
OPENSSL_assert(len == (unsigned int)ret);
if (type == SSL3_RT_HANDSHAKE && ! s->d1->retransmitting)
{
/* should not be done for 'Hello Request's, but in that case
* we'll ignore the result anyway */
unsigned char *p = (unsigned char *)&s->init_buf->data[s->init_off];
const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr;
int xlen;
if (frag_off == 0 && s->version != DTLS1_BAD_VER)
{
/* reconstruct message header is if it
* is being sent in single fragment */
*p++ = msg_hdr->type;
l2n3(msg_hdr->msg_len,p);
s2n (msg_hdr->seq,p);
l2n3(0,p);
l2n3(msg_hdr->msg_len,p);
p -= DTLS1_HM_HEADER_LENGTH;
xlen = ret;
}
else
{
p += DTLS1_HM_HEADER_LENGTH;
xlen = ret - DTLS1_HM_HEADER_LENGTH;
}
ssl3_finish_mac(s, p, xlen);
}
if (ret == s->init_num)
{
if (s->msg_callback)
s->msg_callback(1, s->version, type, s->init_buf->data,
(size_t)(s->init_off + s->init_num), s,
s->msg_callback_arg);
s->init_off = 0; /* done writing this message */
s->init_num = 0;
return(1);
}
s->init_off+=ret;
s->init_num-=ret;
frag_off += (ret -= DTLS1_HM_HEADER_LENGTH);
}
}
return(0);
}
| @@ -616,6 +616,9 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
msg_hdr->msg_len > dtls1_max_handshake_message_len(s))
goto err;
+ if (frag_len == 0)
+ return DTLS1_HM_FRAGMENT_RETRY;
+
/* Try to find item in queue */
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char) (msg_hdr->seq>>8);
@@ -693,7 +696,12 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
goto err;
}
- pqueue_insert(s->d1->buffered_messages, item);
+ item = pqueue_insert(s->d1->buffered_messages, item);
+ /* pqueue_insert fails iff a duplicate item is inserted.
+ * However, |item| cannot be a duplicate. If it were,
+ * |pqueue_find|, above, would have returned it and control
+ * would never have reached this branch. */
+ OPENSSL_assert(item != NULL);
}
return DTLS1_HM_FRAGMENT_RETRY;
@@ -751,7 +759,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
}
else
{
- if (frag_len && frag_len < msg_hdr->msg_len)
+ if (frag_len < msg_hdr->msg_len)
return dtls1_reassemble_fragment(s, msg_hdr, ok);
if (frag_len > dtls1_max_handshake_message_len(s))
@@ -780,7 +788,15 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
if ( item == NULL)
goto err;
- pqueue_insert(s->d1->buffered_messages, item);
+ item = pqueue_insert(s->d1->buffered_messages, item);
+ /* pqueue_insert fails iff a duplicate item is inserted.
+ * However, |item| cannot be a duplicate. If it were,
+ * |pqueue_find|, above, would have returned it. Then, either
+ * |frag_len| != |msg_hdr->msg_len| in which case |item| is set
+ * to NULL and it will have been processed with
+ * |dtls1_reassemble_fragment|, above, or the record will have
+ * been discarded. */
+ OPENSSL_assert(item != NULL);
}
return DTLS1_HM_FRAGMENT_RETRY; | CWE-399 | null | null |
9,975 | dtls1_hm_fragment_free(hm_fragment *frag)
{
if (frag->msg_header.is_ccs)
{
EVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx);
EVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash);
}
if (frag->fragment) OPENSSL_free(frag->fragment);
if (frag->reassembly) OPENSSL_free(frag->reassembly);
OPENSSL_free(frag);
}
| DoS | 0 | dtls1_hm_fragment_free(hm_fragment *frag)
{
if (frag->msg_header.is_ccs)
{
EVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx);
EVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash);
}
if (frag->fragment) OPENSSL_free(frag->fragment);
if (frag->reassembly) OPENSSL_free(frag->reassembly);
OPENSSL_free(frag);
}
| @@ -616,6 +616,9 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
msg_hdr->msg_len > dtls1_max_handshake_message_len(s))
goto err;
+ if (frag_len == 0)
+ return DTLS1_HM_FRAGMENT_RETRY;
+
/* Try to find item in queue */
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char) (msg_hdr->seq>>8);
@@ -693,7 +696,12 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
goto err;
}
- pqueue_insert(s->d1->buffered_messages, item);
+ item = pqueue_insert(s->d1->buffered_messages, item);
+ /* pqueue_insert fails iff a duplicate item is inserted.
+ * However, |item| cannot be a duplicate. If it were,
+ * |pqueue_find|, above, would have returned it and control
+ * would never have reached this branch. */
+ OPENSSL_assert(item != NULL);
}
return DTLS1_HM_FRAGMENT_RETRY;
@@ -751,7 +759,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
}
else
{
- if (frag_len && frag_len < msg_hdr->msg_len)
+ if (frag_len < msg_hdr->msg_len)
return dtls1_reassemble_fragment(s, msg_hdr, ok);
if (frag_len > dtls1_max_handshake_message_len(s))
@@ -780,7 +788,15 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
if ( item == NULL)
goto err;
- pqueue_insert(s->d1->buffered_messages, item);
+ item = pqueue_insert(s->d1->buffered_messages, item);
+ /* pqueue_insert fails iff a duplicate item is inserted.
+ * However, |item| cannot be a duplicate. If it were,
+ * |pqueue_find|, above, would have returned it. Then, either
+ * |frag_len| != |msg_hdr->msg_len| in which case |item| is set
+ * to NULL and it will have been processed with
+ * |dtls1_reassemble_fragment|, above, or the record will have
+ * been discarded. */
+ OPENSSL_assert(item != NULL);
}
return DTLS1_HM_FRAGMENT_RETRY; | CWE-399 | null | null |
9,976 | dtls1_hm_fragment_new(unsigned long frag_len, int reassembly)
{
hm_fragment *frag = NULL;
unsigned char *buf = NULL;
unsigned char *bitmask = NULL;
frag = (hm_fragment *)OPENSSL_malloc(sizeof(hm_fragment));
if ( frag == NULL)
return NULL;
if (frag_len)
{
buf = (unsigned char *)OPENSSL_malloc(frag_len);
if ( buf == NULL)
{
OPENSSL_free(frag);
return NULL;
}
}
/* zero length fragment gets zero frag->fragment */
frag->fragment = buf;
/* Initialize reassembly bitmask if necessary */
if (reassembly)
{
bitmask = (unsigned char *)OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len));
if (bitmask == NULL)
{
if (buf != NULL) OPENSSL_free(buf);
OPENSSL_free(frag);
return NULL;
}
memset(bitmask, 0, RSMBLY_BITMASK_SIZE(frag_len));
}
frag->reassembly = bitmask;
return frag;
}
| DoS | 0 | dtls1_hm_fragment_new(unsigned long frag_len, int reassembly)
{
hm_fragment *frag = NULL;
unsigned char *buf = NULL;
unsigned char *bitmask = NULL;
frag = (hm_fragment *)OPENSSL_malloc(sizeof(hm_fragment));
if ( frag == NULL)
return NULL;
if (frag_len)
{
buf = (unsigned char *)OPENSSL_malloc(frag_len);
if ( buf == NULL)
{
OPENSSL_free(frag);
return NULL;
}
}
/* zero length fragment gets zero frag->fragment */
frag->fragment = buf;
/* Initialize reassembly bitmask if necessary */
if (reassembly)
{
bitmask = (unsigned char *)OPENSSL_malloc(RSMBLY_BITMASK_SIZE(frag_len));
if (bitmask == NULL)
{
if (buf != NULL) OPENSSL_free(buf);
OPENSSL_free(frag);
return NULL;
}
memset(bitmask, 0, RSMBLY_BITMASK_SIZE(frag_len));
}
frag->reassembly = bitmask;
return frag;
}
| @@ -616,6 +616,9 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
msg_hdr->msg_len > dtls1_max_handshake_message_len(s))
goto err;
+ if (frag_len == 0)
+ return DTLS1_HM_FRAGMENT_RETRY;
+
/* Try to find item in queue */
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char) (msg_hdr->seq>>8);
@@ -693,7 +696,12 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
goto err;
}
- pqueue_insert(s->d1->buffered_messages, item);
+ item = pqueue_insert(s->d1->buffered_messages, item);
+ /* pqueue_insert fails iff a duplicate item is inserted.
+ * However, |item| cannot be a duplicate. If it were,
+ * |pqueue_find|, above, would have returned it and control
+ * would never have reached this branch. */
+ OPENSSL_assert(item != NULL);
}
return DTLS1_HM_FRAGMENT_RETRY;
@@ -751,7 +759,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
}
else
{
- if (frag_len && frag_len < msg_hdr->msg_len)
+ if (frag_len < msg_hdr->msg_len)
return dtls1_reassemble_fragment(s, msg_hdr, ok);
if (frag_len > dtls1_max_handshake_message_len(s))
@@ -780,7 +788,15 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
if ( item == NULL)
goto err;
- pqueue_insert(s->d1->buffered_messages, item);
+ item = pqueue_insert(s->d1->buffered_messages, item);
+ /* pqueue_insert fails iff a duplicate item is inserted.
+ * However, |item| cannot be a duplicate. If it were,
+ * |pqueue_find|, above, would have returned it. Then, either
+ * |frag_len| != |msg_hdr->msg_len| in which case |item| is set
+ * to NULL and it will have been processed with
+ * |dtls1_reassemble_fragment|, above, or the record will have
+ * been discarded. */
+ OPENSSL_assert(item != NULL);
}
return DTLS1_HM_FRAGMENT_RETRY; | CWE-399 | null | null |
9,977 | add_bus_environment (BusActivation *activation,
DBusError *error)
{
const char *type;
if (!bus_activation_set_environment_variable (activation,
"DBUS_STARTER_ADDRESS",
activation->server_address,
error))
return FALSE;
type = bus_context_get_type (activation->context);
if (type != NULL)
{
if (!bus_activation_set_environment_variable (activation,
"DBUS_STARTER_BUS_TYPE", type,
error))
return FALSE;
if (strcmp (type, "session") == 0)
{
if (!bus_activation_set_environment_variable (activation,
"DBUS_SESSION_BUS_ADDRESS",
activation->server_address,
error))
return FALSE;
}
else if (strcmp (type, "system") == 0)
{
if (!bus_activation_set_environment_variable (activation,
"DBUS_SYSTEM_BUS_ADDRESS",
activation->server_address,
error))
return FALSE;
}
}
return TRUE;
}
| DoS | 0 | add_bus_environment (BusActivation *activation,
DBusError *error)
{
const char *type;
if (!bus_activation_set_environment_variable (activation,
"DBUS_STARTER_ADDRESS",
activation->server_address,
error))
return FALSE;
type = bus_context_get_type (activation->context);
if (type != NULL)
{
if (!bus_activation_set_environment_variable (activation,
"DBUS_STARTER_BUS_TYPE", type,
error))
return FALSE;
if (strcmp (type, "session") == 0)
{
if (!bus_activation_set_environment_variable (activation,
"DBUS_SESSION_BUS_ADDRESS",
activation->server_address,
error))
return FALSE;
}
else if (strcmp (type, "system") == 0)
{
if (!bus_activation_set_environment_variable (activation,
"DBUS_SYSTEM_BUS_ADDRESS",
activation->server_address,
error))
return FALSE;
}
}
return TRUE;
}
| @@ -1162,14 +1162,11 @@ bus_activation_service_created (BusActivation *activation,
dbus_bool_t
bus_activation_send_pending_auto_activation_messages (BusActivation *activation,
BusService *service,
- BusTransaction *transaction,
- DBusError *error)
+ BusTransaction *transaction)
{
BusPendingActivation *pending_activation;
DBusList *link;
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
/* Check if it's a pending activation */
pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
bus_service_get_name (service));
@@ -1186,6 +1183,9 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection)))
{
DBusConnection *addressed_recipient;
+ DBusError error;
+
+ dbus_error_init (&error);
addressed_recipient = bus_service_get_primary_owners_connection (service);
@@ -1193,8 +1193,22 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!bus_dispatch_matches (transaction,
entry->connection,
addressed_recipient,
- entry->activation_message, error))
- goto error;
+ entry->activation_message, &error))
+ {
+ /* If permission is denied, we just want to return the error
+ * to the original method invoker; in particular, we don't
+ * want to make the RequestName call fail with that error
+ * (see fd.o #78979, CVE-2014-3477). */
+ if (!bus_transaction_send_error_reply (transaction, entry->connection,
+ &error, entry->activation_message))
+ {
+ bus_connection_send_oom_error (entry->connection,
+ entry->activation_message);
+ }
+
+ link = next;
+ continue;
+ }
}
link = next;
@@ -1203,7 +1217,6 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!add_restore_pending_to_transaction (transaction, pending_activation))
{
_dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
- BUS_SET_OOM (error);
goto error;
} | null | null | null |
9,978 | add_restore_pending_to_transaction (BusTransaction *transaction,
BusPendingActivation *pending_activation)
{
RestorePendingData *d;
d = dbus_new (RestorePendingData, 1);
if (d == NULL)
return FALSE;
d->pending_activation = pending_activation;
d->hash_entry = _dbus_hash_table_preallocate_entry (d->pending_activation->activation->pending_activations);
bus_pending_activation_ref (d->pending_activation);
if (d->hash_entry == NULL ||
!bus_transaction_add_cancel_hook (transaction, restore_pending, d,
free_pending_restore_data))
{
free_pending_restore_data (d);
return FALSE;
}
_dbus_verbose ("Saved pending activation to be restored if the transaction fails\n");
return TRUE;
}
| DoS | 0 | add_restore_pending_to_transaction (BusTransaction *transaction,
BusPendingActivation *pending_activation)
{
RestorePendingData *d;
d = dbus_new (RestorePendingData, 1);
if (d == NULL)
return FALSE;
d->pending_activation = pending_activation;
d->hash_entry = _dbus_hash_table_preallocate_entry (d->pending_activation->activation->pending_activations);
bus_pending_activation_ref (d->pending_activation);
if (d->hash_entry == NULL ||
!bus_transaction_add_cancel_hook (transaction, restore_pending, d,
free_pending_restore_data))
{
free_pending_restore_data (d);
return FALSE;
}
_dbus_verbose ("Saved pending activation to be restored if the transaction fails\n");
return TRUE;
}
| @@ -1162,14 +1162,11 @@ bus_activation_service_created (BusActivation *activation,
dbus_bool_t
bus_activation_send_pending_auto_activation_messages (BusActivation *activation,
BusService *service,
- BusTransaction *transaction,
- DBusError *error)
+ BusTransaction *transaction)
{
BusPendingActivation *pending_activation;
DBusList *link;
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
/* Check if it's a pending activation */
pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
bus_service_get_name (service));
@@ -1186,6 +1183,9 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection)))
{
DBusConnection *addressed_recipient;
+ DBusError error;
+
+ dbus_error_init (&error);
addressed_recipient = bus_service_get_primary_owners_connection (service);
@@ -1193,8 +1193,22 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!bus_dispatch_matches (transaction,
entry->connection,
addressed_recipient,
- entry->activation_message, error))
- goto error;
+ entry->activation_message, &error))
+ {
+ /* If permission is denied, we just want to return the error
+ * to the original method invoker; in particular, we don't
+ * want to make the RequestName call fail with that error
+ * (see fd.o #78979, CVE-2014-3477). */
+ if (!bus_transaction_send_error_reply (transaction, entry->connection,
+ &error, entry->activation_message))
+ {
+ bus_connection_send_oom_error (entry->connection,
+ entry->activation_message);
+ }
+
+ link = next;
+ continue;
+ }
}
link = next;
@@ -1203,7 +1217,6 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!add_restore_pending_to_transaction (transaction, pending_activation))
{
_dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
- BUS_SET_OOM (error);
goto error;
} | null | null | null |
9,979 | bus_activation_entry_ref (BusActivationEntry *entry)
{
_dbus_assert (entry->refcount > 0);
entry->refcount++;
return entry;
}
| DoS | 0 | bus_activation_entry_ref (BusActivationEntry *entry)
{
_dbus_assert (entry->refcount > 0);
entry->refcount++;
return entry;
}
| @@ -1162,14 +1162,11 @@ bus_activation_service_created (BusActivation *activation,
dbus_bool_t
bus_activation_send_pending_auto_activation_messages (BusActivation *activation,
BusService *service,
- BusTransaction *transaction,
- DBusError *error)
+ BusTransaction *transaction)
{
BusPendingActivation *pending_activation;
DBusList *link;
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
/* Check if it's a pending activation */
pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
bus_service_get_name (service));
@@ -1186,6 +1183,9 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection)))
{
DBusConnection *addressed_recipient;
+ DBusError error;
+
+ dbus_error_init (&error);
addressed_recipient = bus_service_get_primary_owners_connection (service);
@@ -1193,8 +1193,22 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!bus_dispatch_matches (transaction,
entry->connection,
addressed_recipient,
- entry->activation_message, error))
- goto error;
+ entry->activation_message, &error))
+ {
+ /* If permission is denied, we just want to return the error
+ * to the original method invoker; in particular, we don't
+ * want to make the RequestName call fail with that error
+ * (see fd.o #78979, CVE-2014-3477). */
+ if (!bus_transaction_send_error_reply (transaction, entry->connection,
+ &error, entry->activation_message))
+ {
+ bus_connection_send_oom_error (entry->connection,
+ entry->activation_message);
+ }
+
+ link = next;
+ continue;
+ }
}
link = next;
@@ -1203,7 +1217,6 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!add_restore_pending_to_transaction (transaction, pending_activation))
{
_dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
- BUS_SET_OOM (error);
goto error;
} | null | null | null |
9,980 | bus_activation_entry_unref (BusActivationEntry *entry)
{
if (entry == NULL) /* hash table requires this */
return;
_dbus_assert (entry->refcount > 0);
entry->refcount--;
if (entry->refcount > 0)
return;
dbus_free (entry->name);
dbus_free (entry->exec);
dbus_free (entry->user);
dbus_free (entry->filename);
dbus_free (entry->systemd_service);
dbus_free (entry);
}
| DoS | 0 | bus_activation_entry_unref (BusActivationEntry *entry)
{
if (entry == NULL) /* hash table requires this */
return;
_dbus_assert (entry->refcount > 0);
entry->refcount--;
if (entry->refcount > 0)
return;
dbus_free (entry->name);
dbus_free (entry->exec);
dbus_free (entry->user);
dbus_free (entry->filename);
dbus_free (entry->systemd_service);
dbus_free (entry);
}
| @@ -1162,14 +1162,11 @@ bus_activation_service_created (BusActivation *activation,
dbus_bool_t
bus_activation_send_pending_auto_activation_messages (BusActivation *activation,
BusService *service,
- BusTransaction *transaction,
- DBusError *error)
+ BusTransaction *transaction)
{
BusPendingActivation *pending_activation;
DBusList *link;
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
/* Check if it's a pending activation */
pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
bus_service_get_name (service));
@@ -1186,6 +1183,9 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection)))
{
DBusConnection *addressed_recipient;
+ DBusError error;
+
+ dbus_error_init (&error);
addressed_recipient = bus_service_get_primary_owners_connection (service);
@@ -1193,8 +1193,22 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!bus_dispatch_matches (transaction,
entry->connection,
addressed_recipient,
- entry->activation_message, error))
- goto error;
+ entry->activation_message, &error))
+ {
+ /* If permission is denied, we just want to return the error
+ * to the original method invoker; in particular, we don't
+ * want to make the RequestName call fail with that error
+ * (see fd.o #78979, CVE-2014-3477). */
+ if (!bus_transaction_send_error_reply (transaction, entry->connection,
+ &error, entry->activation_message))
+ {
+ bus_connection_send_oom_error (entry->connection,
+ entry->activation_message);
+ }
+
+ link = next;
+ continue;
+ }
}
link = next;
@@ -1203,7 +1217,6 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!add_restore_pending_to_transaction (transaction, pending_activation))
{
_dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
- BUS_SET_OOM (error);
goto error;
} | null | null | null |
9,981 | bus_activation_new (BusContext *context,
const DBusString *address,
DBusList **directories,
DBusError *error)
{
BusActivation *activation;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
activation = dbus_new0 (BusActivation, 1);
if (activation == NULL)
{
BUS_SET_OOM (error);
return NULL;
}
activation->refcount = 1;
activation->context = context;
activation->n_pending_activations = 0;
if (!bus_activation_reload (activation, address, directories, error))
goto failed;
/* Initialize this hash table once, we don't want to lose pending
* activations on reload. */
activation->pending_activations = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
(DBusFreeFunction)bus_pending_activation_unref);
if (activation->pending_activations == NULL)
{
BUS_SET_OOM (error);
goto failed;
}
activation->environment = _dbus_hash_table_new (DBUS_HASH_STRING,
(DBusFreeFunction) dbus_free,
(DBusFreeFunction) dbus_free);
if (activation->environment == NULL)
{
BUS_SET_OOM (error);
goto failed;
}
if (!populate_environment (activation))
{
BUS_SET_OOM (error);
goto failed;
}
return activation;
failed:
bus_activation_unref (activation);
return NULL;
}
| DoS | 0 | bus_activation_new (BusContext *context,
const DBusString *address,
DBusList **directories,
DBusError *error)
{
BusActivation *activation;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
activation = dbus_new0 (BusActivation, 1);
if (activation == NULL)
{
BUS_SET_OOM (error);
return NULL;
}
activation->refcount = 1;
activation->context = context;
activation->n_pending_activations = 0;
if (!bus_activation_reload (activation, address, directories, error))
goto failed;
/* Initialize this hash table once, we don't want to lose pending
* activations on reload. */
activation->pending_activations = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
(DBusFreeFunction)bus_pending_activation_unref);
if (activation->pending_activations == NULL)
{
BUS_SET_OOM (error);
goto failed;
}
activation->environment = _dbus_hash_table_new (DBUS_HASH_STRING,
(DBusFreeFunction) dbus_free,
(DBusFreeFunction) dbus_free);
if (activation->environment == NULL)
{
BUS_SET_OOM (error);
goto failed;
}
if (!populate_environment (activation))
{
BUS_SET_OOM (error);
goto failed;
}
return activation;
failed:
bus_activation_unref (activation);
return NULL;
}
| @@ -1162,14 +1162,11 @@ bus_activation_service_created (BusActivation *activation,
dbus_bool_t
bus_activation_send_pending_auto_activation_messages (BusActivation *activation,
BusService *service,
- BusTransaction *transaction,
- DBusError *error)
+ BusTransaction *transaction)
{
BusPendingActivation *pending_activation;
DBusList *link;
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-
/* Check if it's a pending activation */
pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
bus_service_get_name (service));
@@ -1186,6 +1183,9 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection)))
{
DBusConnection *addressed_recipient;
+ DBusError error;
+
+ dbus_error_init (&error);
addressed_recipient = bus_service_get_primary_owners_connection (service);
@@ -1193,8 +1193,22 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!bus_dispatch_matches (transaction,
entry->connection,
addressed_recipient,
- entry->activation_message, error))
- goto error;
+ entry->activation_message, &error))
+ {
+ /* If permission is denied, we just want to return the error
+ * to the original method invoker; in particular, we don't
+ * want to make the RequestName call fail with that error
+ * (see fd.o #78979, CVE-2014-3477). */
+ if (!bus_transaction_send_error_reply (transaction, entry->connection,
+ &error, entry->activation_message))
+ {
+ bus_connection_send_oom_error (entry->connection,
+ entry->activation_message);
+ }
+
+ link = next;
+ continue;
+ }
}
link = next;
@@ -1203,7 +1217,6 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation
if (!add_restore_pending_to_transaction (transaction, pending_activation))
{
_dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
- BUS_SET_OOM (error);
goto error;
} | null | null | null |
9,982 | bus_owner_new (BusService *service,
DBusConnection *conn,
dbus_uint32_t flags)
{
BusOwner *result;
result = _dbus_mem_pool_alloc (service->registry->owner_pool);
if (result != NULL)
{
result->refcount = 1;
/* don't ref the connection because we don't want
to block the connection from going away.
transactions take care of reffing the connection
but we need to use refcounting on the owner
so that the owner does not get freed before
we can deref the connection in the transaction
*/
result->conn = conn;
result->service = service;
if (!bus_connection_add_owned_service (conn, service))
{
_dbus_mem_pool_dealloc (service->registry->owner_pool, result);
return NULL;
}
bus_owner_set_flags (result, flags);
}
return result;
}
| DoS | 0 | bus_owner_new (BusService *service,
DBusConnection *conn,
dbus_uint32_t flags)
{
BusOwner *result;
result = _dbus_mem_pool_alloc (service->registry->owner_pool);
if (result != NULL)
{
result->refcount = 1;
/* don't ref the connection because we don't want
to block the connection from going away.
transactions take care of reffing the connection
but we need to use refcounting on the owner
so that the owner does not get freed before
we can deref the connection in the transaction
*/
result->conn = conn;
result->service = service;
if (!bus_connection_add_owned_service (conn, service))
{
_dbus_mem_pool_dealloc (service->registry->owner_pool, result);
return NULL;
}
bus_owner_set_flags (result, flags);
}
return result;
}
| @@ -588,8 +588,9 @@ bus_registry_acquire_service (BusRegistry *registry,
activation = bus_context_get_activation (registry->context);
retval = bus_activation_send_pending_auto_activation_messages (activation,
service,
- transaction,
- error);
+ transaction);
+ if (!retval)
+ BUS_SET_OOM (error);
out:
return retval; | null | null | null |
9,983 | bus_owner_ref (BusOwner *owner)
{
_dbus_assert (owner->refcount > 0);
owner->refcount += 1;
return owner;
}
| DoS | 0 | bus_owner_ref (BusOwner *owner)
{
_dbus_assert (owner->refcount > 0);
owner->refcount += 1;
return owner;
}
| @@ -588,8 +588,9 @@ bus_registry_acquire_service (BusRegistry *registry,
activation = bus_context_get_activation (registry->context);
retval = bus_activation_send_pending_auto_activation_messages (activation,
service,
- transaction,
- error);
+ transaction);
+ if (!retval)
+ BUS_SET_OOM (error);
out:
return retval; | null | null | null |
9,984 | bus_owner_unref (BusOwner *owner)
{
_dbus_assert (owner->refcount > 0);
owner->refcount -= 1;
if (owner->refcount == 0)
{
bus_connection_remove_owned_service (owner->conn, owner->service);
_dbus_mem_pool_dealloc (owner->service->registry->owner_pool, owner);
}
}
| DoS | 0 | bus_owner_unref (BusOwner *owner)
{
_dbus_assert (owner->refcount > 0);
owner->refcount -= 1;
if (owner->refcount == 0)
{
bus_connection_remove_owned_service (owner->conn, owner->service);
_dbus_mem_pool_dealloc (owner->service->registry->owner_pool, owner);
}
}
| @@ -588,8 +588,9 @@ bus_registry_acquire_service (BusRegistry *registry,
activation = bus_context_get_activation (registry->context);
retval = bus_activation_send_pending_auto_activation_messages (activation,
service,
- transaction,
- error);
+ transaction);
+ if (!retval)
+ BUS_SET_OOM (error);
out:
return retval; | null | null | null |
9,985 | int ssl3_connect(SSL *s)
{
BUF_MEM *buf=NULL;
unsigned long Time=(unsigned long)time(NULL);
void (*cb)(const SSL *ssl,int type,int val)=NULL;
int ret= -1;
int new_state,state,skip=0;
RAND_add(&Time,sizeof(Time),0);
ERR_clear_error();
clear_sys_error();
if (s->info_callback != NULL)
cb=s->info_callback;
else if (s->ctx->info_callback != NULL)
cb=s->ctx->info_callback;
s->in_handshake++;
if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
#ifndef OPENSSL_NO_HEARTBEATS
/* If we're awaiting a HeartbeatResponse, pretend we
* already got and don't await it anymore, because
* Heartbeats don't make sense during handshakes anyway.
*/
if (s->tlsext_hb_pending)
{
s->tlsext_hb_pending = 0;
s->tlsext_hb_seq++;
}
#endif
for (;;)
{
state=s->state;
switch(s->state)
{
case SSL_ST_RENEGOTIATE:
s->renegotiate=1;
s->state=SSL_ST_CONNECT;
s->ctx->stats.sess_connect_renegotiate++;
/* break */
case SSL_ST_BEFORE:
case SSL_ST_CONNECT:
case SSL_ST_BEFORE|SSL_ST_CONNECT:
case SSL_ST_OK|SSL_ST_CONNECT:
s->server=0;
if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);
if ((s->version & 0xff00 ) != 0x0300)
{
SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);
ret = -1;
goto end;
}
/* s->version=SSL3_VERSION; */
s->type=SSL_ST_CONNECT;
if (s->init_buf == NULL)
{
if ((buf=BUF_MEM_new()) == NULL)
{
ret= -1;
goto end;
}
if (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))
{
ret= -1;
goto end;
}
s->init_buf=buf;
buf=NULL;
}
if (!ssl3_setup_buffers(s)) { ret= -1; goto end; }
/* setup buffing BIO */
if (!ssl_init_wbio_buffer(s,0)) { ret= -1; goto end; }
/* don't push the buffering BIO quite yet */
ssl3_init_finished_mac(s);
s->state=SSL3_ST_CW_CLNT_HELLO_A;
s->ctx->stats.sess_connect++;
s->init_num=0;
break;
case SSL3_ST_CW_CLNT_HELLO_A:
case SSL3_ST_CW_CLNT_HELLO_B:
s->shutdown=0;
ret=ssl3_client_hello(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_SRVR_HELLO_A;
s->init_num=0;
/* turn on buffering for the next lot of output */
if (s->bbio != s->wbio)
s->wbio=BIO_push(s->bbio,s->wbio);
break;
case SSL3_ST_CR_SRVR_HELLO_A:
case SSL3_ST_CR_SRVR_HELLO_B:
ret=ssl3_get_server_hello(s);
if (ret <= 0) goto end;
if (s->hit)
{
s->state=SSL3_ST_CR_FINISHED_A;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_ticket_expected)
{
/* receive renewed session ticket */
s->state=SSL3_ST_CR_SESSION_TICKET_A;
}
#endif
}
else
s->state=SSL3_ST_CR_CERT_A;
s->init_num=0;
break;
case SSL3_ST_CR_CERT_A:
case SSL3_ST_CR_CERT_B:
#ifndef OPENSSL_NO_TLSEXT
ret=ssl3_check_finished(s);
if (ret <= 0) goto end;
if (ret == 2)
{
s->hit = 1;
if (s->tlsext_ticket_expected)
s->state=SSL3_ST_CR_SESSION_TICKET_A;
else
s->state=SSL3_ST_CR_FINISHED_A;
s->init_num=0;
break;
}
#endif
/* Check if it is anon DH/ECDH */
/* or PSK */
if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&
!(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK))
{
ret=ssl3_get_server_certificate(s);
if (ret <= 0) goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_status_expected)
s->state=SSL3_ST_CR_CERT_STATUS_A;
else
s->state=SSL3_ST_CR_KEY_EXCH_A;
}
else
{
skip = 1;
s->state=SSL3_ST_CR_KEY_EXCH_A;
}
#else
}
else
skip=1;
s->state=SSL3_ST_CR_KEY_EXCH_A;
#endif
s->init_num=0;
break;
case SSL3_ST_CR_KEY_EXCH_A:
case SSL3_ST_CR_KEY_EXCH_B:
ret=ssl3_get_key_exchange(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_CERT_REQ_A;
s->init_num=0;
/* at this point we check that we have the
* required stuff from the server */
if (!ssl3_check_cert_and_algorithm(s))
{
ret= -1;
goto end;
}
break;
case SSL3_ST_CR_CERT_REQ_A:
case SSL3_ST_CR_CERT_REQ_B:
ret=ssl3_get_certificate_request(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_SRVR_DONE_A;
s->init_num=0;
break;
case SSL3_ST_CR_SRVR_DONE_A:
case SSL3_ST_CR_SRVR_DONE_B:
ret=ssl3_get_server_done(s);
if (ret <= 0) goto end;
#ifndef OPENSSL_NO_SRP
if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP)
{
if ((ret = SRP_Calc_A_param(s))<=0)
{
SSLerr(SSL_F_SSL3_CONNECT,SSL_R_SRP_A_CALC);
ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_INTERNAL_ERROR);
goto end;
}
}
#endif
if (s->s3->tmp.cert_req)
s->state=SSL3_ST_CW_CERT_A;
else
s->state=SSL3_ST_CW_KEY_EXCH_A;
s->init_num=0;
break;
case SSL3_ST_CW_CERT_A:
case SSL3_ST_CW_CERT_B:
case SSL3_ST_CW_CERT_C:
case SSL3_ST_CW_CERT_D:
ret=ssl3_send_client_certificate(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_KEY_EXCH_A;
s->init_num=0;
break;
case SSL3_ST_CW_KEY_EXCH_A:
case SSL3_ST_CW_KEY_EXCH_B:
ret=ssl3_send_client_key_exchange(s);
if (ret <= 0) goto end;
/* EAY EAY EAY need to check for DH fix cert
* sent back */
/* For TLS, cert_req is set to 2, so a cert chain
* of nothing is sent, but no verify packet is sent */
/* XXX: For now, we do not support client
* authentication in ECDH cipher suites with
* ECDH (rather than ECDSA) certificates.
* We need to skip the certificate verify
* message when client's ECDH public key is sent
* inside the client certificate.
*/
if (s->s3->tmp.cert_req == 1)
{
s->state=SSL3_ST_CW_CERT_VRFY_A;
}
else
{
s->state=SSL3_ST_CW_CHANGE_A;
s->s3->change_cipher_spec=0;
}
if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY)
{
s->state=SSL3_ST_CW_CHANGE_A;
s->s3->change_cipher_spec=0;
}
s->init_num=0;
break;
case SSL3_ST_CW_CERT_VRFY_A:
case SSL3_ST_CW_CERT_VRFY_B:
ret=ssl3_send_client_verify(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_CHANGE_A;
s->init_num=0;
s->s3->change_cipher_spec=0;
break;
case SSL3_ST_CW_CHANGE_A:
case SSL3_ST_CW_CHANGE_B:
ret=ssl3_send_change_cipher_spec(s,
SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);
if (ret <= 0) goto end;
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state=SSL3_ST_CW_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state=SSL3_ST_CW_NEXT_PROTO_A;
else
s->state=SSL3_ST_CW_FINISHED_A;
#endif
s->init_num=0;
s->session->cipher=s->s3->tmp.new_cipher;
#ifdef OPENSSL_NO_COMP
s->session->compress_meth=0;
#else
if (s->s3->tmp.new_compression == NULL)
s->session->compress_meth=0;
else
s->session->compress_meth=
s->s3->tmp.new_compression->id;
#endif
if (!s->method->ssl3_enc->setup_key_block(s))
{
ret= -1;
goto end;
}
if (!s->method->ssl3_enc->change_cipher_state(s,
SSL3_CHANGE_CIPHER_CLIENT_WRITE))
{
ret= -1;
goto end;
}
break;
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
case SSL3_ST_CW_NEXT_PROTO_A:
case SSL3_ST_CW_NEXT_PROTO_B:
ret=ssl3_send_next_proto(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_FINISHED_A;
break;
#endif
case SSL3_ST_CW_FINISHED_A:
case SSL3_ST_CW_FINISHED_B:
ret=ssl3_send_finished(s,
SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,
s->method->ssl3_enc->client_finished_label,
s->method->ssl3_enc->client_finished_label_len);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_FLUSH;
/* clear flags */
s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
if (s->hit)
{
s->s3->tmp.next_state=SSL_ST_OK;
if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED)
{
s->state=SSL_ST_OK;
s->s3->flags|=SSL3_FLAGS_POP_BUFFER;
s->s3->delay_buf_pop_ret=0;
}
}
else
{
#ifndef OPENSSL_NO_TLSEXT
/* Allow NewSessionTicket if ticket expected */
if (s->tlsext_ticket_expected)
s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;
else
#endif
s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;
}
s->init_num=0;
break;
#ifndef OPENSSL_NO_TLSEXT
case SSL3_ST_CR_SESSION_TICKET_A:
case SSL3_ST_CR_SESSION_TICKET_B:
ret=ssl3_get_new_session_ticket(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_FINISHED_A;
s->init_num=0;
break;
case SSL3_ST_CR_CERT_STATUS_A:
case SSL3_ST_CR_CERT_STATUS_B:
ret=ssl3_get_cert_status(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_KEY_EXCH_A;
s->init_num=0;
break;
#endif
case SSL3_ST_CR_FINISHED_A:
case SSL3_ST_CR_FINISHED_B:
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,
SSL3_ST_CR_FINISHED_B);
if (ret <= 0) goto end;
if (s->hit)
s->state=SSL3_ST_CW_CHANGE_A;
else
s->state=SSL_ST_OK;
s->init_num=0;
break;
case SSL3_ST_CW_FLUSH:
s->rwstate=SSL_WRITING;
if (BIO_flush(s->wbio) <= 0)
{
ret= -1;
goto end;
}
s->rwstate=SSL_NOTHING;
s->state=s->s3->tmp.next_state;
break;
case SSL_ST_OK:
/* clean a few things up */
ssl3_cleanup_key_block(s);
if (s->init_buf != NULL)
{
BUF_MEM_free(s->init_buf);
s->init_buf=NULL;
}
/* If we are not 'joining' the last two packets,
* remove the buffering now */
if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER))
ssl_free_wbio_buffer(s);
/* else do it later in ssl3_write */
s->init_num=0;
s->renegotiate=0;
s->new_session=0;
ssl_update_cache(s,SSL_SESS_CACHE_CLIENT);
if (s->hit) s->ctx->stats.sess_hit++;
ret=1;
/* s->server=0; */
s->handshake_func=ssl3_connect;
s->ctx->stats.sess_connect_good++;
if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);
goto end;
/* break; */
default:
SSLerr(SSL_F_SSL3_CONNECT,SSL_R_UNKNOWN_STATE);
ret= -1;
goto end;
/* break; */
}
/* did we do anything */
if (!s->s3->tmp.reuse_message && !skip)
{
if (s->debug)
{
if ((ret=BIO_flush(s->wbio)) <= 0)
goto end;
}
if ((cb != NULL) && (s->state != state))
{
new_state=s->state;
s->state=state;
cb(s,SSL_CB_CONNECT_LOOP,1);
s->state=new_state;
}
}
skip=0;
}
| DoS | 0 | int ssl3_connect(SSL *s)
{
BUF_MEM *buf=NULL;
unsigned long Time=(unsigned long)time(NULL);
void (*cb)(const SSL *ssl,int type,int val)=NULL;
int ret= -1;
int new_state,state,skip=0;
RAND_add(&Time,sizeof(Time),0);
ERR_clear_error();
clear_sys_error();
if (s->info_callback != NULL)
cb=s->info_callback;
else if (s->ctx->info_callback != NULL)
cb=s->ctx->info_callback;
s->in_handshake++;
if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
#ifndef OPENSSL_NO_HEARTBEATS
/* If we're awaiting a HeartbeatResponse, pretend we
* already got and don't await it anymore, because
* Heartbeats don't make sense during handshakes anyway.
*/
if (s->tlsext_hb_pending)
{
s->tlsext_hb_pending = 0;
s->tlsext_hb_seq++;
}
#endif
for (;;)
{
state=s->state;
switch(s->state)
{
case SSL_ST_RENEGOTIATE:
s->renegotiate=1;
s->state=SSL_ST_CONNECT;
s->ctx->stats.sess_connect_renegotiate++;
/* break */
case SSL_ST_BEFORE:
case SSL_ST_CONNECT:
case SSL_ST_BEFORE|SSL_ST_CONNECT:
case SSL_ST_OK|SSL_ST_CONNECT:
s->server=0;
if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);
if ((s->version & 0xff00 ) != 0x0300)
{
SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);
ret = -1;
goto end;
}
/* s->version=SSL3_VERSION; */
s->type=SSL_ST_CONNECT;
if (s->init_buf == NULL)
{
if ((buf=BUF_MEM_new()) == NULL)
{
ret= -1;
goto end;
}
if (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))
{
ret= -1;
goto end;
}
s->init_buf=buf;
buf=NULL;
}
if (!ssl3_setup_buffers(s)) { ret= -1; goto end; }
/* setup buffing BIO */
if (!ssl_init_wbio_buffer(s,0)) { ret= -1; goto end; }
/* don't push the buffering BIO quite yet */
ssl3_init_finished_mac(s);
s->state=SSL3_ST_CW_CLNT_HELLO_A;
s->ctx->stats.sess_connect++;
s->init_num=0;
break;
case SSL3_ST_CW_CLNT_HELLO_A:
case SSL3_ST_CW_CLNT_HELLO_B:
s->shutdown=0;
ret=ssl3_client_hello(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_SRVR_HELLO_A;
s->init_num=0;
/* turn on buffering for the next lot of output */
if (s->bbio != s->wbio)
s->wbio=BIO_push(s->bbio,s->wbio);
break;
case SSL3_ST_CR_SRVR_HELLO_A:
case SSL3_ST_CR_SRVR_HELLO_B:
ret=ssl3_get_server_hello(s);
if (ret <= 0) goto end;
if (s->hit)
{
s->state=SSL3_ST_CR_FINISHED_A;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_ticket_expected)
{
/* receive renewed session ticket */
s->state=SSL3_ST_CR_SESSION_TICKET_A;
}
#endif
}
else
s->state=SSL3_ST_CR_CERT_A;
s->init_num=0;
break;
case SSL3_ST_CR_CERT_A:
case SSL3_ST_CR_CERT_B:
#ifndef OPENSSL_NO_TLSEXT
ret=ssl3_check_finished(s);
if (ret <= 0) goto end;
if (ret == 2)
{
s->hit = 1;
if (s->tlsext_ticket_expected)
s->state=SSL3_ST_CR_SESSION_TICKET_A;
else
s->state=SSL3_ST_CR_FINISHED_A;
s->init_num=0;
break;
}
#endif
/* Check if it is anon DH/ECDH */
/* or PSK */
if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&
!(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK))
{
ret=ssl3_get_server_certificate(s);
if (ret <= 0) goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_status_expected)
s->state=SSL3_ST_CR_CERT_STATUS_A;
else
s->state=SSL3_ST_CR_KEY_EXCH_A;
}
else
{
skip = 1;
s->state=SSL3_ST_CR_KEY_EXCH_A;
}
#else
}
else
skip=1;
s->state=SSL3_ST_CR_KEY_EXCH_A;
#endif
s->init_num=0;
break;
case SSL3_ST_CR_KEY_EXCH_A:
case SSL3_ST_CR_KEY_EXCH_B:
ret=ssl3_get_key_exchange(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_CERT_REQ_A;
s->init_num=0;
/* at this point we check that we have the
* required stuff from the server */
if (!ssl3_check_cert_and_algorithm(s))
{
ret= -1;
goto end;
}
break;
case SSL3_ST_CR_CERT_REQ_A:
case SSL3_ST_CR_CERT_REQ_B:
ret=ssl3_get_certificate_request(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_SRVR_DONE_A;
s->init_num=0;
break;
case SSL3_ST_CR_SRVR_DONE_A:
case SSL3_ST_CR_SRVR_DONE_B:
ret=ssl3_get_server_done(s);
if (ret <= 0) goto end;
#ifndef OPENSSL_NO_SRP
if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP)
{
if ((ret = SRP_Calc_A_param(s))<=0)
{
SSLerr(SSL_F_SSL3_CONNECT,SSL_R_SRP_A_CALC);
ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_INTERNAL_ERROR);
goto end;
}
}
#endif
if (s->s3->tmp.cert_req)
s->state=SSL3_ST_CW_CERT_A;
else
s->state=SSL3_ST_CW_KEY_EXCH_A;
s->init_num=0;
break;
case SSL3_ST_CW_CERT_A:
case SSL3_ST_CW_CERT_B:
case SSL3_ST_CW_CERT_C:
case SSL3_ST_CW_CERT_D:
ret=ssl3_send_client_certificate(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_KEY_EXCH_A;
s->init_num=0;
break;
case SSL3_ST_CW_KEY_EXCH_A:
case SSL3_ST_CW_KEY_EXCH_B:
ret=ssl3_send_client_key_exchange(s);
if (ret <= 0) goto end;
/* EAY EAY EAY need to check for DH fix cert
* sent back */
/* For TLS, cert_req is set to 2, so a cert chain
* of nothing is sent, but no verify packet is sent */
/* XXX: For now, we do not support client
* authentication in ECDH cipher suites with
* ECDH (rather than ECDSA) certificates.
* We need to skip the certificate verify
* message when client's ECDH public key is sent
* inside the client certificate.
*/
if (s->s3->tmp.cert_req == 1)
{
s->state=SSL3_ST_CW_CERT_VRFY_A;
}
else
{
s->state=SSL3_ST_CW_CHANGE_A;
s->s3->change_cipher_spec=0;
}
if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY)
{
s->state=SSL3_ST_CW_CHANGE_A;
s->s3->change_cipher_spec=0;
}
s->init_num=0;
break;
case SSL3_ST_CW_CERT_VRFY_A:
case SSL3_ST_CW_CERT_VRFY_B:
ret=ssl3_send_client_verify(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_CHANGE_A;
s->init_num=0;
s->s3->change_cipher_spec=0;
break;
case SSL3_ST_CW_CHANGE_A:
case SSL3_ST_CW_CHANGE_B:
ret=ssl3_send_change_cipher_spec(s,
SSL3_ST_CW_CHANGE_A,SSL3_ST_CW_CHANGE_B);
if (ret <= 0) goto end;
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state=SSL3_ST_CW_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state=SSL3_ST_CW_NEXT_PROTO_A;
else
s->state=SSL3_ST_CW_FINISHED_A;
#endif
s->init_num=0;
s->session->cipher=s->s3->tmp.new_cipher;
#ifdef OPENSSL_NO_COMP
s->session->compress_meth=0;
#else
if (s->s3->tmp.new_compression == NULL)
s->session->compress_meth=0;
else
s->session->compress_meth=
s->s3->tmp.new_compression->id;
#endif
if (!s->method->ssl3_enc->setup_key_block(s))
{
ret= -1;
goto end;
}
if (!s->method->ssl3_enc->change_cipher_state(s,
SSL3_CHANGE_CIPHER_CLIENT_WRITE))
{
ret= -1;
goto end;
}
break;
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
case SSL3_ST_CW_NEXT_PROTO_A:
case SSL3_ST_CW_NEXT_PROTO_B:
ret=ssl3_send_next_proto(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_FINISHED_A;
break;
#endif
case SSL3_ST_CW_FINISHED_A:
case SSL3_ST_CW_FINISHED_B:
ret=ssl3_send_finished(s,
SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B,
s->method->ssl3_enc->client_finished_label,
s->method->ssl3_enc->client_finished_label_len);
if (ret <= 0) goto end;
s->state=SSL3_ST_CW_FLUSH;
/* clear flags */
s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
if (s->hit)
{
s->s3->tmp.next_state=SSL_ST_OK;
if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED)
{
s->state=SSL_ST_OK;
s->s3->flags|=SSL3_FLAGS_POP_BUFFER;
s->s3->delay_buf_pop_ret=0;
}
}
else
{
#ifndef OPENSSL_NO_TLSEXT
/* Allow NewSessionTicket if ticket expected */
if (s->tlsext_ticket_expected)
s->s3->tmp.next_state=SSL3_ST_CR_SESSION_TICKET_A;
else
#endif
s->s3->tmp.next_state=SSL3_ST_CR_FINISHED_A;
}
s->init_num=0;
break;
#ifndef OPENSSL_NO_TLSEXT
case SSL3_ST_CR_SESSION_TICKET_A:
case SSL3_ST_CR_SESSION_TICKET_B:
ret=ssl3_get_new_session_ticket(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_FINISHED_A;
s->init_num=0;
break;
case SSL3_ST_CR_CERT_STATUS_A:
case SSL3_ST_CR_CERT_STATUS_B:
ret=ssl3_get_cert_status(s);
if (ret <= 0) goto end;
s->state=SSL3_ST_CR_KEY_EXCH_A;
s->init_num=0;
break;
#endif
case SSL3_ST_CR_FINISHED_A:
case SSL3_ST_CR_FINISHED_B:
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,
SSL3_ST_CR_FINISHED_B);
if (ret <= 0) goto end;
if (s->hit)
s->state=SSL3_ST_CW_CHANGE_A;
else
s->state=SSL_ST_OK;
s->init_num=0;
break;
case SSL3_ST_CW_FLUSH:
s->rwstate=SSL_WRITING;
if (BIO_flush(s->wbio) <= 0)
{
ret= -1;
goto end;
}
s->rwstate=SSL_NOTHING;
s->state=s->s3->tmp.next_state;
break;
case SSL_ST_OK:
/* clean a few things up */
ssl3_cleanup_key_block(s);
if (s->init_buf != NULL)
{
BUF_MEM_free(s->init_buf);
s->init_buf=NULL;
}
/* If we are not 'joining' the last two packets,
* remove the buffering now */
if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER))
ssl_free_wbio_buffer(s);
/* else do it later in ssl3_write */
s->init_num=0;
s->renegotiate=0;
s->new_session=0;
ssl_update_cache(s,SSL_SESS_CACHE_CLIENT);
if (s->hit) s->ctx->stats.sess_hit++;
ret=1;
/* s->server=0; */
s->handshake_func=ssl3_connect;
s->ctx->stats.sess_connect_good++;
if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);
goto end;
/* break; */
default:
SSLerr(SSL_F_SSL3_CONNECT,SSL_R_UNKNOWN_STATE);
ret= -1;
goto end;
/* break; */
}
/* did we do anything */
if (!s->s3->tmp.reuse_message && !skip)
{
if (s->debug)
{
if ((ret=BIO_flush(s->wbio)) <= 0)
goto end;
}
if ((cb != NULL) && (s->state != state))
{
new_state=s->state;
s->state=state;
cb(s,SSL_CB_CONNECT_LOOP,1);
s->state=new_state;
}
}
skip=0;
}
| @@ -2512,6 +2512,13 @@ int ssl3_send_client_key_exchange(SSL *s)
int ecdh_clnt_cert = 0;
int field_size = 0;
+ if (s->session->sess_cert == NULL)
+ {
+ ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);
+ SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_UNEXPECTED_MESSAGE);
+ goto err;
+ }
+
/* Did we send out the client's
* ECDH share for use in premaster
* computation as part of client certificate? | CWE-310 | null | null |
9,986 | _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size)
{
int len_len, len, k;
int leading;
char temp[20];
unsigned long val, val1;
*ret_len = 0;
if (str && str_size > 0)
str[0] = 0; /* no oid */
if (str == NULL || der_len <= 0)
return ASN1_GENERIC_ERROR;
len = asn1_get_length_der (der, der_len, &len_len);
if (len < 0 || len > der_len || len_len > der_len)
return ASN1_DER_ERROR;
val1 = der[len_len] / 40;
val = der[len_len] - val1 * 40;
_asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp));
_asn1_str_cat (str, str_size, ".");
_asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
val = 0;
leading = 1;
for (k = 1; k < len; k++)
{
/* X.690 mandates that the leading byte must never be 0x80
*/
if (leading != 0 && der[len_len + k] == 0x80)
return ASN1_DER_ERROR;
leading = 0;
/* check for wrap around */
if (INT_LEFT_SHIFT_OVERFLOW (val, 7))
return ASN1_DER_ERROR;
val = val << 7;
val |= der[len_len + k] & 0x7F;
if (!(der[len_len + k] & 0x80))
{
_asn1_str_cat (str, str_size, ".");
_asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
val = 0;
leading = 1;
}
}
if (INT_ADD_OVERFLOW (len, len_len))
return ASN1_DER_ERROR;
*ret_len = len + len_len;
return ASN1_SUCCESS;
}
| null | 0 | _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size)
{
int len_len, len, k;
int leading;
char temp[20];
unsigned long val, val1;
*ret_len = 0;
if (str && str_size > 0)
str[0] = 0; /* no oid */
if (str == NULL || der_len <= 0)
return ASN1_GENERIC_ERROR;
len = asn1_get_length_der (der, der_len, &len_len);
if (len < 0 || len > der_len || len_len > der_len)
return ASN1_DER_ERROR;
val1 = der[len_len] / 40;
val = der[len_len] - val1 * 40;
_asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp));
_asn1_str_cat (str, str_size, ".");
_asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
val = 0;
leading = 1;
for (k = 1; k < len; k++)
{
/* X.690 mandates that the leading byte must never be 0x80
*/
if (leading != 0 && der[len_len + k] == 0x80)
return ASN1_DER_ERROR;
leading = 0;
/* check for wrap around */
if (INT_LEFT_SHIFT_OVERFLOW (val, 7))
return ASN1_DER_ERROR;
val = val << 7;
val |= der[len_len + k] & 0x7F;
if (!(der[len_len + k] & 0x80))
{
_asn1_str_cat (str, str_size, ".");
_asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
val = 0;
leading = 1;
}
}
if (INT_ADD_OVERFLOW (len, len_len))
return ASN1_DER_ERROR;
*ret_len = len + len_len;
return ASN1_SUCCESS;
}
| @@ -249,7 +249,7 @@ asn1_get_octet_der (const unsigned char *der, int der_len,
int *ret_len, unsigned char *str, int str_size,
int *str_len)
{
- int len_len;
+ int len_len = 0;
if (der_len <= 0)
return ASN1_GENERIC_ERROR;
@@ -371,7 +371,7 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
int *ret_len, unsigned char *str, int str_size,
int *bit_len)
{
- int len_len, len_byte;
+ int len_len = 0, len_byte;
if (der_len <= 0)
return ASN1_GENERIC_ERROR;
@@ -381,6 +381,9 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
*ret_len = len_byte + len_len + 1;
*bit_len = len_byte * 8 - der[len_len];
+
+ if (*bit_len <= 0)
+ return ASN1_DER_ERROR;
if (str_size >= len_byte)
memcpy (str, der + len_len + 1, len_byte); | CWE-189 | null | null |
9,987 | _asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size)
{
int len_len, str_len;
if (der_len <= 0 || str == NULL)
return ASN1_DER_ERROR;
str_len = asn1_get_length_der (der, der_len, &len_len);
if (str_len < 0 || str_size < str_len)
return ASN1_DER_ERROR;
memcpy (str, der + len_len, str_len);
str[str_len] = 0;
*ret_len = str_len + len_len;
return ASN1_SUCCESS;
}
| null | 0 | _asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size)
{
int len_len, str_len;
if (der_len <= 0 || str == NULL)
return ASN1_DER_ERROR;
str_len = asn1_get_length_der (der, der_len, &len_len);
if (str_len < 0 || str_size < str_len)
return ASN1_DER_ERROR;
memcpy (str, der + len_len, str_len);
str[str_len] = 0;
*ret_len = str_len + len_len;
return ASN1_SUCCESS;
}
| @@ -249,7 +249,7 @@ asn1_get_octet_der (const unsigned char *der, int der_len,
int *ret_len, unsigned char *str, int str_size,
int *str_len)
{
- int len_len;
+ int len_len = 0;
if (der_len <= 0)
return ASN1_GENERIC_ERROR;
@@ -371,7 +371,7 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
int *ret_len, unsigned char *str, int str_size,
int *bit_len)
{
- int len_len, len_byte;
+ int len_len = 0, len_byte;
if (der_len <= 0)
return ASN1_GENERIC_ERROR;
@@ -381,6 +381,9 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
*ret_len = len_byte + len_len + 1;
*bit_len = len_byte * 8 - der[len_len];
+
+ if (*bit_len <= 0)
+ return ASN1_DER_ERROR;
if (str_size >= len_byte)
memcpy (str, der + len_len + 1, len_byte); | CWE-189 | null | null |
9,988 | CreateOK(struct ubik_trans *ut, afs_int32 cid, afs_int32 oid, afs_int32 flag,
int admin)
{
if (restricted && !admin)
return 0;
if (flag & PRFOREIGN) {
/* Foreign users are recognized by the '@' sign and
* not by the PRFOREIGN flag.
*/
return 0;
} else if (flag & PRGRP) {
/* Allow anonymous group creation only if owner specified
* and running noAuth.
*/
if (cid == ANONYMOUSID) {
if ((oid == 0) || !pr_noAuth)
return 0;
}
} else { /* creating a user */
if (!admin && !pr_noAuth)
return 0;
}
return 1; /* OK! */
}
| Bypass | 0 | CreateOK(struct ubik_trans *ut, afs_int32 cid, afs_int32 oid, afs_int32 flag,
int admin)
{
if (restricted && !admin)
return 0;
if (flag & PRFOREIGN) {
/* Foreign users are recognized by the '@' sign and
* not by the PRFOREIGN flag.
*/
return 0;
} else if (flag & PRGRP) {
/* Allow anonymous group creation only if owner specified
* and running noAuth.
*/
if (cid == ANONYMOUSID) {
if ((oid == 0) || !pr_noAuth)
return 0;
}
} else { /* creating a user */
if (!admin && !pr_noAuth)
return 0;
}
return 1; /* OK! */
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,989 | Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid)
{
afs_int32 code;
struct ubik_trans *tt;
struct prentry tentry;
afs_int32 loc, nptr;
int count;
code = Initdb();
if (code)
return code;
if (code != PRSUCCESS)
return code;
if (aid == SYSADMINID || aid == ANYUSERID || aid == AUTHUSERID
|| aid == ANONYMOUSID)
return PRPERM;
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
code = read_DbHeader(tt);
if (code)
ABORT_WITH(tt, code);
code = WhoIsThis(call, tt, cid);
if (code)
ABORT_WITH(tt, PRPERM);
/* Read in entry to be deleted */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
/* Do some access checking */
if (tentry.owner != *cid && !IsAMemberOf(tt, *cid, SYSADMINID)
&& !IsAMemberOf(tt, *cid, tentry.owner) && !pr_noAuth)
ABORT_WITH(tt, PRPERM);
/* Delete each continuation block as a separate transaction so that no one
* transaction become to large to complete. */
nptr = tentry.next;
while (nptr != 0) {
struct contentry centry;
int i;
code = pr_ReadCoEntry(tt, 0, nptr, ¢ry);
if (code != 0)
ABORT_WITH(tt, PRDBFAIL);
for (i = 0; i < COSIZE; i++) {
if (centry.entries[i] == PRBADID)
continue;
if (centry.entries[i] == 0)
break;
#if defined(SUPERGROUPS)
if (aid < 0 && centry.entries[i] < 0) /* Supergroup */
code = RemoveFromSGEntry(tt, aid, centry.entries[i]);
else
#endif
code = RemoveFromEntry(tt, aid, centry.entries[i]);
if (code)
ABORT_WITH(tt, code);
tentry.count--; /* maintain count */
#ifndef AFS_PTHREAD_ENV
if ((i & 3) == 0)
IOMGR_Poll();
#endif
}
tentry.next = centry.next; /* thread out this block */
code = FreeBlock(tt, nptr); /* free continuation block */
if (code)
ABORT_WITH(tt, code);
code = pr_WriteEntry(tt, 0, loc, &tentry); /* update main entry */
if (code)
ABORT_WITH(tt, code);
/* end this trans and start a new one */
code = ubik_EndTrans(tt);
if (code)
return code;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* just to keep the connection alive */
#endif
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
/* re-read entry to get consistent uptodate info */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentry.next;
}
#if defined(SUPERGROUPS)
/* Delete each continuation block as a separate transaction
* so that no one transaction become too large to complete. */
{
struct prentryg *tentryg = (struct prentryg *)&tentry;
nptr = tentryg->nextsg;
while (nptr != 0) {
struct contentry centry;
int i;
code = pr_ReadCoEntry(tt, 0, nptr, ¢ry);
if (code != 0)
ABORT_WITH(tt, PRDBFAIL);
for (i = 0; i < COSIZE; i++) {
if (centry.entries[i] == PRBADID)
continue;
if (centry.entries[i] == 0)
break;
code = RemoveFromEntry(tt, aid, centry.entries[i]);
if (code)
ABORT_WITH(tt, code);
tentryg->countsg--; /* maintain count */
#ifndef AFS_PTHREAD_ENV
if ((i & 3) == 0)
IOMGR_Poll();
#endif
}
tentryg->nextsg = centry.next; /* thread out this block */
code = FreeBlock(tt, nptr); /* free continuation block */
if (code)
ABORT_WITH(tt, code);
code = pr_WriteEntry(tt, 0, loc, &tentry); /* update main entry */
if (code)
ABORT_WITH(tt, code);
/* end this trans and start a new one */
code = ubik_EndTrans(tt);
if (code)
return code;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* just to keep the connection alive */
#endif
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
/* re-read entry to get consistent uptodate info */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentryg->nextsg;
}
}
#endif /* SUPERGROUPS */
/* Then move the owned chain, except possibly ourself to the orphan list.
* Because this list can be very long and so exceed the size of a ubik
* transaction, we start a new transaction every 50 entries. */
count = 0;
nptr = tentry.owned;
while (nptr != 0) {
struct prentry nentry;
code = pr_ReadEntry(tt, 0, nptr, &nentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentry.owned = nentry.nextOwned; /* thread out */
if (nentry.id != tentry.id) { /* don't add us to orphan chain! */
code = AddToOrphan(tt, nentry.id);
if (code)
ABORT_WITH(tt, code);
count++;
#ifndef AFS_PTHREAD_ENV
if ((count & 3) == 0)
IOMGR_Poll();
#endif
}
if (count < 50)
continue;
code = pr_WriteEntry(tt, 0, loc, &tentry); /* update main entry */
if (code)
ABORT_WITH(tt, code);
/* end this trans and start a new one */
code = ubik_EndTrans(tt);
if (code)
return code;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* just to keep the connection alive */
#endif
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
/* re-read entry to get consistent uptodate info */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentry.owned;
}
/* now do what's left of the deletion stuff */
code = DeleteEntry(tt, &tentry, loc);
if (code != PRSUCCESS)
ABORT_WITH(tt, code);
code = ubik_EndTrans(tt);
if (code)
return code;
return PRSUCCESS;
}
| Bypass | 0 | Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid)
{
afs_int32 code;
struct ubik_trans *tt;
struct prentry tentry;
afs_int32 loc, nptr;
int count;
code = Initdb();
if (code)
return code;
if (code != PRSUCCESS)
return code;
if (aid == SYSADMINID || aid == ANYUSERID || aid == AUTHUSERID
|| aid == ANONYMOUSID)
return PRPERM;
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
code = read_DbHeader(tt);
if (code)
ABORT_WITH(tt, code);
code = WhoIsThis(call, tt, cid);
if (code)
ABORT_WITH(tt, PRPERM);
/* Read in entry to be deleted */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
/* Do some access checking */
if (tentry.owner != *cid && !IsAMemberOf(tt, *cid, SYSADMINID)
&& !IsAMemberOf(tt, *cid, tentry.owner) && !pr_noAuth)
ABORT_WITH(tt, PRPERM);
/* Delete each continuation block as a separate transaction so that no one
* transaction become to large to complete. */
nptr = tentry.next;
while (nptr != 0) {
struct contentry centry;
int i;
code = pr_ReadCoEntry(tt, 0, nptr, ¢ry);
if (code != 0)
ABORT_WITH(tt, PRDBFAIL);
for (i = 0; i < COSIZE; i++) {
if (centry.entries[i] == PRBADID)
continue;
if (centry.entries[i] == 0)
break;
#if defined(SUPERGROUPS)
if (aid < 0 && centry.entries[i] < 0) /* Supergroup */
code = RemoveFromSGEntry(tt, aid, centry.entries[i]);
else
#endif
code = RemoveFromEntry(tt, aid, centry.entries[i]);
if (code)
ABORT_WITH(tt, code);
tentry.count--; /* maintain count */
#ifndef AFS_PTHREAD_ENV
if ((i & 3) == 0)
IOMGR_Poll();
#endif
}
tentry.next = centry.next; /* thread out this block */
code = FreeBlock(tt, nptr); /* free continuation block */
if (code)
ABORT_WITH(tt, code);
code = pr_WriteEntry(tt, 0, loc, &tentry); /* update main entry */
if (code)
ABORT_WITH(tt, code);
/* end this trans and start a new one */
code = ubik_EndTrans(tt);
if (code)
return code;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* just to keep the connection alive */
#endif
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
/* re-read entry to get consistent uptodate info */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentry.next;
}
#if defined(SUPERGROUPS)
/* Delete each continuation block as a separate transaction
* so that no one transaction become too large to complete. */
{
struct prentryg *tentryg = (struct prentryg *)&tentry;
nptr = tentryg->nextsg;
while (nptr != 0) {
struct contentry centry;
int i;
code = pr_ReadCoEntry(tt, 0, nptr, ¢ry);
if (code != 0)
ABORT_WITH(tt, PRDBFAIL);
for (i = 0; i < COSIZE; i++) {
if (centry.entries[i] == PRBADID)
continue;
if (centry.entries[i] == 0)
break;
code = RemoveFromEntry(tt, aid, centry.entries[i]);
if (code)
ABORT_WITH(tt, code);
tentryg->countsg--; /* maintain count */
#ifndef AFS_PTHREAD_ENV
if ((i & 3) == 0)
IOMGR_Poll();
#endif
}
tentryg->nextsg = centry.next; /* thread out this block */
code = FreeBlock(tt, nptr); /* free continuation block */
if (code)
ABORT_WITH(tt, code);
code = pr_WriteEntry(tt, 0, loc, &tentry); /* update main entry */
if (code)
ABORT_WITH(tt, code);
/* end this trans and start a new one */
code = ubik_EndTrans(tt);
if (code)
return code;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* just to keep the connection alive */
#endif
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
/* re-read entry to get consistent uptodate info */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentryg->nextsg;
}
}
#endif /* SUPERGROUPS */
/* Then move the owned chain, except possibly ourself to the orphan list.
* Because this list can be very long and so exceed the size of a ubik
* transaction, we start a new transaction every 50 entries. */
count = 0;
nptr = tentry.owned;
while (nptr != 0) {
struct prentry nentry;
code = pr_ReadEntry(tt, 0, nptr, &nentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentry.owned = nentry.nextOwned; /* thread out */
if (nentry.id != tentry.id) { /* don't add us to orphan chain! */
code = AddToOrphan(tt, nentry.id);
if (code)
ABORT_WITH(tt, code);
count++;
#ifndef AFS_PTHREAD_ENV
if ((count & 3) == 0)
IOMGR_Poll();
#endif
}
if (count < 50)
continue;
code = pr_WriteEntry(tt, 0, loc, &tentry); /* update main entry */
if (code)
ABORT_WITH(tt, code);
/* end this trans and start a new one */
code = ubik_EndTrans(tt);
if (code)
return code;
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll(); /* just to keep the connection alive */
#endif
code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
if (code)
return code;
code = ubik_SetLock(tt, 1, 1, LOCKWRITE);
if (code)
ABORT_WITH(tt, code);
/* re-read entry to get consistent uptodate info */
loc = FindByID(tt, aid);
if (loc == 0)
ABORT_WITH(tt, PRNOENT);
code = pr_ReadEntry(tt, 0, loc, &tentry);
if (code)
ABORT_WITH(tt, PRDBFAIL);
nptr = tentry.owned;
}
/* now do what's left of the deletion stuff */
code = DeleteEntry(tt, &tentry, loc);
if (code != PRSUCCESS)
ABORT_WITH(tt, code);
code = ubik_EndTrans(tt);
if (code)
return code;
return PRSUCCESS;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,990 | SPR_AddToGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = addToGroup(call, aid, gid, &cid);
osi_auditU(call, PTS_AdToGrpEvent, code, AUD_ID, gid, AUD_ID, aid,
AUD_END);
ViceLog(5, ("PTS_AddToGroup: code %d cid %d gid %d aid %d\n", code, cid, gid, aid));
return code;
}
| Bypass | 0 | SPR_AddToGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = addToGroup(call, aid, gid, &cid);
osi_auditU(call, PTS_AdToGrpEvent, code, AUD_ID, gid, AUD_ID, aid,
AUD_END);
ViceLog(5, ("PTS_AddToGroup: code %d cid %d gid %d aid %d\n", code, cid, gid, aid));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,991 | SPR_Delete(struct rx_call *call, afs_int32 aid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = Delete(call, aid, &cid);
osi_auditU(call, PTS_DelEvent, code, AUD_ID, aid, AUD_END);
ViceLog(5, ("PTS_Delete: code %d cid %d aid %d\n", code, cid, aid));
return code;
}
| Bypass | 0 | SPR_Delete(struct rx_call *call, afs_int32 aid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = Delete(call, aid, &cid);
osi_auditU(call, PTS_DelEvent, code, AUD_ID, aid, AUD_END);
ViceLog(5, ("PTS_Delete: code %d cid %d aid %d\n", code, cid, aid));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,992 | SPR_DumpEntry(struct rx_call *call, afs_int32 apos,
struct prdebugentry *aentry)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = dumpEntry(call, apos, aentry, &cid);
osi_auditU(call, PTS_DmpEntEvent, code, AUD_LONG, apos, AUD_END);
ViceLog(125, ("PTS_DumpEntry: code %d cid %d apos %d\n", code, cid, apos));
return code;
}
| Bypass | 0 | SPR_DumpEntry(struct rx_call *call, afs_int32 apos,
struct prdebugentry *aentry)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = dumpEntry(call, apos, aentry, &cid);
osi_auditU(call, PTS_DmpEntEvent, code, AUD_LONG, apos, AUD_END);
ViceLog(125, ("PTS_DumpEntry: code %d cid %d apos %d\n", code, cid, apos));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,993 | SPR_GetCPS2(struct rx_call *call, afs_int32 aid, afs_int32 ahost,
prlist *alist, afs_int32 *over)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = getCPS2(call, aid, ahost, alist, over, &cid);
osi_auditU(call, PTS_GetCPS2Event, code, AUD_ID, aid, AUD_HOST, htonl(ahost),
AUD_END);
ViceLog(125, ("PTS_GetCPS2: code %d cid %d aid %d ahost %d\n", code, cid, aid, ahost));
return code;
}
| Bypass | 0 | SPR_GetCPS2(struct rx_call *call, afs_int32 aid, afs_int32 ahost,
prlist *alist, afs_int32 *over)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = getCPS2(call, aid, ahost, alist, over, &cid);
osi_auditU(call, PTS_GetCPS2Event, code, AUD_ID, aid, AUD_HOST, htonl(ahost),
AUD_END);
ViceLog(125, ("PTS_GetCPS2: code %d cid %d aid %d ahost %d\n", code, cid, aid, ahost));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,994 | SPR_GetHostCPS(struct rx_call *call, afs_int32 ahost, prlist *alist,
afs_int32 *over)
{
afs_int32 code;
code = getHostCPS(call, ahost, alist, over);
osi_auditU(call, PTS_GetHCPSEvent, code, AUD_HOST, htonl(ahost), AUD_END);
ViceLog(125, ("PTS_GetHostCPS: code %d ahost %d\n", code, ahost));
return code;
}
| Bypass | 0 | SPR_GetHostCPS(struct rx_call *call, afs_int32 ahost, prlist *alist,
afs_int32 *over)
{
afs_int32 code;
code = getHostCPS(call, ahost, alist, over);
osi_auditU(call, PTS_GetHCPSEvent, code, AUD_HOST, htonl(ahost), AUD_END);
ViceLog(125, ("PTS_GetHostCPS: code %d ahost %d\n", code, ahost));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,995 | SPR_IDToName(struct rx_call *call, idlist *aid, namelist *aname)
{
afs_int32 code;
code = idToName(call, aid, aname);
osi_auditU(call, PTS_IdToNmEvent, code, AUD_END);
ViceLog(125, ("PTS_IDToName: code %d\n", code));
return code;
}
| Bypass | 0 | SPR_IDToName(struct rx_call *call, idlist *aid, namelist *aname)
{
afs_int32 code;
code = idToName(call, aid, aname);
osi_auditU(call, PTS_IdToNmEvent, code, AUD_END);
ViceLog(125, ("PTS_IDToName: code %d\n", code));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,996 | SPR_INewEntry(struct rx_call *call, char aname[], afs_int32 aid, afs_int32 oid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = iNewEntry(call, aname, aid, oid, &cid);
osi_auditU(call, PTS_INewEntEvent, code, AUD_ID, aid, AUD_STR, aname,
AUD_ID, oid, AUD_END);
ViceLog(5, ("PTS_INewEntry: code %d cid %d aid %d aname %s oid %d\n", code, cid, aid, aname, oid));
return code;
}
| Bypass | 0 | SPR_INewEntry(struct rx_call *call, char aname[], afs_int32 aid, afs_int32 oid)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = iNewEntry(call, aname, aid, oid, &cid);
osi_auditU(call, PTS_INewEntEvent, code, AUD_ID, aid, AUD_STR, aname,
AUD_ID, oid, AUD_END);
ViceLog(5, ("PTS_INewEntry: code %d cid %d aid %d aname %s oid %d\n", code, cid, aid, aname, oid));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,997 | SPR_IsAMemberOf(struct rx_call *call, afs_int32 uid, afs_int32 gid,
afs_int32 *flag)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = isAMemberOf(call, uid, gid, flag, &cid);
osi_auditU(call, PTS_IsMemOfEvent, code, AUD_LONG, uid, AUD_LONG, gid,
AUD_END);
ViceLog(125, ("PTS_IsAMemberOf: code %d cid %d uid %d gid %d\n", code, cid, uid, gid));
return code;
}
| Bypass | 0 | SPR_IsAMemberOf(struct rx_call *call, afs_int32 uid, afs_int32 gid,
afs_int32 *flag)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = isAMemberOf(call, uid, gid, flag, &cid);
osi_auditU(call, PTS_IsMemOfEvent, code, AUD_LONG, uid, AUD_LONG, gid,
AUD_END);
ViceLog(125, ("PTS_IsAMemberOf: code %d cid %d uid %d gid %d\n", code, cid, uid, gid));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,998 | SPR_ListElements(struct rx_call *call, afs_int32 aid, prlist *alist,
afs_int32 *over)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = listElements(call, aid, alist, over, &cid);
osi_auditU(call, PTS_LstEleEvent, code, AUD_ID, aid, AUD_END);
ViceLog(125, ("PTS_ListElements: code %d cid %d aid %d\n", code, cid, aid));
return code;
}
| Bypass | 0 | SPR_ListElements(struct rx_call *call, afs_int32 aid, prlist *alist,
afs_int32 *over)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = listElements(call, aid, alist, over, &cid);
osi_auditU(call, PTS_LstEleEvent, code, AUD_ID, aid, AUD_END);
ViceLog(125, ("PTS_ListElements: code %d cid %d aid %d\n", code, cid, aid));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
9,999 | SPR_ListEntries(struct rx_call *call, afs_int32 flag, afs_int32 startindex,
prentries *bulkentries, afs_int32 *nextstartindex)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = listEntries(call, flag, startindex, bulkentries, nextstartindex, &cid);
osi_auditU(call, PTS_LstEntsEvent, code, AUD_LONG, flag, AUD_END);
ViceLog(125, ("PTS_ListEntries: code %d cid %d flag %d\n", code, cid, flag));
return code;
}
| Bypass | 0 | SPR_ListEntries(struct rx_call *call, afs_int32 flag, afs_int32 startindex,
prentries *bulkentries, afs_int32 *nextstartindex)
{
afs_int32 code;
afs_int32 cid = ANONYMOUSID;
code = listEntries(call, flag, startindex, bulkentries, nextstartindex, &cid);
osi_auditU(call, PTS_LstEntsEvent, code, AUD_LONG, flag, AUD_END);
ViceLog(125, ("PTS_ListEntries: code %d cid %d flag %d\n", code, cid, flag));
return code;
}
| @@ -345,13 +345,19 @@ newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid,
* automatic id assignment.
*/
code = WhoIsThisWithName(call, tt, cid, cname);
- if (code != 2) { /* 2 specifies that this is a foreign cell request */
- if (code)
- ABORT_WITH(tt, PRPERM);
- admin = IsAMemberOf(tt, *cid, SYSADMINID);
- } else {
- admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
- oid = *cid = SYSADMINID;
+ if (code && code != 2)
+ ABORT_WITH(tt, PRPERM);
+ admin = IsAMemberOf(tt, *cid, SYSADMINID);
+ if (code == 2 /* foreign cell request */) {
+ if (!restricted && (strcmp(aname, cname) == 0)) {
+ /* can't autoregister while providing an owner id */
+ if (oid != 0)
+ ABORT_WITH(tt, PRPERM);
+
+ admin = 1;
+ oid = SYSADMINID;
+ *cid = SYSADMINID;
+ }
}
if (!CreateOK(tt, *cid, oid, flag, admin))
ABORT_WITH(tt, PRPERM); | CWE-284 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.