This is a further proposal for unification of the random number
generator functions in our tree. It is based upon my previous work,
but takes things a bit further.
I am sending this now, but it is too early to commit. I think we need
two weeks of testing and review of the impact this has on OpenBSD and
portability to other systems. I am hoping this can go into the tree at
the start of the new month, just before the ports hackathon because
providing them with an unexpected libc library crank is always
entertaining.
On to the diff:
Since rand() is now a wrapper around arc4random(), it gains the new
strong randomness semantics, and we can call it directly.
I recognize there will be some who are upset about the uint32_t -> int
change for the return value, but we have accepted this incorrect
return type on snprintf() and other such "standards derived errors"
for so long, maybe this concern is overblown?
In any case ANSI X3.159-1989 prohibits us from changing the return
type of rand().
I have also added matching rand_uniform() and rand_buf() functions.
Bob Beck has pointed out this allows for later audit converting a few
"rand() % moduli" cases into rand_uniform().
At 1900 lines, the diff is a bit long, but I am uncertain about
splitting it up. This only changes userland. The kernel never had
the ANSI C versions, but maybe we can unify in that direction in the
future.
Naturally, the diff starts in the games directory:
Index: distrib/sets/lists/base/md.alpha
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.alpha,v
retrieving revision 1.1024
diff -u -p -u -r1.1024 md.alpha
--- distrib/sets/lists/base/md.alpha 16 Mar 2015 00:57:14 -0000 1.1024
+++ distrib/sets/lists/base/md.alpha 16 Mar 2015 06:11:12 -0000
@@ -2111,7 +2111,6 @@
./usr/libdata/perl5/site_perl/alpha-openbsd/time.ph
./usr/libdata/perl5/site_perl/alpha-openbsd/tls.ph
./usr/libdata/perl5/site_perl/alpha-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/alpha-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/alpha-openbsd/ufs
./usr/libdata/perl5/site_perl/alpha-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/alpha-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.amd64
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.amd64,v
retrieving revision 1.730
diff -u -p -u -r1.730 md.amd64
--- distrib/sets/lists/base/md.amd64 16 Mar 2015 00:57:14 -0000 1.730
+++ distrib/sets/lists/base/md.amd64 16 Mar 2015 06:11:12 -0000
@@ -2143,7 +2143,6 @@
./usr/libdata/perl5/site_perl/amd64-openbsd/time.ph
./usr/libdata/perl5/site_perl/amd64-openbsd/tls.ph
./usr/libdata/perl5/site_perl/amd64-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/amd64-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/amd64-openbsd/ufs
./usr/libdata/perl5/site_perl/amd64-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/amd64-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.armish
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.armish,v
retrieving revision 1.525
diff -u -p -u -r1.525 md.armish
--- distrib/sets/lists/base/md.armish 16 Mar 2015 00:57:14 -0000 1.525
+++ distrib/sets/lists/base/md.armish 16 Mar 2015 06:11:12 -0000
@@ -2126,7 +2126,6 @@
./usr/libdata/perl5/site_perl/arm-openbsd/time.ph
./usr/libdata/perl5/site_perl/arm-openbsd/tls.ph
./usr/libdata/perl5/site_perl/arm-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/arm-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/arm-openbsd/ufs
./usr/libdata/perl5/site_perl/arm-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/arm-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.armv7
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.armv7,v
retrieving revision 1.141
diff -u -p -u -r1.141 md.armv7
--- distrib/sets/lists/base/md.armv7 16 Mar 2015 00:57:14 -0000 1.141
+++ distrib/sets/lists/base/md.armv7 16 Mar 2015 06:11:12 -0000
@@ -2100,7 +2100,6 @@
./usr/libdata/perl5/site_perl/arm-openbsd/time.ph
./usr/libdata/perl5/site_perl/arm-openbsd/tls.ph
./usr/libdata/perl5/site_perl/arm-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/arm-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/arm-openbsd/ufs
./usr/libdata/perl5/site_perl/arm-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/arm-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.aviion
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.aviion,v
retrieving revision 1.408
diff -u -p -u -r1.408 md.aviion
--- distrib/sets/lists/base/md.aviion 16 Mar 2015 00:57:14 -0000 1.408
+++ distrib/sets/lists/base/md.aviion 16 Mar 2015 06:11:12 -0000
@@ -2024,7 +2024,6 @@
./usr/libdata/perl5/site_perl/m88k-openbsd/time.ph
./usr/libdata/perl5/site_perl/m88k-openbsd/tls.ph
./usr/libdata/perl5/site_perl/m88k-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/m88k-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/m88k-openbsd/ufs
./usr/libdata/perl5/site_perl/m88k-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/m88k-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.hppa
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.hppa,v
retrieving revision 1.792
diff -u -p -u -r1.792 md.hppa
--- distrib/sets/lists/base/md.hppa 16 Mar 2015 00:57:14 -0000 1.792
+++ distrib/sets/lists/base/md.hppa 16 Mar 2015 06:11:12 -0000
@@ -2113,7 +2113,6 @@
./usr/libdata/perl5/site_perl/hppa-openbsd/time.ph
./usr/libdata/perl5/site_perl/hppa-openbsd/tls.ph
./usr/libdata/perl5/site_perl/hppa-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/hppa-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/hppa-openbsd/ufs
./usr/libdata/perl5/site_perl/hppa-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/hppa-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.hppa64
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.hppa64,v
retrieving revision 1.619
diff -u -p -u -r1.619 md.hppa64
--- distrib/sets/lists/base/md.hppa64 16 Mar 2015 00:57:14 -0000 1.619
+++ distrib/sets/lists/base/md.hppa64 16 Mar 2015 06:11:12 -0000
@@ -2042,7 +2042,6 @@
./usr/libdata/perl5/site_perl/hppa64-openbsd/time.ph
./usr/libdata/perl5/site_perl/hppa64-openbsd/tls.ph
./usr/libdata/perl5/site_perl/hppa64-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/hppa64-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/hppa64-openbsd/ufs
./usr/libdata/perl5/site_perl/hppa64-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/hppa64-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.i386
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.i386,v
retrieving revision 1.1109
diff -u -p -u -r1.1109 md.i386
--- distrib/sets/lists/base/md.i386 16 Mar 2015 00:57:14 -0000 1.1109
+++ distrib/sets/lists/base/md.i386 16 Mar 2015 06:11:12 -0000
@@ -2148,7 +2148,6 @@
./usr/libdata/perl5/site_perl/i386-openbsd/time.ph
./usr/libdata/perl5/site_perl/i386-openbsd/tls.ph
./usr/libdata/perl5/site_perl/i386-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/i386-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/i386-openbsd/ufs
./usr/libdata/perl5/site_perl/i386-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/i386-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.landisk
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.landisk,v
retrieving revision 1.488
diff -u -p -u -r1.488 md.landisk
--- distrib/sets/lists/base/md.landisk 16 Mar 2015 00:57:14 -0000 1.488
+++ distrib/sets/lists/base/md.landisk 16 Mar 2015 06:11:12 -0000
@@ -2126,7 +2126,6 @@
./usr/libdata/perl5/site_perl/sh-openbsd/time.ph
./usr/libdata/perl5/site_perl/sh-openbsd/tls.ph
./usr/libdata/perl5/site_perl/sh-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/sh-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/sh-openbsd/ufs
./usr/libdata/perl5/site_perl/sh-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/sh-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.loongson
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.loongson,v
retrieving revision 1.315
diff -u -p -u -r1.315 md.loongson
--- distrib/sets/lists/base/md.loongson 16 Mar 2015 00:57:14 -0000 1.315
+++ distrib/sets/lists/base/md.loongson 16 Mar 2015 06:11:12 -0000
@@ -2131,7 +2131,6 @@
./usr/libdata/perl5/site_perl/mips64el-openbsd/time.ph
./usr/libdata/perl5/site_perl/mips64el-openbsd/tls.ph
./usr/libdata/perl5/site_perl/mips64el-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/mips64el-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/mips64el-openbsd/ufs
./usr/libdata/perl5/site_perl/mips64el-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/mips64el-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.luna88k
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.luna88k,v
retrieving revision 1.546
diff -u -p -u -r1.546 md.luna88k
--- distrib/sets/lists/base/md.luna88k 16 Mar 2015 00:57:14 -0000 1.546
+++ distrib/sets/lists/base/md.luna88k 16 Mar 2015 06:11:12 -0000
@@ -2024,7 +2024,6 @@
./usr/libdata/perl5/site_perl/m88k-openbsd/time.ph
./usr/libdata/perl5/site_perl/m88k-openbsd/tls.ph
./usr/libdata/perl5/site_perl/m88k-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/m88k-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/m88k-openbsd/ufs
./usr/libdata/perl5/site_perl/m88k-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/m88k-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.macppc
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.macppc,v
retrieving revision 1.889
diff -u -p -u -r1.889 md.macppc
--- distrib/sets/lists/base/md.macppc 16 Mar 2015 00:57:14 -0000 1.889
+++ distrib/sets/lists/base/md.macppc 16 Mar 2015 06:11:12 -0000
@@ -2158,7 +2158,6 @@
./usr/libdata/perl5/site_perl/powerpc-openbsd/time.ph
./usr/libdata/perl5/site_perl/powerpc-openbsd/tls.ph
./usr/libdata/perl5/site_perl/powerpc-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/powerpc-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/powerpc-openbsd/ufs
./usr/libdata/perl5/site_perl/powerpc-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/powerpc-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.octeon
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.octeon,v
retrieving revision 1.165
diff -u -p -u -r1.165 md.octeon
--- distrib/sets/lists/base/md.octeon 16 Mar 2015 00:57:14 -0000 1.165
+++ distrib/sets/lists/base/md.octeon 16 Mar 2015 06:11:12 -0000
@@ -2094,7 +2094,6 @@
./usr/libdata/perl5/site_perl/mips64-openbsd/time.ph
./usr/libdata/perl5/site_perl/mips64-openbsd/tls.ph
./usr/libdata/perl5/site_perl/mips64-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/mips64-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/mips64-openbsd/ufs
./usr/libdata/perl5/site_perl/mips64-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/mips64-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.sgi
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.sgi,v
retrieving revision 1.696
diff -u -p -u -r1.696 md.sgi
--- distrib/sets/lists/base/md.sgi 16 Mar 2015 00:57:14 -0000 1.696
+++ distrib/sets/lists/base/md.sgi 16 Mar 2015 06:11:12 -0000
@@ -2158,7 +2158,6 @@
./usr/libdata/perl5/site_perl/mips64-openbsd/time.ph
./usr/libdata/perl5/site_perl/mips64-openbsd/tls.ph
./usr/libdata/perl5/site_perl/mips64-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/mips64-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/mips64-openbsd/ufs
./usr/libdata/perl5/site_perl/mips64-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/mips64-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.socppc
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.socppc,v
retrieving revision 1.415
diff -u -p -u -r1.415 md.socppc
--- distrib/sets/lists/base/md.socppc 16 Mar 2015 00:57:14 -0000 1.415
+++ distrib/sets/lists/base/md.socppc 16 Mar 2015 06:11:12 -0000
@@ -2145,7 +2145,6 @@
./usr/libdata/perl5/site_perl/powerpc-openbsd/time.ph
./usr/libdata/perl5/site_perl/powerpc-openbsd/tls.ph
./usr/libdata/perl5/site_perl/powerpc-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/powerpc-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/powerpc-openbsd/ufs
./usr/libdata/perl5/site_perl/powerpc-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/powerpc-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.sparc
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.sparc,v
retrieving revision 1.1072
diff -u -p -u -r1.1072 md.sparc
--- distrib/sets/lists/base/md.sparc 16 Mar 2015 00:57:14 -0000 1.1072
+++ distrib/sets/lists/base/md.sparc 16 Mar 2015 06:11:12 -0000
@@ -1663,7 +1663,6 @@
./usr/libdata/perl5/site_perl/sparc-openbsd/time.ph
./usr/libdata/perl5/site_perl/sparc-openbsd/tls.ph
./usr/libdata/perl5/site_perl/sparc-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/sparc-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/sparc-openbsd/ufs
./usr/libdata/perl5/site_perl/sparc-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/sparc-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.sparc64
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.sparc64,v
retrieving revision 1.883
diff -u -p -u -r1.883 md.sparc64
--- distrib/sets/lists/base/md.sparc64 16 Mar 2015 00:57:14 -0000 1.883
+++ distrib/sets/lists/base/md.sparc64 16 Mar 2015 06:11:12 -0000
@@ -1723,7 +1723,6 @@
./usr/libdata/perl5/site_perl/sparc64-openbsd/time.ph
./usr/libdata/perl5/site_perl/sparc64-openbsd/tls.ph
./usr/libdata/perl5/site_perl/sparc64-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/sparc64-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/sparc64-openbsd/ufs
./usr/libdata/perl5/site_perl/sparc64-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/sparc64-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.vax
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.vax,v
retrieving revision 1.698
diff -u -p -u -r1.698 md.vax
--- distrib/sets/lists/base/md.vax 10 Feb 2015 23:15:31 -0000 1.698
+++ distrib/sets/lists/base/md.vax 13 Mar 2015 23:42:22 -0000
@@ -1491,7 +1491,6 @@
./usr/libdata/perl5/site_perl/vax-openbsd/time.ph
./usr/libdata/perl5/site_perl/vax-openbsd/tls.ph
./usr/libdata/perl5/site_perl/vax-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/vax-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/vax-openbsd/ufs
./usr/libdata/perl5/site_perl/vax-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/vax-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/base/md.zaurus
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/md.zaurus,v
retrieving revision 1.651
diff -u -p -u -r1.651 md.zaurus
--- distrib/sets/lists/base/md.zaurus 16 Mar 2015 00:57:14 -0000 1.651
+++ distrib/sets/lists/base/md.zaurus 16 Mar 2015 06:11:12 -0000
@@ -2080,7 +2080,6 @@
./usr/libdata/perl5/site_perl/arm-openbsd/time.ph
./usr/libdata/perl5/site_perl/arm-openbsd/tls.ph
./usr/libdata/perl5/site_perl/arm-openbsd/ttyent.ph
-./usr/libdata/perl5/site_perl/arm-openbsd/tzfile.ph
./usr/libdata/perl5/site_perl/arm-openbsd/ufs
./usr/libdata/perl5/site_perl/arm-openbsd/ufs/ext2fs
./usr/libdata/perl5/site_perl/arm-openbsd/ufs/ext2fs/ext2fs.ph
Index: distrib/sets/lists/comp/mi
===================================================================
RCS file: /cvs/src/distrib/sets/lists/comp/mi,v
retrieving revision 1.1139
diff -u -p -u -r1.1139 mi
--- distrib/sets/lists/comp/mi 22 Feb 2015 16:09:29 -0000 1.1139
+++ distrib/sets/lists/comp/mi 13 Mar 2015 23:42:22 -0000
@@ -1452,7 +1452,6 @@
./usr/include/time.h
./usr/include/tls.h
./usr/include/ttyent.h
-./usr/include/tzfile.h
./usr/include/ufs
./usr/include/ufs/ext2fs
./usr/include/ufs/ext2fs/ext2fs.h
Index: include/Makefile
===================================================================
RCS file: /cvs/src/include/Makefile,v
retrieving revision 1.200
diff -u -p -u -r1.200 Makefile
--- include/Makefile 18 Feb 2015 15:31:10 -0000 1.200
+++ include/Makefile 13 Mar 2015 17:44:03 -0000
@@ -19,7 +19,7 @@ FILES= a.out.h ar.h asr.h assert.h bitst
resolv.h rmd160.h search.h setjmp.h sha1.h sha2.h signal.h siphash.h \
sndio.h \
spawn.h stdbool.h stddef.h stdio.h stdlib.h string.h strings.h struct.h
\
- sysexits.h tar.h tgmath.h time.h ttyent.h tzfile.h unistd.h utime.h \
+ sysexits.h tar.h tgmath.h time.h ttyent.h unistd.h utime.h \
utmp.h uuid.h vis.h wchar.h wctype.h
FILES+= link.h link_elf.h
Index: include/tzfile.h
===================================================================
RCS file: include/tzfile.h
diff -N include/tzfile.h
--- include/tzfile.h 2 Jun 2003 19:34:12 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,150 +0,0 @@
-/* $OpenBSD: tzfile.h,v 1.4 2003/06/02 19:34:12 millert Exp $ */
-/* $NetBSD: tzfile.h,v 1.3 1994/10/26 00:56:37 cgd Exp $ */
-
-/*
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Arthur David Olson of the National Cancer Institute.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)tzfile.h 5.10 (Berkeley) 4/3/91
- */
-
-#ifndef _TZFILE_H_
-#define _TZFILE_H_
-
-/*
- * Information about time zone files.
- */
- /* Time zone object file directory */
-#define TZDIR "/usr/share/zoneinfo"
-#define TZDEFAULT "/etc/localtime"
-#define TZDEFRULES "posixrules"
-
-/*
-** Each file begins with. . .
-*/
-
-struct tzhead {
- char tzh_reserved[24]; /* reserved for future use */
- char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
- char tzh_leapcnt[4]; /* coded number of leap seconds */
- char tzh_timecnt[4]; /* coded number of transition times */
- char tzh_typecnt[4]; /* coded number of local time types */
- char tzh_charcnt[4]; /* coded number of abbr. chars */
-};
-
-/*
-** . . .followed by. . .
-**
-** tzh_timecnt (char [4])s coded transition times a la time(2)
-** tzh_timecnt (unsigned char)s types of local time starting at above
-** tzh_typecnt repetitions of
-** one (char [4]) coded GMT offset in seconds
-** one (unsigned char) used to set tm_isdst
-** one (unsigned char) that's an abbreviation list index
-** tzh_charcnt (char)s '\0'-terminated zone abbreviations
-** tzh_leapcnt repetitions of
-** one (char [4]) coded leap second transition times
-** one (char [4]) total correction after above
-** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
-** time is standard time, if FALSE,
-** transition time is wall clock time
-** if absent, transition times are
-** assumed to be wall clock time
-*/
-
-/*
-** In the current implementation, "tzset()" refuses to deal with files that
-** exceed any of the limits below.
-*/
-
-/*
-** The TZ_MAX_TIMES value below is enough to handle a bit more than a
-** year's worth of solar time (corrected daily to the nearest second) or
-** 138 years of Pacific Presidential Election time
-** (where there are three time zone transitions every fourth year).
-*/
-#define TZ_MAX_TIMES 370
-
-#define NOSOLAR /* 4BSD doesn't currently handle solar
time */
-
-#ifndef NOSOLAR
-#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
-#else
-#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
-#endif
-
-#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
-
-#define TZ_MAX_LEAPS 50 /* Maximum number of leap second
corrections */
-
-#define SECSPERMIN 60
-#define MINSPERHOUR 60
-#define HOURSPERDAY 24
-#define DAYSPERWEEK 7
-#define DAYSPERNYEAR 365
-#define DAYSPERLYEAR 366
-#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
-#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
-#define MONSPERYEAR 12
-
-#define TM_SUNDAY 0
-#define TM_MONDAY 1
-#define TM_TUESDAY 2
-#define TM_WEDNESDAY 3
-#define TM_THURSDAY 4
-#define TM_FRIDAY 5
-#define TM_SATURDAY 6
-
-#define TM_JANUARY 0
-#define TM_FEBRUARY 1
-#define TM_MARCH 2
-#define TM_APRIL 3
-#define TM_MAY 4
-#define TM_JUNE 5
-#define TM_JULY 6
-#define TM_AUGUST 7
-#define TM_SEPTEMBER 8
-#define TM_OCTOBER 9
-#define TM_NOVEMBER 10
-#define TM_DECEMBER 11
-
-#define TM_YEAR_BASE 1900
-
-#define EPOCH_YEAR 1970
-#define EPOCH_WDAY TM_THURSDAY
-
-/*
-** Accurate only for the past couple of centuries;
-** that will probably do.
-*/
-
-#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
-
-#endif /* !_TZFILE_H_ */
Index: lib/libc/rpc/getrpcent.c
===================================================================
RCS file: /cvs/src/lib/libc/rpc/getrpcent.c,v
retrieving revision 1.16
diff -u -p -u -r1.16 getrpcent.c
--- lib/libc/rpc/getrpcent.c 15 Sep 2014 06:15:48 -0000 1.16
+++ lib/libc/rpc/getrpcent.c 10 Feb 2015 06:59:51 -0000
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
+#include <limits.h>
#include <rpc/rpc.h>
/*
@@ -147,6 +148,7 @@ getrpcent(void)
static struct rpcent *
interpret(char *val, int len)
{
+ const char *errstr;
struct rpcdata *d = _rpcdata();
char *p;
char *cp, **q;
@@ -170,7 +172,9 @@ interpret(char *val, int len)
d->rpc.r_name = d->line;
while (*cp == ' ' || *cp == '\t')
cp++;
- d->rpc.r_number = atoi(cp);
+ d->rpc.r_number = strtonum(cp, 0, INT_MAX, &errstr);
+ if (errstr)
+ return (0);
q = d->rpc.r_aliases = d->rpc_aliases;
cp = strpbrk(cp, " \t");
if (cp != NULL)
Index: lib/libc/time/tzfile.h
===================================================================
RCS file: /cvs/src/lib/libc/time/tzfile.h,v
retrieving revision 1.9
diff -u -p -u -r1.9 tzfile.h
--- lib/libc/time/tzfile.h 13 Sep 2012 11:14:20 -0000 1.9
+++ lib/libc/time/tzfile.h 14 Mar 2015 17:33:53 -0000
@@ -148,8 +148,6 @@ struct tzhead {
#define TM_NOVEMBER 10
#define TM_DECEMBER 11
-#define TM_YEAR_BASE 1900
-
#define EPOCH_YEAR 1970
#define EPOCH_WDAY TM_THURSDAY
Index: lib/libskey/skeylogin.c
===================================================================
RCS file: /cvs/src/lib/libskey/skeylogin.c,v
retrieving revision 1.56
diff -u -p -u -r1.56 skeylogin.c
--- lib/libskey/skeylogin.c 16 Jan 2015 16:48:52 -0000 1.56
+++ lib/libskey/skeylogin.c 10 Feb 2015 08:03:10 -0000
@@ -95,6 +95,7 @@ skeygetent(int fd, struct skey *mp, cons
{
char *cp, filename[PATH_MAX], *last;
struct stat statbuf;
+ const char *errstr;
size_t nread;
FILE *keyfile;
@@ -154,7 +155,9 @@ skeygetent(int fd, struct skey *mp, cons
goto bad_keyfile;
if ((cp = strtok_r(NULL, " \t\n\r", &last)) == NULL)
goto bad_keyfile;
- mp->n = atoi(cp); /* XXX - use strtol() */
+ mp->n = strtonum(cp, 0, UINT_MAX, &errstr);
+ if (errstr)
+ goto bad_keyfile;
if ((mp->seed = strtok_r(NULL, " \t\n\r", &last)) == NULL)
goto bad_keyfile;
if ((mp->val = strtok_r(NULL, " \t\n\r", &last)) == NULL)
Index: lib/libz/zutil.c
===================================================================
RCS file: /cvs/src/lib/libz/zutil.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 zutil.c
--- lib/libz/zutil.c 20 Jul 2005 15:56:41 -0000 1.8
+++ lib/libz/zutil.c 12 Mar 2015 16:35:09 -0000
@@ -303,9 +303,7 @@ voidpf zcalloc (opaque, items, size)
unsigned size;
{
if (opaque) items += size - size; /* make compiler happy */
- if (items * size == 0)
- return (NULL);
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
+ return sizeof(uInt) > 2 ? (voidpf)reallocarray(NULL, items, size) :
(voidpf)calloc(items, size);
}
Index: libexec/comsat/comsat.c
===================================================================
RCS file: /cvs/src/libexec/comsat/comsat.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 comsat.c
--- libexec/comsat/comsat.c 16 Jan 2015 06:39:49 -0000 1.38
+++ libexec/comsat/comsat.c 12 Feb 2015 10:05:25 -0000
@@ -200,13 +200,16 @@ mailfor(char *name)
{
struct utmp *utp = &utmp[nutmp];
char utname[UT_NAMESIZE+1];
+ const char *errstr;
char *cp;
off_t offset;
if (!(cp = strchr(name, '@')))
return;
*cp = '\0';
- offset = atoi(cp + 1);
+ offset = strtonum(cp + 1, 0, INT_MAX, &errstr);
+ if (errstr)
+ return;
while (--utp >= utmp) {
memcpy(utname, utp->ut_name, UT_NAMESIZE);
utname[UT_NAMESIZE] = '\0';
Index: libexec/rpc.rstatd/rpc.rstatd.8
===================================================================
RCS file: /cvs/src/libexec/rpc.rstatd/rpc.rstatd.8,v
retrieving revision 1.9
diff -u -p -u -r1.9 rpc.rstatd.8
--- libexec/rpc.rstatd/rpc.rstatd.8 31 May 2007 19:19:40 -0000 1.9
+++ libexec/rpc.rstatd/rpc.rstatd.8 12 Feb 2015 10:07:07 -0000
@@ -37,6 +37,7 @@
.Nd kernel statistics server
.Sh SYNOPSIS
.Nm rpc.rstatd
+.Op Ar closedown
.Sh DESCRIPTION
.Nm rpc.rstatd
is a server which returns performance statistics obtained from the kernel.
@@ -55,6 +56,8 @@ to
.Pa /var/empty
and switches to user
.Va nobody .
+.Pp
+arguments...
.Pp
.Nm rpc.rstatd
uses an RPC protocol defined in
Index: libexec/rpc.rstatd/rstatd.c
===================================================================
RCS file: /cvs/src/libexec/rpc.rstatd/rstatd.c,v
retrieving revision 1.26
diff -u -p -u -r1.26 rstatd.c
--- libexec/rpc.rstatd/rstatd.c 13 Mar 2015 03:24:27 -0000 1.26
+++ libexec/rpc.rstatd/rstatd.c 13 Mar 2015 06:19:03 -0000
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <signal.h>
#include <pwd.h>
#include <syslog.h>
@@ -65,6 +66,7 @@ main(int argc, char *argv[])
socklen_t fromlen;
struct passwd *pw;
struct sockaddr_storage from;
+ const char *errstr;
SVCXPRT *transp;
openlog("rpc.rstatd", LOG_NDELAY|LOG_CONS|LOG_PID, LOG_DAEMON);
@@ -88,8 +90,8 @@ main(int argc, char *argv[])
}
if (argc == 2)
- closedown = atoi(argv[1]);
- if (closedown <= 0)
+ closedown = strtonum(argv[1], 1, INT_MAX, &errstr);
+ if (errstr)
closedown = 20;
/*
Index: libexec/spamd/spamd.8
===================================================================
RCS file: /cvs/src/libexec/spamd/spamd.8,v
retrieving revision 1.126
diff -u -p -u -r1.126 spamd.8
--- libexec/spamd/spamd.8 15 Feb 2015 22:27:51 -0000 1.126
+++ libexec/spamd/spamd.8 20 Feb 2015 04:03:54 -0000
@@ -125,8 +125,8 @@ This value may not be greater than maxco
The default is
.Ar maxcon
\- 100.
-When this value is exceeded new blacklisted connections will not be stuttered
-at.
+When this value is exceeded, new blacklisted connections will not be
+stuttered at.
.It Fl b
Run in blacklist-only mode.
.It Fl C Ar file
Index: libexec/spamd/spamd.c
===================================================================
RCS file: /cvs/src/libexec/spamd/spamd.c,v
retrieving revision 1.126
diff -u -p -u -r1.126 spamd.c
--- libexec/spamd/spamd.c 12 Mar 2015 20:07:20 -0000 1.126
+++ libexec/spamd/spamd.c 13 Mar 2015 04:13:17 -0000
@@ -1246,22 +1246,23 @@ main(int argc, char *argv[])
bind_address = optarg;
break;
case 'B':
- i = atoi(optarg);
- maxblack = i;
+ maxblack = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-B %s: %s", optarg, errstr);
break;
case 'c':
- i = atoi(optarg);
- if (i > maxfiles) {
+ maxcon = strtonum(optarg, 1, maxfiles, &errstr);
+ if (errstr) {
fprintf(stderr,
"%d > system max of %d connections\n",
- i, maxfiles);
+ maxcon, maxfiles);
usage();
}
- maxcon = i;
break;
case 'p':
- i = atoi(optarg);
- port = i;
+ port = strtonum(optarg, 1, USHRT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-p %s: %s", optarg, errstr);
break;
case 'd':
debug = 1;
@@ -1290,16 +1291,14 @@ main(int argc, char *argv[])
errx(1, "-h arg too long");
break;
case 's':
- i = strtonum(optarg, 0, 10, &errstr);
+ stutter = strtonum(optarg, 0, 10, &errstr);
if (errstr)
usage();
- stutter = i;
break;
case 'S':
- i = strtonum(optarg, 0, 90, &errstr);
+ grey_stutter = strtonum(optarg, 0, 90, &errstr);
if (errstr)
usage();
- grey_stutter = i;
break;
case 'M':
low_prio_mx_ip = optarg;
@@ -1311,9 +1310,9 @@ main(int argc, char *argv[])
verbose = 1;
break;
case 'w':
- window = atoi(optarg);
- if (window <= 0)
- usage();
+ window = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-w %s: %s", optarg, errstr);
break;
case 'Y':
if (sync_addhost(optarg, sync_port) != 0)
Index: sbin/fsck/fsck.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsck.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 fsck.c
--- sbin/fsck/fsck.c 16 Jan 2015 06:39:57 -0000 1.33
+++ sbin/fsck/fsck.c 10 Feb 2015 10:50:25 -0000
@@ -88,6 +88,7 @@ static int hasopt(const char *, const ch
int
main(int argc, char *argv[])
{
+ const char *errstr;
struct fstab *fs;
int i, rval = 0;
char *vfstype = NULL;
@@ -139,7 +140,10 @@ main(int argc, char *argv[])
break;
case 'l':
- maxrun = atoi(optarg);
+ maxrun = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-l %s: %s", optarg, errstr);
+
break;
case 'T':
Index: sbin/newfs/mkfs.c
===================================================================
RCS file: /cvs/src/sbin/newfs/mkfs.c,v
retrieving revision 1.90
diff -u -p -u -r1.90 mkfs.c
--- sbin/newfs/mkfs.c 6 Feb 2015 22:29:00 -0000 1.90
+++ sbin/newfs/mkfs.c 10 Feb 2015 10:51:35 -0000
@@ -1149,7 +1149,7 @@ charsperline(void)
if (ioctl(0, TIOCGWINSZ, &ws) != -1)
columns = ws.ws_col;
if (columns == 0 && (cp = getenv("COLUMNS")))
- columns = atoi(cp);
+ columns = strtonum(cp, 1, INT_MAX, NULL);
if (columns == 0)
columns = 80; /* last resort */
return columns;
Index: sbin/newfs_msdos/newfs_msdos.c
===================================================================
RCS file: /cvs/src/sbin/newfs_msdos/newfs_msdos.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 newfs_msdos.c
--- sbin/newfs_msdos/newfs_msdos.c 16 Jan 2015 06:40:00 -0000 1.25
+++ sbin/newfs_msdos/newfs_msdos.c 10 Feb 2015 22:38:09 -0000
@@ -249,6 +249,7 @@ main(int argc, char *argv[])
ssize_t n;
time_t now;
u_int fat, bss, rds, cls, dir, lsn, x, x1, x2;
+ const char *errstr;
int ch, fd, fd1;
while ((ch = getopt(argc, argv, opts)) != -1)
@@ -260,11 +261,11 @@ main(int argc, char *argv[])
opt_B = optarg;
break;
case 'F':
- if (strcmp(optarg, "12") &&
- strcmp(optarg, "16") &&
- strcmp(optarg, "32"))
+ opt_F = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-l %s: %s", optarg, errstr);
+ if (!(opt_F == 12 || opt_F == 16 || opt_F == 32))
errx(1, "%s: bad FAT type", optarg);
- opt_F = atoi(optarg);
break;
case 'I':
opt_I = argto4(optarg, 0, "volume ID");
Index: sbin/quotacheck/quotacheck.c
===================================================================
RCS file: /cvs/src/sbin/quotacheck/quotacheck.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 quotacheck.c
--- sbin/quotacheck/quotacheck.c 7 Feb 2015 02:09:14 -0000 1.37
+++ sbin/quotacheck/quotacheck.c 10 Feb 2015 22:34:48 -0000
@@ -136,6 +136,7 @@ main(int argc, char *argv[])
struct quotaname *auxdata;
int i, argnum, maxrun, errs, ch;
u_int64_t done = 0; /* XXX supports maximum 64 filesystems */
+ const char *errstr;
char *name;
errs = maxrun = 0;
@@ -151,7 +152,9 @@ main(int argc, char *argv[])
gflag = 1;
break;
case 'l':
- maxrun = atoi(optarg);
+ maxrun = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-l %s: %s", optarg, errstr);
break;
case 'u':
uflag = 1;
Index: sbin/shutdown/shutdown.c
===================================================================
RCS file: /cvs/src/sbin/shutdown/shutdown.c,v
retrieving revision 1.41
diff -u -p -u -r1.41 shutdown.c
--- sbin/shutdown/shutdown.c 15 Mar 2015 00:41:27 -0000 1.41
+++ sbin/shutdown/shutdown.c 15 Mar 2015 00:44:58 -0000
@@ -437,9 +437,12 @@ getoffset(char *timearg)
(void)time(&now);
if (*timearg == '+') { /* +minutes */
- if (!isdigit((unsigned char)*++timearg))
+ const char *errstr;
+
+ offset = strtonum(++timearg, 0, INT_MAX, &errstr);
+ if (errstr);
badtime();
- offset = atoi(timearg) * 60;
+ offset *= 60;
shuttime = now + offset;
return;
}
Index: sbin/swapctl/swapctl.c
===================================================================
RCS file: /cvs/src/sbin/swapctl/swapctl.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 swapctl.c
--- sbin/swapctl/swapctl.c 16 Jan 2015 06:40:01 -0000 1.19
+++ sbin/swapctl/swapctl.c 10 Feb 2015 08:55:23 -0000
@@ -58,6 +58,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <fstab.h>
#include <util.h>
@@ -116,6 +117,7 @@ extern char *__progname; /* from crt0.o
int
main(int argc, char *argv[])
{
+ const char *errstr;
int c;
if (strcmp(__progname, "swapon") == 0)
@@ -149,8 +151,9 @@ main(int argc, char *argv[])
case 'p':
pflag = 1;
- /* XXX strtol() */
- pri = atoi(optarg);
+ pri = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-p %s: %s", errstr, optarg);
break;
case 's':
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.210
diff -u -p -u -r1.210 sysctl.c
--- sbin/sysctl/sysctl.c 13 Feb 2015 00:02:21 -0000 1.210
+++ sbin/sysctl/sysctl.c 20 Feb 2015 04:04:04 -0000
@@ -102,6 +102,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <limits.h>
#include <unistd.h>
#include <machine/cpu.h>
@@ -1297,6 +1298,8 @@ sysctl_bios(char *string, char **bufpp,
return (-1);
mib[2] = indx;
if (indx == BIOS_DISKINFO) {
+ const char *errstr;
+
if (*bufpp == NULL) {
char name[BUFSIZ];
@@ -1312,7 +1315,11 @@ sysctl_bios(char *string, char **bufpp,
warnx("%s: incomplete specification", string);
return (-1);
}
- mib[3] = atoi(name);
+ mib[3] = strtonum(name, 0, INT_MAX, &errstr);
+ if (errstr) {
+ warnx("%s: %s", string, errstr);
+ return (-1);
+ }
*typep = CTLTYPE_STRUCT;
return (4);
} else {
@@ -1802,6 +1809,7 @@ sysctl_malloc(char *string, char **bufpp
{
int indx, stor, i;
char *name, bufp[SYSCTL_BUFSIZ], *buf, *ptr;
+ const char *errstr;
struct list lp;
size_t size;
@@ -1839,7 +1847,9 @@ sysctl_malloc(char *string, char **bufpp
free(lp.list);
return (-1);
}
- mib[3] = atoi(name);
+ mib[3] = strtonum(name, 0, INT_MAX, &errstr);
+ if (errstr)
+ return -1;
return (4);
} else if (mib[2] == KERN_MALLOC_BUCKETS) {
*typep = CTLTYPE_STRING;
@@ -2398,7 +2408,13 @@ sysctl_sensors(char *string, char **bufp
numt = -1;
for (i = 0; typename[i] != '\0'; i++)
if (isdigit((unsigned char)typename[i])) {
- numt = atoi(&typename[i]);
+ const char *errstr;
+
+ numt = strtonum(&typename[i], 0, INT_MAX, &errstr);
+ if (errstr) {
+ warnx("%s: %s", string, errstr);
+ return (-1);
+ }
typename[i] = '\0';
break;
}
@@ -2702,7 +2718,14 @@ sysctl_emul(char *string, char *newval,
mib[2] = emul_names[i].index;
len = sizeof(int);
if (newval) {
- enabled = atoi(newval);
+ const char *errstr;
+
+ enabled = strtonum(newval, 0, INT_MAX, &errstr);
+ if (errstr) {
+ warn("%s", string);
+ print = 0;
+ continue;
+ }
if (sysctl(mib, 4, &old, &len, &enabled, len) == -1) {
warn("%s", string);
print = 0;
Index: sys/arch/alpha/alpha/locore.s
===================================================================
RCS file: /cvs/src/sys/arch/alpha/alpha/locore.s,v
retrieving revision 1.38
diff -u -p -u -r1.38 locore.s
--- sys/arch/alpha/alpha/locore.s 26 Jan 2014 17:40:09 -0000 1.38
+++ sys/arch/alpha/alpha/locore.s 28 Jan 2015 16:32:15 -0000
@@ -969,6 +969,7 @@ NESTED(kcopy, 3, 32, ra, IM_RA|IM_S0|IM_
ldq s0, U_PCB_ONFAULT(at_reg) /* save old handler. */
stq v0, U_PCB_ONFAULT(at_reg)
.set at
+// XXX move to memcpy
CALL(bcopy) /* do the copy. */
.set noat
ldq at_reg, 0(s1) /* restore the old handler. */
@@ -1015,6 +1016,7 @@ NESTED(copyin, 3, 16, ra, IM_RA|IM_S0, 0
ldq at_reg, P_ADDR(at_reg)
stq v0, U_PCB_ONFAULT(at_reg)
.set at
+// XXX move to memcpy
CALL(bcopy) /* do the copy. */
.set noat
ldq at_reg, 0(s0) /* kill the fault handler. */
@@ -1045,6 +1047,7 @@ NESTED(copyout, 3, 16, ra, IM_RA|IM_S0,
ldq at_reg, P_ADDR(at_reg)
stq v0, U_PCB_ONFAULT(at_reg)
.set at
+// XXX move to memcpy
CALL(bcopy) /* do the copy. */
.set noat
ldq at_reg, 0(s0) /* kill the fault handler. */
Index: sys/arch/powerpc/powerpc/pmap.c
===================================================================
RCS file: /cvs/src/sys/arch/powerpc/powerpc/pmap.c,v
retrieving revision 1.142
diff -u -p -u -r1.142 pmap.c
--- sys/arch/powerpc/powerpc/pmap.c 9 Feb 2015 13:35:44 -0000 1.142
+++ sys/arch/powerpc/powerpc/pmap.c 9 Feb 2015 13:53:10 -0000
@@ -1289,13 +1289,13 @@ pmap_release(pmap_t pm)
int i, tblidx, tbloff;
int s;
+ s = splvm();
+
pmap_vp_destroy(pm);
i = (pm->pm_sr[0] & SR_VSID) >> 4;
tblidx = i / (8 * sizeof usedsr[0]);
tbloff = i % (8 * sizeof usedsr[0]);
- /* LOCK? */
- s = splvm();
usedsr[tblidx] &= ~(1 << tbloff);
splx(s);
}
Index: sys/lib/libkern/arch/alpha/memmove.S
===================================================================
RCS file: /cvs/src/sys/lib/libkern/arch/alpha/memmove.S,v
retrieving revision 1.5
diff -u -p -u -r1.5 memmove.S
--- sys/lib/libkern/arch/alpha/memmove.S 15 Jun 2013 18:51:44 -0000
1.5
+++ sys/lib/libkern/arch/alpha/memmove.S 28 Jan 2015 16:32:50 -0000
@@ -27,6 +27,10 @@
#include <machine/asm.h>
+// XX should invert.
+// write in terms of fast-path, which is memcpy/memmove
+// wrap bcopy around that.
+
/*
* Copy a bytes within the kernel's address space. The bcopy and memmove
* variants handle overlapping regions, the memcpy variant does not.
Index: usr.bin/hexdump/odsyntax.c
===================================================================
RCS file: /cvs/src/usr.bin/hexdump/odsyntax.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 odsyntax.c
--- usr.bin/hexdump/odsyntax.c 19 Apr 2014 09:28:20 -0000 1.25
+++ usr.bin/hexdump/odsyntax.c 23 Feb 2015 07:27:03 -0000
@@ -37,6 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <limits.h>
#include "hexdump.h"
@@ -81,6 +82,7 @@ oldsyntax(int argc, char ***argvp)
{
static char empty[] = "", padding[] = PADDING;
int ch;
+ const char *errstr;
char *p, **argv;
#define TYPE_OFFSET 7
@@ -165,8 +167,9 @@ oldsyntax(int argc, char ***argvp)
}
break;
case 'N':
- if ((length = atoi(optarg)) < 0)
- errx(1, "%s: bad length value", optarg);
+ length = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "%s: %s", optarg, errstr);
break;
case 'O':
odadd("4/4 \" %011o \" \"\\n\"");
Index: usr.bin/ipcrm/ipcrm.c
===================================================================
RCS file: /cvs/src/usr.bin/ipcrm/ipcrm.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 ipcrm.c
--- usr.bin/ipcrm/ipcrm.c 19 Dec 2005 19:13:50 -0000 1.10
+++ usr.bin/ipcrm/ipcrm.c 12 Feb 2015 08:24:02 -0000
@@ -39,6 +39,7 @@
#include <sys/shm.h>
#include <stdio.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <ctype.h>
#include <err.h>
@@ -112,6 +113,7 @@ int
main(int argc, char *argv[])
{
int c, result, errflg, target_id;
+ const char *errstr;
key_t target_key;
errflg = 0;
@@ -122,7 +124,9 @@ main(int argc, char *argv[])
case 'q':
case 'm':
case 's':
- target_id = atoi(optarg);
+ target_id = strtonum(optarg, 0, LONG_MAX, &errstr);
+ if (errstr)
+ errx(1, "-%c %s: %s\n", c, optarg, &errstr);
if (c == 'q')
result = msgrm(0, target_id);
else if (c == 'm')
Index: usr.bin/kdump/kdump.c
===================================================================
RCS file: /cvs/src/usr.bin/kdump/kdump.c,v
retrieving revision 1.98
diff -u -p -u -r1.98 kdump.c
--- usr.bin/kdump/kdump.c 26 Jan 2015 04:38:23 -0000 1.98
+++ usr.bin/kdump/kdump.c 12 Feb 2015 08:20:33 -0000
@@ -169,6 +169,7 @@ main(int argc, char *argv[])
int ch, silent;
size_t ktrlen, size;
int trpoints = ALL_POINTS;
+ const char *errstr;
void *m;
def_emul = current = &emulations[0]; /* native */
@@ -192,13 +193,17 @@ main(int argc, char *argv[])
tail = 1;
break;
case 'm':
- maxdata = atoi(optarg);
+ maxdata = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-m %s: %s", optarg, errstr);
break;
case 'n':
fancy = 0;
break;
case 'p':
- pid_opt = atoi(optarg);
+ pid_opt = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-p %s: %s", optarg, errstr);
break;
case 'R':
timestamp = 2; /* relative timestamp */
Index: usr.bin/ktrace/ktrace.c
===================================================================
RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.31
diff -u -p -u -r1.31 ktrace.c
--- usr.bin/ktrace/ktrace.c 16 Jan 2015 06:40:09 -0000 1.31
+++ usr.bin/ktrace/ktrace.c 12 Feb 2015 08:22:02 -0000
@@ -211,7 +211,9 @@ main(int argc, char *argv[])
static int
rpid(const char *p)
{
+ const char *errstr;
static int first;
+ int pid;
if (first++) {
warnx("only one -g or -p flag is permitted.");
@@ -221,7 +223,12 @@ rpid(const char *p)
warnx("illegal process id.");
usage();
}
- return(atoi(p));
+ pid = strtonum(p, 1, INT_MAX, &errstr);
+ if (errstr) {
+ warnx("illegal process id: %s", errstr);
+ usage();
+ }
+ return pid;
}
static void
Index: usr.bin/logger/logger.c
===================================================================
RCS file: /cvs/src/usr.bin/logger/logger.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 logger.c
--- usr.bin/logger/logger.c 27 Nov 2013 13:32:02 -0000 1.13
+++ usr.bin/logger/logger.c 12 Feb 2015 09:48:49 -0000
@@ -32,6 +32,7 @@
#include <errno.h>
#include <unistd.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
@@ -155,10 +156,15 @@ pencode(char *s)
int
decode(char *name, CODE *codetab)
{
+ int n;
CODE *c;
- if (isdigit((unsigned char)*name))
- return (atoi(name));
+ if (isdigit((unsigned char)*name)) {
+ const char *errstr;
+ int n = strtonum(name, 0, INT_MAX, &errstr);
+ if (!errstr)
+ return (n);
+ }
for (c = codetab; c->c_name; c++)
if (!strcasecmp(name, c->c_name))
Index: usr.bin/skeyinit/skeyinit.c
===================================================================
RCS file: /cvs/src/usr.bin/skeyinit/skeyinit.c,v
retrieving revision 1.56
diff -u -p -u -r1.56 skeyinit.c
--- usr.bin/skeyinit/skeyinit.c 16 Jan 2015 06:40:11 -0000 1.56
+++ usr.bin/skeyinit/skeyinit.c 12 Feb 2015 09:46:05 -0000
@@ -52,6 +52,7 @@ main(int argc, char **argv)
char seed[SKEY_MAX_SEED_LEN + 1];
char buf[256], key[SKEY_BINKEY_SIZE], filename[PATH_MAX], *ht;
char lastc, me[UT_NAMESIZE + 1], *p, *auth_type;
+ const char *errstr;
u_int32_t noise;
struct skey skey;
struct passwd *pp;
@@ -108,7 +109,8 @@ main(int argc, char **argv)
case 'n':
if (argv[++i] == NULL || argv[i][0] == '\0')
usage();
- if ((n = atoi(argv[i])) < 1 || n >=
SKEY_MAX_SEQ)
+ n = strtonum(argv[i], 1, SKEY_MAX_SEQ - 1,
&errstr);
+ if (errstr)
errx(1, "count must be > 0 and < %d",
SKEY_MAX_SEQ);
break;
@@ -324,6 +326,7 @@ secure_mode(int *count, char *key, char
char *buf, size_t bufsiz)
{
char *p, newseed[SKEY_MAX_SEED_LEN + 2];
+ const char *errstr;
int i, n;
(void)puts("You need the 6 words generated from the \"skey\" command.");
@@ -335,11 +338,11 @@ secure_mode(int *count, char *key, char
SKEY_MAX_SEQ);
(void)fgets(buf, bufsiz, stdin);
clearerr(stdin);
- n = atoi(buf);
- if (n > 0 && n < SKEY_MAX_SEQ)
+ n = strtonum(buf, 1, SKEY_MAX_SEQ-1, &errstr);
+ if (errstr)
break; /* Valid range */
- (void)fprintf(stderr, "ERROR: Count must be between 1 and %d\n",
- SKEY_MAX_SEQ);
+ fprintf(stderr, "ERROR: Count must be between 1 and %d\n",
+ SKEY_MAX_SEQ);
}
for (i = 0; ; i++) {
@@ -492,6 +495,7 @@ convert_db(void)
FILE *newfile;
char buf[256], *logname, *hashtype, *seed, *val, *cp;
char filename[PATH_MAX];
+ const char *errstr;
int fd, n;
if ((keyfile = fopen(_PATH_SKEYKEYS, "r")) == NULL)
@@ -516,7 +520,9 @@ convert_db(void)
hashtype = cp;
if ((cp = strtok(NULL, " \t")) == NULL)
continue;
- n = atoi(cp);
+ n = strtonum(cp, 0, INT_MAX, &errstr);
+ if (errstr)
+ continue;
if ((seed = strtok(NULL, " \t")) == NULL)
continue;
if ((val = strtok(NULL, " \t")) == NULL)
Index: usr.bin/su/Makefile
===================================================================
RCS file: /cvs/src/usr.bin/su/Makefile,v
retrieving revision 1.8
diff -u -p -u -r1.8 Makefile
--- usr.bin/su/Makefile 29 May 2001 21:40:35 -0000 1.8
+++ usr.bin/su/Makefile 13 Mar 2015 06:50:20 -0000
@@ -3,5 +3,5 @@
PROG= su
BINOWN= root
BINMODE=4555
-
+COPTS=-Wall
.include <bsd.prog.mk>
Index: usr.bin/su/su.c
===================================================================
RCS file: /cvs/src/usr.bin/su/su.c,v
retrieving revision 1.66
diff -u -p -u -r1.66 su.c
--- usr.bin/su/su.c 16 Jan 2015 06:40:13 -0000 1.66
+++ usr.bin/su/su.c 10 Mar 2015 15:33:19 -0000
@@ -118,7 +118,7 @@ main(int argc, char **argv)
prio = getpriority(PRIO_PROCESS, 0);
if (errno)
prio = 0;
- (void)setpriority(PRIO_PROCESS, 0, -2);
+ setpriority(PRIO_PROCESS, 0, -2);
openlog("su", LOG_CONS, 0);
if ((as = auth_open()) == NULL) {
@@ -254,8 +254,8 @@ main(int argc, char **argv)
if (login_getcapbool(lc, "requirehome", 0)) {
auth_err(as, 1, "%s", pwd->pw_dir);
} else {
- (void)printf("No home directory %s!\n",
pwd->pw_dir);
- (void)printf("Logging in with home =
\"/\".\n");
+ printf("No home directory %s!\n",
pwd->pw_dir);
+ printf("Logging in with home =
\"/\".\n");
if (chdir("/") < 0)
auth_err(as, 1, "/");
}
@@ -305,7 +305,7 @@ main(int argc, char **argv)
syslog(LOG_NOTICE|LOG_AUTH, "%s to %s%s",
username, user, ontty());
- (void)setpriority(PRIO_PROCESS, 0, prio);
+ setpriority(PRIO_PROCESS, 0, prio);
if (emlogin) {
flags = LOGIN_SETALL & ~LOGIN_SETPATH;
/*
@@ -417,7 +417,7 @@ getloginname(void)
int ch;
for (;;) {
- (void)printf("login: ");
+ printf("login: ");
for (p = nbuf; (ch = getchar()) != '\n'; ) {
if (ch == EOF)
return (NULL);
@@ -426,7 +426,7 @@ getloginname(void)
}
if (p > nbuf) {
if (nbuf[0] == '-') {
- (void)fprintf(stderr,
+ fprintf(stderr,
"login names may not start with '-'.\n");
} else {
*p = '\0';
Index: usr.bin/systat/main.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/main.c,v
retrieving revision 1.62
diff -u -p -u -r1.62 main.c
--- usr.bin/systat/main.c 12 Mar 2015 01:03:00 -0000 1.62
+++ usr.bin/systat/main.c 15 Mar 2015 16:01:14 -0000
@@ -296,13 +296,12 @@ cmd_delay(const char *buf)
void
cmd_count(const char *buf)
{
+ const char *errstr;
int ms;
- ms = atoi(buf);
- if (ms <= 0 || ms > lines - HEADER_LINES)
+ maxprint = strtonum(buf, 1, lines - HEADER_LINES, &errstr);
+ if (errstr)
maxprint = lines - HEADER_LINES;
- else
- maxprint = ms;
}
@@ -380,6 +379,7 @@ int
main(int argc, char *argv[])
{
char errbuf[_POSIX2_LINE_MAX];
+ const char *errstr;
extern char *optarg;
extern int optind;
double delay = 5;
@@ -418,9 +418,9 @@ main(int argc, char *argv[])
interactive = 0;
break;
case 'd':
- countmax = atoi(optarg);
- if (countmax < 0)
- countmax = 0;
+ countmax = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-d %s: %s", optarg, errstr);
break;
case 'i':
interactive = 1;
@@ -438,11 +438,9 @@ main(int argc, char *argv[])
delay = 5;
break;
case 'w':
- rawwidth = atoi(optarg);
- if (rawwidth < 1)
- rawwidth = DEFAULT_WIDTH;
- if (rawwidth >= MAX_LINE_BUF)
- rawwidth = MAX_LINE_BUF - 1;
+ rawwidth = strtonum(optarg, 1, MAX_LINE_BUF-1, &errstr);
+ if (errstr)
+ errx(1, "-w %s: %s", optarg, errstr);
break;
default:
usage();
Index: usr.bin/unifdef/unifdef.c
===================================================================
RCS file: /cvs/src/usr.bin/unifdef/unifdef.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 unifdef.c
--- usr.bin/unifdef/unifdef.c 17 Feb 2015 05:16:09 -0000 1.18
+++ usr.bin/unifdef/unifdef.c 20 Feb 2015 04:04:26 -0000
@@ -252,6 +252,7 @@ static const char *xstrdup(const ch
int
main(int argc, char *argv[])
{
+ const char *errstr;
int opt;
while ((opt = getopt(argc, argv, "i:D:U:f:I:M:o:x:bBcdehKklmnsStV")) !=
-1)
@@ -332,7 +333,9 @@ main(int argc, char *argv[])
version();
break;
case 'x':
- exitmode = atoi(optarg);
+ exitmode = strtonum(optarg, 0, 2, &errstr);
+ if (errstr)
+ errx(1, "-x %s: %s", optarg, errstr);
if(exitmode < 0 || exitmode > 2)
usage();
break;
Index: usr.bin/vis/vis.c
===================================================================
RCS file: /cvs/src/usr.bin/vis/vis.c,v
retrieving revision 1.16
diff -u -p -u -r1.16 vis.c
--- usr.bin/vis/vis.c 8 Feb 2015 23:40:34 -0000 1.16
+++ usr.bin/vis/vis.c 10 Feb 2015 05:41:34 -0000
@@ -34,6 +34,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <limits.h>
#include <err.h>
#include <vis.h>
@@ -50,6 +51,7 @@ __dead void usage(void);
int
main(int argc, char *argv[])
{
+ const char *errstr;
FILE *fp;
int ch;
@@ -80,10 +82,11 @@ main(int argc, char *argv[])
eflags |= VIS_NOSLASH;
break;
case 'F':
- if ((foldwidth = atoi(optarg))<5) {
+ foldwidth = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "%s: %s", optarg, errstr);
+ if (foldwidth < 5)
errx(1, "can't fold lines to less than 5 cols");
- /* NOTREACHED */
- }
/*FALLTHROUGH*/
case 'f':
fold = 1; /* fold output lines to 80 cols */
Index: usr.bin/xargs/xargs.c
===================================================================
RCS file: /cvs/src/usr.bin/xargs/xargs.c,v
retrieving revision 1.28
diff -u -p -u -r1.28 xargs.c
--- usr.bin/xargs/xargs.c 16 Jan 2015 06:40:14 -0000 1.28
+++ usr.bin/xargs/xargs.c 10 Feb 2015 05:37:07 -0000
@@ -50,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "pathnames.h"
@@ -78,6 +79,7 @@ main(int argc, char *argv[])
int ch, Jflag, nargs, nflag, nline;
size_t linelen;
char *endptr;
+ const char *errstr;
inpline = replstr = NULL;
ep = environ;
@@ -125,19 +127,23 @@ main(int argc, char *argv[])
replstr = optarg;
break;
case 'L':
- Lflag = atoi(optarg);
+ Lflag = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-L %s: %s", optarg, errstr);
break;
case 'n':
nflag = 1;
- if ((nargs = atoi(optarg)) <= 0)
- errx(1, "illegal argument count");
+ nargs = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-n %s: %s", optarg, errstr);
break;
case 'o':
oflag = 1;
break;
case 'P':
- if ((maxprocs = atoi(optarg)) <= 0)
- errx(1, "max. processes must be >0");
+ maxprocs = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-P %s: %s", optarg, errstr);
break;
case 'p':
pflag = 1;
@@ -151,7 +157,9 @@ main(int argc, char *argv[])
errx(1, "replacements must be a number");
break;
case 's':
- nline = atoi(optarg);
+ nline = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-n %s: %s", optarg, errstr);
break;
case 't':
tflag = 1;
Index: usr.sbin/fdformat/fdformat.c
===================================================================
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 fdformat.c
--- usr.sbin/fdformat/fdformat.c 8 Oct 2014 04:55:03 -0000 1.19
+++ usr.sbin/fdformat/fdformat.c 12 Feb 2015 09:52:35 -0000
@@ -45,6 +45,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <limits.h>
#include <ctype.h>
#include <err.h>
#include <util.h>
@@ -181,33 +182,46 @@ main(int argc, char *argv[])
int rate = -1, gaplen = -1, secsize = -1, steps = -1;
int fill = 0xf6, quiet = 0, verify = 1, verify_only = 0;
int fd, c, track, error, tracks_per_dot, bytes_per_track, errs;
+ const char *errstr;
char *devname;
struct fd_type fdt;
while((c = getopt(argc, argv, "c:s:h:r:g:S:F:t:i:qvn")) != -1)
switch (c) {
case 'c': /* # of cyls */
- cyls = atoi(optarg);
+ cyls = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-c %s: %s", optarg, errstr);
break;
case 's': /* # of secs per track */
- secs = atoi(optarg);
+ secs = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-s %s: %s", optarg, errstr);
break;
case 'h': /* # of heads */
- heads = atoi(optarg);
+ heads = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-h %s: %s", optarg, errstr);
break;
case 'r': /* transfer rate, kilobyte/sec */
- rate = atoi(optarg);
+ rate = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-r %s: %s", optarg, errstr);
break;
case 'g': /* length of GAP3 to format with */
- gaplen = atoi(optarg);
+ gaplen = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-g %s: %s", optarg, errstr);
break;
case 'S': /* sector size shift factor (1 << S)*128 */
- secsize = atoi(optarg);
+ secsize = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-S %s: %s", optarg, errstr);
break;
case 'F': /* fill byte, C-like notation allowed */
@@ -215,11 +229,15 @@ main(int argc, char *argv[])
break;
case 't': /* steps per track */
- steps = atoi(optarg);
+ steps = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-t %s: %s", optarg, errstr);
break;
case 'i': /* interleave factor */
- intleave = atoi(optarg);
+ intleave = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-i %s: %s", optarg, errstr);
break;
case 'q':
Index: usr.sbin/inetd/inetd.c
===================================================================
RCS file: /cvs/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.143
diff -u -p -u -r1.143 inetd.c
--- usr.sbin/inetd/inetd.c 16 Jan 2015 06:40:17 -0000 1.143
+++ usr.sbin/inetd/inetd.c 14 Mar 2015 18:29:16 -0000
@@ -547,8 +547,9 @@ void
config(int sig, short event, void *arg)
{
struct servtab *sep, *cp, **sepp;
+ const char *errstr;
int add;
- char protoname[10];
+ char protoname[11];
if (!setconfig()) {
syslog(LOG_ERR, "%s: %m", CONFIG);
@@ -623,8 +624,9 @@ config(int sig, short event, void *arg)
if (isrpcservice(sep)) {
struct rpcent *rp;
- sep->se_rpcprog = atoi(sep->se_service);
- if (sep->se_rpcprog == 0) {
+ sep->se_rpcprog = strtonum(sep->se_service,
+ 1, USHRT_MAX, &errstr);
+ if (errstr) {
rp = getrpcbyname(sep->se_service);
if (rp == 0) {
syslog(LOG_ERR,
@@ -639,12 +641,11 @@ config(int sig, short event, void *arg)
if (sep->se_fd != -1)
register_rpc(sep);
} else {
- u_short port = htons(atoi(sep->se_service));
-
- if (!port) {
- /* XXX */
- strncpy(protoname, sep->se_proto,
- sizeof(protoname));
+ u_short port = strtonum(sep->se_service,
+ 1, USHRT_MAX, &errstr);
+ if (errstr) {
+ strlcpy(protoname, sep->se_proto,
+ sizeof(protoname));
if (isdigit((unsigned char)
protoname[strlen(protoname) - 1]))
protoname[strlen(protoname) -
1] = '\0';
@@ -657,7 +658,9 @@ config(int sig, short event, void *arg)
goto serv_unknown;
}
port = sp->s_port;
- }
+ } else
+ port = htons(port);
+
if (port != sep->se_ctrladdr_in.sin_port) {
sep->se_ctrladdr_in.sin_port = port;
if (sep->se_fd != -1) {
@@ -697,9 +700,8 @@ config(int sig, short event, void *arg)
u_short port = htons(atoi(sep->se_service));
if (!port) {
- /* XXX */
- strncpy(protoname, sep->se_proto,
- sizeof(protoname));
+ strlcpy(protoname, sep->se_proto,
+ sizeof(protoname));
if (isdigit((unsigned char)
protoname[strlen(protoname) - 1]))
protoname[strlen(protoname) -
1] = '\0';
@@ -1249,7 +1251,6 @@ more:
hints.ai_socktype = sep->se_socktype;
hints.ai_flags = AI_PASSIVE;
port = "0";
- /* XXX shortened IPv4 syntax is now forbidden */
error = getaddrinfo(strcmp(host, "*") ? host : NULL,
port, &hints, &res0);
if (error) {
Index: usr.sbin/ndp/ndp.c
===================================================================
RCS file: /cvs/src/usr.sbin/ndp/ndp.c,v
retrieving revision 1.59
diff -u -p -u -r1.59 ndp.c
--- usr.sbin/ndp/ndp.c 16 Jan 2015 06:40:18 -0000 1.59
+++ usr.sbin/ndp/ndp.c 12 Feb 2015 09:54:38 -0000
@@ -102,6 +102,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <err.h>
#include "gmt2local.h"
@@ -202,8 +203,8 @@ main(int argc, char *argv[])
/*NOTREACHED*/
}
mode = 'a';
- repeat = atoi(optarg);
- if (repeat < 0) {
+ repeat = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr) {
usage();
/*NOTREACHED*/
}
Index: usr.sbin/pwd_mkdb/pwd_mkdb.c
===================================================================
RCS file: /cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.c,v
retrieving revision 1.46
diff -u -p -u -r1.46 pwd_mkdb.c
--- usr.sbin/pwd_mkdb/pwd_mkdb.c 16 Jan 2015 06:40:19 -0000 1.46
+++ usr.sbin/pwd_mkdb/pwd_mkdb.c 16 Mar 2015 01:00:10 -0000
@@ -402,7 +402,7 @@ cp(char *from, char *to, mode_t mode)
void
mv(char *from, char *to)
{
- char buf[PATH_MAX * 2];
+ char buf[PATH_MAX + 4 + PATH_MAX];
if (rename(from, to)) {
int sverrno = errno;
Index: usr.sbin/rip6query/rip6query.c
===================================================================
RCS file: /cvs/src/usr.sbin/rip6query/rip6query.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 rip6query.c
--- usr.sbin/rip6query/rip6query.c 19 Mar 2014 14:02:24 -0000 1.14
+++ usr.sbin/rip6query/rip6query.c 12 Feb 2015 09:55:38 -0000
@@ -38,6 +38,7 @@
#include <ctype.h>
#include <signal.h>
#include <errno.h>
+#include <limits.h>
#include <err.h>
#include <sys/types.h>
@@ -76,6 +77,7 @@ main(int argc, char *argv[])
int c;
int ifidx = -1;
int error;
+ const char *errstr;
char pbuf[NI_MAXSERV];
struct addrinfo hints, *res;
@@ -89,7 +91,9 @@ main(int argc, char *argv[])
}
break;
case 'w':
- query_wait = atoi(optarg);
+ query_wait = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-w %s: %s", optarg, errstr);
break;
default:
usage();
Index: usr.sbin/sa/main.c
===================================================================
RCS file: /cvs/src/usr.sbin/sa/main.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 main.c
--- usr.sbin/sa/main.c 24 Nov 2013 01:06:19 -0000 1.12
+++ usr.sbin/sa/main.c 12 Feb 2015 09:58:53 -0000
@@ -72,6 +72,7 @@ main(int argc, char **argv)
{
int ch;
int error = 0;
+ const char *errstr;
extern char *__progname;
while ((ch = getopt(argc, argv, "abcdDfijkKlmnqrstuv:")) != -1)
@@ -156,7 +157,10 @@ main(int argc, char **argv)
case 'v':
/* cull junk */
vflag = 1;
- cutoff = atoi(optarg);
+ /* XXX cutoff could be converted to quad_t? */
+ cutoff = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-v $s: %s", optarg, errstr);
break;
case '?':
default: