projects
/
oweals
/
dinit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3cf5890
)
Build/logic fixes in parse_rlimit.
author
Davin McCall
<davmac@davmac.org>
Fri, 28 Jun 2019 11:16:17 +0000
(21:16 +1000)
committer
Davin McCall
<davmac@davmac.org>
Fri, 28 Jun 2019 11:32:08 +0000
(21:32 +1000)
src/load-service.cc
patch
|
blob
|
history
diff --git
a/src/load-service.cc
b/src/load-service.cc
index c7eb422d430bf8183ba40b79b5734ab59357bc03..1630d30114fc1434e6accfec87d5422a49d38964 100644
(file)
--- a/
src/load-service.cc
+++ b/
src/load-service.cc
@@
-227,7
+227,7
@@
static void parse_rlimit(const std::string &line, const std::string &service_nam
rlimit.hard_set = rlimit.soft_set = false;
try {
rlimit.hard_set = rlimit.soft_set = false;
try {
- c
har * index
;
+ c
onst char * index = cline
;
errno = 0;
if (cline[0] != ':') {
rlimit.soft_set = true;
errno = 0;
if (cline[0] != ':') {
rlimit.soft_set = true;
@@
-236,7
+236,9
@@
static void parse_rlimit(const std::string &line, const std::string &service_nam
index = cline + 1;
}
else {
index = cline + 1;
}
else {
- unsigned long long limit = std::strtoull(cline, &index, 0);
+ char *nindex;
+ unsigned long long limit = std::strtoull(cline, &nindex, 0);
+ index = nindex;
if (errno == ERANGE || limit > std::numeric_limits<rlim_t>::max()) throw std::out_of_range("");
if (index == cline) throw std::invalid_argument("");
rlimit.limits.rlim_cur = limit;
if (errno == ERANGE || limit > std::numeric_limits<rlim_t>::max()) throw std::out_of_range("");
if (index == cline) throw std::invalid_argument("");
rlimit.limits.rlim_cur = limit;
@@
-247,10
+249,10
@@
static void parse_rlimit(const std::string &line, const std::string &service_nam
rlimit.limits.rlim_max = rlimit.limits.rlim_cur;
return;
}
rlimit.limits.rlim_max = rlimit.limits.rlim_cur;
return;
}
- }
- if (*index != ':') {
- throw service_description_exc(service_name, std::string("Bad value for ") + param_name);
+ if (*index != ':') {
+ throw service_description_exc(service_name, std::string("Bad value for ") + param_name);
+ }
}
index++;
}
index++;
@@
-263,8
+265,10
@@
static void parse_rlimit(const std::string &line, const std::string &service_nam
}
}
else {
}
}
else {
- char *hard_start = index;
- unsigned long long limit = std::strtoull(cline, &index, 0);
+ const char *hard_start = index;
+ char *nindex;
+ unsigned long long limit = std::strtoull(cline, &nindex, 0);
+ index = nindex;
if (errno == ERANGE || limit > std::numeric_limits<rlim_t>::max()) throw std::out_of_range("");
if (index == hard_start) throw std::invalid_argument("");
rlimit.limits.rlim_max = limit;
if (errno == ERANGE || limit > std::numeric_limits<rlim_t>::max()) throw std::out_of_range("");
if (index == hard_start) throw std::invalid_argument("");
rlimit.limits.rlim_max = limit;