upstream commit

Fix convtime() overflow test on boundary condition,
spotted by & ok djm.

Upstream-ID: 51f14c507ea87a3022e63f574100613ab2ba5708
This commit is contained in:
dtucker@openbsd.org 2017-03-14 00:55:37 +00:00 committed by Darren Tucker
parent f5746b40cf
commit c6774d2118

6
misc.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.108 2017/03/14 00:25:03 dtucker Exp $ */ /* $OpenBSD: misc.c,v 1.109 2017/03/14 00:55:37 dtucker Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005,2006 Damien Miller. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@ -350,10 +350,10 @@ convtime(const char *s)
default: default:
return -1; return -1;
} }
if (secs > LONG_MAX / multiplier) if (secs >= LONG_MAX / multiplier)
return -1; return -1;
secs *= multiplier; secs *= multiplier;
if (total > LONG_MAX - secs) if (total >= LONG_MAX - secs)
return -1; return -1;
total += secs; total += secs;
if (total < 0) if (total < 0)