From d475628c70c5947fefdb2afe84ffba93b4fa6a8d Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 7 Apr 2015 16:55:04 +0200 Subject: [PATCH] SyncEngine: Fix a crash in csync_vio_file_stat_copy #3051 In some cryptic cases where the getetag property wasn't returned by the server, we might be trying to c_strdup a null pointer in csync_vio_file_stat_copy. At least avoid crashing in this case by looking for CSYNC_VIO_FILE_STAT_FIELDS_ETAG, like csync_vio_file_stat_destroy does. --- csync/src/vio/csync_vio_file_stat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/csync/src/vio/csync_vio_file_stat.c b/csync/src/vio/csync_vio_file_stat.c index a7fd2f0b3b3..ffbd102fce3 100644 --- a/csync/src/vio/csync_vio_file_stat.c +++ b/csync/src/vio/csync_vio_file_stat.c @@ -30,7 +30,9 @@ csync_vio_file_stat_t *csync_vio_file_stat_new(void) { csync_vio_file_stat_t* csync_vio_file_stat_copy(csync_vio_file_stat_t *file_stat) { csync_vio_file_stat_t *file_stat_cpy = csync_vio_file_stat_new(); memcpy(file_stat_cpy, file_stat, sizeof(csync_vio_file_stat_t)); - file_stat_cpy->etag = c_strdup(file_stat_cpy->etag); + if (file_stat_cpy->fields & CSYNC_VIO_FILE_STAT_FIELDS_ETAG) { + file_stat_cpy->etag = c_strdup(file_stat_cpy->etag); + } if (file_stat_cpy->directDownloadCookies) { file_stat_cpy->directDownloadCookies = c_strdup(file_stat_cpy->directDownloadCookies); }