diff options
author | archie <archie@FreeBSD.org> | 1998-12-04 22:54:57 +0000 |
---|---|---|
committer | archie <archie@FreeBSD.org> | 1998-12-04 22:54:57 +0000 |
commit | 982e80577dd08945aa2345ebe35e3f50eef9eb48 (patch) | |
tree | e21ff4cbfbcb4097c6cc444d68ddd9a3fd37837f /sys/i386/ibcs2/ibcs2_xenix.c | |
parent | 707b8f68aa118c7396f2a2633751e32477d9ed08 (diff) | |
download | FreeBSD-src-982e80577dd08945aa2345ebe35e3f50eef9eb48.zip FreeBSD-src-982e80577dd08945aa2345ebe35e3f50eef9eb48.tar.gz |
Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.
These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.
Reviewed by: Bruce Evans <bde@zeta.org.au>
Reviewed by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Mike Spengler <mks@networkcs.com>
Diffstat (limited to 'sys/i386/ibcs2/ibcs2_xenix.c')
-rw-r--r-- | sys/i386/ibcs2/ibcs2_xenix.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/i386/ibcs2/ibcs2_xenix.c b/sys/i386/ibcs2/ibcs2_xenix.c index 0677ede..8ab5556 100644 --- a/sys/i386/ibcs2/ibcs2_xenix.c +++ b/sys/i386/ibcs2/ibcs2_xenix.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ibcs2_xenix.c,v 1.15 1998/06/02 05:39:07 dyson Exp $ + * $Id: ibcs2_xenix.c,v 1.16 1998/08/16 01:21:49 bde Exp $ */ #include <sys/param.h> @@ -157,14 +157,22 @@ xenix_utsname(struct proc *p, struct xenix_utsname_args *uap) DPRINTF(("IBCS2: 'xenix sco_utsname'\n")); bzero(&ibcs2_sco_uname, sizeof(struct ibcs2_sco_utsname)); - strncpy(ibcs2_sco_uname.sysname, ostype, 8); - strncpy(ibcs2_sco_uname.nodename, hostname, 8); - strncpy(ibcs2_sco_uname.release, osrelease, 15); - strncpy(ibcs2_sco_uname.kernelid, version, 19); - strncpy(ibcs2_sco_uname.machine, machine, 8); - bcopy("ISA/EISA", ibcs2_sco_uname.bustype, 8); - bcopy("no charge", ibcs2_sco_uname.sysserial, 9); - bcopy("unlim", ibcs2_sco_uname.numusers, 8); + strncpy(ibcs2_sco_uname.sysname, ostype, + sizeof(ibcs2_sco_uname.sysname) - 1); + strncpy(ibcs2_sco_uname.nodename, hostname, + sizeof(ibcs2_sco_uname.nodename) - 1); + strncpy(ibcs2_sco_uname.release, osrelease, + sizeof(ibcs2_sco_uname.release) - 1); + strncpy(ibcs2_sco_uname.kernelid, version, + sizeof(ibcs2_sco_uname.kernelid) - 1); + strncpy(ibcs2_sco_uname.machine, machine, + sizeof(ibcs2_sco_uname.machine) - 1); + strncpy(ibcs2_sco_uname.bustype, "ISA/EISA", + sizeof(ibcs2_sco_uname.bustype) - 1); + strncpy(ibcs2_sco_uname.sysserial, "no charge", + sizeof(ibcs2_sco_uname.sysserial) - 1); + strncpy(ibcs2_sco_uname.numusers, "unlim", + sizeof(ibcs2_sco_uname.numusers) - 1); ibcs2_sco_uname.sysorigin = 0xFFFF; ibcs2_sco_uname.sysoem = 0xFFFF; ibcs2_sco_uname.numcpu = 1; |