mirror of
https://github.com/ceph/ceph
synced 2025-03-29 15:03:39 +00:00
Merge pull request #6617 from jcsp/wip-13816
tools/cephfs: fix overflow writing header to fixed size buffer (#13816)
This commit is contained in:
commit
acb8fdec05
@ -29,6 +29,7 @@
|
||||
|
||||
#define dout_subsys ceph_subsys_mds
|
||||
|
||||
#define HEADER_LEN 4096
|
||||
|
||||
int Dumper::init(int rank_)
|
||||
{
|
||||
@ -90,9 +91,9 @@ int Dumper::dump(const char *dump_file)
|
||||
int fd = ::open(dump_file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
|
||||
if (fd >= 0) {
|
||||
// include an informative header
|
||||
char buf[200];
|
||||
char buf[HEADER_LEN];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
sprintf(buf, "Ceph mds%d journal dump\n start offset %llu (0x%llx)\n length %llu (0x%llx)\n write_pos %llu (0x%llx)\n format %llu\n trimmed_pos %llu (0x%llx)\n%c",
|
||||
snprintf(buf, HEADER_LEN, "Ceph mds%d journal dump\n start offset %llu (0x%llx)\n length %llu (0x%llx)\n write_pos %llu (0x%llx)\n format %llu\n trimmed_pos %llu (0x%llx)\n%c",
|
||||
rank,
|
||||
(unsigned long long)start, (unsigned long long)start,
|
||||
(unsigned long long)len, (unsigned long long)len,
|
||||
@ -185,7 +186,7 @@ int Dumper::undump(const char *dump_file)
|
||||
// start offset 232401996 (0xdda2c4c)
|
||||
// length 1097504 (0x10bf20)
|
||||
|
||||
char buf[200];
|
||||
char buf[HEADER_LEN];
|
||||
r = safe_read(fd, buf, sizeof(buf));
|
||||
if (r < 0) {
|
||||
VOID_TEMP_FAILURE_RETRY(::close(fd));
|
||||
|
Loading…
Reference in New Issue
Block a user