I believe that there is problem with my constructor but I don't see my
mistake.
class obfuscator {
private:
enum statuses { s_not_ready, s_ready, s_checked, s_no_comments,
s_framework_remembered, s_remembered, s_generated, s_replaced, s_done }
status; // don't change the order
const std::string usage = "Usage: dirtyphp php_application_dir
php_result_dir [--reserved='space separated list of identifiers to
exclude'] [--extension=php_files_extension] [--subdirs='space separated
list of subdirectories'] [--controllers=subdirectory_of_mvc_controllers]
[--views=subdirectory_of_mvc_views] [--framework=ci
--system=path_to_framework] [--idlen=number] [--gui]";
const std::string help = std::string("") +
"...";
const size_t default_random_identifiers_length = 10;
const size_t min_random_identifiers_length = 5;
const std::string random_identifiers_suffix = "_x_x_";
const std::string default_extension = "php";
const std::string identifier = "[a-zA-Z_][a-zA-Z0-9_]+";
const std::string ci_reserved = "config db autoload active_group
query_builder smileys _doctypes foreign_characters route simpleys
platforms robots mobiles browsers lang _remap _output _utility index";
const std::string ci_subdirs = "config core controllers models
views helpers libraries";
const std::string ci_controllers = "controllers";
const std::string ci_views = "views";
const std::string yii_reserved = "";
const std::string yii_subdirs = "backend common/components
common/config common/models console/commands console/config
frontend/components frontend/config frontend/controllers frontend/lib
frontend/models frontend/views";
const std::string yii_controllers = "frontend/controllers";
const std::string yii_views = "frontend/views";
// !!! zmienić:
const std::string zf_reserved = "";
const std::string zf_subdirs = "config configs forms module modules
controllers layouts models views";
const std::string zf_controllers = "controllers";
const std::string zf_views = "views";
std::string reserved_keywords ;
std::string reserved_variables;
std::string reserved_properties;
std::string reserved_functions;
std::string reserved_methods;
enum index_what { i_actions, i_methods, i_functions, i_properties,
i_variables }; // don't change the order
constexpr unsigned short index_what_num = i_variables - i_actions + 1;
std::string php_application_dir, php_result_dir; // program parameters
std::string keywords, reserved, extension, framework,
framework_dir; // program options
strvector subdirs, controllers_dirs, views_dirs; // program options
unsigned short random_identifiers_length;
strvector *identifiers, *random_identifiers, *framework_identifiers;
std::string error_messages; // messages separated by '\n'
std::string check_not_allowed_syntax(std::string file, std::string
regexp, std::string message);
bool check_not_allowed_syntax(std::string file);
void perform_remove_comments_and_whitespaces(std::string dir);
void perform_remember_framework_identifiers(std::string dir);
void perform_remember_identifiers(std::string dir);
void perform_replace_identifiers(std::string dir);
void clear_identifiers();
// void remove_comments_and_whitespaces(std::string file_path,
std::string in_dir);
void remember_identifiers(std::string file_path, std::string
in_dir, strvector *arrids);
void generate_random_identifiers();
void replace_identifiers(std::string file_path, std::string in_dir);
public:
obfuscator() {
status = s_not_ready;
reserved_keywords = "and or xor __FILE__ exception __LINE__
array as break case class const continue declare default die do echo
else elseif empty enddeclare endfor endforeach endif endswitch endwhile
eval exit extends for foreach function global if include include_once
isset list new print require require_once return static switch unset use
var while __FUNCTION__ __CLASS__ __METHOD__ final php_user_filter
interface implements extends public private protected abstract clone try
catch throw cfunction old_function this";
reserved_variables = "this argc argv php_errormsg GLOBALS
_SERVER _GET _POST _COOKIE _REQUEST _ENV _FILES _SESSION HTTP_GET_VARS
HTTP_POST_VARS HTTP_COOKIE_VARS HTTP_ENV_VARS HTTP_SESSION_VARS
HTTP_SERVER_VARS";
reserved_properties = "";
reserved_functions = /* !!! PHP5 */ "__autoload __halt_compiler";
reserved_methods = /* !!! PHP5 */ "__construct __destruct
__get __set __call __callStatic __isset __unset __sleep __wakeup
__toString __invoke __set_state __clone __debugInfo";
php_application_dir = "";
php_result_dir = "";
keywords = string(" ") + reserved_keywords + string(" ") +
strtoupper(reserved_keywords) + string(" ");
random_identifiers_length = default_random_identifiers_length;
extension = default_extension;
identifiers = new strvector[index_what_num];
random_identifiers = new strvector[index_what_num];
framework_identifiers = new strvector[index_what_num];
error_messages = "";
}
~obfuscator() {
delete [] identifiers;
delete [] random_identifiers;
delete [] framework_identifiers;
}
std::string get_usage() const {
return usage;
}
std::string get_help() const {
return help;
}
std::string get_error_messages() const {
return error_messages;
}
bool check_cmdline_usage(int argc, const char *argv[]) const;
bool get_cmdline_options(int argc, const char *argv[]);
bool make_result_dir();
bool check_application(bool after_obfuscation);
bool obfuscate_application();
};
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: Nie ma takiego pliku ani katalogu.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007f37c5f128b1 in __GI_abort () at abort.c:79
#2 0x00007f37c6567957 in ?? () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007f37c656dae6 in ?? () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007f37c656db21 in std::terminate() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007f37c656dd54 in __cxa_throw ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007f37c656e2dc in operator new(unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007f37c65ffb8b in std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long,
unsigned long, char const*, unsigned long) () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8 0x00007f37c6601133 in std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_M_append(char const*,
unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x0000000000409df5 in std::operator+<char, std::char_traits<char>,
std::allocator<char> > (__lhs=...,
__rhs=<error reading variable: Cannot create a lazy string with
address 0x0, and a non-zero length.>) at
/usr/include/c++/7/bits/basic_string.h:5955
#10 0x0000000000408382 in obfuscator::obfuscator (this=0x7ffc6babeb70)
at src/obfuscator.hpp:79
#11 0x000000000040786b in main (argc=6, argv=0x7ffc6babf0b8)