osd: update sprintf() to snprintf()

Which is safer. Also enlarge length of name to 32, which shall be
big enough to hold a int64_t value.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
xiexingguo 2016-02-26 19:35:55 +08:00 committed by xie xingguo
parent 8101df0024
commit 083a0064a3

View File

@ -2771,8 +2771,8 @@ int OSDMap::build_simple_crush_map(CephContext *cct, CrushWrapper& crush,
loc["rack"] = "localrack";
loc["root"] = "default";
ldout(cct, 10) << " adding osd." << o << " at " << loc << dendl;
char name[8];
sprintf(name, "osd.%d", o);
char name[32];
snprintf(name, sizeof(name), "osd.%d", o);
crush.insert_item(cct, o, 1.0, name, loc);
}