summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/__xuname.c
diff options
context:
space:
mode:
authormpp <mpp@FreeBSD.org>1995-07-31 10:10:02 +0000
committermpp <mpp@FreeBSD.org>1995-07-31 10:10:02 +0000
commit51c2dd9b11cdf65018cc3049867cdcb385485d65 (patch)
tree7ce275cea9847f4f0aa09f87a895c33da2f5804d /lib/libc/gen/__xuname.c
parent08d1bb1b892e340765b0d6e348481660b3d28481 (diff)
downloadFreeBSD-src-51c2dd9b11cdf65018cc3049867cdcb385485d65.zip
FreeBSD-src-51c2dd9b11cdf65018cc3049867cdcb385485d65.tar.gz
Null terminate all strings returned by the dummy uname() routine,
and make sure that the version string is somewhat sane. This closes out PR#462. Reviewed by: Bruce Evans
Diffstat (limited to 'lib/libc/gen/__xuname.c')
-rw-r--r--lib/libc/gen/__xuname.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/libc/gen/__xuname.c b/lib/libc/gen/__xuname.c
index 63f2956..93f659e 100644
--- a/lib/libc/gen/__xuname.c
+++ b/lib/libc/gen/__xuname.c
@@ -34,7 +34,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/
static const char rcsid[] =
- "$Id: uname.c,v 1.2 1994/10/13 20:31:19 wollman Exp $";
+ "$Id: uname.c,v 1.3 1995/05/30 05:40:29 rgrimes Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -63,6 +63,7 @@ uname(name)
else
rval = -1;
}
+ name->sysname[sizeof(name->sysname) - 1] = '\0';
mib[0] = CTL_KERN;
mib[1] = KERN_HOSTNAME;
@@ -74,6 +75,7 @@ uname(name)
else
rval = -1;
}
+ name->nodename[sizeof(name->nodename) - 1] = '\0';
mib[0] = CTL_KERN;
mib[1] = KERN_OSRELEASE;
@@ -85,6 +87,7 @@ uname(name)
else
rval = -1;
}
+ name->release[sizeof(name->release) - 1] = '\0';
/* The version may have newlines in it, turn them into spaces. */
mib[0] = CTL_KERN;
@@ -96,14 +99,14 @@ uname(name)
errno = oerrno;
else
rval = -1;
- } else {
- for (p = name->version; len--; ++p) {
- if (*p == '\n' || *p == '\t') {
- if (len > 1)
- *p = ' ';
- else
- *p = '\0';
- }
+ }
+ name->version[sizeof(name->version) - 1] = '\0';
+ for (p = name->version; len--; ++p) {
+ if (*p == '\n' || *p == '\t') {
+ if (len > 1)
+ *p = ' ';
+ else
+ *p = '\0';
}
}
@@ -117,5 +120,6 @@ uname(name)
else
rval = -1;
}
+ name->machine[sizeof(name->machine) - 1] = '\0';
return (rval);
}
OpenPOWER on IntegriCloud