From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4F13042EF5F for ; Thu, 18 Jun 2020 01:04:42 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id g139so1450771lfd.10 for ; Wed, 17 Jun 2020 15:04:42 -0700 (PDT) From: Cyrill Gorcunov Date: Thu, 18 Jun 2020 01:03:34 +0300 Message-Id: <20200617220335.836265-6-gorcunov@gmail.com> In-Reply-To: <20200617220335.836265-1-gorcunov@gmail.com> References: <20200617220335.836265-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 5/6] xlog: xlog_cursor -- use sizeof with snprintf for safety List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy , Alexander Turenko This is more consistent than relying that array size will remain PATH_MAX forever. Signed-off-by: Cyrill Gorcunov --- src/box/xlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/box/xlog.c b/src/box/xlog.c index 1685a4cf7..94f7838bf 100644 --- a/src/box/xlog.c +++ b/src/box/xlog.c @@ -1970,7 +1970,7 @@ xlog_cursor_openfd(struct xlog_cursor *i, int fd, const char *name) diag_set(XlogError, "Unexpected end of file, run with 'force_recovery = true'"); goto error; } - snprintf(i->name, PATH_MAX, "%s", name); + snprintf(i->name, sizeof(i->name), "%s", name); i->zdctx = ZSTD_createDStream(); if (i->zdctx == NULL) { diag_set(ClientError, ER_DECOMPRESSION, @@ -2027,7 +2027,7 @@ xlog_cursor_openmem(struct xlog_cursor *i, const char *data, size_t size, diag_set(XlogError, "Unexpected end of file"); goto error; } - snprintf(i->name, PATH_MAX, "%s", name); + snprintf(i->name, sizeof(i->name), "%s", name); i->zdctx = ZSTD_createDStream(); if (i->zdctx == NULL) { diag_set(ClientError, ER_DECOMPRESSION, -- 2.26.2