Module Name:    src
Committed By:   gsutre
Date:           Thu Sep  5 09:03:13 UTC 2013

Modified Files:
        src/sys/sys: cdefs.h

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

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/sys/cdefs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/cdefs.h
diff -u src/sys/sys/cdefs.h:1.107 src/sys/sys/cdefs.h:1.108
--- src/sys/sys/cdefs.h:1.107	Wed May 29 19:02:30 2013
+++ src/sys/sys/cdefs.h	Thu Sep  5 09:03:13 2013
@@ -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 @@ static __inline int __negative_p(double 
 
 #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'

Reply via email to