summaryrefslogtreecommitdiffstats
path: root/lib/libutil/opendev.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-06-20 10:46:01 +0000
committerderaadt <deraadt@openbsd.org>1996-06-20 10:46:01 +0000
commit679286fb397ce9f958cb48a2a8418bb01abeeecc (patch)
tree993cd7fb7771a0cbba482e3b6c1f58f75adc4e73 /lib/libutil/opendev.c
parentadd fdformat for the i386: based on an old FreeBSD version, gotten from (diff)
downloadwireguard-openbsd-679286fb397ce9f958cb48a2a8418bb01abeeecc.tar.xz
wireguard-openbsd-679286fb397ce9f958cb48a2a8418bb01abeeecc.zip
only write to realpath if non-NULL
Diffstat (limited to 'lib/libutil/opendev.c')
-rw-r--r--lib/libutil/opendev.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libutil/opendev.c b/lib/libutil/opendev.c
index 6603dc0791a..557b4e52ec7 100644
--- a/lib/libutil/opendev.c
+++ b/lib/libutil/opendev.c
@@ -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);