Browse Source

library routines should not be checking for NULL pointers passed in,

and then setting errno to EFAULT.  that is balony programming!  they
should keep stumbling along to purposely create a crash, so that the
programmer stops doing that kind of stupid crap.  ok otto
OPENBSD_3_9
deraadt 18 years ago
parent
commit
945e8d4407
4 changed files with 5 additions and 27 deletions
  1. +2
    -5
      src/lib/libutil/fmt_scaled.3
  2. +1
    -11
      src/lib/libutil/fmt_scaled.c
  3. +1
    -6
      src/lib/libutil/opendisk.3
  4. +1
    -5
      src/lib/libutil/opendisk.c

+ 2
- 5
src/lib/libutil/fmt_scaled.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: fmt_scaled.3,v 1.2 2003/06/02 11:37:27 jmc Exp $
.\" $OpenBSD: fmt_scaled.3,v 1.3 2005/10/19 18:48:11 deraadt Exp $
.\" Copyright (c) 2001, 2003 Ian Darwin. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -61,7 +61,7 @@ The
buffer must be allocated with at least
.Dv FMT_SCALED_STRSIZE
bytes.
The result will be left-justified in the given space, and null-terminated.
The result will be left-justified in the given space, and NUL-terminated.
.Sh RETURN VALUES
The
.Fn scan_scaled
@ -74,9 +74,6 @@ In case of error, they return \-1, leave
as is, and set
.Va errno
to one of the following values:
.Dv EFAULT
if an input pointer is
.Dv NULL .
.Dv ERANGE
if the input string represents a number that is too large to represent.
.Dv EINVAL


+ 1
- 11
src/lib/libutil/fmt_scaled.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: fmt_scaled.c,v 1.7 2005/08/02 21:46:23 espie Exp $ */
/* $OpenBSD: fmt_scaled.c,v 1.8 2005/10/19 18:48:11 deraadt Exp $ */
/*
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@ -76,11 +76,6 @@ scan_scaled(char *scaled, long long *result)
unsigned int i, ndigits = 0, fract_digits = 0;
long long scale_fact = 1, whole = 0, fpart = 0;
if (p == NULL || result == NULL) {
errno = EFAULT;
return -1;
}
/* Skip leading whitespace */
while (*p && isascii(*p) && isspace(*p))
++p;
@ -197,11 +192,6 @@ fmt_scaled(long long number, char *result)
unsigned int i;
unit_type unit = NONE;
if (result == NULL) {
errno = EFAULT;
return -1;
}
abval = (number < 0LL) ? -number : number; /* no long long_abs yet */
/* Not every negative long long has a positive representation.


+ 1
- 6
src/lib/libutil/opendisk.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: opendisk.3,v 1.2 2001/07/13 22:14:07 millert Exp $
.\" $OpenBSD: opendisk.3,v 1.3 2005/10/19 18:48:11 deraadt Exp $
.\" $NetBSD: opendisk.3,v 1.4 1999/07/02 15:49:12 simonb Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -150,11 +150,6 @@ was set in
or
.Xr getrawpartition 3
didn't return a valid partition.
.It Bq Er EFAULT
.Fa buf
was the
.Dv NULL
pointer.
.El
.Pp
The


+ 1
- 5
src/lib/libutil/opendisk.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: opendisk.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $ */
/* $OpenBSD: opendisk.c,v 1.4 2005/10/19 18:48:11 deraadt Exp $ */
/* $NetBSD: opendisk.c,v 1.4 1997/09/30 17:13:50 phil Exp $ */
/*-
@ -53,10 +53,6 @@ opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked)
{
int f, rawpart;
if (buf == NULL) {
errno = EFAULT;
return (-1);
}
snprintf(buf, buflen, "%s", path);
if ((flags & O_CREAT) != 0) {


Loading…
Cancel
Save