[Tarantool-patches] [PATCH 3/6] xlog: xdir -- use PATH_MAX for dirname
Cyrill Gorcunov
gorcunov at gmail.com
Thu Jun 18 01:03:32 MSK 2020
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 <gorcunov at gmail.com>
---
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
More information about the Tarantool-patches
mailing list