From becf6aa58d5b5f53007cf06c688171011baa8a89 Mon Sep 17 00:00:00 2001 From: karas <29292618+gy741@users.noreply.github.com> Date: Thu, 22 Feb 2018 13:28:31 +0900 Subject: [PATCH] Fix Integer Overflow --- minmea.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/minmea.h b/minmea.h index 91568f7..893e6c8 100644 --- a/minmea.h +++ b/minmea.h @@ -260,6 +260,10 @@ static inline float minmea_tocoord(const struct minmea_float *f) { if (f->scale == 0) return NAN; + if (f->scale > (INT_LEAST32_MAX / 100)) + return NAN; + if (f->scale < (INT_LEAST32_MIN / 100)) + return NAN; int_least32_t degrees = f->value / (f->scale * 100); int_least32_t minutes = f->value % (f->scale * 100); return (float) degrees + (float) minutes / (60 * f->scale);