summaryrefslogtreecommitdiff
path: root/lib/librmt
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>1997-01-23 14:01:45 +0000
committermrg <mrg@NetBSD.org>1997-01-23 14:01:45 +0000
commit9cd5492c0260bc081b84b3657f5d7fd950e2aa9b (patch)
tree0980f3cf304e504ae3b29328e52850920b9c01c7 /lib/librmt
parentdff93f1d733a6cdd1fd4234340e77f5621d5895b (diff)
- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
Diffstat (limited to 'lib/librmt')
-rw-r--r--lib/librmt/rmtlib.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/librmt/rmtlib.c b/lib/librmt/rmtlib.c
index 66c3df52e0d..7b0b0227a3c 100644
--- a/lib/librmt/rmtlib.c
+++ b/lib/librmt/rmtlib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rmtlib.c,v 1.4 1996/08/13 20:09:50 thorpej Exp $ */
+/* $NetBSD: rmtlib.c,v 1.5 1997/01/23 14:03:05 mrg Exp $ */
/*
* rmt --- remote tape emulator subroutines
@@ -278,7 +278,8 @@ int mode;
if (*(path - 1) == '@')
{
- (void) strcpy (user, system); /* saw user part of user@host */
+ (void)strncpy(user, system, sizeof(login) - 1);
+ /* saw user part of user@host */
sys = system; /* start over */
while (*path != ':') {
*sys++ = *path++;
@@ -358,7 +359,7 @@ int mode;
* now attempt to open the tape device
*/
- sprintf(buffer, "O%s\n%d\n", device, oflag);
+ (void)snprintf(buffer, sizeof(buffer), "O%s\n%d\n", device, oflag);
if (command(i, buffer) == -1 || status(i) == -1)
return(-1);
@@ -401,7 +402,7 @@ unsigned int nbyte;
int rc, i;
char buffer[BUFMAGIC];
- sprintf(buffer, "R%d\n", nbyte);
+ (void)snprintf(buffer, sizeof buffer, "R%d\n", nbyte);
if (command(fildes, buffer) == -1 || (rc = status(fildes)) == -1)
return(-1);
@@ -434,7 +435,7 @@ unsigned int nbyte;
char buffer[BUFMAGIC];
void (*pstat)();
- sprintf(buffer, "W%d\n", nbyte);
+ (void)snprintf(buffer, sizeof buffer, "W%d\n", nbyte);
if (command(fildes, buffer) == -1)
return(-1);
@@ -464,7 +465,7 @@ int whence;
{
char buffer[BUFMAGIC];
- sprintf(buffer, "L%d\n%d\n", offset, whence);
+ (void)snprintf(buffer, sizeof buffer, "L%d\n%d\n", offset, whence);
if (command(fildes, buffer) == -1)
return(-1);
@@ -492,8 +493,9 @@ char *arg;
if (op == MTIOCTOP)
{
- sprintf(buffer, "I%d\n%d\n", ((struct mtop *) arg)->mt_op,
- ((struct mtop *) arg)->mt_count);
+ (void)snprintf(buffer, sizeof buffer, "I%d\n%d\n",
+ ((struct mtop *)arg)->mt_op,
+ ((struct mtop *)arg)->mt_count);
if (command(fildes, buffer) == -1)
return(-1);
return(status(fildes));