diff --git a/src/csync_update.c b/src/csync_update.c index 3f4e2c604..df6a12864 100644 --- a/src/csync_update.c +++ b/src/csync_update.c @@ -26,6 +26,7 @@ #include #include +#include #include "c_lib.h" #include "c_jhash.h" @@ -54,19 +55,25 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, const csync_vio_fi return -1; } + path = file; switch (ctx->current) { case LOCAL_REPLICA: - path = file + strlen(ctx->local.uri) + 1; + if (strlen(path) <= strlen(ctx->local.uri)) { + return -1; + } + path += strlen(ctx->local.uri) + 1; break; case REMOTE_REPLCIA: - path = file + strlen(ctx->remote.uri) + 1; + if (strlen(path) <= strlen(ctx->remote.uri)) { + return -1; + } + path += strlen(ctx->remote.uri) + 1; break; default: + path = NULL; + return -1; break; } - if (path == NULL) { - return -1; - } len = strlen(path); h = c_jhash64((uint8_t *) path, len, 0);