diff --git a/.gitignore b/.gitignore index fe9955b..320af4f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /libcmis-0.2.3.tar.gz /libcmis-0.3.0.tar.gz /libcmis-0.3.1.tar.gz +/libcmis-0.4.1.tar.gz diff --git a/0001-libcmis-c-handle-possible-bad-allocations.patch b/0001-libcmis-c-handle-possible-bad-allocations.patch deleted file mode 100644 index fbf658c..0000000 --- a/0001-libcmis-c-handle-possible-bad-allocations.patch +++ /dev/null @@ -1,1092 +0,0 @@ -From 2ae17cd3515b9a399840ccb3a0180b44e3b1c5bd Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= -Date: Mon, 8 Apr 2013 09:26:20 +0200 -Subject: [PATCH] libcmis-c: handle possible bad allocations - -Conflicts: - src/libcmis-c/document.cxx - src/libcmis-c/error.cxx - src/libcmis-c/internals.hxx - src/libcmis-c/oauth2-data.cxx - src/libcmis-c/object.cxx - src/libcmis-c/repository.cxx - src/libcmis-c/session-factory.cxx - src/libcmis-c/session.cxx ---- - src/libcmis-c/document.cxx | 111 +++++++++++++++++++++++++++++--------- - src/libcmis-c/error.cxx | 37 +++++-------- - src/libcmis-c/folder.cxx | 102 ++++++++++++++++++++++++++--------- - src/libcmis-c/internals.hxx | 7 +-- - src/libcmis-c/object-type.cxx | 65 ++++++++++++++++------ - src/libcmis-c/object.cxx | 71 ++++++++++++++++-------- - src/libcmis-c/property-type.cxx | 5 +- - src/libcmis-c/property.cxx | 52 ++++++++++-------- - src/libcmis-c/repository.cxx | 11 ++-- - src/libcmis-c/session-factory.cxx | 19 +++++-- - src/libcmis-c/session.cxx | 81 +++++++++++++++++++++++----- - 11 files changed, 401 insertions(+), 160 deletions(-) - -diff --git a/src/libcmis-c/document.cxx b/src/libcmis-c/document.cxx -index 18a8814..8c2df25 100644 ---- a/src/libcmis-c/document.cxx -+++ b/src/libcmis-c/document.cxx -@@ -53,7 +53,7 @@ libcmis_DocumentPtr libcmis_vector_document_get( libcmis_vector_document_Ptr vec - if ( vector != NULL && i < vector->handle.size( ) ) - { - libcmis::DocumentPtr handle = vector->handle[i]; -- item = new libcmis_document( ); -+ item = new( nothrow ) libcmis_document( ); - item->setHandle( handle ); - } - return item; -@@ -80,7 +80,7 @@ libcmis_DocumentPtr libcmis_document_cast( libcmis_ObjectPtr object ) - libcmis::DocumentPtr handle = boost::dynamic_pointer_cast< libcmis::Document >( object->handle ); - if ( handle.get( ) != NULL ) - { -- document = new libcmis_document( ); -+ document = new ( nothrow ) libcmis_document( ); - document->setHandle( handle ); - } - } -@@ -108,9 +108,19 @@ libcmis_vector_folder_Ptr libcmis_document_getParents( libcmis_DocumentPtr docum - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return parents; -@@ -142,15 +152,27 @@ void libcmis_document_getContentStream( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } -- catch ( const ios_base::failure& e ) -+ catch ( const bad_alloc& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new ios_base::failure( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } -+ } -+ catch ( const exception& e ) -+ { -+ if ( error != NULL ) -+ error->message = strdup( e.what() ); -+ } -+ catch ( ... ) -+ { - } - } - } -@@ -185,15 +207,24 @@ void libcmis_document_setContentStream( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } -- catch ( const ios_base::failure& e ) -+ catch ( const exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new ios_base::failure( e ); -+ error->message = strdup( e.what() ); - } - } - } -@@ -237,11 +268,18 @@ libcmis_DocumentPtr libcmis_document_checkOut( libcmis_DocumentPtr document, lib - pwc= new libcmis_document( ); - pwc->handle = handle; - } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ error->badAlloc = true; -+ } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - } - return pwc; -@@ -258,9 +296,11 @@ void libcmis_document_cancelCheckout( libcmis_DocumentPtr document, libcmis_Erro - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - } - } -@@ -286,7 +326,7 @@ libcmis_DocumentPtr libcmis_document_checkIn( - boost::shared_ptr< std::ostream > stream( new stringstream( ) ); - - size_t bufSize = 2048; -- char* buf = new char[ bufSize ]; -+ char * buf = new char[ bufSize ]; - size_t read = 0; - do - { -@@ -314,15 +354,24 @@ libcmis_DocumentPtr libcmis_document_checkIn( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } -- catch ( const ios_base::failure& e ) -+ catch ( const exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new ios_base::failure( e ); -+ error->message = strdup( e.what() ); - } - } - return newVersion; -@@ -343,9 +392,19 @@ libcmis_vector_document_Ptr libcmis_document_getAllVersions( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return result; -diff --git a/src/libcmis-c/error.cxx b/src/libcmis-c/error.cxx -index fb26cc5..7ac787a 100644 ---- a/src/libcmis-c/error.cxx -+++ b/src/libcmis-c/error.cxx -@@ -35,8 +35,7 @@ using namespace std; - - libcmis_ErrorPtr libcmis_error_create( ) - { -- libcmis_ErrorPtr error = new libcmis_error( ); -- error->handle = NULL; -+ libcmis_ErrorPtr error = new( nothrow ) libcmis_error( ); - return error; - } - -@@ -45,41 +44,29 @@ void libcmis_error_free( libcmis_ErrorPtr error ) - { - if ( error != NULL ) - { -- if ( error->handle != NULL ) -- delete error->handle; -- delete[] error->cached_type; -+ delete[] error->message; -+ delete[] error->type; - delete error; - } - } - - const char* libcmis_error_getMessage( libcmis_ErrorPtr error ) - { -- if ( error != NULL && error->handle != NULL ) -- return error->handle->what( ); -+ if ( error != NULL ) -+ { -+ if ( error->badAlloc ) -+ return "Failed to allocate memory"; -+ else -+ return error->message; -+ } - else - return ""; - } - - const char* libcmis_error_getType( libcmis_ErrorPtr error ) - { -- if ( error != NULL && error->handle != NULL ) -- { -- if ( error->cached_type == NULL ) -- { -- libcmis::Exception* cmisException = dynamic_cast< libcmis::Exception* >( error->handle ); -- if ( cmisException != NULL ) -- { -- string const type = cmisException->getType( ); -- size_t const len = type.size( ); -- error->cached_type = new char[len + 1]; -- strncpy( error->cached_type, type.c_str( ), len ); -- error->cached_type[len] = '\0'; -- } -- -- return error->cached_type; -- } -- else return NULL; -- } -+ if ( error != NULL ) -+ return error->type; - else - return NULL; - } -diff --git a/src/libcmis-c/folder.cxx b/src/libcmis-c/folder.cxx -index 00b94e8..ac69ac0 100644 ---- a/src/libcmis-c/folder.cxx -+++ b/src/libcmis-c/folder.cxx -@@ -53,8 +53,9 @@ libcmis_FolderPtr libcmis_vector_folder_get( libcmis_vector_folder_Ptr vector, s - if ( vector != NULL && i < vector->handle.size( ) ) - { - libcmis::FolderPtr handle = vector->handle[i]; -- item = new libcmis_folder( ); -- item->setHandle( handle ); -+ item = new ( nothrow ) libcmis_folder( ); -+ if ( item ) -+ item->setHandle( handle ); - } - return item; - } -@@ -81,8 +82,9 @@ libcmis_FolderPtr libcmis_folder_cast( libcmis_ObjectPtr object ) - libcmis::FolderPtr handle = boost::dynamic_pointer_cast< libcmis::Folder >( object->handle ); - if ( handle.get( ) != NULL ) - { -- folder = new libcmis_folder( ); -- folder->setHandle( handle ); -+ folder = new ( nothrow ) libcmis_folder( ); -+ if ( folder ) -+ folder->setHandle( handle ); - } - } - -@@ -112,9 +114,19 @@ libcmis_FolderPtr libcmis_folder_getParent( libcmis_FolderPtr folder, libcmis_Er - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return parent; -@@ -134,9 +146,19 @@ libcmis_vector_object_Ptr libcmis_folder_getChildren( libcmis_FolderPtr folder, - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return result; -@@ -191,9 +213,19 @@ libcmis_FolderPtr libcmis_folder_createFolder( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return result; -@@ -245,15 +277,24 @@ libcmis_DocumentPtr libcmis_folder_createDocument( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } -- catch ( const ios_base::failure& e ) -+ catch ( const exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new ios_base::failure( e ); -+ error->message = strdup( e.what() ); - } - } - return created; -@@ -266,20 +307,31 @@ libcmis_vector_string_Ptr libcmis_folder_removeTree( libcmis_FolderPtr folder, - bool continueOnError, - libcmis_ErrorPtr error ) - { -- libcmis_vector_string_Ptr failed = new libcmis_vector_string( ); -- if ( folder != NULL && folder->handle.get( ) != NULL ) -+ libcmis_vector_string_Ptr failed = NULL; -+ try - { -- try -+ failed = new libcmis_vector_string( ); -+ if ( folder != NULL && folder->handle.get( ) != NULL ) - { -- vector< string > handle = folder->handle->removeTree( allVersion, -- libcmis::UnfileObjects::Type( unfile ), continueOnError ); -- failed->handle = handle; -+ vector< string > handle = folder->handle->removeTree( allVersion, -+ libcmis::UnfileObjects::Type( unfile ), continueOnError ); -+ failed->handle = handle; - } -- catch ( const libcmis::Exception& e ) -+ } -+ catch ( const libcmis::Exception& e ) -+ { -+ if ( error != NULL ) - { -- // Set the error handle -- if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; - } - } - return failed; -diff --git a/src/libcmis-c/internals.hxx b/src/libcmis-c/internals.hxx -index 492a9f5..449b7ee 100644 ---- a/src/libcmis-c/internals.hxx -+++ b/src/libcmis-c/internals.hxx -@@ -41,10 +41,11 @@ - - struct libcmis_error - { -- std::exception* handle; -- char* cached_type; -+ char* message; -+ char* type; -+ bool badAlloc; - -- libcmis_error( ) : handle( NULL ), cached_type( NULL ) { } -+ libcmis_error( ) : message( NULL ), type( NULL ), badAlloc( false ) { } - }; - - struct libcmis_session -diff --git a/src/libcmis-c/object-type.cxx b/src/libcmis-c/object-type.cxx -index cca598e..ac93989 100644 ---- a/src/libcmis-c/object-type.cxx -+++ b/src/libcmis-c/object-type.cxx -@@ -53,8 +53,9 @@ libcmis_ObjectTypePtr libcmis_vector_object_type_get( libcmis_vector_object_type - if ( vector != NULL && i < vector->handle.size( ) ) - { - libcmis::ObjectTypePtr type = vector->handle[i]; -- item = new libcmis_object_type( ); -- item->handle = type; -+ item = new ( nothrow ) libcmis_object_type( ); -+ if ( item ) -+ item->handle = type; - } - return item; - } -@@ -138,9 +139,19 @@ libcmis_ObjectTypePtr libcmis_object_type_getParentType( - } - catch( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - -@@ -163,9 +174,19 @@ libcmis_ObjectTypePtr libcmis_object_type_getBaseType( - } - catch( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - -@@ -187,9 +208,19 @@ libcmis_vector_object_type_Ptr libcmis_object_type_getChildren( - } - catch( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - -@@ -287,12 +318,15 @@ libcmis_vector_property_type_Ptr libcmis_object_type_getPropertiesTypes( libcmis - if ( type != NULL && type->handle != NULL ) - { - map< string, libcmis::PropertyTypePtr >& handles = type->handle->getPropertiesTypes( ); -- propertyTypes = new libcmis_vector_property_type( ); -- int i = 0; -- for ( map< string, libcmis::PropertyTypePtr >::iterator it = handles.begin( ); -- it != handles.end( ); ++it, ++i ) -+ propertyTypes = new ( nothrow ) libcmis_vector_property_type( ); -+ if ( propertyTypes ) - { -- propertyTypes->handle.push_back( it->second ); -+ int i = 0; -+ for ( map< string, libcmis::PropertyTypePtr >::iterator it = handles.begin( ); -+ it != handles.end( ); ++it, ++i ) -+ { -+ propertyTypes->handle.push_back( it->second ); -+ } - } - } - -@@ -308,8 +342,9 @@ libcmis_PropertyTypePtr libcmis_object_type_getPropertyType( libcmis_ObjectTypeP - map< string, libcmis::PropertyTypePtr >::iterator it = handles.find( string( id ) ); - if ( it != handles.end( ) ) - { -- propertyType = new libcmis_property_type( ); -- propertyType->handle = it->second; -+ propertyType = new ( nothrow ) libcmis_property_type( ); -+ if ( propertyType ) -+ propertyType->handle = it->second; - } - } - -diff --git a/src/libcmis-c/object.cxx b/src/libcmis-c/object.cxx -index 7aed354..94f0586 100644 ---- a/src/libcmis-c/object.cxx -+++ b/src/libcmis-c/object.cxx -@@ -54,8 +54,9 @@ libcmis_ObjectPtr libcmis_vector_object_get( libcmis_vector_object_Ptr vector, s - if ( vector != NULL && i < vector->handle.size( ) ) - { - libcmis::ObjectPtr type = vector->handle[i]; -- item = new libcmis_object( ); -- item->handle = type; -+ item = new ( nothrow ) libcmis_object( ); -+ if ( item ) -+ item->handle = type; - } - return item; - } -@@ -86,15 +87,15 @@ char* libcmis_object_getName( libcmis_ObjectPtr object ) - - libcmis_vector_string_Ptr libcmis_object_getPaths( libcmis_ObjectPtr object ) - { -+ libcmis_vector_string_Ptr c_paths = NULL; - if ( object != NULL && object->handle != NULL ) - { - std::vector< std::string > paths = object->handle->getPaths( ); -- libcmis_vector_string_Ptr c_paths = new libcmis_vector_string( ); -- c_paths->handle = paths; -- return c_paths; -+ c_paths = new ( nothrow ) libcmis_vector_string( ); -+ if ( c_paths ) -+ c_paths->handle = paths; - } -- else -- return NULL; -+ return c_paths; - } - - char* libcmis_object_getBaseType( libcmis_ObjectPtr object ) -@@ -181,12 +182,17 @@ libcmis_vector_property_Ptr libcmis_object_getProperties( libcmis_ObjectPtr obje - if ( object != NULL && object->handle.get( ) != NULL ) - { - map< string, libcmis::PropertyPtr >& handles = object->handle->getProperties( ); -- properties = new libcmis_vector_property( ); -+ properties = new ( std::nothrow ) libcmis_vector_property( ); - int i = 0; - for ( map< string, libcmis::PropertyPtr >::iterator it = handles.begin( ); - it != handles.end( ); ++it, ++i ) - { -- properties->handle.push_back( it->second ); -+ int i = 0; -+ for ( map< string, libcmis::PropertyPtr >::iterator it = handles.begin( ); -+ it != handles.end( ); ++it, ++i ) -+ { -+ properties->handle.push_back( it->second ); -+ } - } - } - return properties; -@@ -202,8 +208,9 @@ libcmis_PropertyPtr libcmis_object_getProperty( libcmis_ObjectPtr object, const - map< string, libcmis::PropertyPtr >::iterator it = handles.find( string( name ) ); - if ( it != handles.end( ) ) - { -- property = new libcmis_property( ); -- property->handle = it->second; -+ property = new ( nothrow ) libcmis_property( ); -+ if ( property ) -+ property->handle = it->second; - } - } - return property; -@@ -235,9 +242,19 @@ libcmis_ObjectPtr libcmis_object_updateProperties( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return result; -@@ -249,8 +266,9 @@ libcmis_ObjectTypePtr libcmis_object_getTypeDescription( libcmis_ObjectPtr objec - libcmis_ObjectTypePtr result = NULL; - if ( object != NULL && object->handle.get( ) != NULL ) - { -- result = new libcmis_object_type( ); -- result->handle = object->handle->getTypeDescription( ); -+ result = new ( nothrow ) libcmis_object_type( ); -+ if ( result ) -+ result->handle = object->handle->getTypeDescription( ); - } - return result; - } -@@ -261,8 +279,9 @@ libcmis_AllowableActionsPtr libcmis_object_getAllowableActions( libcmis_ObjectPt - libcmis_AllowableActionsPtr result = NULL; - if ( object != NULL && object->handle.get( ) != NULL ) - { -- result = new libcmis_allowable_actions( ); -- result->handle = object->handle->getAllowableActions( ); -+ result = new ( nothrow ) libcmis_allowable_actions( ); -+ if ( result ) -+ result->handle = object->handle->getAllowableActions( ); - } - return result; - } -@@ -278,9 +297,11 @@ void libcmis_object_refresh( libcmis_ObjectPtr object, libcmis_ErrorPtr error ) - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - } - } -@@ -305,9 +326,11 @@ void libcmis_object_remove( libcmis_ObjectPtr object, bool allVersions, libcmis_ - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - } - } -@@ -333,9 +356,11 @@ void libcmis_object_move( libcmis_ObjectPtr object, - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - } - } -diff --git a/src/libcmis-c/property-type.cxx b/src/libcmis-c/property-type.cxx -index 15dfe8b..001812c 100644 ---- a/src/libcmis-c/property-type.cxx -+++ b/src/libcmis-c/property-type.cxx -@@ -50,8 +50,9 @@ libcmis_PropertyTypePtr libcmis_vector_property_type_get( libcmis_vector_propert - if ( vector != NULL && i < vector->handle.size( ) ) - { - libcmis::PropertyTypePtr type = vector->handle[i]; -- item = new libcmis_property_type( ); -- item->handle = type; -+ item = new ( std::nothrow ) libcmis_property_type( ); -+ if ( item ) -+ item->handle = type; - } - return item; - } -diff --git a/src/libcmis-c/property.cxx b/src/libcmis-c/property.cxx -index cae4799..6512d59 100644 ---- a/src/libcmis-c/property.cxx -+++ b/src/libcmis-c/property.cxx -@@ -34,7 +34,7 @@ using namespace std; - - libcmis_vector_property_Ptr libcmis_vector_property_create( ) - { -- return new libcmis_vector_property( ); -+ return new ( nothrow ) libcmis_vector_property( ); - } - - -@@ -59,8 +59,9 @@ libcmis_PropertyPtr libcmis_vector_property_get( libcmis_vector_property_Ptr vec - if ( vector != NULL && i < vector->handle.size( ) ) - { - libcmis::PropertyPtr type = vector->handle[i]; -- item = new libcmis_property( ); -- item->handle = type; -+ item = new ( nothrow ) libcmis_property( ); -+ if ( item ) -+ item->handle = type; - } - return item; - } -@@ -81,12 +82,15 @@ libcmis_PropertyPtr libcmis_property_create( libcmis_PropertyTypePtr type, const - libcmis_PropertyPtr property = NULL; - if ( type != NULL && type->handle.get( ) != NULL ) - { -- property = new libcmis_property( ); -- vector< string > values; -- for ( size_t i = 0; i < size; ++i ) -- values.push_back( string( strValues[i] ) ); -- libcmis::PropertyPtr prop( new libcmis::Property( type->handle, values ) ); -- property->handle = prop; -+ property = new ( nothrow ) libcmis_property( ); -+ if ( property ) -+ { -+ vector< string > values; -+ for ( size_t i = 0; i < size; ++i ) -+ values.push_back( string( strValues[i] ) ); -+ libcmis::PropertyPtr prop( new ( nothrow ) libcmis::Property( type->handle, values ) ); -+ property->handle = prop; -+ } - } - - return property; -@@ -105,8 +109,9 @@ libcmis_PropertyTypePtr libcmis_property_getPropertyType( libcmis_PropertyPtr pr - if ( property != NULL && property->handle.get( ) != NULL ) - { - libcmis::PropertyTypePtr handle = property->handle->getPropertyType( ); -- type = new libcmis_property_type( ); -- type->handle = handle; -+ type = new ( nothrow ) libcmis_property_type( ); -+ if ( type ) -+ type->handle = handle; - } - return type; - } -@@ -118,8 +123,9 @@ libcmis_vector_time_Ptr libcmis_property_getDateTimes( libcmis_PropertyPtr prope - if ( property != NULL && property->handle.get( ) != NULL ) - { - vector< boost::posix_time::ptime > handles = property->handle->getDateTimes( ); -- times = new libcmis_vector_time( ); -- times->handle = handles; -+ times = new ( nothrow ) libcmis_vector_time( ); -+ if ( times ) -+ times->handle = handles; - } - return times; - } -@@ -131,8 +137,9 @@ libcmis_vector_bool_Ptr libcmis_property_getBools( libcmis_PropertyPtr property - if ( property != NULL && property->handle.get( ) != NULL ) - { - vector< bool > handles = property->handle->getBools( ); -- values = new libcmis_vector_bool( ); -- values->handle = handles; -+ values = new ( nothrow ) libcmis_vector_bool( ); -+ if ( values ) -+ values->handle = handles; - } - return values; - } -@@ -144,8 +151,9 @@ libcmis_vector_string_Ptr libcmis_property_getStrings( libcmis_PropertyPtr prope - if ( property != NULL && property->handle.get( ) != NULL ) - { - vector< string > handles = property->handle->getStrings( ); -- values = new libcmis_vector_string( ); -- values->handle = handles; -+ values = new ( nothrow ) libcmis_vector_string( ); -+ if ( values ) -+ values->handle = handles; - } - return values; - } -@@ -157,8 +165,9 @@ libcmis_vector_long_Ptr libcmis_property_getLongs( libcmis_PropertyPtr property - if ( property != NULL && property->handle.get( ) != NULL ) - { - vector< long > handles = property->handle->getLongs( ); -- values = new libcmis_vector_long( ); -- values->handle = handles; -+ values = new ( nothrow ) libcmis_vector_long( ); -+ if ( values ) -+ values->handle = handles; - } - return values; - } -@@ -170,8 +179,9 @@ libcmis_vector_double_Ptr libcmis_property_getDoubles( libcmis_PropertyPtr prope - if ( property != NULL && property->handle.get( ) != NULL ) - { - vector< double > handles = property->handle->getDoubles( ); -- values = new libcmis_vector_double( ); -- values->handle = handles; -+ values = new ( nothrow ) libcmis_vector_double( ); -+ if ( values ) -+ values->handle = handles; - } - return values; - } -diff --git a/src/libcmis-c/repository.cxx b/src/libcmis-c/repository.cxx -index c04f62c..bc5399c 100644 ---- a/src/libcmis-c/repository.cxx -+++ b/src/libcmis-c/repository.cxx -@@ -29,12 +29,17 @@ - #include "internals.hxx" - #include "repository.h" - -+using std::nothrow; -+ - libcmis_RepositoryPtr libcmis_repository_create( xmlNodePtr node ) - { -- libcmis_RepositoryPtr repository = new libcmis_repository( ); -+ libcmis_RepositoryPtr repository = new ( nothrow ) libcmis_repository( ); - -- libcmis::RepositoryPtr handle( new libcmis::Repository( node ) ); -- repository->handle = handle; -+ if ( repository ) -+ { -+ libcmis::RepositoryPtr handle( new ( nothrow ) libcmis::Repository( node ) ); -+ repository->handle = handle; -+ } - - return repository; - } -diff --git a/src/libcmis-c/session-factory.cxx b/src/libcmis-c/session-factory.cxx -index 7ebb278..5c5a80f 100644 ---- a/src/libcmis-c/session-factory.cxx -+++ b/src/libcmis-c/session-factory.cxx -@@ -83,9 +83,19 @@ libcmis_SessionPtr libcmis_createSession( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - - return session; -@@ -117,7 +127,10 @@ libcmis_RepositoryPtr* libcmis_getRepositories( - { - // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - return repositories; - } -diff --git a/src/libcmis-c/session.cxx b/src/libcmis-c/session.cxx -index 7f67e1e..f00f04b 100644 ---- a/src/libcmis-c/session.cxx -+++ b/src/libcmis-c/session.cxx -@@ -107,14 +107,17 @@ libcmis_RepositoryPtr libcmis_session_getRepository( - try - { - libcmis::RepositoryPtr handle = session->handle->getRepository( ); -- repository = new libcmis_repository( ); -- repository->handle = handle; -+ repository = new ( nothrow ) libcmis_repository( ); -+ if ( repository ) -+ repository->handle = handle; - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } - } - } - -@@ -137,9 +140,19 @@ libcmis_FolderPtr libcmis_session_getRootFolder( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return folder; -@@ -162,9 +175,19 @@ libcmis_ObjectPtr libcmis_session_getObject( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return object; -@@ -187,9 +210,19 @@ libcmis_ObjectPtr libcmis_session_getObjectByPath( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return object; -@@ -212,9 +245,19 @@ libcmis_FolderPtr libcmis_session_getFolder( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return folder; -@@ -237,9 +280,19 @@ libcmis_ObjectTypePtr libcmis_session_getType( - } - catch ( const libcmis::Exception& e ) - { -- // Set the error handle - if ( error != NULL ) -- error->handle = new libcmis::Exception( e ); -+ { -+ error->message = strdup( e.what() ); -+ error->type = strdup( e.getType().c_str() ); -+ } -+ } -+ catch ( const bad_alloc& e ) -+ { -+ if ( error != NULL ) -+ { -+ error->message = strdup( e.what() ); -+ error->badAlloc = true; -+ } - } - } - return type; --- -1.8.1.4 - diff --git a/0001-rhbz-918079-always-return-40-hexa-digits.patch b/0001-rhbz-918079-always-return-40-hexa-digits.patch deleted file mode 100644 index 706d23c..0000000 --- a/0001-rhbz-918079-always-return-40-hexa-digits.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 264824628f58a1668b54252babb1add4d3c7eb79 Mon Sep 17 00:00:00 2001 -From: David Tardon -Date: Mon, 8 Apr 2013 14:07:23 +0200 -Subject: [PATCH 1/3] rhbz#918079 always return 40 hexa digits (cherry picked - from commit 8e66145d204f7d053549b7cc28aef6863cfd38c8) - ---- - src/libcmis/test-xmlutils.cxx | 12 ++++++++++-- - src/libcmis/xml-utils.cxx | 6 +++++- - 2 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/src/libcmis/test-xmlutils.cxx b/src/libcmis/test-xmlutils.cxx -index dd5082f..0e527ad 100644 ---- a/src/libcmis/test-xmlutils.cxx -+++ b/src/libcmis/test-xmlutils.cxx -@@ -431,8 +431,16 @@ void XmlTest::propertyIntegerAsXmlTest( ) - - void XmlTest::sha1Test( ) - { -- string actual = libcmis::sha1( "Hello" ); -- CPPUNIT_ASSERT_EQUAL( string( "f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0" ), actual ); -+ { -+ string actual = libcmis::sha1( "Hello" ); -+ CPPUNIT_ASSERT_EQUAL( string( "f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0" ), actual ); -+ } -+ -+ { -+ // check correct width -+ string actual = libcmis::sha1( "35969137" ); -+ CPPUNIT_ASSERT_EQUAL( string( "0d93546909cfeb5c00089202104df3980000ec9f" ), actual ); -+ } - } - - CPPUNIT_TEST_SUITE_REGISTRATION( XmlTest ); -diff --git a/src/libcmis/xml-utils.cxx b/src/libcmis/xml-utils.cxx -index dddfafa..645fbcf 100644 ---- a/src/libcmis/xml-utils.cxx -+++ b/src/libcmis/xml-utils.cxx -@@ -498,8 +498,12 @@ namespace libcmis - sha1.get_digest( digest ); - - stringstream out; -+ // Setup writing mode. Every number must produce eight -+ // hexadecimal digits, including possible leading 0s, or we get -+ // less than 40 digits as result. -+ out << hex << setfill('0') << right; - for ( int i = 0; i < 5; ++i ) -- out << hex << digest[i]; -+ out << setw(8) << digest[i]; - return out.str(); - } - --- -1.8.1.4 - diff --git a/0002-rhbz-918080-restrict-the-set-of-protocols-for-curl.patch b/0002-rhbz-918080-restrict-the-set-of-protocols-for-curl.patch deleted file mode 100644 index 4127faf..0000000 --- a/0002-rhbz-918080-restrict-the-set-of-protocols-for-curl.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 3c34544890e6fba5df3ddffd11a0533c96426cc6 Mon Sep 17 00:00:00 2001 -From: David Tardon -Date: Mon, 8 Apr 2013 20:18:19 +0200 -Subject: [PATCH 2/3] rhbz#918080 restrict the set of protocols for curl - (cherry picked from commit 6401443248d7ce9fad1b42bad291418d59f4a623) - -Conflicts: - src/libcmis/base-session.cxx - src/libcmis/base-session.hxx ---- - src/libcmis/base-session.cxx | 10 ++++++++++ - src/libcmis/base-session.hxx | 1 + - 2 files changed, 11 insertions(+) - -diff --git a/src/libcmis/base-session.cxx b/src/libcmis/base-session.cxx -index b007a9d..9d08edc 100644 ---- a/src/libcmis/base-session.cxx -+++ b/src/libcmis/base-session.cxx -@@ -123,6 +123,7 @@ BaseSession::BaseSession( string atomPubUrl, string repositoryId, string usernam - { - curl_global_init( CURL_GLOBAL_ALL ); - m_curlHandle = curl_easy_init( ); -+ initProtocols(); - } - - BaseSession::BaseSession( const BaseSession& copy ) : -@@ -142,6 +143,7 @@ BaseSession::BaseSession( const BaseSession& copy ) : - // Not sure how sharing curl handles is safe. - curl_global_init( CURL_GLOBAL_ALL ); - m_curlHandle = curl_easy_init( ); -+ initProtocols(); - } - - BaseSession& BaseSession::operator=( const BaseSession& copy ) -@@ -161,6 +163,7 @@ BaseSession& BaseSession::operator=( const BaseSession& copy ) - // Not sure how sharing curl handles is safe. - curl_global_init( CURL_GLOBAL_ALL ); - m_curlHandle = curl_easy_init( ); -+ initProtocols(); - - return *this; - } -@@ -535,3 +538,10 @@ libcmis::Exception CurlException::getCmisException( ) const - - return libcmis::Exception( msg, type ); - } -+ -+void BaseSession::initProtocols( ) -+{ -+ const unsigned long protocols = CURLPROTO_HTTP | CURLPROTO_HTTPS; -+ curl_easy_setopt(m_curlHandle, CURLOPT_PROTOCOLS, protocols); -+ curl_easy_setopt(m_curlHandle, CURLOPT_REDIR_PROTOCOLS, protocols); -+} -diff --git a/src/libcmis/base-session.hxx b/src/libcmis/base-session.hxx -index 0b90c1f..6446a41 100644 ---- a/src/libcmis/base-session.hxx -+++ b/src/libcmis/base-session.hxx -@@ -149,6 +149,7 @@ class BaseSession : public libcmis::Session - virtual void setAuthenticationProvider( libcmis::AuthProviderPtr provider ) { m_authProvider = provider; } - private: - void httpRunRequest( std::string url ) throw ( CurlException ); -+ void initProtocols( ); - }; - - #endif --- -1.8.1.4 - diff --git a/0003-Init-protocols-should-be-done-right-after-resetting-.patch b/0003-Init-protocols-should-be-done-right-after-resetting-.patch deleted file mode 100644 index 3f8023b..0000000 --- a/0003-Init-protocols-should-be-done-right-after-resetting-.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 3ea92e49821638be039be7085659af160a6d4ebf Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= -Date: Mon, 22 Apr 2013 15:45:26 +0200 -Subject: [PATCH 3/3] Init protocols should be done right after resetting curl - handle (cherry picked from commit e75bd2548101b8681edf13ea085d62634b7668cf) - -Conflicts: - src/libcmis/base-session.cxx ---- - src/libcmis/base-session.cxx | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/src/libcmis/base-session.cxx b/src/libcmis/base-session.cxx -index 9d08edc..478d0de 100644 ---- a/src/libcmis/base-session.cxx -+++ b/src/libcmis/base-session.cxx -@@ -123,7 +123,6 @@ BaseSession::BaseSession( string atomPubUrl, string repositoryId, string usernam - { - curl_global_init( CURL_GLOBAL_ALL ); - m_curlHandle = curl_easy_init( ); -- initProtocols(); - } - - BaseSession::BaseSession( const BaseSession& copy ) : -@@ -143,7 +142,6 @@ BaseSession::BaseSession( const BaseSession& copy ) : - // Not sure how sharing curl handles is safe. - curl_global_init( CURL_GLOBAL_ALL ); - m_curlHandle = curl_easy_init( ); -- initProtocols(); - } - - BaseSession& BaseSession::operator=( const BaseSession& copy ) -@@ -163,7 +161,6 @@ BaseSession& BaseSession::operator=( const BaseSession& copy ) - // Not sure how sharing curl handles is safe. - curl_global_init( CURL_GLOBAL_ALL ); - m_curlHandle = curl_easy_init( ); -- initProtocols(); - - return *this; - } -@@ -223,6 +220,7 @@ libcmis::HttpResponsePtr BaseSession::httpGetRequest( string url ) throw ( CurlE - { - // Reset the handle for the request - curl_easy_reset( m_curlHandle ); -+ initProtocols( ); - - libcmis::HttpResponsePtr response( new libcmis::HttpResponse( ) ); - -@@ -255,6 +253,7 @@ libcmis::HttpResponsePtr BaseSession::httpPutRequest( string url, istream& is, v - { - // Reset the handle for the request - curl_easy_reset( m_curlHandle ); -+ initProtocols( ); - - libcmis::HttpResponsePtr response( new libcmis::HttpResponse( ) ); - -@@ -320,6 +319,7 @@ libcmis::HttpResponsePtr BaseSession::httpPostRequest( string url, istringstream - { - // Reset the handle for the request - curl_easy_reset( m_curlHandle ); -+ initProtocols( ); - - libcmis::HttpResponsePtr response( new libcmis::HttpResponse( ) ); - -@@ -385,6 +385,7 @@ void BaseSession::httpDeleteRequest( string url ) throw ( CurlException ) - { - // Reset the handle for the request - curl_easy_reset( m_curlHandle ); -+ initProtocols( ); - - curl_easy_setopt( m_curlHandle, CURLOPT_CUSTOMREQUEST, "DELETE" ); - httpRunRequest( url ); --- -1.8.1.4 - diff --git a/libcmis.spec b/libcmis.spec index 2f9b77f..b885fc1 100644 --- a/libcmis.spec +++ b/libcmis.spec @@ -1,9 +1,9 @@ -%global apiversion 0.3 +%global apiversion 0.4 Name: libcmis -Version: 0.3.1 -Release: 8%{?dist} -Summary: A C++ client library for the CMIS interface +Version: 0.4.1 +Release: 1%{?dist} +Summary: A C++ client library for CM interfaces Group: System Environment/Libraries License: GPLv2+ or LGPLv2+ or MPLv1.1 @@ -15,17 +15,12 @@ BuildRequires: libcurl-devel BuildRequires: libxml2-devel BuildRequires: xmlto -Patch0: 0001-libcmis-c-handle-possible-bad-allocations.patch -Patch1: 0001-rhbz-918079-always-return-40-hexa-digits.patch -Patch2: 0002-rhbz-918080-restrict-the-set-of-protocols-for-curl.patch -Patch3: 0003-Init-protocols-should-be-done-right-after-resetting-.patch -# rhbz#1000819 -Patch4: 0001-fixed-libcmis-c.pc-to-point-to-versioned-libcmis-pc-.patch - %description -LibCMIS is a C++ client library for the CMIS interface. This allows C++ -applications to connect to any ECM behaving as a CMIS server like -Alfresco, Nuxeo for the open source ones. +LibCMIS is a C++ client library for working with CM (content management) +interfaces. The primary supported interface (which gave the library its +name) is CMIS, which allows applications to connect to any ECM behaving +as a CMIS server (Alfresco or Nuxeo are examples of open source ones). +Another supported interface is Google Drive. %package devel Summary: Development files for %{name} @@ -47,20 +42,16 @@ command line. %prep %setup -q -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 %build -%configure --disable-static --disable-tests --disable-werror DOCBOOK2MAN='xmlto man' +%configure --disable-silent-rules --disable-static --disable-tests --disable-werror \ + DOCBOOK2MAN='xmlto man' sed -i \ -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \ -e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' \ libtool -make %{?_smp_mflags} V=1 +make %{?_smp_mflags} %install @@ -94,6 +85,9 @@ rm -f %{buildroot}/%{_libdir}/*.la %changelog +* Wed Nov 06 2013 David Tardon - 0.4.1-1 +- new upstream release + * Fri Aug 30 2013 David Tardon - 0.3.1-8 - Resolves: rhbz#1000819 pkgconfig file for libcmis-c is broken diff --git a/sources b/sources index 0d41091..3c7c3a4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -a60f503fa011174737dd603fb345d9e1 libcmis-0.3.1.tar.gz +22f8a85daf4a012180322e1f52a7563b libcmis-0.4.1.tar.gz