diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-08-31 12:26:16 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-09-09 12:58:55 +0200 |
commit | f93c444381f7d5b78d16827890a95bb2a9b343f4 (patch) | |
tree | 72afab702a2e4a226961e7b0e48e19bcd6f57339 | |
parent | 49a9b07924f6bbb4d359254a5c4d5fb1b6868f8e (diff) | |
download | csync-f93c444381f7d5b78d16827890a95bb2a9b343f4.tar.gz csync-f93c444381f7d5b78d16827890a95bb2a9b343f4.tar.xz csync-f93c444381f7d5b78d16827890a95bb2a9b343f4.zip |
owncloud: Make sure we check _cleanPath return value
It can return NULL on uris like owncloud://owncloud.example.com/
and this will lead to crashes if we don't error out early when this
happens.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | modules/csync_owncloud.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/modules/csync_owncloud.c b/modules/csync_owncloud.c index a73f1dc..be83c88 100644 --- a/modules/csync_owncloud.c +++ b/modules/csync_owncloud.c @@ -624,7 +624,7 @@ static int fetch_resource_list( const char *uri, curi = _cleanPath( uri ); - if (!fetchCtx) { + if (!curi) { errno = ENOMEM; SAFE_FREE(curi); return -1; @@ -814,6 +814,12 @@ static int owncloud_stat(const char *uri, csync_vio_file_stat_t *buf) { } curi = _cleanPath( uri ); + if ( ! curi) { + DEBUG_WEBDAV("Could not extract path from %s.\n", curi ); + errno = ENOENT; + SAFE_FREE(fetchCtx); + return -1; + } DEBUG_WEBDAV("I have no stat cache, call propfind for %s.", curi ); fetchCtx->list = NULL; @@ -1333,6 +1339,12 @@ static csync_vio_method_handle_t *owncloud_opendir(const char *uri) { DEBUG_WEBDAV("opendir method called on %s", uri ); + if ( ! curi ) { + DEBUG_WEBDAV("Failed to clean path for %s\n", uri ); + errno = ENOENT; + return NULL; + } + dav_connect( uri ); fetchCtx = c_malloc( sizeof( struct listdir_context )); @@ -1448,6 +1460,12 @@ static int owncloud_rmdir(const char *uri) { int rc = NE_OK; char* curi = _cleanPath( uri ); + if ( ! curi) { + DEBUG_WEBDAV("Could not extract path from %s.\n", curi ); + errno = ENOENT; + return -1; + } + rc = dav_connect(uri); if (rc < 0) { errno = EINVAL; @@ -1481,6 +1499,16 @@ static int owncloud_rename(const char *olduri, const char *newuri) { src = _cleanPath( olduri ); target = _cleanPath( newuri ); + if ( ! src ) { + DEBUG_WEBDAV("Could not extract path from %s.\n", olduri ); + errno = ENOENT; + rc = NE_ERROR; + } + if ( ! target ) { + DEBUG_WEBDAV("Could not extract path from %s.\n", newuri ); + errno = ENOENT; + rc = NE_ERROR; + } if( rc >= 0 ) { DEBUG_WEBDAV("MOVE: %s => %s: %d", src, target, rc ); rc = ne_move(dav_session.ctx, 1, src, target ); @@ -1569,7 +1597,7 @@ static int owncloud_utimes(const char *uri, const struct timeval *times) { curi = _cleanPath( uri ); - if( ! uri ) { + if( ! curi ) { errno = ENOENT; return -1; } |