Skip to content
Commit 1ec3911d authored by Cong Ding's avatar Cong Ding Committed by Alex Elder
Browse files

libceph: fix undefined behavior when using snprintf()



The variable "str" is used as both the source and destination in
function snprintf(), which is undefined behavior based on C11. The
original description in C11 is:
	"If copying takes place between objects that
	overlap, the behavior is undefined."

And, the function of ceph_osdmap_state_str() is to return the osdmap
state, so it should return "doesn't exist" when all the conditions
are not satisfied. I fix it in this patch.

[elder@inktank.com: shortened the commit message]

Signed-off-by: default avatarCong Ding <dinggnu@gmail.com>
Reviewed-by: default avatarAlex Elder <elder@inktank.com>
parent c0430647
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