about class MinidumpDescriptor, why getting c_path_ will cause problems in compromised environments,

29 views
Skip to first unread message

zhang song

unread,
Mar 20, 2019, 6:18:45 AM3/20/19
to google-breakpad-dev


Hi, all :
   i am reading breakpad code and trying to understand it. In minidump_descriptoer.h i found below comments says that the copy constructor should not be called  with a valid path_
(as getting its c_path_ would require heap and cause problems)
 why is that?
also i notice the member `directory_` is just initialized in `copy constructor` method using init list, as described below.
why we treat this two member `directory_` and `path` differently?

it will be so kind and appreciated to have this answered, as it is torturing my mind ~~,thank you ~.

MinidumpDescriptor::MinidumpDescriptor(const MinidumpDescriptor& descriptor)
: mode_(descriptor.mode_),
fd_(descriptor.fd_),
directory_(descriptor.directory_),
c_path_(NULL),
size_limit_(descriptor.size_limit_),
address_within_principal_mapping_(
descriptor.address_within_principal_mapping_),
skip_dump_if_principal_mapping_not_referenced_(
descriptor.skip_dump_if_principal_mapping_not_referenced_),
sanitize_stacks_(descriptor.sanitize_stacks_),
microdump_extra_info_(descriptor.microdump_extra_info_) {
// The copy constructor is not allowed to be called on a MinidumpDescriptor
// with a valid path_, as getting its c_path_ would require the heap which
// can cause problems in compromised environments.
assert(descriptor.path_.empty());
strncpy(fname_prefix_, descriptor.fname_prefix_, descriptor.prefix_len_);
prefix_len_ = descriptor.prefix_len_;
}

Lei Zhang

unread,
Mar 22, 2019, 9:32:31 PM3/22/19
to google-br...@googlegroups.com
Hi,

The comment references "c_path_" but it may have mean to say c_str().
Since |path_| is a std::string, it is referring to
std::string::c_str().

I'm not sure if std::string::c_str() can allocate memory with C++11,
but under older standards it was definitely possible to have a
std::string implementation that does.
> --
> You received this message because you are subscribed to the Google Groups "google-breakpad-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to google-breakpad...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages