summaryrefslogtreecommitdiff
path: root/src/cookie_helper.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2023-09-16 17:22:33 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2023-09-16 17:22:33 +0900
commite5d9ad2f0bc007089394ceb2bdf9847887d671bc (patch)
treeea910d9511bae81cf16ee29dd7fdeff6b7f16eb3 /src/cookie_helper.cc
parentdfdbc22b239311e13facdca926db0aeab9ce28e6 (diff)
Fix test errors with ubsan
Diffstat (limited to 'src/cookie_helper.cc')
-rw-r--r--src/cookie_helper.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/cookie_helper.cc b/src/cookie_helper.cc
index 0e546109..8ad1e518 100644
--- a/src/cookie_helper.cc
+++ b/src/cookie_helper.cc
@@ -300,12 +300,18 @@ std::unique_ptr<Cookie> parse(const std::string& cookieStr,
}
else {
int64_t n = creationTime;
- n += delta;
- if (n < 0 || std::numeric_limits<time_t>::max() < n) {
- maxAge = std::numeric_limits<time_t>::max();
- }
- else {
- maxAge = n;
+
+ if (n > std::numeric_limits<int64_t>::max() - delta) {
+ maxAge = std::numeric_limits<int64_t>::max();
+ } else {
+ n += delta;
+
+ if (n < 0 || std::numeric_limits<time_t>::max() < n) {
+ maxAge = std::numeric_limits<time_t>::max();
+ }
+ else {
+ maxAge = n;
+ }
}
}
}