Commit c61a1abd authored by Alex Elder's avatar Alex Elder Committed by Sage Weil

libceph: fix off-by-one bug in ceph_encode_filepath()

There is a BUG_ON() call that doesn't account for the single byte
structure version at the start of an encoded filepath in
ceph_encode_filepath().  Fix that.
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarYehuda Sadeh <yehuda@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
parent 8842b3be
...@@ -151,7 +151,7 @@ static inline void ceph_encode_filepath(void **p, void *end, ...@@ -151,7 +151,7 @@ static inline void ceph_encode_filepath(void **p, void *end,
u64 ino, const char *path) u64 ino, const char *path)
{ {
u32 len = path ? strlen(path) : 0; u32 len = path ? strlen(path) : 0;
BUG_ON(*p + sizeof(ino) + sizeof(len) + len > end); BUG_ON(*p + 1 + sizeof(ino) + sizeof(len) + len > end);
ceph_encode_8(p, 1); ceph_encode_8(p, 1);
ceph_encode_64(p, ino); ceph_encode_64(p, ino);
ceph_encode_32(p, len); ceph_encode_32(p, len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment