From a71cb1d3efafa04eec45cdaaa6aeab21f0407999 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 21 Feb 2014 16:57:24 +0100 Subject: [PATCH] Fix potential crash in case of abort while update: We need to reset ctx->remote.read_from_db BEFORE caling vio_closedir Otherwise, it may interpret the handle as a 'bdtree' handle instead of a owncloud handle. Should fix #1442 --- csync/src/csync_update.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c index c903371cc..33f471a33 100644 --- a/csync/src/csync_update.c +++ b/csync/src/csync_update.c @@ -598,7 +598,6 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, ctx->status_code = CSYNC_STATUS_UPDATE_ERROR; } - csync_vio_closedir(ctx, dh); ctx->current_fs = previous_fs; goto done; } @@ -608,7 +607,6 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, rc = csync_ftw(ctx, filename, fn, depth - 1); if (rc < 0) { ctx->current_fs = previous_fs; - csync_vio_closedir(ctx, dh); goto done; } @@ -637,6 +635,9 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, done: ctx->remote.read_from_db = read_from_db; + if (dh != NULL) { + csync_vio_closedir(ctx, dh); + } csync_vio_file_stat_destroy(dirent); SAFE_FREE(filename); return rc;