Skip to content

Commit 059fde5

Browse files
committed
intercept: fix static analyzer warnings
1 parent 0b9c26b commit 059fde5

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

source/intercept/source/report/libexec/Resolver.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,17 @@ namespace el {
9494
if (path.empty()) {
9595
continue;
9696
}
97+
// check if it's possible to assemble a PATH
98+
if ((file.size() + path.size() + 2) > PATH_MAX) {
99+
continue;
100+
}
97101
// create a path
98102
char candidate[PATH_MAX];
99103
{
100-
auto it = el::array::copy(path.begin(), path.end(), candidate, candidate + PATH_MAX);
104+
auto candidate_end = candidate + PATH_MAX;
105+
auto it = el::array::copy(path.begin(), path.end(), candidate, candidate_end);
101106
*it++ = DIR_SEPARATOR;
102-
it = el::array::copy(file.begin(), file.end(), it, candidate + PATH_MAX);
107+
it = el::array::copy(file.begin(), file.end(), it, candidate_end);
103108
*it = 0;
104109
}
105110
// check if it's okay to execute.

source/intercept/source/report/wrapper/EventFactory.cc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ namespace wr {
5757
event.set_rid(rid_);
5858
event.set_timestamp(now_as_string());
5959
{
60-
auto event_started_ptr = std::make_unique<rpc::Event_Started>();
61-
event_started_ptr->set_pid(pid);
62-
event_started_ptr->set_ppid(ppid);
63-
event_started_ptr->set_allocated_execution(new rpc::Execution(into(execution)));
64-
event.set_allocated_started(event_started_ptr.release());
60+
rpc::Event_Started &event_started = *event.mutable_started();
61+
event_started.set_pid(pid);
62+
event_started.set_ppid(ppid);
63+
*event_started.mutable_execution() = into(execution);
6564
}
6665
return event;
6766
}
@@ -71,10 +70,8 @@ namespace wr {
7170
result.set_rid(rid_);
7271
result.set_timestamp(now_as_string());
7372
{
74-
auto event = std::make_unique<rpc::Event_Signalled>();
75-
event->set_number(number);
76-
77-
result.set_allocated_signalled(event.release());
73+
rpc::Event_Signalled &event = *result.mutable_signalled();
74+
event.set_number(number);
7875
}
7976
return result;
8077
}
@@ -84,10 +81,8 @@ namespace wr {
8481
result.set_rid(rid_);
8582
result.set_timestamp(now_as_string());
8683
{
87-
auto event = std::make_unique<rpc::Event_Terminated>();
88-
event->set_status(code);
89-
90-
result.set_allocated_terminated(event.release());
84+
rpc::Event_Terminated &event = *result.mutable_terminated();
85+
event.set_status(code);
9186
}
9287
return result;
9388
}

0 commit comments

Comments
 (0)