Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Check for overflow in __type_fit_s when casting to i...



details:   https://anonhg.NetBSD.org/src/rev/d2020cd425db
branches:  trunk
changeset: 789729:d2020cd425db
user:      gsutre <gsutre%NetBSD.org@localhost>
date:      Thu Sep 05 09:03:13 2013 +0000

description:
Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@

diffstat:

 sys/sys/cdefs.h |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (19 lines):

diff -r b1804b3084d1 -r d2020cd425db sys/sys/cdefs.h
--- a/sys/sys/cdefs.h   Thu Sep 05 09:01:27 2013 +0000
+++ b/sys/sys/cdefs.h   Thu Sep 05 09:03:13 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdefs.h,v 1.107 2013/05/29 19:02:30 martin Exp $       */
+/*     $NetBSD: cdefs.h,v 1.108 2013/09/05 09:03:13 gsutre Exp $       */
 
 /*
  * Copyright (c) 1991, 1993
@@ -575,7 +575,8 @@
 
 #define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \
     ((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \
-    ((intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t)))
+    ((intmax_t)((a) + __zeroll()) >= (intmax_t)0 && \
+     (intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t)))
 
 /*
  * return true if value 'a' fits in type 't'



Home | Main Index | Thread Index | Old Index