Skip to content

Commit 343b86c

Browse files
committed
Makes m_fileName a shared pointer
1 parent 14b2bd7 commit 343b86c

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

Diff for: headers/modsecurity/rule.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Rule {
5454
Rule(operators::Operator *_op,
5555
variables::Variables *_variables,
5656
std::vector<actions::Action *> *_actions,
57-
std::string fileName,
57+
std::unique_ptr<std::string> fileName,
5858
int lineNumber);
5959
explicit Rule(const std::string &marker);
6060
virtual ~Rule();
@@ -128,7 +128,7 @@ class Rule {
128128
operators::Operator *m_op;
129129
std::unique_ptr<Rule> m_chainedRuleChild;
130130
Rule *m_chainedRuleParent;
131-
std::string m_fileName;
131+
std::shared_ptr<std::string> m_fileName;
132132
std::string m_marker;
133133
std::string m_rev;
134134
std::string m_ver;

Diff for: headers/modsecurity/rule_message.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class RuleMessage {
104104
std::string m_reference;
105105
std::string m_rev;
106106
Rule *m_rule;
107-
std::string m_ruleFile;
107+
std::shared_ptr<std::string> m_ruleFile;
108108
int m_ruleId;
109109
int m_ruleLine;
110110
bool m_saveMessage;

Diff for: src/parser/seclang-parser.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@ namespace yy {
23182318
/* op */ op,
23192319
/* variables */ v,
23202320
/* actions */ a,
2321-
/* file name */ *yystack_[3].location.end.filename,
2321+
/* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[3].location.end.filename)),
23222322
/* line number */ yystack_[3].location.end.line
23232323
));
23242324

@@ -2341,7 +2341,7 @@ namespace yy {
23412341
/* op */ yystack_[0].value.as < std::unique_ptr<Operator> > ().release(),
23422342
/* variables */ v,
23432343
/* actions */ NULL,
2344-
/* file name */ *yystack_[2].location.end.filename,
2344+
/* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[2].location.end.filename)),
23452345
/* line number */ yystack_[2].location.end.line
23462346
));
23472347
if (driver.addSecRule(std::move(rule)) == false) {
@@ -2362,7 +2362,7 @@ namespace yy {
23622362
/* op */ NULL,
23632363
/* variables */ NULL,
23642364
/* actions */ a,
2365-
/* file name */ *yystack_[1].location.end.filename,
2365+
/* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[1].location.end.filename)),
23662366
/* line number */ yystack_[1].location.end.line
23672367
));
23682368
driver.addSecAction(std::move(rule));
@@ -2381,7 +2381,7 @@ namespace yy {
23812381
std::unique_ptr<RuleScript> r(new RuleScript(
23822382
/* path to script */ yystack_[1].value.as < std::string > (),
23832383
/* actions */ a,
2384-
/* file name */ *yystack_[1].location.end.filename,
2384+
/* file name */ std::unique_ptr<std::string>(new std::string(*yystack_[1].location.end.filename)),
23852385
/* line number */ yystack_[1].location.end.line
23862386
));
23872387

Diff for: src/parser/seclang-parser.yy

+4-4
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ expression:
10801080
/* op */ op,
10811081
/* variables */ v,
10821082
/* actions */ a,
1083-
/* file name */ *@1.end.filename,
1083+
/* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
10841084
/* line number */ @1.end.line
10851085
));
10861086

@@ -1099,7 +1099,7 @@ expression:
10991099
/* op */ $3.release(),
11001100
/* variables */ v,
11011101
/* actions */ NULL,
1102-
/* file name */ *@1.end.filename,
1102+
/* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
11031103
/* line number */ @1.end.line
11041104
));
11051105
if (driver.addSecRule(std::move(rule)) == false) {
@@ -1116,7 +1116,7 @@ expression:
11161116
/* op */ NULL,
11171117
/* variables */ NULL,
11181118
/* actions */ a,
1119-
/* file name */ *@1.end.filename,
1119+
/* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
11201120
/* line number */ @1.end.line
11211121
));
11221122
driver.addSecAction(std::move(rule));
@@ -1131,7 +1131,7 @@ expression:
11311131
std::unique_ptr<RuleScript> r(new RuleScript(
11321132
/* path to script */ $1,
11331133
/* actions */ a,
1134-
/* file name */ *@1.end.filename,
1134+
/* file name */ std::unique_ptr<std::string>(new std::string(*@1.end.filename)),
11351135
/* line number */ @1.end.line
11361136
));
11371137

Diff for: src/rule.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Rule::Rule(const std::string &marker)
7070
m_op(NULL),
7171
m_chainedRuleChild(nullptr),
7272
m_chainedRuleParent(NULL),
73-
m_fileName(""),
73+
/* m_fileName(""), */
7474
m_marker(marker),
7575
m_rev(""),
7676
m_ver(""),
@@ -83,7 +83,7 @@ Rule::Rule(const std::string &marker)
8383
Rule::Rule(Operator *_op,
8484
variables::Variables *_variables,
8585
std::vector<Action *> *actions,
86-
std::string fileName,
86+
std::unique_ptr<std::string> fileName,
8787
int lineNumber)
8888
: m_theDisruptiveAction(nullptr),
8989
m_logData(nullptr),
@@ -103,7 +103,7 @@ Rule::Rule(Operator *_op,
103103
m_op(_op),
104104
m_chainedRuleChild(nullptr),
105105
m_chainedRuleParent(NULL),
106-
m_fileName(fileName),
106+
m_fileName(std::move(fileName)),
107107
m_marker(""),
108108
m_rev(""),
109109
m_ver(""),

Diff for: src/rule_message.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace modsecurity {
2626
std::string RuleMessage::_details(const RuleMessage *rm) {
2727
std::string msg;
2828

29-
msg.append(" [file \"" + std::string(rm->m_ruleFile) + "\"]");
29+
msg.append(" [file \"" + std::string(*rm->m_ruleFile.get()) + "\"]");
3030
msg.append(" [line \"" + std::to_string(rm->m_ruleLine) + "\"]");
3131
msg.append(" [id \"" + std::to_string(rm->m_ruleId) + "\"]");
3232
msg.append(" [rev \"" + rm->m_rev + "\"]");

Diff for: src/rule_script.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class RuleScript : public Rule {
4646
public:
4747
RuleScript(const std::string &name,
4848
std::vector<Action *> *actions,
49-
const std::string &fileName,
49+
std::unique_ptr<std::string> fileName,
5050
int lineNumber)
51-
: Rule(NULL, NULL, actions, fileName, lineNumber),
51+
: Rule(NULL, NULL, actions, std::move(fileName), lineNumber),
5252
m_name(name) { }
5353

5454
bool init(std::string *err);

Diff for: src/transaction.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ std::string Transaction::toJSON(int parts) {
17641764
LOGFY_ADD("match", a.m_match.c_str());
17651765
LOGFY_ADD("reference", a.m_reference.c_str());
17661766
LOGFY_ADD("ruleId", std::to_string(a.m_ruleId).c_str());
1767-
LOGFY_ADD("file", a.m_ruleFile.c_str());
1767+
LOGFY_ADD("file", a.m_ruleFile->c_str());
17681768
LOGFY_ADD("lineNumber", std::to_string(a.m_ruleLine).c_str());
17691769
LOGFY_ADD("data", a.m_data.c_str());
17701770
LOGFY_ADD("severity", std::to_string(a.m_severity).c_str());

0 commit comments

Comments
 (0)