diff options
author | Jim Meyering <meyering@redhat.com> | 2012-06-04 16:41:17 +0200 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-07-02 15:30:54 -0700 |
commit | 64a2627cc1cfb8cc547c160c2362d05401b8ed87 (patch) | |
tree | 21889da7172883968e63cd33d401a1162a2a289a /xlators/storage | |
parent | d1610978436dda903e50552eed0cb8116dae88b9 (diff) |
bdb: fix erroneous strncpy in file name construction
Using strncpy like that fails to copy the trailing NUL byte of
dirent->d_name, which is required, since the result buffer,
entry_path is stat'ed in the code just below. Besides, there is
no need for strncpy, since we know the source buffer will fit
in the possibly-just-realloc'd destination buffer: use memcpy
and +1 to include the trailing NUL.
Change-Id: I4d4cfb5b7df3c018516919f2d67c21c07de126cb
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3588
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/bdb/src/bdb.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/xlators/storage/bdb/src/bdb.c b/xlators/storage/bdb/src/bdb.c index 1a5ef02b2f3..384094b57ad 100644 --- a/xlators/storage/bdb/src/bdb.c +++ b/xlators/storage/bdb/src/bdb.c @@ -1360,8 +1360,8 @@ dir_read: } } - strncpy (&entry_path[real_path_len+1], dirent->d_name, - tmp_name_len); + memcpy (&entry_path[real_path_len+1], dirent->d_name, + tmp_name_len + 1); op_ret = stat (entry_path, &buf); if (op_ret < 0) { op_errno = errno; |