Skip to content

Commit 54952f7

Browse files
Gumixlocker
authored andcommitted
box: fix out-of-bounds read in index_opts_parse_layout()
It's not safe to use `strlcpy()` for non-null-terminated strings, because this function requires a null-terminated string. Found by AddressSanitizer. Follow-up tarantool/tarantool-ee#1089 NO_DOC=bugfix NO_CHANGELOG=unreleased NO_TEST=hard to create a stable reproducer
1 parent 1bca646 commit 54952f7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/box/index_def.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ index_opts_parse_layout(const char **data, void *opts, struct region *region)
127127
const char *str = mp_decode_str(data, &len);
128128
if (len > 0) {
129129
index_opts->layout = xregion_alloc(region, len + 1);
130-
strlcpy(index_opts->layout, str, len + 1);
130+
memcpy(index_opts->layout, str, len);
131+
index_opts->layout[len] = '\0';
131132
}
132133
return 0;
133134
}

0 commit comments

Comments
 (0)