New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: don't specify a length when converting bl -> string #15599

Merged
merged 1 commit into from Jun 19, 2017

Conversation

Projects
None yet
2 participants
@theanalyst
Member

theanalyst commented Jun 9, 2017

in rgw_admin we're assigning a string from a bufferlist by explicitly
specifying a size and using assign, in this case the whole contents of
the buffer are copied regardless of whether the null character is seen.
Just use normal assign which would only copy until the null is
encountered

Fixes: http://tracker.ceph.com/issues/20037
Signed-off-by: Abhishek Lekshmanan abhishek@suse.com

rgw: don't specify a length when convert bl -> string
in rgw_admin we're assigning a string from a bufferlist by explicitly
specifying a size and using assign, in this case the whole contents of
the buffer are copied regardless of whether the null character is seen.
Just use normal assign which would only copy until the null is
encountered

Fixes: http://tracker.ceph.com/issues/20037
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>

@theanalyst theanalyst requested a review from cbodley Jun 9, 2017

@theanalyst theanalyst changed the title from rgw: don't specify a length when convert bl -> string to rgw: don't specify a length when converting bl -> string Jun 9, 2017

@cbodley

cbodley approved these changes Jun 9, 2017

looks good. there's a bufferlist::to_str() that i prefer over both, because it avoids calling c_str() (which has to reallocate and flatten when the bufferlist contains multiple segments). but to_str() doesn't help with the trailing null here

@theanalyst

This comment has been minimized.

Member

theanalyst commented Jun 9, 2017

@cbodley I guess for the logging calls we could do the to_str() calls then?

@cbodley

This comment has been minimized.

Contributor

cbodley commented Jun 9, 2017

@theanalyst in this case, i think to_str() would do the same thing as the string(bl.c_str(), bl.length()) version, because it's also based on buffer length. so i'm fine with your c_str() approach here

@theanalyst

This comment has been minimized.

Member

theanalyst commented Jun 9, 2017

jenkins test this please

@theanalyst

This comment has been minimized.

Member

theanalyst commented Jun 13, 2017

jenkins test this please

@cbodley

This comment has been minimized.

@cbodley cbodley merged commit fbf106b into ceph:master Jun 19, 2017

4 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodified Submodules submodules for project are unmodified
Details
arm64 make check arm64 make check succeeded
Details
make check make check succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment