aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-12-17 17:54:28 +0100
committerKristian Evers <kristianevers@gmail.com>2017-12-17 17:54:28 +0100
commit533207012bfd2c5de652b9df8b2104cad82b6988 (patch)
tree24877501f46d46cc7b477aa32f5be634116df65e
parent9ede4c65a92781ab4c1be5b0adac81ba593bfa8c (diff)
downloadPROJ-533207012bfd2c5de652b9df8b2104cad82b6988.tar.gz
PROJ-533207012bfd2c5de652b9df8b2104cad82b6988.zip
Fix integer overflow in unitconvert.
For sufficiently large values of modified julian date the mjd_to_yyyymmdd function would integer overflow in the calculation of the return value. This is fixed by implicit type conversion. Credit to OSS-Fuzz. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4658 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4667
-rw-r--r--src/PJ_unitconvert.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/PJ_unitconvert.c b/src/PJ_unitconvert.c
index 36461150..fc90821b 100644
--- a/src/PJ_unitconvert.c
+++ b/src/PJ_unitconvert.c
@@ -252,7 +252,7 @@ static double mjd_to_yyyymmdd(double mjd) {
day = (int)(mjd - mjd_iter + 1);
- return year*10000 + month*100 + day;
+ return year*10000.0 + month*100.0 + day;
}