summaryrefslogtreecommitdiff
path: root/usr.sbin/rpc.pcnfsd
diff options
context:
space:
mode:
authorAnil Madhavapeddy <avsm@cvs.openbsd.org>2003-04-05 10:43:40 +0000
committerAnil Madhavapeddy <avsm@cvs.openbsd.org>2003-04-05 10:43:40 +0000
commitf87dc77124778b3926e89f9dd6cb4bdaf32798eb (patch)
tree4fc025339cd96821c316d50bf67589156b225cac /usr.sbin/rpc.pcnfsd
parent1086e8e4c74a510f632910fccb44559d933a6287 (diff)
strlcpy/strlcat conversions; tedu@ ok
Diffstat (limited to 'usr.sbin/rpc.pcnfsd')
-rw-r--r--usr.sbin/rpc.pcnfsd/pcnfsd_print.c26
-rw-r--r--usr.sbin/rpc.pcnfsd/pcnfsd_test.c6
2 files changed, 17 insertions, 15 deletions
diff --git a/usr.sbin/rpc.pcnfsd/pcnfsd_print.c b/usr.sbin/rpc.pcnfsd/pcnfsd_print.c
index 502899958a3..b17bf9270c1 100644
--- a/usr.sbin/rpc.pcnfsd/pcnfsd_print.c
+++ b/usr.sbin/rpc.pcnfsd/pcnfsd_print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcnfsd_print.c,v 1.16 2003/04/04 22:37:47 avsm Exp $ */
+/* $OpenBSD: pcnfsd_print.c,v 1.17 2003/04/05 10:43:39 avsm Exp $ */
/* $NetBSD: pcnfsd_print.c,v 1.3 1995/08/14 19:45:18 gwr Exp $ */
/*
@@ -807,9 +807,10 @@ char *command;
if (strstr(command, "$FILE"))
alias[num_aliases].a_command = strdup(command);
else {
- alias[num_aliases].a_command = (char *)grab(strlen(command) + 8);
- strcpy(alias[num_aliases].a_command, command);
- strcat(alias[num_aliases].a_command, " $FILE");
+ int len = strlen(command) + 8;
+ alias[num_aliases].a_command = (char *)grab(len);
+ strlcpy(alias[num_aliases].a_command, command, len);
+ strlcat(alias[num_aliases].a_command, " $FILE", len);
}
num_aliases++;
}
@@ -862,18 +863,19 @@ map_printer_name(printer)
}
static void
-substitute(string, token, data)
+substitute(string, token, data, slength)
char *string, *token, *data;
+ size_t slength;
{
char temp[512], *c;
while (c = strstr(string, token)) {
*c = '\0';
- strcpy(temp, string);
- strcat(temp, data);
+ strlcpy(temp, string, sizeof(temp));
+ strlcat(temp, data, sizeof(temp));
c += strlen(token);
- strcat(temp, c);
- strcpy(string, temp);
+ strlcat(temp, c, sizeof(temp));
+ strlcpy(string, temp, slength);
}
}
@@ -889,9 +891,9 @@ int i;
for (i = 0; i < num_aliases; i++){
if (!strcmp(printer, alias[i].a_printer)) {
strlcpy(expansion, alias[i].a_command, sizeof(expansion));
- substitute(expansion, "$FILE", file);
- substitute(expansion, "$USER", user);
- substitute(expansion, "$HOST", host);
+ substitute(expansion, "$FILE", file, sizeof(expansion));
+ substitute(expansion, "$USER", user, sizeof(expansion));
+ substitute(expansion, "$HOST", host, sizeof(expansion));
return (expansion);
}
}
diff --git a/usr.sbin/rpc.pcnfsd/pcnfsd_test.c b/usr.sbin/rpc.pcnfsd/pcnfsd_test.c
index 820e744d973..1746aaa27ab 100644
--- a/usr.sbin/rpc.pcnfsd/pcnfsd_test.c
+++ b/usr.sbin/rpc.pcnfsd/pcnfsd_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcnfsd_test.c,v 1.5 2003/02/15 12:15:04 deraadt Exp $ */
+/* $OpenBSD: pcnfsd_test.c,v 1.6 2003/04/05 10:43:39 avsm Exp $ */
/* $NetBSD: pcnfsd_test.c,v 1.2 1995/07/25 22:21:01 gwr Exp $ */
/*
@@ -247,7 +247,7 @@ v2_pr_init_results *rp;
}
printf("results: stat = %d, dir = '%s', cm = '%s'\n",
rp->stat, rp->dir, rp->cm);
- strcpy(spooldirbuff, rp->dir);
+ strlcpy(spooldirbuff, rp->dir, sizeof(spooldirbuf));
/* free up allocated strings */
if(rp->cm)
free(rp->cm);
@@ -303,7 +303,7 @@ FILE *fp;
printf("results: stat = %d, jobid = '%s', cm = '%s'\n",
rp->stat, rp->id, rp->cm);
if(rp->stat == PS_RES_OK)
- strcpy(last_id, rp->id);
+ strlcpy(last_id, rp->id, sizeof(last_id));
/* free up allocated strings */
if(rp->cm)
free(rp->cm);