From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (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 443DD42EF5E for ; Thu, 18 Jun 2020 01:04:19 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id z9so4762869ljh.13 for ; Wed, 17 Jun 2020 15:04:19 -0700 (PDT) From: Cyrill Gorcunov Date: Thu, 18 Jun 2020 01:03:32 +0300 Message-Id: <20200617220335.836265-4-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 3/6] xlog: xdir -- use PATH_MAX for dirname List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy , Alexander Turenko The PATH_MAX is the longest path including end of string, no need for +1 byte. Same time use sizeof(dirname) to not bound how exactly dirname is declared. Signed-off-by: Cyrill Gorcunov --- src/box/xlog.c | 2 +- src/box/xlog.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/box/xlog.c b/src/box/xlog.c index 8254cce20..8b2818326 100644 --- a/src/box/xlog.c +++ b/src/box/xlog.c @@ -335,7 +335,7 @@ xdir_create(struct xdir *dir, const char *dirname, enum xdir_type type, /* Default mode. */ dir->mode = 0660; dir->instance_uuid = instance_uuid; - snprintf(dir->dirname, PATH_MAX, "%s", dirname); + snprintf(dir->dirname, sizeof(dir->dirname), "%s", dirname); dir->open_wflags = 0; switch (type) { case SNAP: diff --git a/src/box/xlog.h b/src/box/xlog.h index 47df3a549..329d78c77 100644 --- a/src/box/xlog.h +++ b/src/box/xlog.h @@ -162,7 +162,7 @@ struct xdir { /** * Directory path. */ - char dirname[PATH_MAX+1]; + char dirname[PATH_MAX]; /** Snapshots or xlogs */ enum xdir_type type; }; -- 2.26.2