]> git.baikalelectronics.ru Git - kernel.git/commit
libceph: fix undefined behavior when using snprintf()
authorCong Ding <dinggnu@gmail.com>
Fri, 25 Jan 2013 23:48:59 +0000 (17:48 -0600)
committerAlex Elder <elder@inktank.com>
Fri, 25 Jan 2013 23:48:59 +0000 (17:48 -0600)
commit442594baf00e11c2cfa75017ee1f8cd8ab373cd9
tree95aac4248cb875f7e3f99b1373fdea5ada061298
parent11ac584f433423202811eb7aa20394646945c140
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: Cong Ding <dinggnu@gmail.com>
Reviewed-by: Alex Elder <elder@inktank.com>
net/ceph/osdmap.c