Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/include/sys Avoid undefined behavior in an ATF test: t...
details: https://anonhg.NetBSD.org/src/rev/2d97d3b1d2bf
branches: trunk
changeset: 991676:2d97d3b1d2bf
user: kamil <kamil%NetBSD.org@localhost>
date: Wed Jul 25 21:51:32 2018 +0000
description:
Avoid undefined behavior in an ATF test: t_types
Replace UB with implementation defined logic to check whether ssize_t can
wrap to a negative number.
t_types.c:63:7, signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'
Detected with micro-UBSan in the user mode.
diffstat:
tests/include/sys/t_types.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r 5015aafa6297 -r 2d97d3b1d2bf tests/include/sys/t_types.c
--- a/tests/include/sys/t_types.c Wed Jul 25 20:05:35 2018 +0000
+++ b/tests/include/sys/t_types.c Wed Jul 25 21:51:32 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_types.c,v 1.4 2012/03/18 07:14:08 jruoho Exp $ */
+/* $NetBSD: t_types.c,v 1.5 2018/07/25 21:51:32 kamil Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_types.c,v 1.4 2012/03/18 07:14:08 jruoho Exp $");
+__RCSID("$NetBSD: t_types.c,v 1.5 2018/07/25 21:51:32 kamil Exp $");
#include <sys/types.h>
@@ -60,7 +60,7 @@
size = SSIZE_MAX;
ATF_REQUIRE(size > 0);
- size = size + 1;
+ size = (ssize_t)((size_t)size + 1);
ATF_REQUIRE(size < 0);
/*
Home |
Main Index |
Thread Index |
Old Index