Browse Source

only write to realpath if non-NULL

OPENBSD_2_0
deraadt 28 years ago
parent
commit
343aaa30a5
2 changed files with 11 additions and 7 deletions
  1. +4
    -3
      src/lib/libutil/opendev.3
  2. +7
    -4
      src/lib/libutil/opendev.c

+ 4
- 3
src/lib/libutil/opendev.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: opendev.3,v 1.3 1996/06/18 09:13:41 downsj Exp $
.\" $OpenBSD: opendev.3,v 1.4 1996/06/20 10:46:01 deraadt Exp $
.\"
.\" Copyright (c) 1996, Jason Downs. All rights reserved.
.\"
@ -59,8 +59,9 @@ OPENDEV_PART attempt to open the raw partition during expansion
OPENDEV_DRCT attempt to open the device itself during expansion
.Ed
.Pp
.Ar Realpath
will be modified to point at the fully expanded device name.
If
.Ar realpath
is not NULL, it is modified to point at the fully expanded device name.
.Pp
.Sh RETURN VALUES
The


+ 7
- 4
src/lib/libutil/opendev.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: opendev.c,v 1.2 1996/06/17 07:46:03 downsj Exp $ */
/* $OpenBSD: opendev.c,v 1.3 1996/06/20 10:46:02 deraadt Exp $ */
/*
* Copyright (c) 1996, Jason Downs. All rights reserved.
@ -48,7 +48,8 @@ opendev(path, oflags, dflags, realpath)
int fd;
static char namebuf[256];
*realpath = path;
if (realpath)
*realpath = path;
fd = open(path, oflags);
if ((fd < 0) && (errno == ENOENT)) {
@ -70,7 +71,8 @@ opendev(path, oflags, dflags, realpath)
fd = open(namebuf, oflags);
}
*realpath = namebuf;
if (realpath)
*realpath = namebuf;
}
}
if ((fd < 0) && (errno == ENOENT) && (path[0] != '/')) {
@ -78,7 +80,8 @@ opendev(path, oflags, dflags, realpath)
_PATH_DEV, path);
fd = open(namebuf, oflags);
*realpath = namebuf;
if (realpath)
*realpath = namebuf;
}
return (fd);


Loading…
Cancel
Save